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