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

Unified Diff: test/inspector/runtime/run-script-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 side-by-side diff with in-line comments
Download patch
Index: test/inspector/runtime/run-script-async.js
diff --git a/test/inspector/runtime/run-script-async.js b/test/inspector/runtime/run-script-async.js
index 914d662f5e8eee662236478770df28574dd1fabd..0aa90962a5d18263272ddb2deb5461eed61eb44f 100644
--- a/test/inspector/runtime/run-script-async.js
+++ b/test/inspector/runtime/run-script-async.js
@@ -7,127 +7,104 @@ print("Tests that Runtime.compileScript and Runtime.runScript work with awaitPro
InspectorTest.runTestSuite([
function testRunAndCompileWithoutAgentEnable(next)
{
- InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "", sourceURL: "", persistScript: true })
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: "1" }))
- .then((result) => dumpResult(result))
+ Protocol.Runtime.compileScript({ expression: "", sourceURL: "", persistScript: true })
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.runScript({ scriptId: "1" }))
+ .then((result) => InspectorTest.logMessage(result))
.then(() => next());
},
function testSyntaxErrorInScript(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "\n }", sourceURL: "boo.js", persistScript: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "\n }", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testSyntaxErrorInEvalInScript(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "{\n eval(\"\\\n}\")\n}", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "{\n eval(\"\\\n}\")\n}", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testRunNotCompiledScript(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: "1" }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then((result) => Protocol.Runtime.runScript({ scriptId: "1" }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testRunCompiledScriptAfterAgentWasReenabled(next)
{
var scriptId;
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "{\n eval(\"\\\n}\")\n}", sourceURL: "boo.js", persistScript: true }))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "{\n eval(\"\\\n}\")\n}", sourceURL: "boo.js", persistScript: true }))
.then((result) => scriptId = result.result.scriptId)
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: scriptId }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.enable", {}))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: scriptId }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ .then(() => Protocol.Runtime.disable())
+ .then((result) => Protocol.Runtime.runScript({ scriptId: scriptId }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.enable())
+ .then((result) => Protocol.Runtime.runScript({ scriptId: scriptId }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testRunScriptWithPreview(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId, generatePreview: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId, generatePreview: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testRunScriptReturnByValue(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId, returnByValue: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId, returnByValue: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testAwaitNotPromise(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId, awaitPromise: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "({a:1})", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId, awaitPromise: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testAwaitResolvedPromise(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "Promise.resolve({a:1})", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId, awaitPromise: true, returnByValue: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "Promise.resolve({a:1})", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId, awaitPromise: true, returnByValue: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
},
function testAwaitRejectedPromise(next)
{
- InspectorTest.sendCommandPromise("Runtime.enable", {})
- .then(() => InspectorTest.sendCommandPromise("Runtime.compileScript", { expression: "Promise.reject({a:1})", sourceURL: "boo.js", persistScript: true }))
- .then((result) => InspectorTest.sendCommandPromise("Runtime.runScript", { scriptId: result.result.scriptId, awaitPromise: true, returnByValue: true }))
- .then((result) => dumpResult(result))
- .then(() => InspectorTest.sendCommandPromise("Runtime.disable", {}))
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.compileScript({ expression: "Promise.reject({a:1})", sourceURL: "boo.js", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId, awaitPromise: true, returnByValue: true }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.disable())
.then(() => next());
}
]);
-
-function dumpResult(result)
-{
- if (result.error) {
- result.error.code = 0;
- InspectorTest.logObject(result.error);
- return;
- }
- result = result.result;
- if (result.exceptionDetails) {
- result.exceptionDetails.exceptionId = 0;
- result.exceptionDetails.exception.objectId = 0;
- }
- if (result.exceptionDetails && result.exceptionDetails.scriptId)
- result.exceptionDetails.scriptId = 0;
- if (result.exceptionDetails && result.exceptionDetails.stackTrace) {
- for (var frame of result.exceptionDetails.stackTrace.callFrames)
- frame.scriptId = 0;
- }
- if (result.result && result.result.objectId)
- result.result.objectId = "[ObjectId]";
- InspectorTest.logObject(result);
-}
« no previous file with comments | « test/inspector/runtime/property-on-console-proto-expected.txt ('k') | test/inspector/runtime/run-script-async-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698