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 --- .../tests/fenced-frame/resources/badging-sw.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 testing/web-platform/tests/fenced-frame/resources/badging-sw.js (limited to 'testing/web-platform/tests/fenced-frame/resources/badging-sw.js') diff --git a/testing/web-platform/tests/fenced-frame/resources/badging-sw.js b/testing/web-platform/tests/fenced-frame/resources/badging-sw.js new file mode 100644 index 0000000000..5bc3c9a190 --- /dev/null +++ b/testing/web-platform/tests/fenced-frame/resources/badging-sw.js @@ -0,0 +1,23 @@ +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; + if (method === 'setAppBadge') { + promise = self.navigator.setAppBadge(1); + } else if (method === 'clearAppBadge') { + promise = self.navigator.clearAppBadge(); + } else { + promise = Promise.resolve(); + } + + const error = await promise + .then(() => { + return `[Badging API ${method}] Unexpectedly started`; + }) + .catch((e) => e); + + e.source.postMessage(error); +}); -- cgit v1.2.3