1'use strict'; 2const common = require('../common'); 3 4common.skipIfInspectorDisabled(); 5 6(async function test() { 7 const { strictEqual } = require('assert'); 8 const { Session } = require('inspector'); 9 const { promisify } = require('util'); 10 const vm = require('vm'); 11 const session = new Session(); 12 session.connect(); 13 session.post = promisify(session.post); 14 await session.post('Debugger.enable'); 15 await check('http://example.com', 'http://example.com'); 16 await check(undefined, 'evalmachine.<anonymous>'); 17 await check('file:///foo.js', 'file:///foo.js'); 18 await check('file:///foo.js', 'file:///foo.js'); 19 await check('foo.js', 'foo.js'); 20 await check('[eval]', '[eval]'); 21 await check('%.js', '%.js'); 22 23 if (common.isWindows) { 24 await check('C:\\foo.js', 'file:///C:/foo.js'); 25 await check('C:\\a\\b\\c\\foo.js', 'file:///C:/a/b/c/foo.js'); 26 await check('a:\\%.js', 'file:///a:/%25.js'); 27 } else { 28 await check('/foo.js', 'file:///foo.js'); 29 await check('/a/b/c/d/foo.js', 'file:///a/b/c/d/foo.js'); 30 await check('/%%%.js', 'file:///%25%25%25.js'); 31 } 32 33 async function check(filename, expected) { 34 const promise = 35 new Promise((resolve) => session.once('inspectorNotification', resolve)); 36 new vm.Script('42', { filename }).runInThisContext(); 37 const { params: { url } } = await promise; 38 strictEqual(url, expected); 39 } 40})().then(common.mustCall()); 41