11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci(async function test() { 71cb0ef41Sopenharmony_ci const { strictEqual } = require('assert'); 81cb0ef41Sopenharmony_ci const { Session } = require('inspector'); 91cb0ef41Sopenharmony_ci const { promisify } = require('util'); 101cb0ef41Sopenharmony_ci const vm = require('vm'); 111cb0ef41Sopenharmony_ci const session = new Session(); 121cb0ef41Sopenharmony_ci session.connect(); 131cb0ef41Sopenharmony_ci session.post = promisify(session.post); 141cb0ef41Sopenharmony_ci await session.post('Debugger.enable'); 151cb0ef41Sopenharmony_ci await check('http://example.com', 'http://example.com'); 161cb0ef41Sopenharmony_ci await check(undefined, 'evalmachine.<anonymous>'); 171cb0ef41Sopenharmony_ci await check('file:///foo.js', 'file:///foo.js'); 181cb0ef41Sopenharmony_ci await check('file:///foo.js', 'file:///foo.js'); 191cb0ef41Sopenharmony_ci await check('foo.js', 'foo.js'); 201cb0ef41Sopenharmony_ci await check('[eval]', '[eval]'); 211cb0ef41Sopenharmony_ci await check('%.js', '%.js'); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci if (common.isWindows) { 241cb0ef41Sopenharmony_ci await check('C:\\foo.js', 'file:///C:/foo.js'); 251cb0ef41Sopenharmony_ci await check('C:\\a\\b\\c\\foo.js', 'file:///C:/a/b/c/foo.js'); 261cb0ef41Sopenharmony_ci await check('a:\\%.js', 'file:///a:/%25.js'); 271cb0ef41Sopenharmony_ci } else { 281cb0ef41Sopenharmony_ci await check('/foo.js', 'file:///foo.js'); 291cb0ef41Sopenharmony_ci await check('/a/b/c/d/foo.js', 'file:///a/b/c/d/foo.js'); 301cb0ef41Sopenharmony_ci await check('/%%%.js', 'file:///%25%25%25.js'); 311cb0ef41Sopenharmony_ci } 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci async function check(filename, expected) { 341cb0ef41Sopenharmony_ci const promise = 351cb0ef41Sopenharmony_ci new Promise((resolve) => session.once('inspectorNotification', resolve)); 361cb0ef41Sopenharmony_ci new vm.Script('42', { filename }).runInThisContext(); 371cb0ef41Sopenharmony_ci const { params: { url } } = await promise; 381cb0ef41Sopenharmony_ci strictEqual(url, expected); 391cb0ef41Sopenharmony_ci } 401cb0ef41Sopenharmony_ci})().then(common.mustCall()); 41