From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../fenced-frame/resources/background-fetch-sw.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 testing/web-platform/tests/fenced-frame/resources/background-fetch-sw.js (limited to 'testing/web-platform/tests/fenced-frame/resources/background-fetch-sw.js') diff --git a/testing/web-platform/tests/fenced-frame/resources/background-fetch-sw.js b/testing/web-platform/tests/fenced-frame/resources/background-fetch-sw.js new file mode 100644 index 0000000000..44b7d087b5 --- /dev/null +++ b/testing/web-platform/tests/fenced-frame/resources/background-fetch-sw.js @@ -0,0 +1,36 @@ +self.addEventListener('install', e => e.waitUntil(skipWaiting())); +self.addEventListener('activate', e => e.waitUntil(clients.claim())); + +self.addEventListener('message', async e => { + const method = e.data; + + let promise; + switch (method) { + case 'fetch': + promise = self.registration.backgroundFetch.fetch( + 'test-fetch', ['background-fetch-inner.https.html.headers'], + {title: 'Background Fetch'}); + break; + case 'get': + promise = self.registration.backgroundFetch.get('test-fetch') + break; + case 'getIds': + promise = registration.backgroundFetch.getIds(); + break; + default: + promise = Promise.resolve(); + break; + } + + const message = + await promise + .then(() => { + return `[backgroundFetch.${method}] Unexpectedly started`; + }) + .catch((e) => { + return `[backgroundFetch.${ + method}] Failed inside fencedframe as expected`; + }); + + e.source.postMessage(message); +}); -- cgit v1.2.3