Repository navigation
Conversation
Previously, many tests un-registered service workers only after all assertions had been satisfied. This meant that failing tests would *not* un-register workers. In order to account for workers that persisted from previous test failures, the tests included "setup" code to defensively un-register such workers. The `Test#add_cleanup` method was recently extended to support asynchronous "clean up" operations [1], but the functionality is only available to tests declared using `promise_test`. Update tests which were previously declared with `async_test` and use the new "async cleanup" API to schedule service worker un-registration so that it occurs regardless of the result of each test. [1] web-platform-tests#8748
mfalken
left a comment
There was a problem hiding this comment.
Sorry for the review delay. I didn't have an effective system for receiving GitHub reviews in my inbox. This is great. Thank you for all your work adding async cleanup and for converting these tests.
This patch is fine as-is. One observation is we sometimes remove frames inline and sometimes in add_cleanup. I think add_cleanup is better to isolate promise_tests from each other. We've also tried to remove the frames before calling unregister, as it makes it more likely for the service worker to actually get deactivated, since otherwise it waits for all clients to close. But that's sometimes inconvenient to code.
| wait_for_state(t, worker, 'installed') | ||
| .then(function() { | ||
|
|
||
|
|
| wait_for_state(t, worker, 'redundant') | ||
| .then(function() { | ||
|
|
||
|
|
| wait_for_state(t, worker, 'installed') | ||
| .then(function() { | ||
|
|
||
|
|
| service_worker_unregister_and_done(t, scope); | ||
| }; | ||
| if (event.target.state != 'activated') | ||
| return onStateChange(expectedTarget); |
There was a problem hiding this comment.
Hum this is felt too clever for me but it seems to work. Also I'm not sure why this test terminates at 'activated' while having checkStateTransition for activated and redundant.
|
Happy to help out! Would you mind merging on my behalf, @mattto? I noticed some inconsistency with iframe management while writing this patch. I'd be happy to normalize things a bit in a follow up. |
|
Thanks! Sorry for the delay. I didn't know I could merge things. |
Previously, many tests un-registered service workers only after all
assertions had been satisfied. This meant that failing tests would not
un-register workers. In order to account for workers that persisted from
previous test failures, the tests included "setup" code to defensively
un-register such workers.
The
Test#add_cleanupmethod was recently extended to supportasynchronous "clean up" operations [1], but the functionality is only
available to tests declared using
promise_test. Update tests whichwere previously declared with
async_testand use the new "asynccleanup" API to schedule service worker un-registration so that it
occurs regardless of the result of each test.
[1] #8748
This patch is not intended to influence test results. To verify that, I used
the WPT CLI to run the affected tests in Chromium and Firefox, comparing the
summary it produced both on
masterand on this branch.Chromium on
master:Chromium with patch applied:
Firefox on
master:Firefox with patch applied:
The discrepancy in Firefox is expected. In
master, two of the fourasync_testsinfetch-request-css-images.https.htmltime out in Firefox.This branch refactors all four into
promise_tests.promise_tests run inseries (unlike the parallel
async_tests), so the harness stops running thetests following the first timeout and reports the final test as "NOT RUN".
I've attempted to ease the review process by splitting the work across a few
pull requests, but this patch is still pretty onerous. I'd be happy to break it
up further if desired.