Skip to content

Commit dc383d1

Browse files
authored
Allow unrestricted Promise usage in testharness.js (#93)
1 parent 14560be commit dc383d1

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

rfcs/promise.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# RFC 93: Allow testharness.js to depend on Promise being available
2+
3+
## Summary
4+
5+
Currently testharness.js has a test-enforced policy that ES Promises
6+
are only required by features which specifically depend on promises
7+
(e.g. `promise_test`). Other functionality must work in the absence of
8+
promises.
9+
10+
This RFC removes that restriction, allowing ES Promises to be used
11+
throughout the testharness.js codebase.
12+
13+
## Details
14+
15+
Historically ES Promises were not widely supported across browser
16+
engines. Native promises became available in 2014, and even some years
17+
later browsers that were known to make use of web-platform-tests were
18+
running JavaScript engine versions without Promise support. In
19+
particular Servo was making heavy use of web-platform-tests but didn't
20+
support promises until late
21+
[2016](https://github.com/servo/servo/issues/4282), whilst Internet
22+
Explorer has never had Promise support.
23+
24+
Due to the Servo requirements in particular, the testharness.js tests
25+
were written to run in a mode with the [global promise constructor
26+
removed](https://github.com/web-platform-tests/wpt/commit/08995880734011eed359c4e79420db29626016ff#diff-d33a74992c12a398b4876be7ea865df0387f779f740be2ff79e792f7d4db5badR12-R14). This
27+
ensures that features which don't explicitly depend on Promise don't
28+
accidentally rely on it, allowing most tests to run in
29+
implementations without Promises.
30+
31+
Today the number of browsers which might conceivably run wpt but lack
32+
Promise support is very low. Many new DOM APIs require promises, so
33+
the only implementations which lack Promise support are those such as
34+
IE 11 which are no longer receiving feature updates. This makes it
35+
safe to rely on promises across the entire testharness codebase. It
36+
opens up the possibility of refactorings to make the code simpler, and
37+
removes a point of confusion for new contributors who are unaware of
38+
the unusual policy of avoiding promises.
39+
40+
The proposal is that we allow promises throughout testharness as a
41+
matter of policy, and remove the variants feature from the
42+
testharness.js tests, along with all usage of it. Since this feature
43+
is currently only used for with and without promise variants, we can
44+
simplify test authoring by not having the additional complexity.
45+
46+
## Risks
47+
48+
* Some unusual older browsers might still be running wpt. For example
49+
we know that the WAVE server is used for testing TV-based browsers,
50+
which could conceivably be so outdated as to not support
51+
promises. We don't have much insight into how this is used so could
52+
conceivably result in "dark matter" breakage.
53+
54+
* Removing the variants feature from testharness.js tests entirely
55+
might be premature if we find we need similar functionality in the
56+
future. However the fact that we've currently only used it for this
57+
one use case, and the fact that it adds noticeable complexity to test
58+
authoring and to the harness suggests we should consider re-adding
59+
the feature if we find an additional use case.

0 commit comments

Comments
 (0)