Commit bab66151 authored by Jeff Fisher's avatar Jeff Fisher Committed by Commit Bot

[inspector] Add tests for Debugger domain

New tests added for these calls:

* evaluateOnCallFrame
* setAsyncCallStackDepth
* setBreakpoint
* setVariableValue

For setAsyncCallStackDepth, this change updates the test to manufacture async callstacks in a different way so that there is more than one. The previous promise chain method was broken by f61facfd.

Change-Id: I9083b0b1c08849d4c7ebb5349cfa4489f551aa39
Reviewed-on: https://chromium-review.googlesource.com/c/1465118
Commit-Queue: Jeff Fisher <jeffish@microsoft.com>
Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59745}
parent 0b07a888
Tests that exercise various result types from Debugger.evaluateOnCallFrame
Running test: testCreateFunction
{
id : <messageId>
result : {
result : {
type : string
value : SUCCESS
}
}
}
Running test: testNumericValue
{
id : <messageId>
result : {
result : {
description : -578.28
type : number
value : -578.28
}
}
}
Running test: testUnserializableValues
{
id : <messageId>
result : {
result : {
description : NaN
type : number
unserializableValue : NaN
}
}
}
{
id : <messageId>
result : {
result : {
description : Infinity
type : number
unserializableValue : Infinity
}
}
}
{
id : <messageId>
result : {
result : {
description : -Infinity
type : number
unserializableValue : -Infinity
}
}
}
{
id : <messageId>
result : {
result : {
description : -0
type : number
unserializableValue : -0
}
}
}
Running test: testBooleanValue
{
id : <messageId>
result : {
result : {
type : boolean
value : true
}
}
}
Running test: testObject
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
Running test: testConsoleLog
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
description : 42
type : number
value : 42
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 8
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : log
}
}
Running test: testSymbol
{
id : <messageId>
result : {
result : {
description : Symbol(foo)
objectId : <objectId>
type : symbol
}
}
}
Running test: testSymbolReturnByValueError
{
error : {
code : -32000
message : Object couldn't be returned by value
}
id : <messageId>
}
Running test: testPromiseResolveReturnByVal
{
id : <messageId>
result : {
result : {
type : object
value : {
}
}
}
}
Running test: testPromiseResolve
{
id : <messageId>
result : {
result : {
className : Promise
description : Promise
objectId : <objectId>
subtype : promise
type : object
}
}
}
Running test: testReleaseObject
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
Running test: testReleaseObjectInvalid
ReleaseObject with invalid params.
{
error : {
code : -32602
data : objectId: string value expected
message : Invalid parameters
}
id : <messageId>
}
Running test: testObjectGroups
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
{
error : {
code : -32000
message : Could not find object with given id
}
id : <messageId>
}
Running test: testReleaseObjectGroupInvalid
ReleaseObjectGroup with invalid params
{
error : {
code : -32602
data : objectGroup: string value expected
message : Invalid parameters
}
id : <messageId>
}
Running test: testEvaluateSyntaxError
{
className : SyntaxError
description : SyntaxError: Unexpected token ] at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
}
Running test: testEvaluateReferenceError
{
className : ReferenceError
description : ReferenceError: totalRandomNotRealVariable789 is not defined at eval (eval at <anonymous> (:1:1), <anonymous>:1:1) at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
}
Running test: testCallFrameIdTypeError
{
error : {
code : -32602
data : callFrameId: string value expected
message : Invalid parameters
}
id : <messageId>
}
Running test: testCallFrameIdInvalidInput
Testing evaluateOnCallFrame with non-existent callFrameId
{
error : {
code : -32000
message : Invalid call frame id
}
id : <messageId>
}
Running test: testNullExpression
{
error : {
code : -32602
data : expression: string value expected
message : Invalid parameters
}
id : <messageId>
}
\ No newline at end of file
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const {Protocol} = InspectorTest.start(
`Tests that exercise various result types from Debugger.evaluateOnCallFrame`);
(async function test(){
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
Protocol.Runtime.evaluate({expression: "debugger;"});
const {params:{callFrames:[{callFrameId}]}} = await Protocol.Debugger.oncePaused();
InspectorTest.runAsyncTestSuite([
async function testCreateFunction() {
await evalAndLog('function testFunc() {return "SUCCESS";}; testFunc();', callFrameId, /*returnByValue*/ true );
},
async function testNumericValue() {
await evalAndLog('-578.28', callFrameId);
},
async function testUnserializableValues() {
const unserializableExpressions = ['NaN', 'Infinity', '-Infinity', '-0'];
for (const expression of unserializableExpressions)
await evalAndLog(expression, callFrameId);
},
async function testBooleanValue() {
await evalAndLog('Infinity > 0', callFrameId);
},
async function testObject() {
await evalAndLog('({ })', callFrameId);
},
async function testConsoleLog() {
Protocol.Debugger.evaluateOnCallFrame({ expression: `console.log(42)`, callFrameId });
const result = await Protocol.Runtime.onceConsoleAPICalled();
InspectorTest.logMessage(result);
},
async function testSymbol() {
await evalAndLog(`const symbolTest = Symbol('foo'); symbolTest;`, callFrameId);
},
async function testSymbolReturnByValueError() {
await evalAndLog(`const symbolTest = Symbol('foo'); symbolTest;`, callFrameId, /*returnByValue*/ true);
},
async function testPromiseResolveReturnByVal() {
await evalAndLog('Promise.resolve(239)', callFrameId, /*returnByValue*/ true);
},
async function testPromiseResolve() {
await evalAndLog('Promise.resolve(239)', callFrameId);
},
async function testReleaseObject() {
await Protocol.Runtime.evaluate({ expression: 'var a = {x:3};', callFrameId });
await Protocol.Runtime.evaluate({ expression: 'var b = {x:4};', callFrameId });
const ids = [];
let result = await Protocol.Runtime.evaluate({ expression: 'a', callFrameId });
const id1 = result.result.result.objectId;
ids.push(id1);
result = await Protocol.Runtime.evaluate({ expression: 'b', callFrameId });
const id2 = result.result.result.objectId;
ids.push(id2);
// Call Function on both objects and log:
await objectGroupHelper(ids);
Protocol.Runtime.releaseObject({ objectId: id1 });
await objectGroupHelper(ids);
Protocol.Runtime.releaseObject({ objectId: id2 });
await objectGroupHelper(ids);
},
async function testReleaseObjectInvalid() {
const releaseObjectResult = await Protocol.Runtime.releaseObject({});
InspectorTest.log('ReleaseObject with invalid params.');
InspectorTest.logMessage(releaseObjectResult);
},
async function testObjectGroups() {
await Protocol.Runtime.evaluate({ expression: 'var a = {x:3};', callFrameId });
await Protocol.Runtime.evaluate({ expression: 'var b = {x:4};', callFrameId });
const ids = [];
let result = await Protocol.Runtime.evaluate({ expression: 'a', objectGroup: 'a', callFrameId });
const id1 = result.result.result.objectId;
ids.push(id1);
result = await Protocol.Runtime.evaluate({ expression: 'b', objectGroup: 'b', callFrameId });
const id2 = result.result.result.objectId;
ids.push(id2);
// Call Function on both objects and log:
await objectGroupHelper(ids);
Protocol.Runtime.releaseObjectGroup({ objectGroup: 'a' });
await objectGroupHelper(ids);
Protocol.Runtime.releaseObjectGroup({ objectGroup: 'b' });
await objectGroupHelper(ids);
},
async function testReleaseObjectGroupInvalid() {
const releaseObjectGroupResult = await Protocol.Runtime.releaseObjectGroup({});
InspectorTest.log('ReleaseObjectGroup with invalid params');
InspectorTest.logMessage(releaseObjectGroupResult);
},
async function testEvaluateSyntaxError() {
const result = await Protocol.Debugger.evaluateOnCallFrame({ expression: `[]]`, callFrameId });
InspectorTest.logMessage(result.result.exceptionDetails.exception);
},
async function testEvaluateReferenceError() {
const result = await Protocol.Debugger.evaluateOnCallFrame({ expression: `totalRandomNotRealVariable789`, callFrameId });
InspectorTest.logMessage(result.result.exceptionDetails.exception);
},
async function testCallFrameIdTypeError() {
const result = await Protocol.Debugger.evaluateOnCallFrame({ expression: `console.log(42)`, callFrameId: {} });
InspectorTest.logMessage(result);
},
async function testCallFrameIdInvalidInput() {
InspectorTest.log('Testing evaluateOnCallFrame with non-existent callFrameId');
const result = await Protocol.Debugger.evaluateOnCallFrame({ expression: `console.log(42)`, callFrameId: '1234' });
InspectorTest.logMessage(result);
},
async function testNullExpression() {
await evalAndLog(null, callFrameId, /*returnByValue*/ true);
}
]);
async function evalAndLog(expression, callFrameId, returnByValue) {
const result = await Protocol.Debugger.evaluateOnCallFrame({ expression, callFrameId, returnByValue });
InspectorTest.logMessage(result);
}
// Helper function that calls a function on all objects with ids in objectIds, then returns
async function objectGroupHelper(objectIds) {
return new Promise(async resolve => {
for (let objectId of objectIds) {
const result = await Protocol.Runtime.callFunctionOn({ objectId, functionDeclaration: 'function(){ return this;}' });
InspectorTest.logMessage(result);
}
resolve();
});
}
})();
Checks that we report not more then maxDepth call chains.
Running test: testPaused
Actual call chain length: 8
setAsyncCallStackDepth(maxDepth): 16
reported: 1
Actual call chain length: 8
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 8
reported: 1
reported: 4
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 4
reported: 4
Actual call chain length: 8
setAsyncCallStackDepth(maxDepth): 7
reported: 1
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 3
reported: 3
Actual call chain length: 8
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 0
reported: 0
Running test: testConsoleTrace
Actual call chain length: 8
setAsyncCallStackDepth(maxDepth): 16
reported: 1
Actual call chain length: 8
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 8
reported: 1
reported: 4
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 4
reported: 4
Actual call chain length: 8
setAsyncCallStackDepth(maxDepth): 7
reported: 1
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 3
reported: 3
Actual call chain length: 8
Actual call chain length: 4
setAsyncCallStackDepth(maxDepth): 0
reported: 0
......@@ -2,57 +2,70 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(kozyatinskiy): fix or remove it later with new stack traces it's almost
// imposible to hit limit.
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we report not more then maxDepth call chains.');
contextGroup.addScript(`
function promisesChain(num) {
var p = Promise.resolve();
for (var i = 0; i < num - 1; ++i) {
p = p.then(() => 42);
function asyncChain(breakAtEnd) {
function asyncOpNested() {
setTimeout(asyncOpNested1, 0);
}
return p;
function asyncOpNested1() {
setTimeout(asyncOpNested2, 0);
}
function asyncOpNested2() {
setTimeout(asyncOpNested3, 0);
}
function asyncOpNested3() {
setTimeout(asyncOpNested4, 0);
}
function asyncOpNested4() {
if (breakAtEnd) {
debugger;
} else {
console.trace(42);
}
}
asyncOpNested();
}
`);
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testPaused() {
let callback = '() => { debugger; }';
startTest({ generated: 8, limit: 16, callback});
const breakAtEnd = true;
startTest({ limit: 8, breakAtEnd });
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 8, callback});
startTest({ limit: 4, breakAtEnd });
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 7, callback});
startTest({ limit: 3, breakAtEnd });
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 0, callback});
startTest({ limit: 0, breakAtEnd });
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
},
async function testConsoleTrace() {
await Protocol.Runtime.enable();
let callback = '() => { console.trace(42); }';
startTest({ generated: 8, limit: 16, callback});
const breakAtEnd = false;
startTest({ limit: 8, breakAtEnd});
let msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 8, callback});
startTest({ limit: 4, breakAtEnd});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 7, callback});
startTest({ limit: 3, breakAtEnd});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 0, callback});
startTest({ limit: 0, breakAtEnd});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
......@@ -61,12 +74,12 @@ InspectorTest.runAsyncTestSuite([
]);
function startTest(params) {
InspectorTest.log('Actual call chain length: ' + params.generated);
InspectorTest.log('setAsyncCallStackDepth(maxDepth): ' + params.limit);
InspectorTest.log('Actual call chain length: 4');
InspectorTest.log(`setAsyncCallStackDepth(maxDepth): ${params.limit}`);
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: params.limit});
Protocol.Runtime.evaluate({expression:
`promisesChain(${params.generated}).then(${params.callback})`});
`asyncChain(${params.breakAtEnd})`});
}
function dumpCaptured(stack) {
......
Tests for calling setBreakpoint with urlRegex
Running test: testSetBreakpointByUrlRegex
[
[0] : {
columnNumber : 2
lineNumber : 2
scriptId : <scriptId>
}
]
Successfully paused during eval of: 'test()'
Successfully completed eval of: 'test()'
Running test: testSetBreakpointByUrlWithConditions
[
[0] : {
columnNumber : 2
lineNumber : 2
scriptId : <scriptId>
}
]
Successfully completed eval of: 'test()'
[
[0] : {
columnNumber : 2
lineNumber : 2
scriptId : <scriptId>
}
]
Successfully paused during eval of: 'test()'
\ No newline at end of file
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const { contextGroup, Protocol } = InspectorTest.start(
`Tests for calling setBreakpoint with urlRegex`);
(async function test(){
await Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: `
function test() {
return 42;
}
//# sourceURL=some-kind-of-test.js`});
await Protocol.Debugger.onceScriptParsed();
InspectorTest.runAsyncTestSuite([
async function testSetBreakpointByUrlRegex() {
const result = await Protocol.Debugger.setBreakpointByUrl({ lineNumber: 2, urlRegex: '.*of-test.js' });
InspectorTest.logMessage(result.result.locations);
await expectBreakInEval('test()');
await Protocol.Debugger.removeBreakpoint({ breakpointId: result.result.breakpointId });
await expectNoBreakInEval('test()');
},
async function testSetBreakpointByUrlWithConditions() {
// Test Condition false
let result = await Protocol.Debugger.setBreakpointByUrl({ lineNumber: 2, urlRegex: '.*of-test.js', condition: 'false' });
InspectorTest.logMessage(result.result.locations);
await expectNoBreakInEval('test()');
await Protocol.Debugger.removeBreakpoint({ breakpointId: result.result.breakpointId });
// Test condition true
result = await Protocol.Debugger.setBreakpointByUrl({ lineNumber: 2, urlRegex: '.*of-test.js', condition: 'true' });
InspectorTest.logMessage(result.result.locations);
await expectBreakInEval('test()');
await Protocol.Debugger.removeBreakpoint({ breakpointId: result.result.breakpointId });
},
]);
// Function that will evaluate an expression and return once completed.
// Used to validate that breakpoint is not hit within the evaluated expression.
async function expectNoBreakInEval(expression) {
await Protocol.Runtime.evaluate({expression});
InspectorTest.log(`Successfully completed eval of: '${expression}'`);
}
// Function that will evaluate an expression and return once a paused event is received
// and the debugger is resumed.
// Used to validate that breakpoint is hit within the evaluated expression.
async function expectBreakInEval(expression) {
Protocol.Runtime.evaluate({expression});
await Protocol.Debugger.oncePaused();
InspectorTest.log(`Successfully paused during eval of: '${expression}'`);
await Protocol.Debugger.resume();
}
})();
Tests that exercise Debugger.setVariableValue
Running test: testSetVariableValueMain
{
id : <messageId>
result : {
result : {
description : 5
type : number
value : 5
}
}
}
{
id : <messageId>
result : {
result : {
description : 10
type : number
value : 10
}
}
}
{
id : <messageId>
result : {
result : {
description : NaN
type : number
unserializableValue : NaN
}
}
}
{
id : <messageId>
result : {
result : {
type : boolean
value : true
}
}
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
id : <messageId>
result : {
result : [
[0] : {
configurable : true
enumerable : true
isOwn : true
name : a
value : {
description : 3
type : number
value : 3
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
{
id : <messageId>
result : {
result : {
className : Array
description : Array(3)
objectId : <objectId>
subtype : array
type : object
}
}
}
{
id : <messageId>
result : {
result : [
[0] : {
configurable : true
enumerable : true
isOwn : true
name : 0
value : {
type : string
value : 1
}
writable : true
}
[1] : {
configurable : true
enumerable : true
isOwn : true
name : 1
value : {
type : string
value : 2
}
writable : true
}
[2] : {
configurable : true
enumerable : true
isOwn : true
name : 2
value : {
type : string
value : 3
}
writable : true
}
[3] : {
configurable : false
enumerable : false
isOwn : true
name : length
value : {
description : 3
type : number
value : 3
}
writable : true
}
[4] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Array
description : Array(0)
objectId : <objectId>
subtype : array
type : object
}
writable : true
}
]
}
}
{
id : <messageId>
result : {
result : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
}
{
id : <messageId>
result : {
result : [
[0] : {
configurable : true
enumerable : true
isOwn : true
name : b
value : {
description : 4
type : number
value : 4
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
Running test: testInvalidFrame
setVariableValue with invalid callFrameId
{
error : {
code : -32000
message : Invalid call frame id
}
id : <messageId>
}
setVariableValue with invalid scopeNumber
{
error : {
code : -32602
data : scopeNumber: integer value expected
message : Invalid parameters
}
id : <messageId>
}
setVariableValue with invalid scopeNumber
{
error : {
code : -32000
message : Could not find scope with given number
}
id : <messageId>
}
setVariableValue with invalid variableName
{
error : {
code : -32603
message : Internal error
}
id : <messageId>
}
Running test: testNewValueErrors
setVariableValue with invalid unserializableValue
{
error : {
code : -32000
message : Couldn't parse value object in call argument
}
id : <messageId>
}
setVariableValue with invalid objectId
{
error : {
code : -32602
data : newValue.objectId: string value expected
message : Invalid parameters
}
id : <messageId>
}
\ No newline at end of file
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --no-always-opt
const { contextGroup, Protocol } = InspectorTest.start(
`Tests that exercise Debugger.setVariableValue`);
(async function test(){
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
contextGroup.addInlineScript(`
function test() {
let num = 5;
let obj = {b: 4};
let bool = true;
let set_breakpoint_here = true;
debugger;
}
`, 'test.js');
Protocol.Runtime.evaluate({expression: "test();"});
const {params:{callFrames:[{callFrameId}]}} = await Protocol.Debugger.oncePaused();
InspectorTest.runAsyncTestSuite([
async function testSetVariableValueMain() {
// Set value to a Number
let result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { value: 10 }, callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
// Set Value to NaN
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { unserializableValue: 'NaN' }, callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
// Set Value to boolean:true
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { value: true }, callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
// Set Value to a new object
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { value: { a: 3 } }, callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
let props = await Protocol.Runtime.getProperties({ objectId: result.result.result.objectId, ownProperties: true });
InspectorTest.logMessage(props);
// Set Value to new Array
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { value: ['1', '2', '3'] }, callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId });
InspectorTest.logMessage(result);
props = await Protocol.Runtime.getProperties({ objectId: result.result.result.objectId, ownProperties: true });
InspectorTest.logMessage(props);
// Set Value to existing object with objectId
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'obj', callFrameId: callFrameId });
let objectId = result.result.result.objectId;
await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { objectId: objectId }, callFrameId: callFrameId });
result = await Protocol.Debugger.evaluateOnCallFrame({ expression: 'num', callFrameId: callFrameId });
InspectorTest.logMessage(result);
props = await Protocol.Runtime.getProperties({ objectId: result.result.result.objectId, ownProperties: true });
InspectorTest.logMessage(props);
},
async function testInvalidFrame() {
let result = await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { unserializableValue: 'NaN' }, callFrameId: 'fakeCallFrame' });
InspectorTest.log('setVariableValue with invalid callFrameId');
InspectorTest.logMessage(result);
result = await Protocol.Debugger.setVariableValue({ scopeNumber: 'invalidScopeType', variableName: 'num', newValue: { unserializableValue: 'NaN' }, callFrameId });
InspectorTest.log('setVariableValue with invalid scopeNumber')
InspectorTest.logMessage(result);
result = await Protocol.Debugger.setVariableValue({ scopeNumber: 1000, variableName: 'num', newValue: { unserializableValue: 'NaN' }, callFrameId });
InspectorTest.log('setVariableValue with invalid scopeNumber');
InspectorTest.logMessage(result);
result = await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'FakeObjectName', newValue: { unserializableValue: 'NaN' }, callFrameId });
InspectorTest.log('setVariableValue with invalid variableName');
InspectorTest.logMessage(result);
},
async function testNewValueErrors() {
let result = await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { unserializableValue: 'not unserializable value' }, callFrameId });
InspectorTest.log('setVariableValue with invalid unserializableValue');
InspectorTest.logMessage(result);
result = await Protocol.Debugger.setVariableValue({ scopeNumber: 0, variableName: 'num', newValue: { objectId: 2000 }, callFrameId });
InspectorTest.log('setVariableValue with invalid objectId');
InspectorTest.logMessage(result);
}
]);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment