Skip to content

Commit 59e7897

Browse files
committed
Add support for testing the WebExtensions API in WPT
This RFC documents our proposal for adding support for testing the WebExtensions API in the web platform tests.
1 parent 720ae56 commit 59e7897

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

rfcs/web_extensions.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.js` test type, `.extension.js`, to handle|
10+
testing this API, in addition to using `testdriver.js` to load and unload extensions.
11+
12+
## Details
13+
14+
Using `testdriver.js`, we added 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` internally and they can easily port over existing tests to
23+
the web platform tests.
24+
25+
Because these tests won’t leverage `testharness.js` directly, we’ve introduced a new
26+
`testharness.js`, `.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 https://github.com/web-platform-tests/wpt/pull/50648.
31+
32+
## Alternatives considered
33+
34+
We considered loading the extension statically before each `testharness.js` test is run,
35+
but we decided against that since `testdriver.js` 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 rather than using JavaScript tests, but we decided
40+
against it because it was a lot more work compared to using `testharness.js`.
41+
42+
## Risks
43+
44+
There are two potential concerns with this implementation:
45+
46+
1. We have no precedent for tests run via a Classic command in some user agents
47+
and BiDi command in others. However, the Classic implementation of loading
48+
and unloading extension is modeled on the BiDi implementation, so we expect the
49+
behavior to be the same. The Classic implementation is defined in the WebExtensions Community Group
50+
[here](https://github.com/w3c/webextensions/blob/main/specification/webdriver-classic.bs),
51+
and the BiDi implementation is defined
52+
[here](https://www.w3.org/TR/webdriver-bidi/#module-webExtension).
53+
54+
2. Another concern could be with using `browser.test` assertions and mapping them to
55+
`testharness.js` assertions. With `testharness.js` not in charge of generating assertions,
56+
we might end up with less useful failure messages.

0 commit comments

Comments
 (0)