| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function timeoutPromise(value, ms) | 7 function timeoutPromise(value, ms) |
| 8 { | 8 { |
| 9 return new Promise(function promiseCallback(resolve, reject) { | 9 return new Promise(function promiseCallback(resolve, reject) { |
| 10 function resolvePromise() | 10 function resolvePromise() |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return new Promise(resolveCallback); | 38 return new Promise(resolveCallback); |
| 39 } | 39 } |
| 40 | 40 |
| 41 function testFunction() | 41 function testFunction() |
| 42 { | 42 { |
| 43 setTimeout(testFunctionTimeout, 0); | 43 setTimeout(testFunctionTimeout, 0); |
| 44 } | 44 } |
| 45 | 45 |
| 46 function testFunctionTimeout() | 46 function testFunctionTimeout() |
| 47 { | 47 { |
| 48 var functions = [doTestPromiseConstructor, doTestSettledPromisesResolved, do
TestSettledPromisesRejected, doTestChainedPromises, doTestChainedPromisesJSON, d
oTestPromiseAll, doTestThrowFromChain, doTestRejectFromChain, doTestPromiseResol
ve, doTestPromiseReject]; | 48 var functions = [doTestPromiseConstructor, doTestSettledPromisesResolved, do
TestSettledPromisesRejected, doTestChainedPromises, doTestChainedPromisesJSON]; |
| 49 for (var i = 0; i < functions.length; ++i) | 49 for (var i = 0; i < functions.length; ++i) |
| 50 functions[i](); | 50 functions[i](); |
| 51 } | 51 } |
| 52 | 52 |
| 53 function thenCallback(value) | 53 function thenCallback(value) |
| 54 { | 54 { |
| 55 debugger; | 55 debugger; |
| 56 } | 56 } |
| 57 | 57 |
| 58 function errorCallback(error) | 58 function errorCallback(error) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 try { | 115 try { |
| 116 let one = await timeoutPromise(1); | 116 let one = await timeoutPromise(1); |
| 117 let stringify = await JSON.stringify(one); | 117 let stringify = await JSON.stringify(one); |
| 118 let parse = await JSON.parse(stringify); | 118 let parse = await JSON.parse(stringify); |
| 119 thenCallback(parse); | 119 thenCallback(parse); |
| 120 } catch (e) { | 120 } catch (e) { |
| 121 errorCallback(e); | 121 errorCallback(e); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 async function doTestPromiseAll() | |
| 126 { | |
| 127 try { | |
| 128 let all = await Promise.all([11, 22, 33, 44, 55].map(timeoutPromise)); | |
| 129 thenCallback(all); | |
| 130 } catch (e) { | |
| 131 errorCallback(e); | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 async function throwFromChain() | |
| 136 { | |
| 137 await timeoutPromise(1); | |
| 138 await timeoutPromise(2); | |
| 139 await settledPromise(3); | |
| 140 throw Error("thrown from 4"); | |
| 141 await timeoutPromise(5); | |
| 142 debugger; | |
| 143 } | |
| 144 | |
| 145 async function doTestThrowFromChain() | |
| 146 { | |
| 147 try { | |
| 148 let result = await throwFromChain(); | |
| 149 thencallback(result); | |
| 150 } catch (e) { | |
| 151 errorCallback(e); | |
| 152 } | |
| 153 } | |
| 154 | |
| 155 async function rejectFromChain() | |
| 156 { | |
| 157 await timeoutPromise(1); | |
| 158 await timeoutPromise(2); | |
| 159 await timeoutPromise(3); | |
| 160 await timeoutPromise(new Error(4)); | |
| 161 throw new Error("thrown from rejectFromChain"); | |
| 162 debugger; | |
| 163 } | |
| 164 | |
| 165 async function doTestRejectFromChain() | |
| 166 { | |
| 167 try { | |
| 168 let result = await rejectFromChain(); | |
| 169 thenCallback(result); | |
| 170 } catch (e) { | |
| 171 errorCallback(e); | |
| 172 } | |
| 173 } | |
| 174 | |
| 175 async function doTestPromiseResolve() | |
| 176 { | |
| 177 try { | |
| 178 let result = await Promise.resolve(1); | |
| 179 thenCallback(result); | |
| 180 } catch (e) { | |
| 181 errorCallback(e); | |
| 182 } | |
| 183 } | |
| 184 | |
| 185 async function doTestPromiseReject() | |
| 186 { | |
| 187 try { | |
| 188 let result = await Promise.reject(new Error("2")) | |
| 189 thenCallback(result); | |
| 190 } catch (e) { | |
| 191 errorCallback(e); | |
| 192 } | |
| 193 } | |
| 194 | |
| 195 var test = function() | 125 var test = function() |
| 196 { | 126 { |
| 197 var totalDebuggerStatements = 15; | 127 var totalDebuggerStatements = 10; |
| 198 var maxAsyncCallStackDepth = 5; | 128 var maxAsyncCallStackDepth = 5; |
| 199 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallSt
ackDepth); | 129 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallSt
ackDepth); |
| 200 } | 130 } |
| 201 | 131 |
| 202 </script> | 132 </script> |
| 203 </head> | 133 </head> |
| 204 | 134 |
| 205 <body onload="runTest()"> | 135 <body onload="runTest()"> |
| 206 <p> | 136 <p> |
| 207 Tests asynchronous call stacks for async functions. | 137 Tests asynchronous call stacks for async functions. |
| 208 </p> | 138 </p> |
| 209 | 139 |
| 210 </body> | 140 </body> |
| 211 </html> | 141 </html> |
| OLD | NEW |