Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: test/inspector/runtime/evaluate-async.js

Issue 2390733002: [inspector] Make InspectorTest.sendCommand* private (Closed)
Patch Set: addressed comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 print("Tests that Runtime.evaluate works with awaitPromise flag."); 5 print("Tests that Runtime.evaluate works with awaitPromise flag.");
6 6
7 InspectorTest.evaluateInPage(` 7 InspectorTest.addScript(`
8 function createPromiseAndScheduleResolve() 8 function createPromiseAndScheduleResolve()
9 { 9 {
10 var resolveCallback; 10 var resolveCallback;
11 var promise = new Promise((resolve) => resolveCallback = resolve); 11 var promise = new Promise((resolve) => resolveCallback = resolve);
12 setTimeout(resolveCallback.bind(null, { a : 239 }), 0); 12 setTimeout(resolveCallback.bind(null, { a : 239 }), 0);
13 return promise; 13 return promise;
14 }`); 14 }`);
15 15
16 function dumpResult(result)
17 {
18 if (result.exceptionDetails) {
19 result.exceptionDetails.scriptId = "(scriptId)";
20 result.exceptionDetails.exceptionId = 0;
21 result.exceptionDetails.exception.objectId = 0;
22 }
23 InspectorTest.logObject(result);
24 }
25
26 InspectorTest.runTestSuite([ 16 InspectorTest.runTestSuite([
27 function testResolvedPromise(next) 17 function testResolvedPromise(next)
28 { 18 {
29 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise. resolve(239)", awaitPromise: true, generatePreview: true }) 19 Protocol.Runtime.evaluate({ expression: "Promise.resolve(239)", awaitPromise : true, generatePreview: true })
30 .then((result) => dumpResult(result.result)) 20 .then(result => InspectorTest.logMessage(result))
31 .then(() => next()); 21 .then(() => next());
32 }, 22 },
33 23
34 function testRejectedPromise(next) 24 function testRejectedPromise(next)
35 { 25 {
36 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise. reject(239)", awaitPromise: true }) 26 Protocol.Runtime.evaluate({ expression: "Promise.reject(239)", awaitPromise: true })
37 .then((result) => dumpResult(result.result)) 27 .then(result => InspectorTest.logMessage(result))
38 .then(() => next()); 28 .then(() => next());
39 }, 29 },
40 30
41 function testPrimitiveValueInsteadOfPromise(next) 31 function testPrimitiveValueInsteadOfPromise(next)
42 { 32 {
43 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "true", a waitPromise: true }) 33 Protocol.Runtime.evaluate({ expression: "true", awaitPromise: true })
44 .then((result) => InspectorTest.logObject(result.error)) 34 .then(result => InspectorTest.logMessage(result))
45 .then(() => next()); 35 .then(() => next());
46 }, 36 },
47 37
48 function testObjectInsteadOfPromise(next) 38 function testObjectInsteadOfPromise(next)
49 { 39 {
50 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "({})", a waitPromise: true }) 40 Protocol.Runtime.evaluate({ expression: "({})", awaitPromise: true })
51 .then((result) => InspectorTest.logObject(result.error)) 41 .then(result => InspectorTest.logMessage(result))
52 .then(() => next()); 42 .then(() => next());
53 }, 43 },
54 44
55 function testPendingPromise(next) 45 function testPendingPromise(next)
56 { 46 {
57 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "createPr omiseAndScheduleResolve()", awaitPromise: true, returnByValue: true }) 47 Protocol.Runtime.evaluate({ expression: "createPromiseAndScheduleResolve()", awaitPromise: true, returnByValue: true })
58 .then((result) => dumpResult(result.result)) 48 .then(result => InspectorTest.logMessage(result))
59 .then(() => next()); 49 .then(() => next());
60 }, 50 },
61 51
62 function testExceptionInEvaluate(next) 52 function testExceptionInEvaluate(next)
63 { 53 {
64 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "throw 23 9", awaitPromise: true }) 54 Protocol.Runtime.evaluate({ expression: "throw 239", awaitPromise: true })
65 .then((result) => dumpResult(result.result)) 55 .then(result => InspectorTest.logMessage(result))
66 .then(() => next()); 56 .then(() => next());
67 } 57 }
68 ]); 58 ]);
OLDNEW
« no previous file with comments | « test/inspector/runtime/console-timestamp.js ('k') | test/inspector/runtime/evaluate-async-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698