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

Unified 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, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
diff --git a/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js b/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
index 5327843a0b62dc8432680179b5b6707e40d6964c..dbb5b2454cfe1fd5a7c34d6aae615ffa85018f6e 100644
--- a/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
+++ b/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
@@ -1,8 +1,25 @@
importScripts('/resources/testharness-helpers.js');
+// For copying Notification.data. Currently a deep copy algorithm is used. Note
+// that the robustness of this function (and also |assert_object_equals| in
+// testharness.js) affects the types of possible testing can be done.
+// TODO(peter): change this to a structured clone algorithm.
+function cloneObject(src) {
+ if (typeof src != 'object' || src === null)
+ return src;
+ var dst = Array.isArray(src) ? [] : {};
+ for (var property in src) {
+ if (src.hasOwnProperty(property))
+ dst[property] = cloneObject(src[property]);
+ }
+ return dst;
+}
+
// Copies the serializable attributes of |notification|.
function cloneNotification(notification) {
- return JSON.parse(stringifyDOMObject(notification));
+ var copiedNotification = JSON.parse(stringifyDOMObject(notification));
+ copiedNotification.data = cloneObject(notification.data);
+ return copiedNotification;
}
// Allows a document to exercise the Notifications API within a service worker by sending commands.
« 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