| 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 = [doTestPromiseAll, doTestThrowFromChain, doTestRejectFromCha
in, doTestPromiseResolve, doTestPromiseReject]; | 48 var functions = [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) |
| 59 { | 59 { |
| 60 debugger; | 60 debugger; |
| 61 } | 61 } |
| 62 | 62 |
| 63 async function doTestPromiseAll() | 63 async function doTestChainedPromises() |
| 64 { | 64 { |
| 65 try { | 65 try { |
| 66 let all = await Promise.all([11, 22, 33, 44, 55].map(timeoutPromise)); | 66 await timeoutPromise(1); |
| 67 thenCallback(all); | 67 debugger; |
| 68 await timeoutPromise(2); |
| 69 debugger; |
| 70 await 3; |
| 71 debugger; |
| 72 await settledPromise(4); |
| 73 debugger; |
| 74 thenCallback(await timeoutPromise(5)); |
| 68 } catch (e) { | 75 } catch (e) { |
| 69 errorCallback(e); | 76 errorCallback(e); |
| 70 } | 77 } |
| 71 } | 78 } |
| 72 | 79 |
| 73 async function throwFromChain() | 80 async function doTestChainedPromisesJSON() |
| 74 { | |
| 75 await timeoutPromise(1); | |
| 76 await timeoutPromise(2); | |
| 77 await settledPromise(3); | |
| 78 throw Error("thrown from 4"); | |
| 79 await timeoutPromise(5); | |
| 80 debugger; | |
| 81 } | |
| 82 | |
| 83 async function doTestThrowFromChain() | |
| 84 { | 81 { |
| 85 try { | 82 try { |
| 86 let result = await throwFromChain(); | 83 let one = await timeoutPromise(1); |
| 87 thencallback(result); | 84 let stringify = await JSON.stringify(one); |
| 85 let parse = await JSON.parse(stringify); |
| 86 thenCallback(parse); |
| 88 } catch (e) { | 87 } catch (e) { |
| 89 errorCallback(e); | 88 errorCallback(e); |
| 90 } | 89 } |
| 91 } | |
| 92 | |
| 93 async function rejectFromChain() | |
| 94 { | |
| 95 await timeoutPromise(1); | |
| 96 await timeoutPromise(2); | |
| 97 await timeoutPromise(3); | |
| 98 await timeoutPromise(new Error(4)); | |
| 99 throw new Error("thrown from rejectFromChain"); | |
| 100 debugger; | |
| 101 } | |
| 102 | |
| 103 async function doTestRejectFromChain() | |
| 104 { | |
| 105 try { | |
| 106 let result = await rejectFromChain(); | |
| 107 thenCallback(result); | |
| 108 } catch (e) { | |
| 109 errorCallback(e); | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 async function doTestPromiseResolve() | |
| 114 { | |
| 115 try { | |
| 116 let result = await Promise.resolve(1); | |
| 117 thenCallback(result); | |
| 118 } catch (e) { | |
| 119 errorCallback(e); | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 async function doTestPromiseReject() | |
| 124 { | |
| 125 try { | |
| 126 let result = await Promise.reject(new Error("2")) | |
| 127 thenCallback(result); | |
| 128 } catch (e) { | |
| 129 errorCallback(e); | |
| 130 } | |
| 131 } | 90 } |
| 132 | 91 |
| 133 var test = function() | 92 var test = function() |
| 134 { | 93 { |
| 135 var totalDebuggerStatements = 5; | 94 var totalDebuggerStatements = 6; |
| 136 var maxAsyncCallStackDepth = 5; | 95 var maxAsyncCallStackDepth = 5; |
| 137 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallSt
ackDepth); | 96 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallSt
ackDepth); |
| 138 } | 97 } |
| 139 | 98 |
| 140 </script> | 99 </script> |
| 141 </head> | 100 </head> |
| 142 | 101 |
| 143 <body onload="runTest()"> | 102 <body onload="runTest()"> |
| 144 <p> | 103 <p> |
| 145 Tests asynchronous call stacks for async functions. | 104 Tests asynchronous call stacks for async functions. |
| 146 </p> | 105 </p> |
| 147 | 106 |
| 148 </body> | 107 </body> |
| 149 </html> | 108 </html> |
| OLD | NEW |