v8/test/inspector/runtime/function-scopes.js
Simon Zünd 735401e1fb [inspector] Disable [[Scopes]] internal property
We don't remove the code just yet in case we need to re-enable the
feature. This could be in case we discover workflows not covered by
the "Scope View" and the scopes we report on "Debugger.paused".

R=kimanh@chromium.org

Bug: chromium:1365858
Change-Id: I636cc861af932156944a3f6e0a149cce0f939329
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905185
Reviewed-by: Kim-Anh Tran <kimanh@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83379}
2022-09-22 07:12:24 +00:00

59 lines
2.0 KiB
JavaScript

// 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.
// Flags: --no-experimental-remove-internal-scopes-property
let {session, contextGroup, Protocol} = InspectorTest.start('Checks [[Scopes]] for functions');
contextGroup.addScript(`
var f;
try {
throw 1;
} catch (a) {
with({b:2}) {
function closure() {
var c = 3;
function foo() {
var d = 4;
return a + b + c + d;
}
return foo;
}
f = closure;
}
}
var e = 5;
//# sourceURL=test.js`);
(async function test() {
let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({
expression: 'f()'
});
let {result:{internalProperties}} = await Protocol.Runtime.getProperties({
objectId
});
let scopes = internalProperties.find(prop => prop.name === '[[Scopes]]');
let {result:{result}} = await Protocol.Runtime.getProperties({
objectId: scopes.value.objectId
});
await Promise.all(result.map(async scope => {
scope.variables = (await Protocol.Runtime.getProperties({
objectId: scope.value.objectId
})).result.result;
}));
let catchScope = result.find(scope => scope.value.description === 'Catch');
InspectorTest.log('Catch:');
InspectorTest.logMessage(catchScope.variables.find(variable => variable.name === 'a'));
InspectorTest.log('With block:');
let withScope = result.find(scope => scope.value.description === 'With Block');
InspectorTest.logMessage(withScope.variables.find(variable => variable.name === 'b'));
InspectorTest.log('Closure (closure):');
let closureScope = result.find(scope => scope.value.description === 'Closure (closure)');
InspectorTest.logMessage(closureScope.variables.find(variable => variable.name === 'c'));
InspectorTest.log('Global:');
let globalScope = result.find(scope => scope.value.description === 'Global');
InspectorTest.logMessage(globalScope.variables.find(variable => variable.name === 'e'));
InspectorTest.completeTest();
})();