1 if (self.importScripts) {
2 importScripts('/resources/testharness.js');
3 importScripts('worker-helpers.js');
6 async_test(function(test) {
7 if (Notification.permission != 'granted') {
8 assert_unreached('No permission has been granted for displaying notifications.');
12 // We require two asynchronous events to happen when a notification gets updated, (1)
13 // the old instance should receive the "close" event, and (2) the new notification
14 // should receive the "show" event, but only after (1) has happened.
15 var closedOriginalNotification = false;
17 var notification = new Notification('My Notification', { tag: 'notification-test' });
18 notification.addEventListener('show', function() {
19 var updatedNotification = new Notification('Second Notification', { tag: 'notification-test' });
20 updatedNotification.addEventListener('show', function() {
21 assert_true(closedOriginalNotification);
26 notification.addEventListener('close', function() {
27 closedOriginalNotification = true;
30 notification.addEventListener('error', function() {
31 assert_unreached('The error event should not be thrown.');
34 }, 'Replacing a notification will discard the previous notification.');
36 if (isDedicatedOrSharedWorker())