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