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

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: 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..07f85ebf520ca74401be98558c1f5ac7f2e146c4 100644
--- a/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
+++ b/LayoutTests/http/tests/notifications/resources/instrumentation-service-worker.js
@@ -1,8 +1,28 @@
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')
Peter Beverloo 2015/09/01 15:31:44 nit: could change this to the following, which mat
lwchkg 2015/09/01 16:21:09 Sounds good.
+ return src;
+ if (src === null)
+ return null;
+ var dst = Array.isArray(src) ? [] : {};
+ for (var property in src) {
+ if (src.hasOwnProperty(property)) {
Peter Beverloo 2015/09/01 15:31:44 nit: no need for {} (one-statement if clause)
lwchkg 2015/09/01 16:21:09 Acknowledged.
+ dst[property] = cloneObject(src[property]);
+ }
+ }
+ return dst;
+}
+
// Copies the serializable attributes of |notification|.
function cloneNotification(notification) {
- return JSON.parse(stringifyDOMObject(notification));
+ var dst = JSON.parse(stringifyDOMObject(notification));
Peter Beverloo 2015/09/01 15:31:44 nit: could we name this "copiedNotification"? We p
lwchkg 2015/09/01 16:21:09 Sounds good. Agree that "dst" is not clear enough.
+ dst.data = cloneObject(notification.data);
+ return dst;
}
// 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