[inspector] Make InspectorTest.sendCommand* private
Introduce Protocol.Domain.method(args) and Protocol.Domain.onEventName() instead. Renamed InspectorTest.evaluateInPage -> InspectorTest.addScript. Improved InspectorTest.logMessage. BUG=chromium:635948 R=dgozman@chromium.org,alph@chromium.org Review-Url: https://codereview.chromium.org/2390733002 Cr-Commit-Position: refs/heads/master@{#39942}
This commit is contained in:
parent
b5c9e31c97
commit
24beac30ee
@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "let a = 42;" }, step2);
|
||||
Protocol.Runtime.evaluate({ expression: "let a = 42;" }).then(step2);
|
||||
|
||||
function step2(response)
|
||||
{
|
||||
failIfError(response);
|
||||
InspectorTest.log("first \"let a = 1;\" result: wasThrown = " + !!response.result.exceptionDetails);
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "let a = 239;" }, step3);
|
||||
Protocol.Runtime.evaluate({ expression: "let a = 239;" }).then(step3);
|
||||
}
|
||||
|
||||
function step3(response)
|
||||
@ -17,7 +17,7 @@ function step3(response)
|
||||
InspectorTest.log("second \"let a = 1;\" result: wasThrown = " + !!response.result.exceptionDetails);
|
||||
if (response.result.exceptionDetails)
|
||||
InspectorTest.log("exception message: " + response.result.exceptionDetails.text + " " + response.result.exceptionDetails.exception.description);
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "a" }, step4);
|
||||
Protocol.Runtime.evaluate({ expression: "a" }).then(step4);
|
||||
}
|
||||
|
||||
function step4(response)
|
||||
@ -42,7 +42,7 @@ function checkMethod(response)
|
||||
if (!method)
|
||||
InspectorTest.completeTest();
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: method, includeCommandLineAPI: true }, checkMethod);
|
||||
Protocol.Runtime.evaluate({ expression: method, includeCommandLineAPI: true }).then(checkMethod);
|
||||
}
|
||||
|
||||
function failIfError(response)
|
||||
|
@ -1,6 +1,6 @@
|
||||
Tests checks that console.memory property can be set in strict mode (crbug.com/468611).
|
||||
{
|
||||
id : 0
|
||||
id : <messageId>
|
||||
result : {
|
||||
result : {
|
||||
type : undefined
|
||||
|
@ -4,11 +4,10 @@
|
||||
|
||||
print("Tests checks that console.memory property can be set in strict mode (crbug.com/468611).")
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "\"use strict\"\nconsole.memory = {};undefined" }, dumpResult);
|
||||
Protocol.Runtime.evaluate({ expression: "\"use strict\"\nconsole.memory = {};undefined" }).then(dumpResult);
|
||||
|
||||
function dumpResult(result)
|
||||
{
|
||||
result.id = 0;
|
||||
InspectorTest.logObject(result);
|
||||
InspectorTest.logMessage(result);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Tests that \"console.profileEnd()\" does not cause crash. (webkit:105759)");
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function collectProfiles()
|
||||
{
|
||||
console.profile();
|
||||
@ -19,16 +19,16 @@ InspectorTest.fail = function(message)
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
||||
InspectorTest.sendCommand("Profiler.enable", {});
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "collectProfiles()"}, didCollectProfiles);
|
||||
Protocol.Profiler.enable();
|
||||
Protocol.Runtime.evaluate({ expression: "collectProfiles()"}).then(didCollectProfiles);
|
||||
|
||||
var headers = [];
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
|
||||
Protocol.Profiler.onConsoleProfileFinished(function(messageObject)
|
||||
{
|
||||
headers.push({
|
||||
title: messageObject["params"]["title"]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function didCollectProfiles(messageObject)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.");
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function collectProfiles()
|
||||
{
|
||||
console.profile("outer");
|
||||
@ -19,17 +19,17 @@ InspectorTest.fail = function(message)
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
||||
InspectorTest.sendCommand("Profiler.enable", {});
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "collectProfiles()"}, didCollectProfiles);
|
||||
Protocol.Profiler.enable();
|
||||
Protocol.Runtime.evaluate({ expression: "collectProfiles()"}).then(didCollectProfiles);
|
||||
|
||||
var headers = [];
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
|
||||
Protocol.Profiler.onConsoleProfileFinished(function(messageObject)
|
||||
{
|
||||
headers.push({
|
||||
profile: messageObject["params"]["profile"],
|
||||
title: messageObject["params"]["title"]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function didCollectProfiles(messageObject)
|
||||
{
|
||||
|
@ -4,59 +4,59 @@
|
||||
|
||||
print("Test that profiling can only be started when Profiler was enabled and that Profiler.disable command will stop recording all profiles.");
|
||||
|
||||
InspectorTest.sendCommand("Profiler.start", {}, didFailToStartWhenDisabled);
|
||||
Protocol.Profiler.start().then(didFailToStartWhenDisabled);
|
||||
disallowConsoleProfiles();
|
||||
|
||||
function disallowConsoleProfiles()
|
||||
{
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messageObject)
|
||||
Protocol.Profiler.onConsoleProfileStarted(function(messageObject)
|
||||
{
|
||||
InspectorTest.log("FAIL: console profile started " + JSON.stringify(messageObject, null, 4));
|
||||
}
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
|
||||
});
|
||||
Protocol.Profiler.onConsoleProfileFinished(function(messageObject)
|
||||
{
|
||||
InspectorTest.log("FAIL: unexpected profile received " + JSON.stringify(messageObject, null, 4));
|
||||
}
|
||||
});
|
||||
}
|
||||
function allowConsoleProfiles()
|
||||
{
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messageObject)
|
||||
Protocol.Profiler.onConsoleProfileStarted(function(messageObject)
|
||||
{
|
||||
InspectorTest.log("PASS: console initiated profile started");
|
||||
}
|
||||
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
|
||||
});
|
||||
Protocol.Profiler.onConsoleProfileFinished(function(messageObject)
|
||||
{
|
||||
InspectorTest.log("PASS: console initiated profile received");
|
||||
}
|
||||
});
|
||||
}
|
||||
function didFailToStartWhenDisabled(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageObject))
|
||||
return;
|
||||
allowConsoleProfiles();
|
||||
InspectorTest.sendCommand("Profiler.enable", {});
|
||||
InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile);
|
||||
Protocol.Profiler.enable();
|
||||
Protocol.Profiler.start().then(didStartFrontendProfile);
|
||||
}
|
||||
function didStartFrontendProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profile('p1');"}, didStartConsoleProfile);
|
||||
Protocol.Runtime.evaluate({expression: "console.profile('p1');"}).then(didStartConsoleProfile);
|
||||
}
|
||||
|
||||
function didStartConsoleProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Profiler.disable", {}, didDisableProfiler);
|
||||
Protocol.Profiler.disable().then(didDisableProfiler);
|
||||
}
|
||||
|
||||
function didDisableProfiler(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Profiler.enable", {});
|
||||
InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile);
|
||||
Protocol.Profiler.enable();
|
||||
Protocol.Profiler.stop().then(didStopFrontendProfile);
|
||||
}
|
||||
|
||||
function didStopFrontendProfile(messageObject)
|
||||
@ -64,7 +64,7 @@ function didStopFrontendProfile(messageObject)
|
||||
if (!InspectorTest.expectedError("no front-end initiated profiles found", messageObject))
|
||||
return;
|
||||
disallowConsoleProfiles();
|
||||
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profileEnd();"}, didStopConsoleProfile);
|
||||
Protocol.Runtime.evaluate({expression: "console.profileEnd();"}).then(didStopConsoleProfile);
|
||||
}
|
||||
|
||||
function didStopConsoleProfile(messageObject)
|
||||
|
@ -4,41 +4,41 @@
|
||||
|
||||
print("Test that profiler is able to record a profile. Also it tests that profiler returns an error when it unable to find the profile.");
|
||||
|
||||
InspectorTest.sendCommand("Profiler.enable", {});
|
||||
InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile);
|
||||
Protocol.Profiler.enable();
|
||||
Protocol.Profiler.start().then(didStartFrontendProfile);
|
||||
function didStartFrontendProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("startFrontendProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profile('Profile 1');"}, didStartConsoleProfile);
|
||||
Protocol.Runtime.evaluate({expression: "console.profile('Profile 1');"}).then(didStartConsoleProfile);
|
||||
}
|
||||
|
||||
function didStartConsoleProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("startConsoleProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profileEnd('Profile 1');"}, didStopConsoleProfile);
|
||||
Protocol.Runtime.evaluate({expression: "console.profileEnd('Profile 1');"}).then(didStopConsoleProfile);
|
||||
}
|
||||
|
||||
function didStopConsoleProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("stopConsoleProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile);
|
||||
Protocol.Profiler.stop().then(didStopFrontendProfile);
|
||||
}
|
||||
|
||||
function didStopFrontendProfile(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("stoppedFrontendProfile", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile2);
|
||||
Protocol.Profiler.start().then(didStartFrontendProfile2);
|
||||
}
|
||||
|
||||
function didStartFrontendProfile2(messageObject)
|
||||
{
|
||||
if (!InspectorTest.expectedSuccess("startFrontendProfileSecondTime", messageObject))
|
||||
return;
|
||||
InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile2);
|
||||
Protocol.Profiler.stop().then(didStopFrontendProfile2);
|
||||
}
|
||||
|
||||
function didStopFrontendProfile2(messageObject)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Test that profiler doesn't crash when we call stop without preceeding start.");
|
||||
|
||||
InspectorTest.sendCommand("Profiler.stop", {}, didStopProfile);
|
||||
Protocol.Profiler.stop().then(didStopProfile);
|
||||
function didStopProfile(messageObject)
|
||||
{
|
||||
InspectorTest.expectedError("ProfileAgent.stop", messageObject);
|
||||
|
@ -2,18 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function testFunction()
|
||||
{
|
||||
debugger;
|
||||
}
|
||||
//# sourceURL=foo.js`);
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
Protocol.Debugger.enable();
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedOne;
|
||||
Protocol.Debugger.oncePaused().then(handleDebuggerPausedOne);
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(testFunction, 0)" });
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0)" });
|
||||
|
||||
var obsoleteTopFrameId;
|
||||
|
||||
@ -24,30 +24,28 @@ function handleDebuggerPausedOne(messageObject)
|
||||
var topFrame = messageObject.params.callFrames[0];
|
||||
obsoleteTopFrameId = topFrame.callFrameId;
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = undefined;
|
||||
|
||||
InspectorTest.sendCommand("Debugger.resume", { }, callbackResume);
|
||||
Protocol.Debugger.resume().then(callbackResume);
|
||||
}
|
||||
|
||||
function callbackResume(response)
|
||||
{
|
||||
InspectorTest.log("resume");
|
||||
InspectorTest.log("restartFrame");
|
||||
InspectorTest.sendCommand("Debugger.restartFrame", { callFrameId: obsoleteTopFrameId }, callbackRestartFrame);
|
||||
Protocol.Debugger.restartFrame({ callFrameId: obsoleteTopFrameId }).then(callbackRestartFrame);
|
||||
}
|
||||
|
||||
function callbackRestartFrame(response)
|
||||
{
|
||||
logErrorResponse(response);
|
||||
InspectorTest.log("evaluateOnFrame");
|
||||
InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", { callFrameId: obsoleteTopFrameId, expression: "0"} , callbackEvaluate);
|
||||
Protocol.Debugger.evaluateOnCallFrame({ callFrameId: obsoleteTopFrameId, expression: "0"}).then(callbackEvaluate);
|
||||
}
|
||||
|
||||
function callbackEvaluate(response)
|
||||
{
|
||||
logErrorResponse(response);
|
||||
InspectorTest.log("setVariableValue");
|
||||
InspectorTest.sendCommand("Debugger.setVariableValue", { callFrameId: obsoleteTopFrameId, scopeNumber: 0, variableName: "a", newValue: { value: 0 } }, callbackSetVariableValue);
|
||||
Protocol.Debugger.setVariableValue({ callFrameId: obsoleteTopFrameId, scopeNumber: 0, variableName: "a", newValue: { value: 0 } }).then(callbackSetVariableValue);
|
||||
}
|
||||
|
||||
function callbackSetVariableValue(response)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("setTimeout(console.count, 0) doesn't crash with enabled async stacks.")
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
InspectorTest.sendCommand("Debugger.setAsyncCallStackDepth", { maxDepth: 1 });
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "setTimeout(console.count, 0)" });
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 1 });
|
||||
Protocol.Runtime.evaluate({ expression: "setTimeout(console.count, 0)" });
|
||||
InspectorTest.completeTestAfterPendingTimeouts();
|
||||
|
@ -2,16 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function testFunction()
|
||||
{
|
||||
var a = 2;
|
||||
debugger;
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPaused;
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(testFunction, 0)" });
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.oncePaused().then(handleDebuggerPaused);
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0)" });
|
||||
|
||||
function handleDebuggerPaused(messageObject)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function statementsExample()
|
||||
{
|
||||
var self = arguments.callee;
|
||||
@ -33,14 +33,14 @@ var scenario = [
|
||||
[ 17, 6, 17 ],
|
||||
];
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
Protocol.Debugger.enable();
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExample" }, callbackEvalFunctionObject);
|
||||
Protocol.Runtime.evaluate({ "expression": "statementsExample" }).then(callbackEvalFunctionObject);
|
||||
|
||||
function callbackEvalFunctionObject(response)
|
||||
{
|
||||
var functionObjectId = response.result.result.objectId;
|
||||
InspectorTest.sendCommand("Runtime.getProperties", { objectId: functionObjectId }, callbackFunctionDetails);
|
||||
Protocol.Runtime.getProperties({ objectId: functionObjectId }).then(callbackFunctionDetails);
|
||||
}
|
||||
|
||||
function callbackFunctionDetails(response)
|
||||
@ -65,17 +65,17 @@ function callbackFunctionDetails(response)
|
||||
|
||||
function gotoSinglePassChain(scriptId, lineNumber, expectedResult, expectedLineNumber, next)
|
||||
{
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedOne;
|
||||
Protocol.Debugger.oncePaused().then(handleDebuggerPausedOne);
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(statementsExample, 0)" });
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(statementsExample, 0)" });
|
||||
|
||||
function handleDebuggerPausedOne(messageObject)
|
||||
{
|
||||
InspectorTest.log("Paused on debugger statement");
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedTwo;
|
||||
Protocol.Debugger.oncePaused().then(handleDebuggerPausedTwo);
|
||||
|
||||
InspectorTest.sendCommand("Debugger.continueToLocation", { location: { scriptId: scriptId, lineNumber: lineNumber, columnNumber: 0} }, logContinueToLocation);
|
||||
Protocol.Debugger.continueToLocation({ location: { scriptId: scriptId, lineNumber: lineNumber, columnNumber: 0} }).then(logContinueToLocation);
|
||||
|
||||
function logContinueToLocation(response)
|
||||
{
|
||||
@ -92,9 +92,9 @@ function gotoSinglePassChain(scriptId, lineNumber, expectedResult, expectedLineN
|
||||
|
||||
InspectorTest.log("Stopped on line " + actualLineNumber + ", expected " + expectedLineNumber + ", requested " + lineNumber + ", (0-based numbers).");
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedUnexpected;
|
||||
Protocol.Debugger.oncePaused(handleDebuggerPausedUnexpected);
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExample.step" }, callbackStepEvaluate);
|
||||
Protocol.Runtime.evaluate({ "expression": "statementsExample.step" }).then(callbackStepEvaluate);
|
||||
}
|
||||
|
||||
function callbackStepEvaluate(response)
|
||||
@ -102,7 +102,7 @@ function gotoSinglePassChain(scriptId, lineNumber, expectedResult, expectedLineN
|
||||
var resultValue = response.result.result.value;
|
||||
InspectorTest.log("Control parameter 'step' calculation result: " + resultValue + ", expected: " + expectedResult);
|
||||
InspectorTest.log(resultValue === expectedResult ? "SUCCESS" : "FAIL");
|
||||
InspectorTest.sendCommand("Debugger.resume", { });
|
||||
Protocol.Debugger.resume();
|
||||
next();
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,15 @@
|
||||
|
||||
print("Check that stepInto at then end of the script go to next user script instead InjectedScriptSource.js.");
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function foo()
|
||||
{
|
||||
return 239;
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommandOrDie("Debugger.enable", {});
|
||||
InspectorTest.eventHandler["Debugger.paused"] = debuggerPaused;
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "(function boo() { setTimeout(foo, 0); debugger; })()" });
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.onPaused(debuggerPaused);
|
||||
Protocol.Runtime.evaluate({ "expression": "(function boo() { setTimeout(foo, 0); debugger; })()" });
|
||||
|
||||
var actions = [ "stepInto", "stepInto", "stepInto" ];
|
||||
function debuggerPaused(result)
|
||||
@ -24,9 +24,9 @@ function debuggerPaused(result)
|
||||
|
||||
var action = actions.shift();
|
||||
if (!action) {
|
||||
InspectorTest.sendCommandOrDie("Debugger.resume", {}, () => InspectorTest.completeTest());
|
||||
Protocol.Debugger.resume().then(InspectorTest.completeTest);
|
||||
return;
|
||||
}
|
||||
InspectorTest.log("Perform " + action);
|
||||
InspectorTest.sendCommandOrDie("Debugger." + action, {});
|
||||
Protocol.Debugger[action]();
|
||||
}
|
||||
|
@ -1,17 +1,19 @@
|
||||
{
|
||||
result : [
|
||||
[0] : {
|
||||
configurable : true
|
||||
enumerable : true
|
||||
isOwn : true
|
||||
name : a
|
||||
value : {
|
||||
description : 2
|
||||
type : number
|
||||
value : 2
|
||||
id : <messageId>
|
||||
result : {
|
||||
result : [
|
||||
[0] : {
|
||||
configurable : true
|
||||
enumerable : true
|
||||
isOwn : true
|
||||
name : a
|
||||
value : {
|
||||
description : 2
|
||||
type : number
|
||||
value : 2
|
||||
}
|
||||
writable : true
|
||||
}
|
||||
writable : true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function testFunction()
|
||||
{
|
||||
for (var a of [1]) {
|
||||
@ -11,9 +11,9 @@ InspectorTest.evaluateInPage(
|
||||
}
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommandOrDie("Debugger.enable", {});
|
||||
InspectorTest.eventHandler["Debugger.paused"] = dumpScopeOnPause;
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "testFunction()" });
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.oncePaused().then(dumpScopeOnPause);
|
||||
Protocol.Runtime.evaluate({ "expression": "testFunction()" });
|
||||
|
||||
var waitScopeObjects = 0;
|
||||
function dumpScopeOnPause(message)
|
||||
@ -29,14 +29,14 @@ function dumpScopeOnPause(message)
|
||||
InspectorTest.completeTest();
|
||||
} else {
|
||||
for (var objectId of localScopeObjectIds)
|
||||
InspectorTest.sendCommandOrDie("Runtime.getProperties", { "objectId" : objectId }, dumpProperties);
|
||||
Protocol.Runtime.getProperties({ "objectId" : objectId }).then(dumpProperties);
|
||||
}
|
||||
}
|
||||
|
||||
function dumpProperties(message)
|
||||
{
|
||||
InspectorTest.logObject(message);
|
||||
InspectorTest.logMessage(message);
|
||||
--waitScopeObjects;
|
||||
if (!waitScopeObjects)
|
||||
InspectorTest.sendCommandOrDie("Debugger.resume", {}, () => InspectorTest.completeTest());
|
||||
Protocol.Debugger.resume().then(InspectorTest.completeTest);
|
||||
}
|
||||
|
@ -5,14 +5,13 @@
|
||||
var hashes = new Set(["1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18",
|
||||
"EBF1ECD351E7A3294CB5762843D429DC872EBA18",
|
||||
"86A31E7131896CF01BA837945C2894385F369F24"]);
|
||||
InspectorTest.sendCommandOrDie("Debugger.enable", {}, function() {
|
||||
InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
|
||||
{
|
||||
if (hashes.has(messageObject.params.hash))
|
||||
InspectorTest.log(`Hash received: ${messageObject.params.hash}`);
|
||||
else
|
||||
InspectorTest.log(`[FAIL]: unknown hash ${messageObject.params.hash}`);
|
||||
}
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.onScriptParsed(function(messageObject)
|
||||
{
|
||||
if (hashes.has(messageObject.params.hash))
|
||||
InspectorTest.log(`Hash received: ${messageObject.params.hash}`);
|
||||
else
|
||||
InspectorTest.log(`[FAIL]: unknown hash ${messageObject.params.hash}`);
|
||||
});
|
||||
|
||||
function longScript() {
|
||||
@ -21,10 +20,10 @@ function longScript() {
|
||||
longScript += "++b;";
|
||||
}
|
||||
|
||||
InspectorTest.sendCommandOrDie("Runtime.enable");
|
||||
InspectorTest.sendCommandOrDie("Runtime.compileScript", { expression: "1", sourceURL: "foo1.js", persistScript: true });
|
||||
InspectorTest.sendCommandOrDie("Runtime.compileScript", { expression: "239", sourceURL: "foo2.js", persistScript: true });
|
||||
InspectorTest.sendCommandOrDie("Runtime.compileScript", { expression: "(" + longScript + ")()", sourceURL: "foo3.js", persistScript: true }, step2);
|
||||
Protocol.Runtime.enable();
|
||||
Protocol.Runtime.compileScript({ expression: "1", sourceURL: "foo1.js", persistScript: true });
|
||||
Protocol.Runtime.compileScript({ expression: "239", sourceURL: "foo2.js", persistScript: true });
|
||||
Protocol.Runtime.compileScript({ expression: "(" + longScript + ")()", sourceURL: "foo3.js", persistScript: true }).then(step2);
|
||||
|
||||
function step2()
|
||||
{
|
||||
|
@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function bar()
|
||||
{
|
||||
return 42;
|
||||
}`);
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function foo()
|
||||
{
|
||||
var a = bar();
|
||||
@ -16,7 +16,7 @@ InspectorTest.evaluateInPage(
|
||||
}
|
||||
//# sourceURL=foo.js`);
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function qwe()
|
||||
{
|
||||
var a = foo();
|
||||
@ -24,7 +24,7 @@ InspectorTest.evaluateInPage(
|
||||
}
|
||||
//# sourceURL=qwe.js`);
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function baz()
|
||||
{
|
||||
var a = qwe();
|
||||
@ -32,15 +32,15 @@ InspectorTest.evaluateInPage(
|
||||
}
|
||||
//# sourceURL=baz.js`);
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
InspectorTest.sendCommand("Debugger.setBlackboxPatterns", { patterns: [ "foo([" ] }, dumpError);
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Debugger.setBlackboxPatterns({ patterns: [ "foo([" ] }).then(dumpError);
|
||||
|
||||
function dumpError(message)
|
||||
{
|
||||
InspectorTest.log(message.error.message);
|
||||
InspectorTest.eventHandler["Debugger.paused"] = dumpStackAndRunNextCommand;
|
||||
InspectorTest.sendCommandOrDie("Debugger.setBlackboxPatterns", { patterns: [ "baz\.js", "foo\.js" ] });
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "debugger;baz()" });
|
||||
Protocol.Debugger.onPaused(dumpStackAndRunNextCommand);
|
||||
Protocol.Debugger.setBlackboxPatterns({ patterns: [ "baz\.js", "foo\.js" ] });
|
||||
Protocol.Runtime.evaluate({ "expression": "debugger;baz()" });
|
||||
}
|
||||
|
||||
var commands = [ "stepInto", "stepInto", "stepInto", "stepOut", "stepInto", "stepInto" ];
|
||||
@ -55,5 +55,5 @@ function dumpStackAndRunNextCommand(message)
|
||||
InspectorTest.completeTest();
|
||||
return;
|
||||
}
|
||||
InspectorTest.sendCommandOrDie("Debugger." + command, {});
|
||||
Protocol.Debugger[command]();
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.sendCommand("Debugger.setBreakpointByUrl", { url: "http://example.com", lineNumber: 10 }, didSetBreakpointByUrlBeforeEnable);
|
||||
Protocol.Debugger.setBreakpointByUrl({ url: "http://example.com", lineNumber: 10 }).then(didSetBreakpointByUrlBeforeEnable);
|
||||
|
||||
function didSetBreakpointByUrlBeforeEnable(message)
|
||||
{
|
||||
InspectorTest.log("setBreakpointByUrl error: " + JSON.stringify(message.error, null, 2));
|
||||
InspectorTest.sendCommand("Debugger.setBreakpoint", {}, didSetBreakpointBeforeEnable);
|
||||
Protocol.Debugger.setBreakpoint().then(didSetBreakpointBeforeEnable);
|
||||
}
|
||||
|
||||
function didSetBreakpointBeforeEnable(message)
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function TestExpression(a, b) {
|
||||
return a + b;
|
||||
}`);
|
||||
@ -62,7 +62,8 @@ function runRequestSeries(step) {
|
||||
}
|
||||
processStep(next);
|
||||
}
|
||||
InspectorTest.sendCommand(currentStep.command, currentStep.params, innerCallback);
|
||||
var command = currentStep.command.split(".");
|
||||
Protocol[command[0]][command[1]](currentStep.params).then(innerCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function testFunction()
|
||||
{
|
||||
function foo()
|
||||
@ -17,15 +17,15 @@ InspectorTest.evaluateInPage(
|
||||
console.log("completed");
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommandOrDie("Debugger.enable", {});
|
||||
InspectorTest.sendCommandOrDie("Runtime.enable", {});
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Runtime.enable();
|
||||
step1();
|
||||
|
||||
function step1()
|
||||
{
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "setTimeout(testFunction, 0);"});
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0);"});
|
||||
var commands = [ "Print", "stepOver", "stepOver", "Print", "resume" ];
|
||||
InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
|
||||
Protocol.Debugger.onPaused(function(messageObject)
|
||||
{
|
||||
var command = commands.shift();
|
||||
if (command === "Print") {
|
||||
@ -35,24 +35,24 @@ function step1()
|
||||
command = commands.shift();
|
||||
}
|
||||
if (command)
|
||||
InspectorTest.sendCommandOrDie("Debugger." + command, {});
|
||||
}
|
||||
Protocol.Debugger[command]();
|
||||
});
|
||||
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = function(messageObject)
|
||||
Protocol.Runtime.onConsoleAPICalled(function(messageObject)
|
||||
{
|
||||
if (messageObject.params.args[0].value === "completed") {
|
||||
if (commands.length)
|
||||
InspectorTest.log("[FAIL]: execution was resumed too earlier.")
|
||||
step2();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function step2()
|
||||
{
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "setTimeout(testFunction, 0);"});
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0);"});
|
||||
var commands = [ "Print", "stepOver", "stepInto", "stepOver", "stepOver", "Print", "resume" ];
|
||||
InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
|
||||
Protocol.Debugger.onPaused(function(messageObject)
|
||||
{
|
||||
var command = commands.shift();
|
||||
if (command === "Print") {
|
||||
@ -62,15 +62,15 @@ function step2()
|
||||
command = commands.shift();
|
||||
}
|
||||
if (command)
|
||||
InspectorTest.sendCommandOrDie("Debugger." + command, {});
|
||||
}
|
||||
Protocol.Debugger[command]();
|
||||
});
|
||||
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = function(messageObject)
|
||||
Protocol.Runtime.onConsoleAPICalled(function(messageObject)
|
||||
{
|
||||
if (messageObject.params.args[0].value === "completed") {
|
||||
if (commands.length)
|
||||
InspectorTest.log("[FAIL]: execution was resumed too earlier.")
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function blackboxedBoo()
|
||||
{
|
||||
var a = 42;
|
||||
@ -11,7 +11,7 @@ InspectorTest.evaluateInPage(
|
||||
}
|
||||
//# sourceURL=blackboxed-script.js`);
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function notBlackboxedFoo()
|
||||
{
|
||||
var a = 42;
|
||||
@ -34,7 +34,7 @@ function notBlackboxedBoo()
|
||||
}
|
||||
//# sourceURL=mixed-source.js`);
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function testFunction()
|
||||
{
|
||||
notBlackboxedBoo(); // for setup ranges and stepOut
|
||||
@ -47,22 +47,22 @@ function foo()
|
||||
return 239;
|
||||
}`);
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = setBlackboxedScriptRanges;
|
||||
InspectorTest.sendCommandOrDie("Debugger.enable", {}, callTestFunction);
|
||||
Protocol.Debugger.oncePaused().then(setBlackboxedScriptRanges);
|
||||
Protocol.Debugger.enable().then(callTestFunction);
|
||||
|
||||
function callTestFunction(response)
|
||||
{
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "setTimeout(testFunction, 0);"});
|
||||
Protocol.Runtime.evaluate({ expression: "setTimeout(testFunction, 0);"});
|
||||
}
|
||||
|
||||
function setBlackboxedScriptRanges(response)
|
||||
{
|
||||
var callFrames = response.params.callFrames;
|
||||
printCallFrames(callFrames);
|
||||
InspectorTest.sendCommand("Debugger.setBlackboxedRanges", {
|
||||
Protocol.Debugger.setBlackboxedRanges({
|
||||
scriptId: callFrames[1].location.scriptId,
|
||||
positions: [ { lineNumber: 0, columnNumber: 0 } ] // blackbox ranges for blackboxed.js
|
||||
}, setIncorrectRanges.bind(null, callFrames[2].location.scriptId));
|
||||
}).then(setIncorrectRanges.bind(null, callFrames[2].location.scriptId));
|
||||
}
|
||||
|
||||
var incorrectPositions = [
|
||||
@ -81,19 +81,19 @@ function setIncorrectRanges(scriptId, response)
|
||||
return;
|
||||
}
|
||||
InspectorTest.log("Try to set positions: " + JSON.stringify(positions));
|
||||
InspectorTest.sendCommand("Debugger.setBlackboxedRanges", {
|
||||
Protocol.Debugger.setBlackboxedRanges({
|
||||
scriptId: scriptId,
|
||||
positions: positions
|
||||
}, setIncorrectRanges.bind(null, scriptId));
|
||||
}).then(setIncorrectRanges.bind(null, scriptId));
|
||||
}
|
||||
|
||||
function setMixedSourceRanges(scriptId)
|
||||
{
|
||||
InspectorTest.eventHandler["Debugger.paused"] = runAction;
|
||||
InspectorTest.sendCommandOrDie("Debugger.setBlackboxedRanges", {
|
||||
Protocol.Debugger.onPaused(runAction);
|
||||
Protocol.Debugger.setBlackboxedRanges({
|
||||
scriptId: scriptId,
|
||||
positions: [ { lineNumber: 8, columnNumber: 0 }, { lineNumber: 15, columnNumber: 0 } ] // blackbox ranges for mixed.js
|
||||
}, runAction);
|
||||
}).then(runAction);
|
||||
}
|
||||
|
||||
var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print",
|
||||
@ -111,7 +111,7 @@ function runAction(response)
|
||||
runAction({});
|
||||
} else {
|
||||
InspectorTest.log("action: " + action);
|
||||
InspectorTest.sendCommandOrDie("Debugger." + action, {});
|
||||
Protocol.Debugger[action]();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`function TestFunction()
|
||||
{
|
||||
var a = 2;
|
||||
@ -12,34 +12,33 @@ InspectorTest.evaluateInPage(
|
||||
|
||||
var newVariableValue = 55;
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {});
|
||||
Protocol.Debugger.enable();
|
||||
|
||||
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPaused;
|
||||
Protocol.Debugger.oncePaused().then(handleDebuggerPaused);
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(TestFunction, 0)" });
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(TestFunction, 0)" });
|
||||
|
||||
function handleDebuggerPaused(messageObject)
|
||||
{
|
||||
InspectorTest.log("Paused on 'debugger;'");
|
||||
InspectorTest.eventHandler["Debugger.paused"] = undefined;
|
||||
|
||||
var topFrame = messageObject.params.callFrames[0];
|
||||
var topFrameId = topFrame.callFrameId;
|
||||
InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", { "callFrameId": topFrameId, "expression": "a = " + newVariableValue }, callbackChangeValue);
|
||||
Protocol.Debugger.evaluateOnCallFrame({ "callFrameId": topFrameId, "expression": "a = " + newVariableValue }).then(callbackChangeValue);
|
||||
}
|
||||
|
||||
function callbackChangeValue(response)
|
||||
{
|
||||
InspectorTest.log("Variable value changed");
|
||||
InspectorTest.eventHandler["Debugger.paused"] = callbackGetBacktrace;
|
||||
InspectorTest.sendCommand("Debugger.resume", { });
|
||||
Protocol.Debugger.oncePaused().then(callbackGetBacktrace);
|
||||
Protocol.Debugger.resume();
|
||||
}
|
||||
|
||||
function callbackGetBacktrace(response)
|
||||
{
|
||||
InspectorTest.log("Stacktrace re-read again");
|
||||
var localScope = response.params.callFrames[0].scopeChain[0];
|
||||
InspectorTest.sendCommand("Runtime.getProperties", { "objectId": localScope.object.objectId }, callbackGetProperties);
|
||||
Protocol.Runtime.getProperties({ "objectId": localScope.object.objectId }).then(callbackGetProperties);
|
||||
}
|
||||
|
||||
function callbackGetProperties(response)
|
||||
|
@ -157,7 +157,7 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel {
|
||||
|
||||
void SendMessageToFrontend(const v8_inspector::StringView& message) final {
|
||||
v8_inspector::String16Builder script;
|
||||
script.append("InspectorTest.dispatchMessage(");
|
||||
script.append("InspectorTest._dispatchMessage(");
|
||||
script.append(ToString16(message));
|
||||
script.append(")");
|
||||
frontend_task_runner_->Append(new ExecuteStringTask(script.toString()));
|
||||
|
@ -6,85 +6,52 @@ InspectorTest = {};
|
||||
InspectorTest._dispatchTable = new Map();
|
||||
InspectorTest._requestId = 0;
|
||||
InspectorTest._dumpInspectorProtocolMessages = false;
|
||||
InspectorTest.eventHandler = {};
|
||||
InspectorTest._eventHandler = {};
|
||||
|
||||
InspectorTest.startDumpingProtocolMessages = function()
|
||||
{
|
||||
InspectorTest._dumpInspectorProtocolMessages = true;
|
||||
}
|
||||
|
||||
InspectorTest.sendCommand = function(method, params, handler)
|
||||
{
|
||||
var requestId = ++InspectorTest._requestId;
|
||||
var messageObject = { "id": requestId, "method": method, "params": params };
|
||||
InspectorTest.sendRawCommand(requestId, JSON.stringify(messageObject), handler);
|
||||
}
|
||||
|
||||
InspectorTest.sendRawCommand = function(requestId, command, handler)
|
||||
{
|
||||
if (InspectorTest._dumpInspectorProtocolMessages)
|
||||
print("frontend: " + command);
|
||||
InspectorTest._dispatchTable.set(requestId, handler);
|
||||
sendMessageToBackend(command);
|
||||
}
|
||||
|
||||
InspectorTest.sendCommandOrDie = function(command, properties, callback)
|
||||
{
|
||||
InspectorTest.sendCommand(command, properties, commandCallback);
|
||||
function commandCallback(msg)
|
||||
{
|
||||
if (msg.error) {
|
||||
InspectorTest.log("ERROR: " + msg.error.message);
|
||||
InspectorTest.completeTest();
|
||||
return;
|
||||
}
|
||||
if (callback)
|
||||
callback(msg.result);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorTest.sendCommandPromise = function(method, params)
|
||||
{
|
||||
return new Promise(fulfill => InspectorTest.sendCommand(method, params, fulfill));
|
||||
}
|
||||
|
||||
InspectorTest.waitForEventPromise = function(eventName)
|
||||
{
|
||||
return new Promise(fulfill => InspectorTest.eventHandler[eventName] = fullfillAndClearListener.bind(null, fulfill));
|
||||
|
||||
function fullfillAndClearListener(fulfill, result)
|
||||
{
|
||||
delete InspectorTest.eventHandler[eventName];
|
||||
fulfill(result);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorTest.dispatchMessage = function(messageObject)
|
||||
{
|
||||
if (InspectorTest._dumpInspectorProtocolMessages)
|
||||
print("backend: " + JSON.stringify(messageObject));
|
||||
try {
|
||||
var messageId = messageObject["id"];
|
||||
if (typeof messageId === "number") {
|
||||
var handler = InspectorTest._dispatchTable.get(messageId);
|
||||
if (handler) {
|
||||
handler(messageObject);
|
||||
InspectorTest._dispatchTable.delete(messageId);
|
||||
Protocol = new Proxy({}, {
|
||||
get: function(target, agentName, receiver) {
|
||||
return new Proxy({}, {
|
||||
get: function(target, methodName, receiver) {
|
||||
const eventPattern = /^on(ce)?([A-Z][A-Za-z0-9]+)/;
|
||||
var match = eventPattern.exec(methodName);
|
||||
if (!match) {
|
||||
return (args) => InspectorTest._sendCommandPromise(`${agentName}.${methodName}`, args || {});
|
||||
} else {
|
||||
var eventName = match[2];
|
||||
eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1);
|
||||
if (match[1])
|
||||
return (args) => InspectorTest._waitForEventPromise(`${agentName}.${eventName}`, args || {});
|
||||
else
|
||||
return (listener) => { InspectorTest._eventHandler[`${agentName}.${eventName}`] = listener };
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var eventName = messageObject["method"];
|
||||
var eventHandler = InspectorTest.eventHandler[eventName];
|
||||
if (eventHandler)
|
||||
eventHandler(messageObject);
|
||||
}
|
||||
} catch (e) {
|
||||
InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stack + "\n message = " + JSON.stringify(messageObject, null, 2));
|
||||
InspectorTest.completeTest();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
InspectorTest.log = print.bind(null);
|
||||
|
||||
InspectorTest.logMessage = function(message)
|
||||
{
|
||||
if (message.id)
|
||||
message.id = "<messageId>";
|
||||
|
||||
const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp"]);
|
||||
var objects = [ message ];
|
||||
while (objects.length) {
|
||||
var object = objects.shift();
|
||||
for (var key in object) {
|
||||
if (nonStableFields.has(key))
|
||||
object[key] = `<${key}>`;
|
||||
else if (typeof object[key] === "object")
|
||||
objects.push(object[key]);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorTest.logObject(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
InspectorTest.logObject = function(object, title)
|
||||
{
|
||||
var lines = [];
|
||||
@ -133,27 +100,6 @@ InspectorTest.logObject = function(object, title)
|
||||
InspectorTest.log(lines.join("\n"));
|
||||
}
|
||||
|
||||
InspectorTest.logMessage = function(message)
|
||||
{
|
||||
if (message.id)
|
||||
message.id = 0;
|
||||
|
||||
const nonStableFields = new Set(["objectId", "scriptId", "exceptionId"]);
|
||||
var objects = [ message ];
|
||||
while (objects.length) {
|
||||
var object = objects.shift();
|
||||
for (var key in object) {
|
||||
if (nonStableFields.has(key))
|
||||
object[key] = `<${key}>`;
|
||||
else if (typeof object[key] === "object")
|
||||
objects.push(object[key]);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorTest.logObject(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
InspectorTest.completeTest = quit.bind(null);
|
||||
|
||||
InspectorTest.completeTestAfterPendingTimeouts = function()
|
||||
@ -163,18 +109,32 @@ InspectorTest.completeTestAfterPendingTimeouts = function()
|
||||
awaitPromise: true }, InspectorTest.completeTest);
|
||||
}
|
||||
|
||||
InspectorTest.evaluateInPage = function(string, callback)
|
||||
InspectorTest.addScript = function(string)
|
||||
{
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": string }, function(message) {
|
||||
return InspectorTest._sendCommandPromise("Runtime.evaluate", { "expression": string }).then(dumpErrorIfNeeded);
|
||||
|
||||
function dumpErrorIfNeeded(message)
|
||||
{
|
||||
if (message.error) {
|
||||
InspectorTest.log("Error while executing '" + string + "': " + message.error.message);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
else if (callback)
|
||||
callback(message.result.result.value);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
InspectorTest.startDumpingProtocolMessages = function()
|
||||
{
|
||||
InspectorTest._dumpInspectorProtocolMessages = true;
|
||||
}
|
||||
|
||||
InspectorTest.sendRawCommand = function(requestId, command, handler)
|
||||
{
|
||||
if (InspectorTest._dumpInspectorProtocolMessages)
|
||||
print("frontend: " + command);
|
||||
InspectorTest._dispatchTable.set(requestId, handler);
|
||||
sendMessageToBackend(command);
|
||||
}
|
||||
|
||||
InspectorTest.checkExpectation = function(fail, name, messageObject)
|
||||
{
|
||||
if (fail === !!messageObject.error) {
|
||||
@ -203,3 +163,48 @@ InspectorTest.runTestSuite = function(testSuite)
|
||||
}
|
||||
nextTest();
|
||||
}
|
||||
|
||||
InspectorTest._sendCommandPromise = function(method, params)
|
||||
{
|
||||
var requestId = ++InspectorTest._requestId;
|
||||
var messageObject = { "id": requestId, "method": method, "params": params };
|
||||
var fulfillCallback;
|
||||
var promise = new Promise(fulfill => fulfillCallback = fulfill);
|
||||
InspectorTest.sendRawCommand(requestId, JSON.stringify(messageObject), fulfillCallback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
InspectorTest._waitForEventPromise = function(eventName)
|
||||
{
|
||||
return new Promise(fulfill => InspectorTest._eventHandler[eventName] = fullfillAndClearListener.bind(null, fulfill));
|
||||
|
||||
function fullfillAndClearListener(fulfill, result)
|
||||
{
|
||||
delete InspectorTest._eventHandler[eventName];
|
||||
fulfill(result);
|
||||
}
|
||||
}
|
||||
|
||||
InspectorTest._dispatchMessage = function(messageObject)
|
||||
{
|
||||
if (InspectorTest._dumpInspectorProtocolMessages)
|
||||
print("backend: " + JSON.stringify(messageObject));
|
||||
try {
|
||||
var messageId = messageObject["id"];
|
||||
if (typeof messageId === "number") {
|
||||
var handler = InspectorTest._dispatchTable.get(messageId);
|
||||
if (handler) {
|
||||
handler(messageObject);
|
||||
InspectorTest._dispatchTable.delete(messageId);
|
||||
}
|
||||
} else {
|
||||
var eventName = messageObject["method"];
|
||||
var eventHandler = InspectorTest._eventHandler[eventName];
|
||||
if (eventHandler)
|
||||
eventHandler(messageObject);
|
||||
}
|
||||
} catch (e) {
|
||||
InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stack + "\n message = " + JSON.stringify(messageObject, null, 2));
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
}
|
||||
|
@ -2,103 +2,118 @@ Tests that Runtime.awaitPromise works.
|
||||
|
||||
Running test: testResolvedPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testRejectedPromise
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
objectId : 0
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testRejectedPromiseWithStack
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
parent : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 4
|
||||
functionName : rejectPromise
|
||||
lineNumber : 17
|
||||
scriptId : <scriptId>
|
||||
url : test.js
|
||||
}
|
||||
[1] : {
|
||||
columnNumber : 0
|
||||
functionName :
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
url :
|
||||
}
|
||||
]
|
||||
description : Promise.reject
|
||||
}
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
objectId : 0
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
parent : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 4
|
||||
functionName : rejectPromise
|
||||
lineNumber : 17
|
||||
scriptId : 0
|
||||
url : test.js
|
||||
}
|
||||
[1] : {
|
||||
columnNumber : 0
|
||||
functionName : (anonymous)
|
||||
lineNumber : 0
|
||||
scriptId : 0
|
||||
url : (empty)
|
||||
}
|
||||
]
|
||||
description : Promise.reject
|
||||
}
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testPendingPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testResolvedWithoutArgsPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : undefined
|
||||
result : {
|
||||
type : undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testGarbageCollectedPromise
|
||||
{
|
||||
code : -32000
|
||||
message : Promise was collected
|
||||
error : {
|
||||
code : -32000
|
||||
message : Promise was collected
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
print("Tests that Runtime.awaitPromise works.");
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`
|
||||
var resolveCallback;
|
||||
var rejectCallback;
|
||||
@ -30,105 +30,86 @@ function rejectPromise()
|
||||
|
||||
//# sourceURL=test.js`);
|
||||
|
||||
InspectorTest.sendCommandPromise("Debugger.enable", {})
|
||||
.then(() => InspectorTest.sendCommandPromise("Debugger.setAsyncCallStackDepth", { maxDepth: 128 }))
|
||||
.then(() => testSuite());
|
||||
|
||||
function dumpResult(result)
|
||||
{
|
||||
if (result.exceptionDetails) {
|
||||
if (result.exceptionDetails.stackTrace && result.exceptionDetails.stackTrace.parent) {
|
||||
for (var frame of result.exceptionDetails.stackTrace.parent.callFrames) {
|
||||
frame.scriptId = 0;
|
||||
if (!frame.url)
|
||||
frame.url = "(empty)";
|
||||
if (!frame.functionName)
|
||||
frame.functionName = "(anonymous)";
|
||||
}
|
||||
}
|
||||
result.exceptionDetails.exceptionId = 0;
|
||||
if (result.exceptionDetails.exception)
|
||||
result.exceptionDetails.exception.objectId = 0;
|
||||
}
|
||||
InspectorTest.logObject(result);
|
||||
}
|
||||
Protocol.Debugger.enable()
|
||||
.then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }))
|
||||
.then(() => testSuite());
|
||||
|
||||
function testSuite()
|
||||
{
|
||||
InspectorTest.runTestSuite([
|
||||
function testResolvedPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise.resolve(239)"})
|
||||
.then((result) => InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: false, generatePreview: true }))
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "Promise.resolve(239)"})
|
||||
.then(result => Protocol.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: false, generatePreview: true }))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testRejectedPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise.reject({ a : 1 })"})
|
||||
.then((result) => InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "Promise.reject({ a : 1 })"})
|
||||
.then(result => Protocol.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testRejectedPromiseWithStack(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "createPromise()"})
|
||||
.then((result) => scheduleRejectAndAwaitPromise(result))
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "createPromise()"})
|
||||
.then(result => scheduleRejectAndAwaitPromise(result))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
|
||||
function scheduleRejectAndAwaitPromise(result)
|
||||
{
|
||||
var promise = InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: result.result.result.objectId });
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "rejectPromise()" });
|
||||
var promise = Protocol.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId });
|
||||
Protocol.Runtime.evaluate({ expression: "rejectPromise()" });
|
||||
return promise;
|
||||
}
|
||||
},
|
||||
|
||||
function testPendingPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "createPromise()"})
|
||||
.then((result) => scheduleFulfillAndAwaitPromise(result))
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "createPromise()"})
|
||||
.then(result => scheduleFulfillAndAwaitPromise(result))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
|
||||
function scheduleFulfillAndAwaitPromise(result)
|
||||
{
|
||||
var promise = InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: result.result.result.objectId });
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "resolvePromise()" });
|
||||
var promise = Protocol.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId });
|
||||
Protocol.Runtime.evaluate({ expression: "resolvePromise()" });
|
||||
return promise;
|
||||
}
|
||||
},
|
||||
|
||||
function testResolvedWithoutArgsPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise.resolve()"})
|
||||
.then((result) => InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "Promise.resolve()"})
|
||||
.then(result => Protocol.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testGarbageCollectedPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "new Promise(() => undefined)" })
|
||||
.then((result) => scheduleGCAndawaitPromise(result))
|
||||
.then((result) => InspectorTest.logObject(result.error))
|
||||
Protocol.Runtime.evaluate({ expression: "new Promise(() => undefined)" })
|
||||
.then(result => scheduleGCAndawaitPromise(result))
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
|
||||
function scheduleGCAndawaitPromise(result)
|
||||
{
|
||||
var objectId = result.result.result.objectId;
|
||||
var promise = InspectorTest.sendCommandPromise("Runtime.awaitPromise", { promiseObjectId: objectId });
|
||||
var promise = Protocol.Runtime.awaitPromise({ promiseObjectId: objectId });
|
||||
gcPromise(objectId);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function gcPromise(objectId)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.releaseObject", { objectId: objectId})
|
||||
.then(() => InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "gc()" }));
|
||||
Protocol.Runtime.releaseObject({ objectId: objectId})
|
||||
.then(() => Protocol.Runtime.evaluate({ expression: "gc()" }));
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
@ -2,59 +2,68 @@ Tests that Runtime.callFunctionOn works with awaitPromise flag.
|
||||
|
||||
Running test: testArguments
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : string
|
||||
value : undefined|NaN|[object Object]|[object Object]
|
||||
result : {
|
||||
type : string
|
||||
value : undefined|NaN|[object Object]|[object Object]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testSyntaxErrorInFunction
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 2
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 2
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token }
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 1
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token }
|
||||
objectId : 0
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 1
|
||||
scriptId : 0
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token }
|
||||
objectId : [ObjectId]
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testExceptionInFunctionExpression
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 15
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 15
|
||||
exception : {
|
||||
className : Error
|
||||
description : Error at <anonymous>:1:22 at <anonymous>:1:36
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : Error
|
||||
description : Error at <anonymous>:1:22 at <anonymous>:1:36
|
||||
objectId : 0
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
scriptId : 0
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : Error
|
||||
description : Error at <anonymous>:1:22 at <anonymous>:1:36
|
||||
objectId : [ObjectId]
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,60 +75,67 @@ Running test: testFunctionReturnNotPromise
|
||||
|
||||
Running test: testFunctionReturnResolvedPromiseReturnByValue
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 3
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testFunctionReturnResolvedPromiseWithPreview
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
className : Object
|
||||
description : Object
|
||||
objectId : [ObjectId]
|
||||
preview : {
|
||||
result : {
|
||||
className : Object
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : a
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
]
|
||||
objectId : <objectId>
|
||||
preview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : a
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
type : object
|
||||
}
|
||||
type : object
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testFunctionReturnRejectedPromise
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
objectId : 0
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
type : object
|
||||
value : {
|
||||
a : 3
|
||||
}
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 3
|
||||
}
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ true,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ false)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -27,7 +27,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ false,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -40,7 +40,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ false,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -53,7 +53,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ false,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => InspectorTest.logObject(result.error))
|
||||
.then((result) => InspectorTest.logMessage(result.error))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -66,7 +66,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ true,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -79,7 +79,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ false,
|
||||
/* generatePreview */ true,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
@ -92,7 +92,7 @@ InspectorTest.runTestSuite([
|
||||
/* returnByValue */ true,
|
||||
/* generatePreview */ false,
|
||||
/* awaitPromise */ true)
|
||||
.then((result) => dumpResult(result.result))
|
||||
.then((result) => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
}
|
||||
]);
|
||||
@ -101,14 +101,14 @@ function callFunctionOn(objectExpression, functionDeclaration, argumentExpressio
|
||||
{
|
||||
var objectId;
|
||||
var callArguments = [];
|
||||
var promise = InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: objectExpression })
|
||||
var promise = Protocol.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(() => Protocol.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 }));
|
||||
return promise.then(() => Protocol.Runtime.callFunctionOn({ objectId: objectId, functionDeclaration: functionDeclaration, arguments: callArguments, returnByValue: returnByValue, generatePreview: generatePreview, awaitPromise: awaitPromise }));
|
||||
|
||||
function addArgument(result)
|
||||
{
|
||||
@ -122,21 +122,8 @@ function callFunctionOn(objectExpression, functionDeclaration, argumentExpressio
|
||||
callArguments.push({});
|
||||
} else {
|
||||
InspectorTest.log("Unexpected argument object:");
|
||||
InspectorTest.logObject(result);
|
||||
InspectorTest.logMessage(result);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dumpResult(result)
|
||||
{
|
||||
if (result.exceptionDetails && result.exceptionDetails.scriptId)
|
||||
result.exceptionDetails.scriptId = 0;
|
||||
if (result.result && result.result.objectId)
|
||||
result.result.objectId = "[ObjectId]";
|
||||
if (result.exceptionDetails) {
|
||||
result.exceptionDetails.exceptionId = 0;
|
||||
result.exceptionDetails.exception.objectId = 0;
|
||||
}
|
||||
InspectorTest.logObject(result);
|
||||
}
|
||||
|
@ -1,127 +1,177 @@
|
||||
Tests that CommandLineAPI is presented only while evaluation.
|
||||
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 15
|
||||
type : number
|
||||
value : 15
|
||||
result : {
|
||||
description : 15
|
||||
type : number
|
||||
value : 15
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
setPropertyForMethod()
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
}
|
||||
}
|
||||
}
|
||||
defineValuePropertyForMethod()
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
}
|
||||
}
|
||||
}
|
||||
definePropertiesForMethod()
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
}
|
||||
}
|
||||
}
|
||||
defineAccessorPropertyForMethod()
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
}
|
||||
}
|
||||
}
|
||||
redefineGetOwnPropertyDescriptors()
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
result : {
|
||||
description : 14
|
||||
type : number
|
||||
value : 14
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
result : {
|
||||
description : 42
|
||||
type : number
|
||||
value : 42
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Tests that CommandLineAPI is presented only while evaluation.");
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`
|
||||
var methods = ["dir","dirxml","profile","profileEnd","clear","table","keys","values","debug","undebug","monitor","unmonitor","inspect","copy"];
|
||||
var window = this;
|
||||
@ -85,10 +85,7 @@ runExpressionAndDumpPresentedMethods("")
|
||||
|
||||
function evaluate(expression, includeCommandLineAPI)
|
||||
{
|
||||
var cb;
|
||||
var p = new Promise(resolver => cb = resolver);
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: expression, objectGroup: "console", includeCommandLineAPI: includeCommandLineAPI }, cb);
|
||||
return p;
|
||||
return Protocol.Runtime.evaluate({ expression: expression, objectGroup: "console", includeCommandLineAPI: includeCommandLineAPI });
|
||||
}
|
||||
|
||||
function setLastEvaluationResultTo239()
|
||||
@ -101,7 +98,7 @@ function runExpressionAndDumpPresentedMethods(expression)
|
||||
InspectorTest.log(expression);
|
||||
return setLastEvaluationResultTo239()
|
||||
.then(() => evaluate(expression + "; var a = presentedAPIMethods(); a", true))
|
||||
.then((result) => InspectorTest.logObject(result));
|
||||
.then((result) => InspectorTest.logMessage(result));
|
||||
}
|
||||
|
||||
function dumpLeftMethods()
|
||||
@ -109,12 +106,12 @@ function dumpLeftMethods()
|
||||
// Should always be zero.
|
||||
return setLastEvaluationResultTo239()
|
||||
.then(() => evaluate("presentedAPIMethods()", false))
|
||||
.then((result) => InspectorTest.logObject(result));
|
||||
.then((result) => InspectorTest.logMessage(result));
|
||||
}
|
||||
|
||||
function dumpDir()
|
||||
{
|
||||
// Should always be presented.
|
||||
return evaluate("dir", false)
|
||||
.then((result) => InspectorTest.logObject(result));
|
||||
.then((result) => InspectorTest.logMessage(result));
|
||||
}
|
||||
|
@ -1,51 +1,66 @@
|
||||
Compiling script: foo1.js
|
||||
persist: false
|
||||
compilation result: {
|
||||
exceptionDetails : {
|
||||
columnNumber : 2
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected end of input
|
||||
objectId : 0
|
||||
subtype : error
|
||||
type : object
|
||||
compilation result:
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 2
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected end of input
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 1
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 1
|
||||
scriptId : 0
|
||||
text : Uncaught
|
||||
}
|
||||
}
|
||||
-----
|
||||
Compiling script: foo2.js
|
||||
persist: true
|
||||
Debugger.scriptParsed: foo2.js
|
||||
compilation result: {
|
||||
scriptId : 0
|
||||
compilation result:
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
scriptId : <scriptId>
|
||||
}
|
||||
}
|
||||
-----
|
||||
Compiling script: foo3.js
|
||||
persist: false
|
||||
compilation result: {
|
||||
compilation result:
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
}
|
||||
}
|
||||
-----
|
||||
Compiling script: foo4.js
|
||||
persist: false
|
||||
compilation result: {
|
||||
exceptionDetails : {
|
||||
columnNumber : 13
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected identifier
|
||||
objectId : 0
|
||||
subtype : error
|
||||
type : object
|
||||
compilation result:
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 13
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected identifier
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
scriptId : 0
|
||||
text : Uncaught
|
||||
}
|
||||
}
|
||||
-----
|
||||
|
||||
-----
|
@ -4,13 +4,13 @@
|
||||
|
||||
var executionContextId;
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable", {}, onDebuggerEnabled);
|
||||
Protocol.Debugger.enable().then(onDebuggerEnabled);
|
||||
|
||||
function onDebuggerEnabled()
|
||||
{
|
||||
InspectorTest.sendCommand("Runtime.enable", {});
|
||||
InspectorTest.eventHandler["Debugger.scriptParsed"] = onScriptParsed;
|
||||
InspectorTest.eventHandler["Runtime.executionContextCreated"] = onExecutionContextCreated;
|
||||
Protocol.Runtime.enable();
|
||||
Protocol.Debugger.onScriptParsed(onScriptParsed);
|
||||
Protocol.Runtime.onExecutionContextCreated(onExecutionContextCreated);
|
||||
}
|
||||
|
||||
function onScriptParsed(messageObject)
|
||||
@ -34,28 +34,17 @@ function testCompileScript(expression, persistScript, sourceURL)
|
||||
{
|
||||
InspectorTest.log("Compiling script: " + sourceURL);
|
||||
InspectorTest.log(" persist: " + persistScript);
|
||||
var callback;
|
||||
var promise = new Promise(resolver => callback = resolver);
|
||||
InspectorTest.sendCommand("Runtime.compileScript", {
|
||||
return Protocol.Runtime.compileScript({
|
||||
expression: expression,
|
||||
sourceURL: sourceURL,
|
||||
persistScript: persistScript,
|
||||
executionContextId: executionContextId
|
||||
}, onCompiled);
|
||||
return promise;
|
||||
}).then(onCompiled);
|
||||
|
||||
function onCompiled(messageObject)
|
||||
{
|
||||
var result = messageObject.result;
|
||||
if (result.exceptionDetails) {
|
||||
result.exceptionDetails.exceptionId = 0;
|
||||
result.exceptionDetails.exception.objectId = 0;
|
||||
result.exceptionDetails.scriptId = 0;
|
||||
}
|
||||
if (result.scriptId)
|
||||
result.scriptId = 0;
|
||||
InspectorTest.logObject(result, "compilation result: ");
|
||||
InspectorTest.log("compilation result: ");
|
||||
InspectorTest.logMessage(messageObject);
|
||||
InspectorTest.log("-----");
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ print("Check that console.log is reported through Console domain as well.");
|
||||
var expectedMessages = 4;
|
||||
var messages = [];
|
||||
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = consoleAPICalled;
|
||||
InspectorTest.eventHandler["Console.messageAdded"] = messageAdded;
|
||||
InspectorTest.sendCommandOrDie("Runtime.enable", {});
|
||||
InspectorTest.sendCommandOrDie("Console.enable", {});
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "console.log(42)" });
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "console.error('abc')" });
|
||||
Protocol.Runtime.onConsoleAPICalled(consoleAPICalled);
|
||||
Protocol.Console.onMessageAdded(messageAdded);
|
||||
Protocol.Runtime.enable();
|
||||
Protocol.Console.enable();
|
||||
Protocol.Runtime.evaluate({ "expression": "console.log(42)" });
|
||||
Protocol.Runtime.evaluate({ "expression": "console.error('abc')" });
|
||||
|
||||
function consoleAPICalled(result)
|
||||
{
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
print("Tests checks that deprecation messages for console.")
|
||||
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = messageAdded;
|
||||
InspectorTest.sendCommand("Runtime.enable", {});
|
||||
Protocol.Runtime.onConsoleAPICalled(messageAdded);
|
||||
Protocol.Runtime.enable();
|
||||
|
||||
var deprecatedMethods = [
|
||||
"console.timeline(\"42\")",
|
||||
@ -14,7 +14,7 @@ var deprecatedMethods = [
|
||||
"console.timelineEnd(\"42\")",
|
||||
"console.markTimeline(\"42\")",
|
||||
];
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: deprecatedMethods.join(";") });
|
||||
Protocol.Runtime.evaluate({ expression: deprecatedMethods.join(";") });
|
||||
|
||||
var messagesLeft = 3;
|
||||
function messageAdded(data)
|
||||
|
@ -1,29 +1,52 @@
|
||||
{
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
method : Runtime.consoleAPICalled
|
||||
params : {
|
||||
args : [
|
||||
[0] : {
|
||||
columnNumber : 8
|
||||
functionName : (anonymous)
|
||||
lineNumber : 0
|
||||
scriptId : 0
|
||||
url : (empty)
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
]
|
||||
executionContextId : 1
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 8
|
||||
functionName :
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
url :
|
||||
}
|
||||
]
|
||||
}
|
||||
timestamp : <timestamp>
|
||||
type : log
|
||||
}
|
||||
type : log
|
||||
}
|
||||
{
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
method : Runtime.consoleAPICalled
|
||||
params : {
|
||||
args : [
|
||||
[0] : {
|
||||
columnNumber : 2
|
||||
functionName : (anonymous)
|
||||
lineNumber : 1
|
||||
scriptId : 0
|
||||
url : (empty)
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
]
|
||||
executionContextId : 1
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 2
|
||||
functionName :
|
||||
lineNumber : 1
|
||||
scriptId : <scriptId>
|
||||
url :
|
||||
}
|
||||
]
|
||||
}
|
||||
timestamp : <timestamp>
|
||||
type : log
|
||||
}
|
||||
type : log
|
||||
}
|
||||
|
||||
}
|
@ -2,34 +2,17 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.sendCommand("Runtime.enable", {});
|
||||
Protocol.Runtime.enable();
|
||||
|
||||
addConsoleMessagePromise("console.log(239)")
|
||||
.then(dumpMessage)
|
||||
.then(message => InspectorTest.logMessage(message))
|
||||
.then(() => addConsoleMessagePromise("var l = console.log;\n l(239)"))
|
||||
.then(dumpMessage)
|
||||
.then(message => InspectorTest.logMessage(message))
|
||||
.then(() => InspectorTest.completeTest());
|
||||
|
||||
function addConsoleMessagePromise(expression)
|
||||
{
|
||||
var cb;
|
||||
var p = new Promise((resolver) => cb = resolver);
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = (messageObject) => cb(messageObject);
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: expression });
|
||||
return p;
|
||||
}
|
||||
|
||||
function dumpMessage(messageObject)
|
||||
{
|
||||
var msg = messageObject.params;
|
||||
delete msg.executionContextId;
|
||||
delete msg.args;
|
||||
delete msg.timestamp;
|
||||
for (var frame of msg.stackTrace.callFrames)
|
||||
frame.scriptId = 0;
|
||||
if (!frame.functionName)
|
||||
frame.functionName = "(anonymous)";
|
||||
if (!frame.url)
|
||||
frame.url = "(empty)";
|
||||
InspectorTest.logObject(msg);
|
||||
var wait = Protocol.Runtime.onceConsoleAPICalled();
|
||||
Protocol.Runtime.evaluate({ expression: expression });
|
||||
return wait;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Check that console.log doesn't run microtasks.");
|
||||
|
||||
InspectorTest.evaluateInPage(
|
||||
InspectorTest.addScript(
|
||||
`
|
||||
function testFunction()
|
||||
{
|
||||
@ -13,10 +13,10 @@ function testFunction()
|
||||
console.log(43);
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommandOrDie("Runtime.enable", {});
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = messageAdded;
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "testFunction()" });
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "setTimeout(() => console.log(\"finished\"), 0)" });
|
||||
Protocol.Runtime.enable();
|
||||
Protocol.Runtime.onConsoleAPICalled(messageAdded);
|
||||
Protocol.Runtime.evaluate({ "expression": "testFunction()" });
|
||||
Protocol.Runtime.evaluate({ "expression": "setTimeout(() => console.log(\"finished\"), 0)" });
|
||||
|
||||
function messageAdded(result)
|
||||
{
|
||||
|
@ -18,7 +18,6 @@ function messageAdded(data)
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
||||
InspectorTest.eventHandler["Runtime.consoleAPICalled"] = messageAdded;
|
||||
InspectorTest.sendCommand("Runtime.enable", {});
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { expression: "console.log('testUnique'); for (var i = 0; i < 2; ++i) console.log('testDouble');" });
|
||||
Protocol.Runtime.onConsoleAPICalled(messageAdded);
|
||||
Protocol.Runtime.enable();
|
||||
Protocol.Runtime.evaluate({ expression: "console.log('testUnique'); for (var i = 0; i < 2; ++i) console.log('testDouble');" });
|
||||
|
@ -2,80 +2,94 @@ Tests that Runtime.evaluate works with awaitPromise flag.
|
||||
|
||||
Running test: testResolvedPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testRejectedPromise
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
objectId : 0
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
scriptId : (scriptId)
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testPrimitiveValueInsteadOfPromise
|
||||
{
|
||||
code : -32000
|
||||
message : Result of the evaluation is not a promise
|
||||
error : {
|
||||
code : -32000
|
||||
message : Result of the evaluation is not a promise
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testObjectInsteadOfPromise
|
||||
{
|
||||
code : -32000
|
||||
message : Result of the evaluation is not a promise
|
||||
error : {
|
||||
code : -32000
|
||||
message : Result of the evaluation is not a promise
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testPendingPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 239
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 239
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testExceptionInEvaluate
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
objectId : 0
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
scriptId : (scriptId)
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
description : 239
|
||||
type : number
|
||||
value : 239
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ Test that Runtime.evaluate correctly process errors during wrapping async result
|
||||
code : -32000
|
||||
message : Object couldn't be returned by value
|
||||
}
|
||||
id : 0
|
||||
id : <messageId>
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ var evaluateArguments = {
|
||||
returnByValue: true,
|
||||
awaitPromise: true
|
||||
};
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", evaluateArguments)
|
||||
Protocol.Runtime.evaluate(evaluateArguments)
|
||||
.then(message => InspectorTest.logMessage(message))
|
||||
.then(_ => InspectorTest.completeTest());
|
||||
.then(() => InspectorTest.completeTest());
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Tests that Runtime.evaluate works with awaitPromise flag.");
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function createPromiseAndScheduleResolve()
|
||||
{
|
||||
var resolveCallback;
|
||||
@ -13,56 +13,46 @@ function createPromiseAndScheduleResolve()
|
||||
return promise;
|
||||
}`);
|
||||
|
||||
function dumpResult(result)
|
||||
{
|
||||
if (result.exceptionDetails) {
|
||||
result.exceptionDetails.scriptId = "(scriptId)";
|
||||
result.exceptionDetails.exceptionId = 0;
|
||||
result.exceptionDetails.exception.objectId = 0;
|
||||
}
|
||||
InspectorTest.logObject(result);
|
||||
}
|
||||
|
||||
InspectorTest.runTestSuite([
|
||||
function testResolvedPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise.resolve(239)", awaitPromise: true, generatePreview: true })
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "Promise.resolve(239)", awaitPromise: true, generatePreview: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testRejectedPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "Promise.reject(239)", awaitPromise: true })
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "Promise.reject(239)", awaitPromise: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testPrimitiveValueInsteadOfPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "true", awaitPromise: true })
|
||||
.then((result) => InspectorTest.logObject(result.error))
|
||||
Protocol.Runtime.evaluate({ expression: "true", awaitPromise: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testObjectInsteadOfPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "({})", awaitPromise: true })
|
||||
.then((result) => InspectorTest.logObject(result.error))
|
||||
Protocol.Runtime.evaluate({ expression: "({})", awaitPromise: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testPendingPromise(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "createPromiseAndScheduleResolve()", awaitPromise: true, returnByValue: true })
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "createPromiseAndScheduleResolve()", awaitPromise: true, returnByValue: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
},
|
||||
|
||||
function testExceptionInEvaluate(next)
|
||||
{
|
||||
InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "throw 239", awaitPromise: true })
|
||||
.then((result) => dumpResult(result.result))
|
||||
Protocol.Runtime.evaluate({ expression: "throw 239", awaitPromise: true })
|
||||
.then(result => InspectorTest.logMessage(result))
|
||||
.then(() => next());
|
||||
}
|
||||
]);
|
||||
|
@ -4,6 +4,6 @@ Tests that DevTools doesn't crash on Runtime.evaluate with contextId equals 0.
|
||||
code : -32000
|
||||
message : Cannot find context with specified id
|
||||
}
|
||||
id : 0
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,6 @@
|
||||
|
||||
print("Tests that DevTools doesn't crash on Runtime.evaluate with contextId equals 0.");
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "contextId": 0, "expression": "" }, evaluateCallback);
|
||||
|
||||
function evaluateCallback(result)
|
||||
{
|
||||
result.id = 0;
|
||||
InspectorTest.logObject(result);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
Protocol.Runtime.evaluate({ "contextId": 0, "expression": "" })
|
||||
.then(message => InspectorTest.logMessage(message))
|
||||
.then(() => InspectorTest.completeTest());
|
||||
|
@ -1,9 +1,11 @@
|
||||
Check that while Runtime.getProperties call on proxy object no user defined trap will be executed.
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
result : {
|
||||
description : 0
|
||||
type : number
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Check that while Runtime.getProperties call on proxy object no user defined trap will be executed.");
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
var self = this;
|
||||
function testFunction()
|
||||
{
|
||||
@ -82,20 +82,20 @@ function testFunction()
|
||||
return new Proxy({ a : 1}, handler);
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "testFunction()"}, requestProperties);
|
||||
Protocol.Runtime.evaluate({ expression: "testFunction()"}).then(requestProperties);
|
||||
|
||||
function requestProperties(result)
|
||||
{
|
||||
InspectorTest.sendCommandOrDie("Runtime.getProperties", { objectId: result.result.objectId, generatePreview: true }, checkCounter);
|
||||
Protocol.Runtime.getProperties({ objectId: result.result.objectId, generatePreview: true }).then(checkCounter);
|
||||
}
|
||||
|
||||
function checkCounter(result)
|
||||
{
|
||||
InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "self.counter" }, dumpCounter);
|
||||
Protocol.Runtime.evaluate({ expression: "self.counter" }).then(dumpCounter);
|
||||
}
|
||||
|
||||
function dumpCounter(result)
|
||||
{
|
||||
InspectorTest.logObject(result);
|
||||
InspectorTest.logMessage(result);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "({p1: {a:1}, p2: {b:'foo', bb:'bar'}})" }, callbackEvaluate);
|
||||
Protocol.Runtime.evaluate({ "expression": "({p1: {a:1}, p2: {b:'foo', bb:'bar'}})" }).then(callbackEvaluate);
|
||||
|
||||
function callbackEvaluate(result)
|
||||
{
|
||||
InspectorTest.sendCommand("Runtime.getProperties", { "objectId": result.result.result.objectId, "ownProperties": true }, callbackGetProperties.bind(null, false));
|
||||
InspectorTest.sendCommand("Runtime.getProperties", { "objectId": result.result.result.objectId, "ownProperties": true, "generatePreview": true }, callbackGetProperties.bind(null, true));
|
||||
Protocol.Runtime.getProperties({ "objectId": result.result.result.objectId, "ownProperties": true }).then(callbackGetProperties.bind(null, false));
|
||||
Protocol.Runtime.getProperties({ "objectId": result.result.result.objectId, "ownProperties": true, "generatePreview": true }).then(callbackGetProperties.bind(null, true));
|
||||
}
|
||||
|
||||
function callbackGetProperties(completeTest, result)
|
||||
|
@ -50,7 +50,8 @@ function runRequestSeries(step)
|
||||
}
|
||||
processStep(next);
|
||||
}
|
||||
InspectorTest.sendCommand(s.command, s.params, innerCallback);
|
||||
var command = s.command.split(".");
|
||||
Protocol[command[0]][command[1]](s.params).then(innerCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
Tests that property defined on console.__proto__ doesn't observable on other Objects.
|
||||
{
|
||||
id : 0
|
||||
id : <messageId>
|
||||
result : {
|
||||
result : {
|
||||
description : 0
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Tests that property defined on console.__proto__ doesn't observable on other Objects.");
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function testFunction()
|
||||
{
|
||||
var amountOfProperties = 0;
|
||||
@ -16,11 +16,10 @@ function testFunction()
|
||||
return amountOfProperties;
|
||||
}`);
|
||||
|
||||
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, dumpResult);
|
||||
Protocol.Runtime.evaluate({ "expression": "testFunction()" }).then(dumpResult);
|
||||
|
||||
function dumpResult(result)
|
||||
{
|
||||
result.id = 0;
|
||||
InspectorTest.logObject(result);
|
||||
InspectorTest.logMessage(result);
|
||||
InspectorTest.completeTest();
|
||||
}
|
||||
|
@ -2,156 +2,190 @@ Tests that Runtime.compileScript and Runtime.runScript work with awaitPromise fl
|
||||
|
||||
Running test: testRunAndCompileWithoutAgentEnable
|
||||
{
|
||||
code : 0
|
||||
message : Runtime agent is not enabled
|
||||
error : {
|
||||
code : -32000
|
||||
message : Runtime agent is not enabled
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
{
|
||||
code : 0
|
||||
message : Runtime agent is not enabled
|
||||
error : {
|
||||
code : -32000
|
||||
message : Runtime agent is not enabled
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testSyntaxErrorInScript
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 1
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token }
|
||||
objectId : 0
|
||||
subtype : error
|
||||
type : object
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 1
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token }
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 1
|
||||
scriptId : <scriptId>
|
||||
text : Uncaught
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 1
|
||||
scriptId : 0
|
||||
text : Uncaught
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testSyntaxErrorInEvalInScript
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token } at boo.js:2:2
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
scriptId : <scriptId>
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 1
|
||||
functionName :
|
||||
lineNumber : 1
|
||||
scriptId : <scriptId>
|
||||
url : boo.js
|
||||
}
|
||||
]
|
||||
}
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token } at boo.js:2:2
|
||||
objectId : 0
|
||||
objectId : <objectId>
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
scriptId : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
[0] : {
|
||||
columnNumber : 1
|
||||
functionName :
|
||||
lineNumber : 1
|
||||
scriptId : 0
|
||||
url : boo.js
|
||||
}
|
||||
]
|
||||
}
|
||||
text : Uncaught
|
||||
}
|
||||
result : {
|
||||
className : SyntaxError
|
||||
description : SyntaxError: Unexpected token } at boo.js:2:2
|
||||
objectId : [ObjectId]
|
||||
subtype : error
|
||||
type : object
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testRunNotCompiledScript
|
||||
{
|
||||
code : 0
|
||||
message : No script with given id
|
||||
error : {
|
||||
code : -32000
|
||||
message : No script with given id
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testRunCompiledScriptAfterAgentWasReenabled
|
||||
{
|
||||
code : 0
|
||||
message : Runtime agent is not enabled
|
||||
error : {
|
||||
code : -32000
|
||||
message : Runtime agent is not enabled
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
{
|
||||
code : 0
|
||||
message : No script with given id
|
||||
error : {
|
||||
code : -32000
|
||||
message : No script with given id
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testRunScriptWithPreview
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
className : Object
|
||||
description : Object
|
||||
objectId : [ObjectId]
|
||||
preview : {
|
||||
result : {
|
||||
className : Object
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : a
|
||||
type : number
|
||||
value : 1
|
||||
}
|
||||
]
|
||||
objectId : <objectId>
|
||||
preview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : a
|
||||
type : number
|
||||
value : 1
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
type : object
|
||||
}
|
||||
type : object
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testRunScriptReturnByValue
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testAwaitNotPromise
|
||||
{
|
||||
code : 0
|
||||
message : Result of the script execution is not a promise
|
||||
error : {
|
||||
code : -32000
|
||||
message : Result of the script execution is not a promise
|
||||
}
|
||||
id : <messageId>
|
||||
}
|
||||
|
||||
Running test: testAwaitResolvedPromise
|
||||
{
|
||||
id : <messageId>
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Running test: testAwaitRejectedPromise
|
||||
{
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
objectId : 0
|
||||
id : <messageId>
|
||||
result : {
|
||||
exceptionDetails : {
|
||||
columnNumber : 0
|
||||
exception : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
exceptionId : <exceptionId>
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
exceptionId : 0
|
||||
lineNumber : 0
|
||||
stackTrace : {
|
||||
callFrames : [
|
||||
]
|
||||
}
|
||||
text : Uncaught (in promise)
|
||||
}
|
||||
result : {
|
||||
type : object
|
||||
value : {
|
||||
a : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
print("Test that Runtime.getProperties doesn't truncate set and map entries in internalProperties.")
|
||||
|
||||
InspectorTest.evaluateInPage(`
|
||||
InspectorTest.addScript(`
|
||||
function createSet(size) {
|
||||
var s = new Set();
|
||||
var a = {};
|
||||
@ -22,8 +22,8 @@ InspectorTest.evaluateInPage(`
|
||||
}
|
||||
`);
|
||||
|
||||
InspectorTest.sendCommand("Debugger.enable");
|
||||
InspectorTest.sendCommand("Runtime.enable");
|
||||
Protocol.Debugger.enable();
|
||||
Protocol.Runtime.enable();
|
||||
|
||||
testExpression("createSet(10)")
|
||||
.then(() => testExpression("createSet(1000)"))
|
||||
@ -33,8 +33,8 @@ testExpression("createSet(10)")
|
||||
|
||||
function testExpression(expression)
|
||||
{
|
||||
return InspectorTest.sendCommandPromise("Runtime.evaluate", { "expression": expression})
|
||||
.then(result => InspectorTest.sendCommandPromise("Runtime.getProperties", { ownProperties: true, objectId: result.result.result.objectId }))
|
||||
return Protocol.Runtime.evaluate({ "expression": expression})
|
||||
.then(result => Protocol.Runtime.getProperties({ ownProperties: true, objectId: result.result.result.objectId }))
|
||||
.then(message => dumpEntriesDescription(expression, message));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user