Skip to content

[cookie-store] Deflake service worker registration #18324

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

Merged
merged 1 commit into from
Aug 8, 2019

Conversation

Hexcles
Copy link
Member

@Hexcles Hexcles commented Aug 7, 2019

Instead of attempting to unregister previously installed service workers
at the beginning of a test, use add_completion_callback to unregister
them at test completion. This will deflake the tests when they are run
multiple times without restarts (--rerun).

The alternative is to do what many tests in service-workers do:
unregister service workers at the start, but wait for newly installed
service workers to become activated and use registration.active
instead of registration.installing, which is a bit more complex.

Fixes the flakiness observed in #17866 .

Instead of attempting to unregister previously installed service workers
at the beginning of a test, use `add_completion_callback` to unregister
them at test completion. This will deflake the tests when they are run
multiple times without restarts (`--rerun`).

The alternative is to do what many tests in service-workers do:
unregister service workers at the start, but wait for newly installed
service workers to become activated and use `registration.active`
instead of `registration.installing`, which is a bit more complex.
@Hexcles
Copy link
Member Author

Hexcles commented Aug 7, 2019

There are a few other tests in this directory that can benefit from the same treatment, but they seem to be flaky both with and without the patch (there's probably some other existing flakiness). I'll perhaps send out a part 2 PR for those so that this PR can be green.

Copy link
Contributor

@inexorabletash inexorabletash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

I think we went with the "unregistered first" pattern to defend against leftover data from a failed/flaky test that didn't clean up, but if this improves things in practice then let's do it.

@Hexcles
Copy link
Member Author

Hexcles commented Aug 7, 2019

I think we went with the "unregistered first" pattern to defend against leftover data from a failed/flaky test that didn't clean up, but if this improves things in practice then let's do it.

That does work in principle. In practice, I've observed that registration of a service worker from scratch is initially in the "installing" state, whereas registration of a sw immediately after unregistering the same one is in the "active" state right away. Tests in service-workers always wait for the registration to become active, so either code path will work. We could also do the same here; and I'm not familiar with service workers enough to tell which approach is better.

In general, I think it's safe to assume that tests start from a clean state and strive to make sure tests clean up after themselves regardless of the results.

@Hexcles Hexcles merged commit cc9dc6b into master Aug 8, 2019
@Hexcles Hexcles deleted the fix-cookiestore-tests branch August 8, 2019 21:28
@Hexcles Hexcles restored the fix-cookiestore-tests branch August 8, 2019 22:04
Hexcles added a commit that referenced this pull request Aug 8, 2019
This is a follow-up to
#18324

This change by itself isn't sufficient to deflake the two tests.
@Hexcles Hexcles deleted the fix-cookiestore-tests branch August 8, 2019 22:07
Hexcles added a commit that referenced this pull request Aug 15, 2019
This is a follow-up to
#18324

This change by itself isn't sufficient to deflake the two tests.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 23, 2019
…ing service worker tests, a=testonly

Automatic update from web-platform-tests
[cookie-store] Deflake service worker registration (part 2)

This is a follow-up to
web-platform-tests/wpt#18324

This change by itself isn't sufficient to deflake the two tests.

--
[cookie-store] Attempt to deflake two tests

Move the event handler registration to the top scope of the service
worker (Chrome warning: "Event handler of ... event must be added on the
initial evaluation of worker script.").

--

wpt-commits: a13797b678be16d1bec8cae0a8288e6101569cae, 909a1049b9431ae7e1a64c871b5c6822f0a90367
wpt-pr: 18340
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Aug 23, 2019
…ing service worker tests, a=testonly

Automatic update from web-platform-tests
[cookie-store] Deflake service worker registration (part 2)

This is a follow-up to
web-platform-tests/wpt#18324

This change by itself isn't sufficient to deflake the two tests.

--
[cookie-store] Attempt to deflake two tests

Move the event handler registration to the top scope of the service
worker (Chrome warning: "Event handler of ... event must be added on the
initial evaluation of worker script.").

--

wpt-commits: a13797b678be16d1bec8cae0a8288e6101569cae, 909a1049b9431ae7e1a64c871b5c6822f0a90367
wpt-pr: 18340
natechapin pushed a commit to natechapin/wpt that referenced this pull request Aug 23, 2019
This is a follow-up to
web-platform-tests#18324

This change by itself isn't sufficient to deflake the two tests.
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 4, 2019
…ing service worker tests, a=testonly

Automatic update from web-platform-tests
[cookie-store] Deflake service worker registration (part 2)

This is a follow-up to
web-platform-tests/wpt#18324

This change by itself isn't sufficient to deflake the two tests.

--
[cookie-store] Attempt to deflake two tests

Move the event handler registration to the top scope of the service
worker (Chrome warning: "Event handler of ... event must be added on the
initial evaluation of worker script.").

--

wpt-commits: a13797b678be16d1bec8cae0a8288e6101569cae, 909a1049b9431ae7e1a64c871b5c6822f0a90367
wpt-pr: 18340

UltraBlame original commit: e2ca31539fd1be204f9d095fa98d77521b82329a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 4, 2019
…ing service worker tests, a=testonly

Automatic update from web-platform-tests
[cookie-store] Deflake service worker registration (part 2)

This is a follow-up to
web-platform-tests/wpt#18324

This change by itself isn't sufficient to deflake the two tests.

--
[cookie-store] Attempt to deflake two tests

Move the event handler registration to the top scope of the service
worker (Chrome warning: "Event handler of ... event must be added on the
initial evaluation of worker script.").

--

wpt-commits: a13797b678be16d1bec8cae0a8288e6101569cae, 909a1049b9431ae7e1a64c871b5c6822f0a90367
wpt-pr: 18340

UltraBlame original commit: e2ca31539fd1be204f9d095fa98d77521b82329a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
…ing service worker tests, a=testonly

Automatic update from web-platform-tests
[cookie-store] Deflake service worker registration (part 2)

This is a follow-up to
web-platform-tests/wpt#18324

This change by itself isn't sufficient to deflake the two tests.

--
[cookie-store] Attempt to deflake two tests

Move the event handler registration to the top scope of the service
worker (Chrome warning: "Event handler of ... event must be added on the
initial evaluation of worker script.").

--

wpt-commits: a13797b678be16d1bec8cae0a8288e6101569cae, 909a1049b9431ae7e1a64c871b5c6822f0a90367
wpt-pr: 18340

UltraBlame original commit: e2ca31539fd1be204f9d095fa98d77521b82329a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants