v8/test/inspector/debugger/evaluate-on-call-frame-in-module.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

175 lines
4.8 KiB
JavaScript
Raw Normal View History

// Copyright 2017 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests evaluateOnCallFrame in module.');
var module1 = `
let a1 = 10;
let g1 = 1;
export let b1 = 11;
export function foo1() {
let c1 = 12;
let g1 = 2;
debugger;
return a1 + b1 + c1 + g1;
};
export default 42;
`;
var module2 = `
import { foo1 } from 'module1';
let a2 = 20;
export * as mod1 from 'module1';
export let b2 = 21;
export function foo2() {
let c2 = 22;
return foo1() + a2 + b2 + c2;
}`;
var module3 = `
import { foo2 } from 'module2';
let a3 = 30;
export let b3 = 31;
foo2();
`;
var module4 = `
let a = 1;
let b = 2;
function bar() {
let a = 0;
(() => {a; debugger;})();
};
bar();`;
var module5 = `
import { b2 } from 'module2';
export const a = 0;
export let b = 0;
export var c = 0;
debugger;
`;
var module6 = `
let x = 5;
(function() { let y = x; debugger; })()
`;
var module7 = `
let x = 5;
debugger;
`;
InspectorTest.runAsyncTestSuite([
async function testTotal() {
session.setupScriptMap();
Protocol.Debugger.enable();
contextGroup.addModule(module1, 'module1');
contextGroup.addModule(module2, 'module2');
contextGroup.addModule(module3, 'module3');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testAnother() {
contextGroup.addModule(module4, 'module4');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testDifferentModuleVariables() {
contextGroup.addModule(module5, 'module5');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testCapturedLocalVariable() {
contextGroup.addModule(module6, 'module6');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
},
async function testLocalVariableToplevel() {
contextGroup.addModule(module7, 'module7');
let {params:{callFrames}} = (await Protocol.Debugger.oncePaused());
session.logCallFrames(callFrames);
for (let i = 0; i < callFrames.length; ++i) {
await checkFrame(callFrames[i], i);
}
await Protocol.Debugger.resume();
}
]);
async function checkFrame(frame, i) {
let variables = new Set();
variables.add('Array');
for (let scopeChain of frame.scopeChain) {
if (scopeChain.name) {
InspectorTest.log(scopeChain.type + ':' + scopeChain.name);
} else {
InspectorTest.log(scopeChain.type);
}
if (scopeChain.type === 'global') {
InspectorTest.log('[\n ...\n]');
continue;
}
let {result: {result}} = await Protocol.Runtime.getProperties({
objectId: scopeChain.object.objectId});
result.forEach(v => variables.add(v.name));
result = result.map(v => v.value ?
Revert "[inspector] RemoteObject.description should be empty for primitive type" This reverts commit 003159e777ea2af3a8a9653955897a44d8e34e72. Reason for revert: breaks roll into Chromium: https://ci.chromium.org/p/chromium/builders/luci.chromium.try/linux_chromium_headless_rel/3140 Original change's description: > [inspector] RemoteObject.description should be empty for primitive type > > We currently report description field for numbers. On client side user > can calculate description as remoteObject.unserializableValue || > (remoteObject.value + ''). Let's report description only for objects to > simplify value -> remoteObject logic a bit. > > R=​dgozman@chromium.org > TBR=jgruber@chromium.org > > Bug: chromium:595206 > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel > Change-Id: I91356a44aa3024e20c8f966869abf4a41b88e4bc > Reviewed-on: https://chromium-review.googlesource.com/737485 > Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> > Reviewed-by: Pavel Feldman <pfeldman@chromium.org> > Cr-Commit-Position: refs/heads/master@{#53453} TBR=dgozman@chromium.org,pfeldman@chromium.org,kozyatinskiy@chromium.org Change-Id: Ifc184e1ac158d9ea7034922a7250444448fac49f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:595206 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel Reviewed-on: https://chromium-review.googlesource.com/1081207 Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org> Commit-Queue: Sergiy Byelozyorov <sergiyb@chromium.org> Cr-Commit-Position: refs/heads/master@{#53461}
2018-05-31 18:51:49 +00:00
(v.name + ' = ' + v.value.description) : (v.name));
InspectorTest.logMessage(result);
}
InspectorTest.log(`Check variables in frame#${i}`);
await session.logSourceLocation(frame.location);
await checkVariables(frame.callFrameId, variables);
}
async function checkVariables(callFrameId, names) {
for (let name of names) {
var {result:{result}} = await Protocol.Debugger.evaluateOnCallFrame({
callFrameId, expression: name});
if (result.type === 'object' && result.subtype && result.subtype === 'error') {
continue;
}
InspectorTest.log(name + ' = ');
InspectorTest.logMessage(result);
if (result.type === "number") {
let updateExpression = '++' + name;
InspectorTest.log('Evaluating: ' + updateExpression);
await Protocol.Debugger.evaluateOnCallFrame({
callFrameId, expression: updateExpression});
var {result:{result}} = await Protocol.Debugger.evaluateOnCallFrame({
callFrameId, expression: name});
InspectorTest.log('updated ' + name + ' = ');
InspectorTest.logMessage(result);
updateExpression = '--' + name;
InspectorTest.log('Evaluating: ' + updateExpression);
await Protocol.Debugger.evaluateOnCallFrame({
callFrameId, expression: updateExpression});
}
}
}