OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-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 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 | |
26 InspectorTest.runTestSuite([ | |
27 function testResolvedPromise(next) | |
28 { | |
29 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
Promise.resolve(239)", awaitPromise: true, generatePreview: true }) | |
30 .then((result) => dumpResult(result.result)) | |
31 .then(() => next()); | |
32 }, | |
33 | |
34 function testRejectedPromise(next) | |
35 { | |
36 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
Promise.reject(239)", awaitPromise: true }) | |
37 .then((result) => dumpResult(result.result)) | |
38 .then(() => next()); | |
39 }, | |
40 | |
41 function testPrimitiveValueInsteadOfPromise(next) | |
42 { | |
43 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
true", awaitPromise: true }) | |
44 .then((result) => InspectorTest.logObject(result.error)) | |
45 .then(() => next()); | |
46 }, | |
47 | |
48 function testObjectInsteadOfPromise(next) | |
49 { | |
50 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
({})", awaitPromise: true }) | |
51 .then((result) => InspectorTest.logObject(result.error)) | |
52 .then(() => next()); | |
53 }, | |
54 | |
55 function testPendingPromise(next) | |
56 { | |
57 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
createPromiseAndScheduleResolve()", awaitPromise: true, returnByValue: true }) | |
58 .then((result) => dumpResult(result.result)) | |
59 .then(() => next()); | |
60 }, | |
61 | |
62 function testExceptionInEvaluate(next) | |
63 { | |
64 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "
throw 239", awaitPromise: true }) | |
65 .then((result) => dumpResult(result.result)) | |
66 .then(() => next()); | |
67 } | |
68 ]); | |
69 } | |
70 </script> | |
71 </head> | |
72 <body onLoad="runTest();"> | |
73 Tests that Runtime.evaluate works with awaitPromise flag. | |
74 </body> | |
75 </html> | |
76 | |
OLD | NEW |