OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script> |
| 5 |
| 6 function createPromiseAndScheduleResolve() |
| 7 { |
| 8 var resolveCallback; |
| 9 var promise = new Promise((resolve) => resolveCallback = resolve); |
| 10 setTimeout(resolveCallback.bind(null, { a : 239 }), 0); |
| 11 return promise; |
| 12 } |
| 13 |
| 14 function test() |
| 15 { |
| 16 InspectorTest.runTestSuite([ |
| 17 function testResolvedPromise(next) |
| 18 { |
| 19 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
Promise.resolve(239)", awaitPromise: true, generatePreview: true }) |
| 20 .then((result) => InspectorTest.logObject(result.result)) |
| 21 .then(() => next()); |
| 22 }, |
| 23 |
| 24 function testRejectedPromise(next) |
| 25 { |
| 26 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
Promise.reject(239)", awaitPromise: true }) |
| 27 .then((result) => InspectorTest.logObject(result.result)) |
| 28 .then(() => next()); |
| 29 }, |
| 30 |
| 31 function testPrimitiveValueInsteadOfPromise(next) |
| 32 { |
| 33 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
true", awaitPromise: true }) |
| 34 .then((result) => InspectorTest.logObject(result.error)) |
| 35 .then(() => next()); |
| 36 }, |
| 37 |
| 38 function testObjectInsteadOfPromise(next) |
| 39 { |
| 40 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
({})", awaitPromise: true }) |
| 41 .then((result) => InspectorTest.logObject(result.error)) |
| 42 .then(() => next()); |
| 43 }, |
| 44 |
| 45 function testPendingPromise(next) |
| 46 { |
| 47 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
createPromiseAndScheduleResolve()", awaitPromise: true, returnByValue: true }) |
| 48 .then((result) => InspectorTest.logObject(result.result)) |
| 49 .then(() => next()); |
| 50 }, |
| 51 |
| 52 function testExceptionInEvaluate(next) |
| 53 { |
| 54 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
throw 239", awaitPromise: true }) |
| 55 .then((result) => dumpResult(result.result)) |
| 56 .then(() => next()); |
| 57 |
| 58 function dumpResult(result) |
| 59 { |
| 60 result.exceptionDetails.scriptId = ""; |
| 61 InspectorTest.logObject(result); |
| 62 } |
| 63 } |
| 64 ]); |
| 65 } |
| 66 </script> |
| 67 </head> |
| 68 <body onLoad="runTest();"> |
| 69 Tests that Runtime.evaluate works with awaitPromise flag. |
| 70 </body> |
| 71 </html> |
| 72 |
OLD | NEW |