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

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

Issue 2403893002: Add layout test for reply property of notificationclick event (Closed)
Patch Set: Make reply field nullable in .idl files; add test cases for empty and null Created 4 years, 2 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 // Deep-copies the attributes of |notification|. Note that the 1 // Deep-copies the attributes of |notification|. Note that the
2 // robustness of this function (and also |assert_object_equals| in 2 // robustness of this function (and also |assert_object_equals| in
3 // testharness.js) affects the types of possible testing can be done. 3 // testharness.js) affects the types of possible testing can be done.
4 // TODO(peter): change this to a structured clone algorithm. 4 // TODO(peter): change this to a structured clone algorithm.
5 function cloneNotification(notification) { 5 function cloneNotification(notification) {
6 function deepCopy(src) { 6 function deepCopy(src) {
7 if (typeof src !== 'object' || src === null) 7 if (typeof src !== 'object' || src === null)
8 return src; 8 return src;
9 var dst = Array.isArray(src) ? [] : {}; 9 var dst = Array.isArray(src) ? [] : {};
10 for (var property in src) { 10 for (var property in src) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (event.notification.body.indexOf('ACTION:CLOSE') != -1) 105 if (event.notification.body.indexOf('ACTION:CLOSE') != -1)
106 event.notification.close(); 106 event.notification.close();
107 107
108 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp t 108 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp t
109 // to open a new window for an example URL. 109 // to open a new window for an example URL.
110 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) 110 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1)
111 event.waitUntil(clients.openWindow('https://example.com/')); 111 event.waitUntil(clients.openWindow('https://example.com/'));
112 112
113 messagePort.postMessage({ command: 'click', 113 messagePort.postMessage({ command: 'click',
114 notification: notificationCopy, 114 notification: notificationCopy,
115 action: event.action }); 115 action: event.action,
116 reply: event.reply });
116 }); 117 });
117 118
118 addEventListener('notificationclose', event => { 119 addEventListener('notificationclose', event => {
119 var notificationCopy = cloneNotification(event.notification); 120 var notificationCopy = cloneNotification(event.notification);
120 messagePort.postMessage({ command: 'close', 121 messagePort.postMessage({ command: 'close',
121 notification: notificationCopy }); 122 notification: notificationCopy });
122 }); 123 });
123 124
124 addEventListener('fetch', event => { 125 addEventListener('fetch', event => {
125 fetchHistory.push(event.request.url); 126 fetchHistory.push(event.request.url);
126 event.respondWith(fetch(event.request)); 127 event.respondWith(fetch(event.request));
127 }); 128 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698