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

Side by Side Diff: test/inspector/runtime/call-function-on-async.js

Issue 2369753004: [inspector] added inspector test runner [part 5] (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
(Empty)
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
3 // found in the LICENSE file.
4
5 print("Tests that Runtime.callFunctionOn works with awaitPromise flag.");
6
7 InspectorTest.runTestSuite([
8 function testArguments(next)
9 {
10 callFunctionOn(
11 "({a : 1})",
12 "function(arg1, arg2, arg3, arg4) { return \"\" + arg1 + \"|\" + arg2 + \" |\" + arg3 + \"|\" + arg4; }",
13 [ "undefined", "NaN", "({a:2})", "this"],
14 /* returnByValue */ true,
15 /* generatePreview */ false,
16 /* awaitPromise */ false)
17 .then((result) => dumpResult(result.result))
18 .then(() => next());
19 },
20
21 function testSyntaxErrorInFunction(next)
22 {
23 callFunctionOn(
24 "({a : 1})",
25 "\n }",
26 [],
27 /* returnByValue */ false,
28 /* generatePreview */ false,
29 /* awaitPromise */ true)
30 .then((result) => dumpResult(result.result))
31 .then(() => next());
32 },
33
34 function testExceptionInFunctionExpression(next)
35 {
36 callFunctionOn(
37 "({a : 1})",
38 "(function() { throw new Error() })()",
39 [],
40 /* returnByValue */ false,
41 /* generatePreview */ false,
42 /* awaitPromise */ true)
43 .then((result) => dumpResult(result.result))
44 .then(() => next());
45 },
46
47 function testFunctionReturnNotPromise(next)
48 {
49 callFunctionOn(
50 "({a : 1})",
51 "(function() { return 239; })",
52 [],
53 /* returnByValue */ false,
54 /* generatePreview */ false,
55 /* awaitPromise */ true)
56 .then((result) => InspectorTest.logObject(result.error))
57 .then(() => next());
58 },
59
60 function testFunctionReturnResolvedPromiseReturnByValue(next)
61 {
62 callFunctionOn(
63 "({a : 1})",
64 "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
65 [ "({a:2})" ],
66 /* returnByValue */ true,
67 /* generatePreview */ false,
68 /* awaitPromise */ true)
69 .then((result) => dumpResult(result.result))
70 .then(() => next());
71 },
72
73 function testFunctionReturnResolvedPromiseWithPreview(next)
74 {
75 callFunctionOn(
76 "({a : 1})",
77 "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
78 [ "({a:2})" ],
79 /* returnByValue */ false,
80 /* generatePreview */ true,
81 /* awaitPromise */ true)
82 .then((result) => dumpResult(result.result))
83 .then(() => next());
84 },
85
86 function testFunctionReturnRejectedPromise(next)
87 {
88 callFunctionOn(
89 "({a : 1})",
90 "(function(arg) { return Promise.reject({a : this.a + arg.a}); })",
91 [ "({a:2})" ],
92 /* returnByValue */ true,
93 /* generatePreview */ false,
94 /* awaitPromise */ true)
95 .then((result) => dumpResult(result.result))
96 .then(() => next());
97 }
98 ]);
99
100 function callFunctionOn(objectExpression, functionDeclaration, argumentExpressio ns, returnByValue, generatePreview, awaitPromise)
101 {
102 var objectId;
103 var callArguments = [];
104 var promise = InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: objectExpression })
105 .then((result) => objectId = result.result.result.objectId)
106 for (let argumentExpression of argumentExpressions) {
107 promise = promise
108 .then(() => InspectorTest.sendCommandPromise("Runtime.evaluate", { express ion: argumentExpression }))
109 .then((result) => addArgument(result.result.result));
110 }
111 return promise.then(() => InspectorTest.sendCommandPromise("Runtime.callFuncti onOn", { objectId: objectId, functionDeclaration: functionDeclaration, arguments : callArguments, returnByValue: returnByValue, generatePreview: generatePreview, awaitPromise: awaitPromise }));
112
113 function addArgument(result)
114 {
115 if (result.objectId) {
116 callArguments.push({ objectId: result.objectId });
117 } else if (result.value) {
118 callArguments.push({ value: result.value })
119 } else if (result.unserializableValue) {
120 callArguments.push({ unserializableValue: result.unserializableValue });
121 } else if (result.type === "undefined") {
122 callArguments.push({});
123 } else {
124 InspectorTest.log("Unexpected argument object:");
125 InspectorTest.logObject(result);
126 InspectorTest.completeTest();
127 }
128 }
129 }
130
131 function dumpResult(result)
132 {
133 if (result.exceptionDetails && result.exceptionDetails.scriptId)
134 result.exceptionDetails.scriptId = 0;
135 if (result.result && result.result.objectId)
136 result.result.objectId = "[ObjectId]";
137 if (result.exceptionDetails) {
138 result.exceptionDetails.exceptionId = 0;
139 result.exceptionDetails.exception.objectId = 0;
140 }
141 InspectorTest.logObject(result);
142 }
OLDNEW
« no previous file with comments | « test/inspector/runtime/await-promise-expected.txt ('k') | test/inspector/runtime/call-function-on-async-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698