| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
| 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | |
| 5 <script> | |
| 6 | |
| 7 function createPromise() | |
| 8 { | |
| 9 var result = {}; | |
| 10 var p = new Promise(function(resolve, reject) { | |
| 11 result.resolve = resolve; | |
| 12 result.reject = reject; | |
| 13 }); | |
| 14 result.promise = p; | |
| 15 return result; | |
| 16 } | |
| 17 | |
| 18 function testFunction() | |
| 19 { | |
| 20 var resolved = createPromise(); | |
| 21 var caught = createPromise(); | |
| 22 var uncaught = createPromise(); | |
| 23 | |
| 24 caught.promise | |
| 25 .then(function c1() {}) | |
| 26 .then(function c2() {}) | |
| 27 .catch(function c3() {}); | |
| 28 uncaught.promise | |
| 29 .then(function f1() {}) | |
| 30 .then(function f2() {}) | |
| 31 .then(function f3() {}); // Last is uncaught. | |
| 32 | |
| 33 resolved.resolve(42); // Should not pause. | |
| 34 caught.reject(new Error("caught")); | |
| 35 uncaught.reject(new Error("uncaught")); | |
| 36 } | |
| 37 | |
| 38 var test = function() | |
| 39 { | |
| 40 InspectorTest.setQuiet(true); | |
| 41 InspectorTest.startDebuggerTest(step1); | |
| 42 | |
| 43 function waitUntilPausedNTimes(count, callback) | |
| 44 { | |
| 45 function inner() | |
| 46 { | |
| 47 if (count--) | |
| 48 InspectorTest.waitUntilPausedAndDumpStackAndResume(inner); | |
| 49 else | |
| 50 callback(); | |
| 51 } | |
| 52 inner(); | |
| 53 } | |
| 54 | |
| 55 function step1() | |
| 56 { | |
| 57 InspectorTest.DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerMo
del.PauseOnExceptionsState.PauseOnUncaughtExceptions); | |
| 58 InspectorTest.showScriptSource("debugger-pause-on-promise-rejection.html
", step2); | |
| 59 } | |
| 60 | |
| 61 function step2() | |
| 62 { | |
| 63 InspectorTest.addResult("=== Pausing only on uncaught exceptions ==="); | |
| 64 InspectorTest.runTestFunction(); | |
| 65 waitUntilPausedNTimes(1, step3); | |
| 66 } | |
| 67 | |
| 68 function step3() | |
| 69 { | |
| 70 InspectorTest.DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerMo
del.PauseOnExceptionsState.PauseOnAllExceptions); | |
| 71 InspectorTest.addResult("\n=== Pausing on all exceptions ==="); | |
| 72 InspectorTest.runTestFunction(); | |
| 73 waitUntilPausedNTimes(2, step4); | |
| 74 } | |
| 75 | |
| 76 function step4() | |
| 77 { | |
| 78 InspectorTest.DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerMo
del.PauseOnExceptionsState.DontPauseOnExceptions); | |
| 79 InspectorTest.completeDebuggerTest(); | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 </script> | |
| 84 </head> | |
| 85 | |
| 86 <body onload="runTest()"> | |
| 87 <p> | |
| 88 Tests that pause on promise rejection works. | |
| 89 </p> | |
| 90 | |
| 91 </body> | |
| 92 </html> | |
| OLD | NEW |