| OLD | NEW |
| 1 importScripts('/resources/testharness-helpers.js'); | 1 importScripts('/resources/testharness-helpers.js'); |
| 2 | 2 |
| 3 // For copying Notification.data. Currently a deep copy algorithm is used. Note | 3 // For copying Notification.data. Currently a deep copy algorithm is used. Note |
| 4 // that the robustness of this function (and also |assert_object_equals| in | 4 // that the robustness of this function (and also |assert_object_equals| in |
| 5 // testharness.js) affects the types of possible testing can be done. | 5 // testharness.js) affects the types of possible testing can be done. |
| 6 // TODO(peter): change this to a structured clone algorithm. | 6 // TODO(peter): change this to a structured clone algorithm. |
| 7 function cloneObject(src) { | 7 function cloneObject(src) { |
| 8 if (typeof src != 'object' || src === null) | 8 if (typeof src != 'object' || src === null) |
| 9 return src; | 9 return src; |
| 10 var dst = Array.isArray(src) ? [] : {}; | 10 var dst = Array.isArray(src) ? [] : {}; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp
t | 96 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp
t |
| 97 // to open a new window for an example URL. | 97 // to open a new window for an example URL. |
| 98 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) | 98 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) |
| 99 event.waitUntil(clients.openWindow('https://example.com/')); | 99 event.waitUntil(clients.openWindow('https://example.com/')); |
| 100 | 100 |
| 101 messagePort.postMessage({ command: 'click', | 101 messagePort.postMessage({ command: 'click', |
| 102 notification: notificationCopy, | 102 notification: notificationCopy, |
| 103 action: event.action }); | 103 action: event.action }); |
| 104 }); | 104 }); |
| 105 |
| 106 addEventListener('notificationclose', function(event) { |
| 107 var notificationCopy = cloneNotification(event.notification); |
| 108 messagePort.postMessage({ command: 'close', |
| 109 notification: notificationCopy }); |
| 110 }); |
| OLD | NEW |