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

Side by Side Diff: LayoutTests/http/tests/resources/testharness-helpers.js

Issue 885343002: bindings: Fixes connect-helper to use stringifyDOMObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed review comments. Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/navigatorconnect/resources/connect-helper.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * testharness-helpers contains various useful extensions to testharness.js to 2 * testharness-helpers contains various useful extensions to testharness.js to
3 * allow them to be used across multiple tests before they have been 3 * allow them to be used across multiple tests before they have been
4 * upstreamed. This file is intended to be usable from both document and worker 4 * upstreamed. This file is intended to be usable from both document and worker
5 * environments, so code should for example not rely on the DOM. 5 * environments, so code should for example not rely on the DOM.
6 */ 6 */
7 7
8 // Returns a promise that fulfills after the provided |promise| is fulfilled. 8 // Returns a promise that fulfills after the provided |promise| is fulfilled.
9 // The |test| succeeds only if |promise| rejects with an exception matching 9 // The |test| succeeds only if |promise| rejects with an exception matching
10 // |code|. Accepted values for |code| follow those accepted for assert_throws(). 10 // |code|. Accepted values for |code| follow those accepted for assert_throws().
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 assert_true(typeof object === "object", description); 137 assert_true(typeof object === "object", description);
138 138
139 assert_true("hasOwnProperty" in object, description); 139 assert_true("hasOwnProperty" in object, description);
140 140
141 // Do not test if |attribute_name| is not an own property because 141 // Do not test if |attribute_name| is not an own property because
142 // |attribute_name| is in the middle of the transition to a prototype 142 // |attribute_name| is in the middle of the transition to a prototype
143 // chain. (http://crbug.com/43394) 143 // chain. (http://crbug.com/43394)
144 144
145 assert_true(attribute_name in object, description); 145 assert_true(attribute_name in object, description);
146 } 146 }
147
148 // Stringifies a DOM object. This function stringifies not only own properties
149 // but also DOM attributes which are on a prototype chain. Note that
150 // JSON.stringify only stringifies own properties.
151 function stringifyDOMObject(object)
152 {
153 function deepCopy(src) {
154 if (typeof src != "object")
155 return src;
156 var dst = Array.isArray(src) ? [] : {};
157 for (var property in src) {
158 dst[property] = deepCopy(src[property]);
159 }
160 return dst;
161 }
162 return JSON.stringify(deepCopy(object));
163 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/navigatorconnect/resources/connect-helper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698