diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/serviceworkers/test/sw_storage_not_allow.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/serviceworkers/test/sw_storage_not_allow.js')
-rw-r--r-- | dom/serviceworkers/test/sw_storage_not_allow.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/sw_storage_not_allow.js b/dom/serviceworkers/test/sw_storage_not_allow.js new file mode 100644 index 0000000000..2eb2403309 --- /dev/null +++ b/dom/serviceworkers/test/sw_storage_not_allow.js @@ -0,0 +1,33 @@ +let clientId; +addEventListener("fetch", function (event) { + event.respondWith( + (async function () { + if (event.request.url.includes("getClients")) { + // Expected to fail since the storage access is not allowed. + try { + await self.clients.matchAll(); + } catch (e) { + // expected failure + } + } else if (event.request.url.includes("getClient-stage1")) { + let clients = await self.clients.matchAll(); + clientId = clients[0].id; + } else if (event.request.url.includes("getClient-stage2")) { + // Expected to fail since the storage access is not allowed. + try { + await self.clients.get(clientId); + } catch (e) { + // expected failure + } + } + + // Pass through the network request once our various Clients API + // promises have completed. + return await fetch(event.request); + })() + ); +}); + +addEventListener("activate", function (event) { + event.waitUntil(clients.claim()); +}); |