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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.html

Issue 2954093003: [DevTools] Migrate inspector-protocol/runtime tests to new harness (Closed)
Patch Set: fail: Created 3 years, 5 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 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource s/inspector-protocol-test.js"></script>
4 <script>
5
6 testRunner.setDumpConsoleMessages(false);
7 function test()
8 {
9 InspectorTest.runTestSuite([
10 function testArguments(next)
11 {
12 callFunctionOn(
13 "({a : 1})",
14 "function(arg1, arg2, arg3, arg4) { return \"\" + arg1 + \"|\" + arg2 + \"|\" + arg3 + \"|\" + arg4; }",
15 [ "undefined", "NaN", "({a:2})", "window"],
16 /* returnByValue */ true,
17 /* generatePreview */ false,
18 /* awaitPromise */ false)
19 .then((result) => dumpResult(result.result))
20 .then(() => next());
21 },
22
23 function testSyntaxErrorInFunction(next)
24 {
25 callFunctionOn(
26 "({a : 1})",
27 "\n }",
28 [],
29 /* returnByValue */ false,
30 /* generatePreview */ false,
31 /* awaitPromise */ true)
32 .then((result) => dumpResult(result.result))
33 .then(() => next());
34 },
35
36 function testExceptionInFunctionExpression(next)
37 {
38 callFunctionOn(
39 "({a : 1})",
40 "(function() { throw new Error() })()",
41 [],
42 /* returnByValue */ false,
43 /* generatePreview */ false,
44 /* awaitPromise */ true)
45 .then((result) => dumpResult(result.result))
46 .then(() => next());
47 },
48
49 function testFunctionReturnNotPromise(next)
50 {
51 callFunctionOn(
52 "({a : 1})",
53 "(function() { return 239; })",
54 [],
55 /* returnByValue */ false,
56 /* generatePreview */ false,
57 /* awaitPromise */ true)
58 .then((result) => InspectorTest.logObject(result.error))
59 .then(() => next());
60 },
61
62 function testFunctionReturnResolvedPromiseReturnByValue(next)
63 {
64 callFunctionOn(
65 "({a : 1})",
66 "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
67 [ "({a:2})" ],
68 /* returnByValue */ true,
69 /* generatePreview */ false,
70 /* awaitPromise */ true)
71 .then((result) => dumpResult(result.result))
72 .then(() => next());
73 },
74
75 function testFunctionReturnResolvedPromiseWithPreview(next)
76 {
77 callFunctionOn(
78 "({a : 1})",
79 "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
80 [ "({a:2})" ],
81 /* returnByValue */ false,
82 /* generatePreview */ true,
83 /* awaitPromise */ true)
84 .then((result) => dumpResult(result.result))
85 .then(() => next());
86 },
87
88 function testFunctionReturnRejectedPromise(next)
89 {
90 callFunctionOn(
91 "({a : 1})",
92 "(function(arg) { return Promise.reject({a : this.a + arg.a}); } )",
93 [ "({a:2})" ],
94 /* returnByValue */ true,
95 /* generatePreview */ false,
96 /* awaitPromise */ true)
97 .then((result) => dumpResult(result.result))
98 .then(() => next());
99 }
100 ]);
101
102 function callFunctionOn(objectExpression, functionDeclaration, argumentExpre ssions, returnByValue, generatePreview, awaitPromise)
103 {
104 var objectId;
105 var callArguments = [];
106 var promise = InspectorTest.sendCommandPromise("Runtime.evaluate", { exp ression: objectExpression })
107 .then((result) => objectId = result.result.result.objectId)
108 for (let argumentExpression of argumentExpressions) {
109 promise = promise
110 .then(() => InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: argumentExpression }))
111 .then((result) => addArgument(result.result.result));
112 }
113 return promise.then(() => InspectorTest.sendCommandPromise("Runtime.call FunctionOn", { objectId: objectId, functionDeclaration: functionDeclaration, arg uments: callArguments, returnByValue: returnByValue, generatePreview: generatePr eview, awaitPromise: awaitPromise }));
114
115 function addArgument(result)
116 {
117 if (result.objectId) {
118 callArguments.push({ objectId: result.objectId });
119 } else if (result.value) {
120 callArguments.push({ value: result.value })
121 } else if (result.unserializableValue) {
122 callArguments.push({ unserializableValue: result.unserializableV alue });
123 } else if (result.type === "undefined") {
124 callArguments.push({});
125 } else {
126 InspectorTest.log("Unexpected argument object:");
127 InspectorTest.logObject(result);
128 InspectorTest.completeTest();
129 }
130 }
131 }
132
133 function dumpResult(result)
134 {
135 if (result.exceptionDetails && result.exceptionDetails.scriptId)
136 result.exceptionDetails.scriptId = 0;
137 if (result.result && result.result.objectId)
138 result.result.objectId = "[ObjectId]";
139 if (result.exceptionDetails) {
140 result.exceptionDetails.exceptionId = 0;
141 result.exceptionDetails.exception.objectId = 0;
142 }
143 InspectorTest.logObject(result);
144 }
145 }
146 </script>
147 </head>
148 <body onLoad="runTest();">
149 Tests that Runtime.callFunctionOn works with awaitPromise flag.
150 </body>
151 </html>
152
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698