registration-association.https.window.js (1574B)
1 // META: script=/resources/testdriver.js 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=resources/helpers.js 4 5 "use strict"; 6 7 /** @type {ServiceWorkerRegistration} */ 8 let registration; 9 10 promise_setup(async () => { 11 registration = await prepareActiveServiceWorker("noop-sw.js"); 12 await trySettingPermission("granted"); 13 }); 14 15 promise_test(async (t) => { 16 t.add_cleanup(closeAllNotifications); 17 18 await registration.showNotification("foo"); 19 await registration.unregister(); 20 registration = await prepareActiveServiceWorker("noop-sw.js"); 21 const notifications = await registration.getNotifications(); 22 23 // The spec says notifications should be associated with service worker registration 24 // and thus unregistering should dissociate the notification. 25 // 26 // (Step 5.2 of https://notifications.spec.whatwg.org/#dom-serviceworkerregistration-getnotifications) 27 // > Let notifications be a list of all notifications in the list of notifications whose origin 28 // > is same origin with origin, whose service worker registration is this, and whose tag, if tag 29 // > is not the empty string, is tag. 30 assert_equals(notifications.length, 0, "Should return zero notification"); 31 }, "A new SW registration gets no previous notification"); 32 33 promise_test(async (t) => { 34 await registration.showNotification("foo"); 35 await registration.unregister(); 36 const notifications = await registration.getNotifications(); 37 assert_equals(notifications.length, 0, "Should return zero notification"); 38 }, "An unregistered SW registration gets no previous notification");