forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear-Site-Data: clients uncontrolled by service workers after storag…
…e directive Adds a failing test, asserting that pages actively controlled by a service worker become uncontrolled after the Clear-Site-Data storage directive. We agreed on this behavior in a spec issue and confirmed the need for this test at the TPAC Service Workers F2F. w3c/ServiceWorker#614 F2F notes: https://docs.google.com/document/d/1_Qfw5m3BJEaL1xIzTJd41HXjgJ9gq7mroBDXqSJIzic/edit
- Loading branch information
Showing
5 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def main(request, response): | ||
return ([("Content-Type", "text/html")], | ||
"FROM_NETWORK") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Clear-Site-Data + Service Workers Test Page</title> | ||
</head> | ||
<body> | ||
<script> | ||
function beaconResponseBody(body) { | ||
window.top.postMessage({ | ||
subject: "service-worker-page-request", | ||
body: body | ||
}, "*"); | ||
} | ||
function requestServiceWorkerPage() { | ||
// Make a request to a URL that can be controlled by the service worker | ||
fetch("controlled-endpoint.py").then(function(result) { | ||
if (!result.ok) { | ||
beaconResponseBody(); | ||
} else { | ||
result.text().then(function (text) { | ||
beaconResponseBody(text); | ||
}); | ||
} | ||
}); | ||
} | ||
window.addEventListener("message", requestServiceWorkerPage); | ||
|
||
navigator.serviceWorker.addEventListener("controllerchange", function() { | ||
window.top.postMessage({ | ||
subject: "service-worker-page-controllerchange", | ||
hasController: !!navigator.serviceWorker.controller | ||
}, "*"); | ||
}); | ||
|
||
requestServiceWorkerPage(); | ||
</script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
/* This file is intentionally left blank. */ | ||
self.addEventListener('fetch', (e) => { | ||
const url = new URL(e.request.url); | ||
if (url.pathname.match('controlled-endpoint.py')) { | ||
e.respondWith(new Response('FROM_SERVICE_WORKER')); | ||
} | ||
}); |
This file contains 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