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

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

Issue 2206483002: [DevTools] Add awaitPromise flag for Runtime.callFunctionOn protocol method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-error-string-from-async
Patch Set: rebased Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.html
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.html b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.html
new file mode 100644
index 0000000000000000000000000000000000000000..f70887e837085dbf13a451b16cc53914648ebfb5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.html
@@ -0,0 +1,148 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script>
+
+function createPromiseAndScheduleResolve()
+{
+ var resolveCallback;
+ var promise = new Promise((resolve) => resolveCallback = resolve);
+ setTimeout(resolveCallback.bind(null, { a : 239 }), 0);
+ return promise;
+}
+
+function test()
+{
+ InspectorTest.runTestSuite([
+ function testArguments(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "function(arg1, arg2, arg3, arg4) { return \"\" + arg1 + \"|\" + arg2 + \"|\" + arg3 + \"|\" + arg4; }",
+ [ "undefined", "NaN", "({a:2})", "window"],
+ /* returnByValue */ true,
+ /* generatePreview */ false,
+ /* awaitPromise */ false)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ },
+
+ function testSyntaxErrorInFunction(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "\n }",
+ [],
+ /* returnByValue */ false,
+ /* generatePreview */ false,
+ /* awaitPromise */ true)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ },
+
+ function testExceptionInFunctionExpression(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "(function() { throw new Error() })()",
+ [],
+ /* returnByValue */ false,
+ /* generatePreview */ false,
+ /* awaitPromise */ true)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ },
+
+ function testFunctionReturnNotPromise(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "(function() { return 239; })",
+ [],
+ /* returnByValue */ false,
+ /* generatePreview */ false,
+ /* awaitPromise */ true)
+ .then((result) => InspectorTest.logObject(result.error))
+ .then(() => next());
+ },
+
+ function testFunctionReturnResolvedPromiseReturnByValue(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
+ [ "({a:2})" ],
+ /* returnByValue */ true,
+ /* generatePreview */ false,
+ /* awaitPromise */ true)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ },
+
+ function testFunctionReturnResolvedPromiseWithPreview(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "(function(arg) { return Promise.resolve({a : this.a + arg.a}); })",
+ [ "({a:2})" ],
+ /* returnByValue */ false,
+ /* generatePreview */ true,
+ /* awaitPromise */ true)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ },
+
+ function testFunctionReturnRejectedPromise(next)
+ {
+ callFunctionOn(
+ "({a : 1})",
+ "(function(arg) { return Promise.reject({a : this.a + arg.a}); })",
+ [ "({a:2})" ],
+ /* returnByValue */ true,
+ /* generatePreview */ false,
+ /* awaitPromise */ true)
+ .then((result) => dumpResult(result.result))
+ .then(() => next());
+ }
+ ]);
+
+ function callFunctionOn(objectExpression, functionDeclaration, argumentExpressions, returnByValue, generatePreview, awaitPromise)
+ {
+ var objectId;
+ var callArguments = [];
+ var promise = InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: objectExpression })
+ .then((result) => objectId = result.result.result.objectId)
+ for (let argumentExpression of argumentExpressions) {
+ promise = promise
+ .then(() => InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: argumentExpression }))
+ .then((result) => addArgument(result.result.result));
+ }
+ return promise.then(() => InspectorTest.sendCommandPromise("Runtime.callFunctionOn", { objectId: objectId, functionDeclaration: functionDeclaration, arguments: callArguments, returnByValue: returnByValue, generatePreview: generatePreview, awaitPromise: awaitPromise }));
+
+ function addArgument(result)
+ {
+ if (result.objectId)
+ callArguments.push({ objectId: result.objectId, type: result.type });
+ else if (result.value)
+ callArguments.push({ value: result.value, type: result.type })
+ else
+ callArguments.push({ type: result.type });
+ }
+ }
+
+ function dumpResult(result)
+ {
+ if (result.exceptionDetails && result.exceptionDetails.scriptId)
+ result.exceptionDetails.scriptId = 0;
+ if (result.result && result.result.objectId)
+ result.result.objectId = "[ObjectId]";
+ InspectorTest.logObject(result);
+ }
+}
+</script>
+</head>
+<body onLoad="runTest();">
+Tests that Runtime.callFunctionOn works with awaitPromise flag.
+</body>
+</html>
+
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698