MCPcopy Create free account
hub / github.com/nodejs/node / test

Function test

deps/v8/test/inspector/debugger/restore-breakpoint.js:84–110  ·  view source on GitHub ↗
(source, newSource, location, next)

Source from the content-addressed store, hash-verified

82]);
83
84async function test(source, newSource, location, next) {
85 function dumpSourceWithBreakpoint(source, location) {
86 var lineNumber = location.lineNumber;
87 var columnNumber = location.columnNumber;
88 var lines = source.split('\n');
89 lines = lines.map(line => line.length > 80 ? line.substring(0, 77) + '...' : line);
90 lines[lineNumber] = lines[lineNumber].slice(0, columnNumber) + '#' + lines[lineNumber].slice(columnNumber);
91 InspectorTest.log(lines.join('\n'));
92 }
93
94 Protocol.Debugger.onScriptParsed(({ params: { resolvedBreakpoints } }) => {
95 for (const {location} of resolvedBreakpoints ?? []) {
96 dumpSourceWithBreakpoint(newSource, location);
97 }
98 })
99
100 var sourceURL = `test${++finishedTests}.js`;
101 await Protocol.Runtime.evaluate({ expression: `${source}\n//# sourceURL=${sourceURL}` });
102 let {result:{locations}} = await Protocol.Debugger.setBreakpointByUrl({
103 url: sourceURL,
104 lineNumber: location.lineNumber,
105 columnNumber: location.columnNumber
106 });
107 dumpSourceWithBreakpoint(source, locations[0]);
108 await Protocol.Runtime.evaluate({ expression: `${newSource}\n//# sourceURL=${sourceURL}` });
109 next();
110}

Callers 1

Calls 4

dumpSourceWithBreakpointFunction · 0.85
onScriptParsedMethod · 0.80
nextFunction · 0.50
evaluateMethod · 0.45

Tested by

no test coverage detected