mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:23:43 +00:00

PR-URL: https://github.com/nodejs/node/pull/21983 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
// Copyright 2018 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('Check [[FunctionLocation]] internal property');
|
|
|
|
contextGroup.addScript(
|
|
`function a() { b(); };
|
|
function b() {
|
|
c(true);
|
|
};
|
|
function c(x) {
|
|
if (x) {
|
|
return 1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
};
|
|
function d(x) {
|
|
x = 1 ;
|
|
x = 2 ;
|
|
x = 3 ;
|
|
x = 4 ;
|
|
x = 5 ;
|
|
x = 6 ;
|
|
x = 7 ;
|
|
x = 8 ;
|
|
x = 9 ;
|
|
x = 10;
|
|
x = 11;
|
|
x = 12;
|
|
x = 13;
|
|
x = 14;
|
|
x = 15;
|
|
}`);
|
|
|
|
(async function test() {
|
|
session.setupScriptMap();
|
|
Protocol.Debugger.enable();
|
|
await session.logSourceLocation(await functionLocation('a'), true);
|
|
await session.logSourceLocation(await functionLocation('b'), true);
|
|
await session.logSourceLocation(await functionLocation('c'), true);
|
|
await session.logSourceLocation(await functionLocation('d'), true);
|
|
InspectorTest.completeTest();
|
|
})();
|
|
|
|
async function functionLocation(name) {
|
|
const {result:{result}} = await Protocol.Runtime.evaluate({expression: name});
|
|
const {result:{internalProperties}} = await Protocol.Runtime.getProperties({
|
|
objectId: result.objectId
|
|
});
|
|
const {value:{value}} = internalProperties.find(
|
|
prop => prop.name === '[[FunctionLocation]]');
|
|
return value;
|
|
}
|