Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js

Issue 1656823002: Add layout tests for ServiceWorker's notificationclose event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now the test actually works Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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});
Peter Beverloo 2016/02/02 23:50:10 micro nit: space before }
Nina 2016/02/03 15:04:23 Done.
110 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698