Repository navigation
Do not return value from "cleanup" functions - #8742
Merged
Merged
Conversation
Today, the return value of functions provided to the global `add_cleanup` function has no effect on the behavior of the test runner. An upcoming feature addition to `testharness.js` will cause the return value to influence test results [1]. Despite this, some existing tests have already been authored to return a value. Introducing the new test harness functionality may trigger unexpected results in those contexts. To avoid this, refactor existing tests to avoid returning a value. [1] web-platform-tests#6075
wpt-pr-bot
requested review from
ayg,
beidson,
ehsan,
jdm,
mfalken and
zqzhang
December 19, 2017 20:57
Build PASSEDStarted: 2017-12-20 16:36:09 View more information about this build on: |
This was referenced Dec 19, 2017
foolip
approved these changes
Dec 20, 2017
foolip
left a comment
Member
There was a problem hiding this comment.
LGTM % tracking the remaining work.
| return service_worker_unregister_and_register(t, script, scope) | ||
| .then(r => { | ||
| t.add_cleanup(() => r.unregister()); | ||
| t.add_cleanup(() => { r.unregister(); }); |
Member
There was a problem hiding this comment.
Can you add a TODO here to revert it back when promise cleanup has landed?
jugglinmike
commented
Dec 20, 2017
| return service_worker_unregister_and_register(t, script, scope) | ||
| .then(r => { | ||
| t.add_cleanup(() => r.unregister()); | ||
| t.add_cleanup(() => { r.unregister(); }); |
foolip
approved these changes
Dec 20, 2017
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Today, the return value of functions provided to the global
add_cleanupfunction has no effect on the behavior of the test runner.An upcoming feature addition to
testharness.jswill cause the returnvalue to influence test results [1].
Despite this, some existing tests have already been authored to return a
value. Introducing the new test harness functionality may trigger
unexpected results in those contexts. To avoid this, refactor existing
tests to avoid returning a value.
[1] #6075
The Service Worker test I've modified returns a "thenable" which is actually
amenable to the proposed
testharness.jsextension. We could leave it as-is,and when/if an implementation for gh-6075 lands, that test would become less
fragile automatically. Still, it seems safer to introduce the new functionality
with the confidence that it doesn't trigger any implicit opt-in, and then
incrementally begin to use it with intentional follow-up commits. (And for the
Service Worker test suite, this will entail updating many files besides the one
modified here.)
For those curious: I located these tests programatically by modifying the test
runner and using that to run all tests that reference
add_cleanup:And
Both browsers identified the same usages.