Skip to content

Commit

Permalink
Fix Clear-Site-Data WPT that clears active service worker.
Browse files Browse the repository at this point in the history
A service worker was handling the network request for an iframe page
load. That load also cleared storage (and service workers) via Clear-
Site-Data. This interrupted the page load and prevented the test from
completing.

Specifically, 'support/echo-clear-site-data.py' was returning
[Clear-Site-Data: "storage"] which clobbered the service worker which
was registered for 'support/' which prevented the subload of
'support/test_utils.sub.js'.

The solution is to narrow the scope of the service worker so that it
doesn't apply to the page the iframe is loading.

Bug: 1198698
Change-Id: I6724f5ef8e2140d031b6c570b9c708359a97d140
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4334942
Reviewed-by: Ayu Ishii <[email protected]>
Commit-Queue: Evan Stade <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1116968}
  • Loading branch information
Evan Stade authored and chromium-wpt-export-bot committed Mar 14, 2023
1 parent a823469 commit 2dc57a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clear-site-data/storage.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
.then(() => {
return new Promise(function(resolve, reject) {
promise_test(function(t) {
return navigator.serviceWorker.getRegistration("support/").then(function(reg) {
return navigator.serviceWorker.getRegistration("support/page_using_service_worker.html").then(function(reg) {
return wait_for_state(t, reg.installing || reg.waiting || reg.active, 'activated');
}).then(resolve, reject);
});
Expand Down
2 changes: 1 addition & 1 deletion clear-site-data/support/test_utils.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var TestUtils = (function() {
"add": function() {
return navigator.serviceWorker.register(
"support/service_worker.js",
{ scope: "support/"});
{ scope: "support/page_using_service_worker.html"});
},
"isEmpty": function() {
return new Promise(function(resolve, reject) {
Expand Down

0 comments on commit 2dc57a5

Please sign in to comment.