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

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

Issue 1935703003: Layout Tests: Remove stringifyDOMObject() helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-idlattr
Patch Set: Update expectation for test w/ line # change Created 4 years, 8 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 | third_party/WebKit/LayoutTests/http/tests/resources/testharness-helpers.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/resources/testharness-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698