-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signaling when preconditions are not met on a reftest #178
Open
frivoal
wants to merge
3
commits into
web-platform-tests:master
Choose a base branch
from
frivoal:reftest-precondition
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# RFC 178: Signaling when preconditions are not met on a reftest | ||
|
||
## Summary | ||
|
||
This is a proposal to add a way to make a reftest neither fail nor pass, but return `PRECONDITION_FAILED`. This is useful if some precondition of the normative statement we want to test is not satisfied. | ||
|
||
## Details | ||
|
||
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. | ||
|
||
This is particularly annoying when the precondition is en environmental factor over which the test has no control. | ||
|
||
* "When printing, the UA must…", but you're running the test on screen, not printing | ||
* "On devices with a keyboard, the UA must…", but you're running the test on a phone | ||
* "If the UA uses overlay scrollbars, the UA must…", but you're running the test on a device with old-fashioned layout-affecting scrollbars | ||
|
||
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. | ||
|
||
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. | ||
|
||
It'd be a lot more accurate to return `PRECONDITION_FAILED`, rather than passed or failed. So far, there's no way to signal that. | ||
|
||
## Proposed solution: use a waiting reftest and add a class on the root | ||
|
||
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"` | ||
|
||
We could add a convenience method , similar to `takeScreenshot()` to `/common/reftest-wait.js`: | ||
|
||
```js | ||
function preconditionFailed() { | ||
document.documentElement.classList.add("precondition-failed"); | ||
document.documentElement.classList.remove("reftest-wait"); | ||
} | ||
``` | ||
|
||
This would be picked up by the test runner, which would then report the `PRECONDITION_FAILED` statust, rather than a failed or passed one. | ||
|
||
### Risks | ||
|
||
Tests that return `PRECONDITION_FAILED` cannot be included in interop stats because it's not clear how they should be counted. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually seems like a benefit to me :) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Risk: would this work reliably / consistently if these two calls were reversed? Do we already define the exact timing of test finishing vs removing the class? (E.g., sync, on a (micro)task, by polling)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wptrunner implementation relies on MutationObservers, which implies it depends on microtasks IIRC. (That said, the internal Marionette implementation may well differ.)