v8/test/inspector/regress/regress-crbug-1085693.js
Simon Zünd e24c3ac022 [inspector] Add regression test for leaking vars in debug-evaluate
This CL adds the regression test originally authored for
crbug.com/1085693. It no longer crashes or re-produces but we were
unable to bisect to the CL that fixed the problem since bisecting
seems to be broken.

R=bmeurer@chromium.org

Fixed: chromium:1085693
Change-Id: Iaaf2b557767a02829fc497591ed7f3623965a66c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4012718
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84108}
2022-11-08 08:08:37 +00:00

44 lines
1.2 KiB
JavaScript

// Copyright 2022 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 {session, contextGroup, Protocol} = InspectorTest.start(
'Test that var does not leak into object in parent scope. crbug.com/1085693');
const inputSnippet = `
function testFunction() {
const objectWeShouldNotLeakInto = {};
(() => {
debugger; // evaluate "var leakedProperty = 1" at this break
console.log(objectWeShouldNotLeakInto);
})();
}
testFunction();
`;
(async () => {
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
Protocol.Runtime.evaluate({
expression: inputSnippet,
replMode: true,
});
const pausedMessage = await Protocol.Debugger.oncePaused();
InspectorTest.log('Paused in arrow function');
const topFrame = pausedMessage.params.callFrames[0];
await Protocol.Debugger.evaluateOnCallFrame({
expression: 'var leakedProperty = 1;',
callFrameId: topFrame.callFrameId,
});
Protocol.Debugger.resume();
const { params } = await Protocol.Runtime.onceConsoleAPICalled();
InspectorTest.logMessage(params.args[0]);
InspectorTest.completeTest();
})();