summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/notification-sw.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/fenced-frame/resources/notification-sw.js')
-rw-r--r--testing/web-platform/tests/fenced-frame/resources/notification-sw.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fenced-frame/resources/notification-sw.js b/testing/web-platform/tests/fenced-frame/resources/notification-sw.js
new file mode 100644
index 0000000000..e9b1e2b9dd
--- /dev/null
+++ b/testing/web-platform/tests/fenced-frame/resources/notification-sw.js
@@ -0,0 +1,20 @@
+self.addEventListener('install', e => e.waitUntil(skipWaiting()));
+self.addEventListener('activate', e => e.waitUntil(clients.claim()));
+
+self.addEventListener('message', async event => {
+ const method = event.data;
+
+ if (method === 'constructor') {
+ try {
+ new Notification('test');
+ } catch (e) {
+ event.source.postMessage(e.message);
+ }
+ } else if (method === 'showNotification') {
+ try {
+ await self.registration.showNotification('test', {body: 'test'});
+ } catch (e) {
+ event.source.postMessage(e.message);
+ }
+ }
+});