OLD | NEW |
1 importScripts('/resources/testharness-helpers.js'); | 1 importScripts('/resources/testharness-helpers.js'); |
2 | 2 |
3 // Copies the serializable attributes of |notification|. | 3 // Copies the serializable attributes of |notification|. |
4 function cloneNotification(notification) { | 4 function cloneNotification(notification) { |
5 return JSON.parse(stringifyDOMObject(notification)); | 5 return JSON.parse(stringifyDOMObject(notification)); |
6 } | 6 } |
7 | 7 |
8 // Allows a document to exercise the Notifications API within a service worker b
y sending commands. | 8 // Allows a document to exercise the Notifications API within a service worker b
y sending commands. |
9 var messagePort = null; | 9 var messagePort = null; |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // immediately by the Service Worker. | 70 // immediately by the Service Worker. |
71 if (event.notification.body.indexOf('ACTION:CLOSE') != -1) | 71 if (event.notification.body.indexOf('ACTION:CLOSE') != -1) |
72 event.notification.close(); | 72 event.notification.close(); |
73 | 73 |
74 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp
t | 74 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp
t |
75 // to open a new window for an example URL. | 75 // to open a new window for an example URL. |
76 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) | 76 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) |
77 event.waitUntil(clients.openWindow('https://example.com/')); | 77 event.waitUntil(clients.openWindow('https://example.com/')); |
78 | 78 |
79 messagePort.postMessage({ command: 'click', | 79 messagePort.postMessage({ command: 'click', |
80 notification: notificationCopy }); | 80 notification: notificationCopy, |
| 81 action: event.action }); |
81 }); | 82 }); |
OLD | NEW |