Skip to content

Commit 60223fe

Browse files
committed
Skipping a reftest when preconditions are not met
1 parent de59a45 commit 60223fe

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

rfcs/reftest-precondition.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# RFC 178: Skipping a reftest when preconditions are not met
2+
3+
## Summary
4+
5+
This is a proposal to add a way to make a reftest neither fail nor pass, but instead get skipped. This is useful if some precondition of the normative statement we want to test is not satisfied.
6+
7+
## Details
8+
9+
Sometimes, a specification will make a normative statement about something that MUST be done if a certain precondition is fulfilled. If the precondition is not fulfilled, there's nothing to test. For testharness, there is [assert_implements_optional](http://web-platform-tests.org/writing-tests/testharness-api.html#assert_implements_optional), but for reftests, there is no equivalent.
10+
11+
This is particularly annoying when the precondition is en environmental factor over which the test has no control.
12+
13+
* "When printing, the UA must…", but you're running the test on screen, not printing
14+
* "On devices with a keyboard, the UA must…", but you're running the test on a phone
15+
* "If the UA uses overlay scrollbars, the UA must…", but you're running the test on a device with old-fashioned layout-affecting scrollbars
16+
17+
Note: I'm not talking about the case where you cannot detect whether the precondition has been fulfilled or not, but rather of the case where the test can detect that it is not fulfilled.
18+
19+
From a logical point of you, you could set up all these tests to pass, since the UA has violated no normative requirement. However, this would give a false sense of comfort: for example, UAs that have not even implemented the feature at all would pass the test when you run them in the right (i.e. wrong) environment.
20+
21+
It'd be a lot more accurate to report that the test was skipped, rather than passed or failed. So far, there's no way to signal that.
22+
23+
## Proposed solution: use a waiting reftest and add a class on the root
24+
25+
If a reftest is setup with `class="reftest-wait"` on the root, the harness will wait before taking a screenshot until that class has been removed. We can take advantage of that by running tests in js during that time, and signaling through another class on the root when the precondition has failed. For instance `class="precondition-failed"`
26+
27+
We could add a convenience method , similar to `takeScreenshot()` to `/common/reftest-wait.js`:
28+
29+
```js
30+
function skipTest() {
31+
document.documentElement.classList.add("precondition-failed");
32+
document.documentElement.classList.remove("reftest-wait");
33+
}
34+
```
35+
36+
This would be picked up by the test runner, which would then report a skipped test, rather than a failed or passed one.
37+
38+
### Risks
39+
40+
None identified.

0 commit comments

Comments
 (0)