Index: LayoutTests/http/tests/resources/testharness-helpers.js |
diff --git a/LayoutTests/http/tests/resources/testharness-helpers.js b/LayoutTests/http/tests/resources/testharness-helpers.js |
index d241ac0e4882222a01807c49510d786614eab4c4..4d7af1ff9ca77c85696f35368ff3a7a1c4b2480b 100644 |
--- a/LayoutTests/http/tests/resources/testharness-helpers.js |
+++ b/LayoutTests/http/tests/resources/testharness-helpers.js |
@@ -144,3 +144,20 @@ function assert_will_be_idl_attribute(object, attribute_name, description) { |
assert_true(attribute_name in object, description); |
} |
+ |
+// Stringifies a DOM object. This function stringifies not only own properties |
+// but also DOM attributes which are on a prototype chain. Note that |
+// JSON.stringify only stringifies own properties. |
+function stringifyDOMObject(object) |
+{ |
+ function deepCopy(src) { |
+ if (typeof src != "object") |
+ return src; |
+ var dst = Array.isArray(src) ? [] : {}; |
+ for (var property in src) { |
+ dst[property] = deepCopy(src[property]); |
+ } |
+ return dst; |
+ } |
+ return JSON.stringify(deepCopy(object)); |
+} |