| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (typeof src != "object") | 135 if (typeof src != "object") |
| 136 return src; | 136 return src; |
| 137 var dst = Array.isArray(src) ? [] : {}; | 137 var dst = Array.isArray(src) ? [] : {}; |
| 138 for (var property in src) { | 138 for (var property in src) { |
| 139 dst[property] = deepCopy(src[property]); | 139 dst[property] = deepCopy(src[property]); |
| 140 } | 140 } |
| 141 return dst; | 141 return dst; |
| 142 } | 142 } |
| 143 return JSON.stringify(deepCopy(object)); | 143 return JSON.stringify(deepCopy(object)); |
| 144 } | 144 } |
| 145 | |
| 146 (function() { | |
| 147 var promise_tests = Promise.resolve(); | |
| 148 // Helper function to run promise tests one after the other. | |
| 149 // TODO(ortuno): Remove once https://github.com/w3c/testharness.js/pull/115/fi
les | |
| 150 // gets through. | |
| 151 function sequential_promise_test(func, name) { | |
| 152 var test = async_test(name); | |
| 153 promise_tests = promise_tests.then(function() { | |
| 154 return test.step(func, test, test); | |
| 155 }).then(function() { | |
| 156 test.done(); | |
| 157 }).catch(test.step_func(function(value) { | |
| 158 // step_func catches the error again so the error doesn't propagate. | |
| 159 throw value; | |
| 160 })); | |
| 161 } | |
| 162 | |
| 163 self.sequential_promise_test = sequential_promise_test; | |
| 164 })(); | |
| OLD | NEW |