-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[WPT] BFCache: service worker clients #31082
Conversation
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 review process for this patch is being conducted in the Chromium project.
40c13a9
to
89b57ab
Compare
89b57ab
to
0dd142f
Compare
0dd142f
to
58615a8
Compare
html/browsers/browsing-the-web/back-forward-cache/service-worker-unregister.https.html
Outdated
Show resolved
Hide resolved
await pageA.execute_script(waitForPageShow); | ||
await assert_bfcached(pageA); | ||
|
||
// `pageA` should be still controlled after restored from BFCache. |
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.
Hmm, is this the behavior we want?
Given https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister
the registration would be there until bfcache entry is evicted or page brought back to foreground?
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.
@rakina, any thoughts?
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.
cc @rubberyuzu @wanderview @fergald as they have a better idea about SW interaction with bfcache
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.
Friendly ping. Any thoughts?
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.
In my understanding, according to the current https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister the registration is removed so that subsequent navigation are no longer controlled by the service worker, while the page in BFCache still remains controlled (as "currently controlled service worker client's active service worker's containing service worker registration is effective"), but not sure.
This also aligns with Firefox/Chrome/Safari's behavior.
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.
I don't think it matters here what browsers do here, since bfcache + SW is largely undefined. But it would be, IMO, rather odd to keep the page registered while you can't still communicate with it. So I would expect unregister to evict any bfcached pages (well, that is what UAs can do anyhow, since eviction may happen at any point).
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.
Oh, interesting. I think service worker unregistration actually already triggers eviction of the controllees in Chrome's implementation: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/service_worker/service_worker_container_host.cc;l=643;drc=b24429781c133fd2482edbb4d0c8c8305031b082
Not sure if this test is testing a different case, or is somehow not testing what it should be. But I guess eviction makes sense in the case linked above?
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.
@hiroshige-g, let's update the test to expect eviction after service worker unregistration. @smaug---- , do you have other concerns for the tests? Maybe we can add a Client.postMessage()
test too, but I don't think that's blocking the rest of the tests here from landing?
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.
I think service worker unregistration actually already triggers eviction of the controllees in Chrome's implementation:
Probably Comments 7 and 8 of https://bugs.chromium.org/p/chromium/issues/detail?id=1204228 is the explanation for this. Because there are still active controlled pages at the time of unregister()
, the full eviction code doesn't run.
Anyway I updated the test to expect eviction from BFCache on unregister()
.
09ba04a
to
19d7086
Compare
How should Client.postMessage behave if the other side is in bfcache? I guess evict the other side from bfcache. |
Yep we are already evicting in Chrome: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/service_worker/service_worker_version.cc;l=1448;drc=b24429781c133fd2482edbb4d0c8c8305031b082 |
2986287
to
432f728
Compare
This CL adds service worker tests for BFCache: - navigator.serviceWorker.controller - Fetch interception - Clients.claim() - Clients.matchAll() and - unregister(). Expected behavior: - Controlled pages should remain controlled after restored from BFCache, i.e. navigator.serviceWorker.controller should remain non-null and fetch should be intercepted. - Clients.claim() should evict pages that would be affected from BFCache. - Clients.matchAll() shouldn't list pages in BFCache. - unregister() should evict controlled pages from BFCache. Failing tests: - service-worker-clients-claim.https.html: On Safari/Firefox, Clients.claim() doesn't evict pages from BFCache. - service-worker-controlled-after-restore.https.html: On Firefox, fetches are not intercepted after restored from BFCache while `navigator.serviceWorker.controller` is non-null. - service-worker-unregister.https.html: Controlled pages aren't evicted by unregister() (all browsers). Bug: 1107415, 1204228, w3c/ServiceWorker#1594 Change-Id: I73233cf917e31dd91b974823d5490d0190f0eade Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3201011 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Reviewed-by: Ben Kelly <wanderview@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#1008327}
432f728
to
39f5f59
Compare
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> | ||
<script> | ||
// When a service worker is unregistered when a controlled page is in BFCache, | ||
// the page can be still restored from BFCache and remain controlled by the |
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.
This comment looks now wrong. The assertion is "navigator.serviceWorker.controller === null" and assertion comment 'pageA should not be controlled'
But there is no test for Client.postMessage? |
I'm adding basic tests for Client.postMessage. Firefox and Chrome behave in those similarly (once I land some tweaks to Gecko) |
Looks like the tests were reverted on chromium's side 40ac061 just when I had fixed something on Mozilla's side |
@hiroshige-g We should reland them but with flaky expectations and we can look at debugging them in the future. |
That is happening here #34505, but looks like Chrome has still some issues with the tests. |
If we were to force merge #34505 (once it's on mozilla-central) would you set the flaky metadata in Chrome as part of the sync? |
Yes, that'd be fine. Thanks. |
This CL adds service worker tests for BFCache:
Expected behavior:
restored from BFCache, i.e.
navigator.serviceWorker.controller should remain non-null
and fetch should be intercepted.
that would be affected from BFCache.
Failing tests:
On Safari/Firefox, Clients.claim() doesn't evict pages from BFCache.
On Firefox, fetches are not intercepted after restored from
BFCache while
navigator.serviceWorker.controller
is non-null.Controlled pages aren't evicted by unregister() (all browsers).
Bug: 1107415, 1204228, w3c/ServiceWorker#1594
Change-Id: I73233cf917e31dd91b974823d5490d0190f0eade
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3201011
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1008327}