Index: third_party/WebKit/LayoutTests/http/tests/notifications/instrumentation-service-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/instrumentation-service-worker.js b/third_party/WebKit/LayoutTests/http/tests/notifications/instrumentation-service-worker.js |
index 16c6b8231636f6e2b9dd2e796a3c6e9cee9e4636..fcda391abc6355b4f95dbdde4b57451606a12040 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/instrumentation-service-worker.js |
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/instrumentation-service-worker.js |
@@ -1,25 +1,21 @@ |
-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 |
+// Deep-copies the attributes of |notification|. 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]); |
+function cloneNotification(notification) { |
+ function deepCopy(src) { |
+ if (typeof src !== 'object' || src === null) |
+ return src; |
+ var dst = Array.isArray(src) ? [] : {}; |
+ for (var property in src) { |
+ if (typeof src[property] === 'function') |
+ continue; |
+ dst[property] = deepCopy(src[property]); |
+ } |
+ return dst; |
} |
- return dst; |
-} |
-// Copies the serializable attributes of |notification|. |
-function cloneNotification(notification) { |
- var copiedNotification = JSON.parse(stringifyDOMObject(notification)); |
- copiedNotification.data = cloneObject(notification.data); |
- return copiedNotification; |
+ return deepCopy(notification); |
} |
// Allows a document to exercise the Notifications API within a service worker by sending commands. |