Skip to content

Commit 5d3b992

Browse files
committed
Add support for testing the WebExtensions API in WPT
1 parent 720ae56 commit 5d3b992

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

rfcs/web_extensions.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# RFC #219: Add support for WebExtensions in WPT
2+
3+
## Summary
4+
5+
The WebExtensions API extends the capabilities of the browser. Adding support
6+
for WebExtensions in the web platform tests will increase interoperability
7+
and will help drive the standardization of this API.
8+
9+
This RFC proposes adding a new testharness test type `.extension.js` to handle|
10+
testing this API, in addition to using `test_driver` to load and unload extensions.
11+
12+
## Details
13+
14+
Using test_driver, we add support for testing the WebExtensions API by loading
15+
a web extension designed to test the functionality of a specific API.
16+
The extension will be loaded after the tests begins, and unloaded before the
17+
test is finished.
18+
19+
Most of the test execution is handled within the extension, via the
20+
[browser.test](https://chromium.googlesource.com/chromium/src.git/+/master/extensions/docs/testing_api.md)
21+
API. We’ve elected to use these APIs since all participating browser vendors use
22+
`browser.test` to test the web extensions internally and they can easily port over
23+
existing tests to the web platform tests.
24+
25+
Because these tests won’t leverage testharness.js directly, we’ve introduced a new
26+
testharness test type `.extension.js` that will create the necessary boilerplate to
27+
convert the `browser.test` assertions into the corresponding assertions in the test
28+
harness.
29+
30+
A proposed patch is available at [insert WPT link here]
31+
32+
## Alternatives considered
33+
34+
We considered loading the extension statically before each testharness test is run,
35+
but we decided against that since test_driver will allow the tests to drive the
36+
browser, and in the future, test functionality such as opening popups and clicking
37+
menu items.
38+
39+
We considered adding a new test type other than using JavaScript tests, but we decided
40+
against it because it was a lot more work compared to using testharness.js.
41+
42+
43+
## Risks
44+
45+
There are two potential concerns with this implementation:
46+
47+
1. We have no precedent for tests run via a Classic command in some user agents
48+
and BiDi command in others. However, the Classic implementation of loading
49+
and unloading extension is modeled on the BiDi implementation, so we expect the
50+
behavior to be the same. The Classic implementation is defined in the WebExtensions Community Group
51+
[here](https://github.com/w3c/webextensions/blob/main/specification/webdriver-classic.bs),
52+
and the BiDi implementation is defined
53+
[here](https://www.w3.org/TR/webdriver-bidi/#module-webExtension).
54+
55+
2. Another concern could be with using `browser.test` assertions and mapping them to
56+
`testharness.js` assertions. With `testharness.js` not in charge of generating assertions,
57+
we might end up with less useful failure messages.

0 commit comments

Comments
 (0)