| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |