inspector: implemented V8InspectorClient::resourceNameToUrl

This method is required by inspector to report normalized urls over
the protocol.

Fixes https://github.com/nodejs/node/issues/22223
PR-URL: https://github.com/nodejs/node/pull/22251
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit is contained in:
Alexey Kozyatinskiy committed 2018-09-14 08:32:08 -07:00
1 parent cf340fe0f5
commit 0827c80920
10 files changed
+90 -16

No files matched your search

+4 -2
View File
@@ -1,9 +1,11 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const inspector = require('inspector');
const path = require('path');
const { pathToFileURL } = require('url');
// This test case will set a breakpoint 4 lines below
function debuggedFunction() {
@@ -84,8 +86,8 @@ function testSampleDebugSession() {
}, TypeError);
session.post('Debugger.enable', () => cbAsSecondArgCalled = true);
session.post('Debugger.setBreakpointByUrl', {
'lineNumber': 12,
'url': path.resolve(__dirname, __filename),
'lineNumber': 14,
'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(),
'columnNumber': 0,
'condition': ''
});
@@ -5,6 +5,7 @@ common.skipIfInspectorDisabled();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
const fixtures = require('../common/fixtures');
const { pathToFileURL } = require('url');
const script = fixtures.path('inspector-global-function.js');
@@ -26,7 +27,7 @@ async function breakOnLine(session) {
const commands = [
{ 'method': 'Debugger.setBreakpointByUrl',
'params': { 'lineNumber': 9,
'url': script,
'url': pathToFileURL(script).toString(),
'columnNumber': 0,
'condition': ''
}
@@ -45,7 +46,7 @@ async function breakOnLine(session) {
}
];
session.send(commands);
await session.waitForBreakOnLine(9, script);
await session.waitForBreakOnLine(9, pathToFileURL(script).toString());
}
async function stepOverConsoleStatement(session) {
@@ -24,7 +24,7 @@ async function testBreakpointOnStart(session) {
];
session.send(commands);
await session.waitForBreakOnLine(0, session.scriptPath());
await session.waitForBreakOnLine(0, session.scriptURL());
}
async function runTests() {
+2 -1
View File
@@ -7,6 +7,7 @@ common.skipIfInspectorDisabled();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
const { pathToFileURL } = require('url');
const script = fixtures.path('throws_error.js');
@@ -29,7 +30,7 @@ async function testBreakpointOnStart(session) {
];
await session.send(commands);
await session.waitForBreakOnLine(21, script);
await session.waitForBreakOnLine(21, pathToFileURL(script).toString());
}
@@ -0,0 +1,40 @@
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
(async function test() {
const { strictEqual } = require('assert');
const { Session } = require('inspector');
const { promisify } = require('util');
const vm = require('vm');
const session = new Session();
session.connect();
session.post = promisify(session.post);
await session.post('Debugger.enable');
await check('http://example.com', 'http://example.com');
await check(undefined, 'evalmachine.<anonymous>');
await check('file:///foo.js', 'file:///foo.js');
await check('file:///foo.js', 'file:///foo.js');
await check('foo.js', 'foo.js');
await check('[eval]', '[eval]');
await check('%.js', '%.js');
if (common.isWindows) {
await check('C:\\foo.js', 'file:///C:/foo.js');
await check('C:\\a\\b\\c\\foo.js', 'file:///C:/a/b/c/foo.js');
await check('a:\\%.js', 'file:///a:/%25.js');
} else {
await check('/foo.js', 'file:///foo.js');
await check('/a/b/c/d/foo.js', 'file:///a/b/c/d/foo.js');
await check('/%%%.js', 'file:///%25%25%25.js');
}
async function check(filename, expected) {
const promise =
new Promise((resolve) => session.once('inspectorNotification', resolve));
new vm.Script('42', { filename }).runInThisContext();
const { params: { url } } = await promise;
strictEqual(url, expected);
}
})();
+3 -3
View File
@@ -69,7 +69,7 @@ async function testBreakpointOnStart(session) {
];
await session.send(commands);
await session.waitForBreakOnLine(0, session.scriptPath());
await session.waitForBreakOnLine(0, session.scriptURL());
}
async function testBreakpoint(session) {
@@ -77,7 +77,7 @@ async function testBreakpoint(session) {
const commands = [
{ 'method': 'Debugger.setBreakpointByUrl',
'params': { 'lineNumber': 5,
'url': session.scriptPath(),
'url': session.scriptURL(),
'columnNumber': 0,
'condition': ''
}
@@ -92,7 +92,7 @@ async function testBreakpoint(session) {
`Script source is wrong: ${scriptSource}`);
await session.waitForConsoleOutput('log', ['A message', 5]);
const paused = await session.waitForBreakOnLine(5, session.scriptPath());
const paused = await session.waitForBreakOnLine(5, session.scriptURL());
const scopeId = paused.params.callFrames[0].scopeChain[0].object.objectId;
console.log('[test]', 'Verify we can read current application state');