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

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

Issue 1311413006: - Changed instrumentation-service-worker.js so the value NaN can be tested (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Respond to comments Created 5 years, 3 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-data-reflection.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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.
6 // TODO(peter): change this to a structured clone algorithm.
7 function cloneObject(src) {
8 if (typeof src != 'object' || src === null)
9 return src;
10 var dst = Array.isArray(src) ? [] : {};
11 for (var property in src) {
12 if (src.hasOwnProperty(property))
13 dst[property] = cloneObject(src[property]);
14 }
15 return dst;
16 }
17
3 // Copies the serializable attributes of |notification|. 18 // Copies the serializable attributes of |notification|.
4 function cloneNotification(notification) { 19 function cloneNotification(notification) {
5 return JSON.parse(stringifyDOMObject(notification)); 20 var copiedNotification = JSON.parse(stringifyDOMObject(notification));
21 copiedNotification.data = cloneObject(notification.data);
22 return copiedNotification;
6 } 23 }
7 24
8 // Allows a document to exercise the Notifications API within a service worker b y sending commands. 25 // Allows a document to exercise the Notifications API within a service worker b y sending commands.
9 var messagePort = null; 26 var messagePort = null;
10 27
11 addEventListener('message', function(workerEvent) { 28 addEventListener('message', function(workerEvent) {
12 messagePort = workerEvent.data; 29 messagePort = workerEvent.data;
13 30
14 // Listen to incoming commands on the message port. 31 // Listen to incoming commands on the message port.
15 messagePort.onmessage = function(event) { 32 messagePort.onmessage = function(event) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 90
74 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp t 91 // Notifications containing "ACTION:OPENWINDOW" in their message will attemp t
75 // to open a new window for an example URL. 92 // to open a new window for an example URL.
76 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1) 93 if (event.notification.body.indexOf('ACTION:OPENWINDOW') != -1)
77 event.waitUntil(clients.openWindow('https://example.com/')); 94 event.waitUntil(clients.openWindow('https://example.com/'));
78 95
79 messagePort.postMessage({ command: 'click', 96 messagePort.postMessage({ command: 'click',
80 notification: notificationCopy, 97 notification: notificationCopy,
81 action: event.action }); 98 action: event.action });
82 }); 99 });
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-data-reflection.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698