Bug 1770959 - [devtools] Use standard URL constructor instead of whatwg-url module. r=nchevobbe

And remove this module which is no longer used.

Differential Revision: https://phabricator.services.mozilla.com/D147194
This commit is contained in:
Alexandre Poirot 2022-05-25 16:56:44 +00:00
parent f475940c79
commit 215ceb2657
8 changed files with 8793 additions and 8947 deletions

View file

@ -1208,7 +1208,22 @@
"../node_modules/babel-loader/lib/index.js??ref--1!../packages/devtools-source-map/src/utils/network-request.js": 1056,
"../node_modules/babel-loader/lib/index.js??ref--1!../../shared/worker-dispatcher.js": 1057,
"../node_modules/babel-loader/lib/index.js??ref--1!../packages/devtools-source-map/src/utils/privileged-network-request.js": 1058,
"../node_modules/babel-loader/lib/index.js??ref--1!../../shared/worker-utils.js": 1059
"../node_modules/babel-loader/lib/index.js??ref--1!../../shared/worker-utils.js": 1059,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/url-state-machine.js": 1060,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/urlencoded.js": 1061,
"../packages/devtools-source-map/node_modules/webidl-conversions/lib/index.js": 1062,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/utils.js": 1063,
"../node_modules/node-libs-browser/node_modules/punycode/punycode.js": 1064,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/infra.js": 1065,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/URLSearchParams.js": 1066,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/public-api.js": 1067,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/URL.js": 1068,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/URL-impl.js": 1069,
"../packages/devtools-source-map/node_modules/tr46/index.js": 1070,
"../packages/devtools-source-map/node_modules/tr46/lib/regexes.js": 1071,
"../node_modules/json-loader/index.js!../packages/devtools-source-map/node_modules/tr46/lib/mappingTable.json": 1072,
"../packages/devtools-source-map/node_modules/whatwg-url/lib/URLSearchParams-impl.js": 1073,
"../node_modules/lodash.sortby/index.js": 1074
},
"usedIds": {
"0": 0,
@ -2270,7 +2285,22 @@
"1056": 1056,
"1057": 1057,
"1058": 1058,
"1059": 1059
"1059": 1059,
"1060": 1060,
"1061": 1061,
"1062": 1062,
"1063": 1063,
"1064": 1064,
"1065": 1065,
"1066": 1066,
"1067": 1067,
"1068": 1068,
"1069": 1069,
"1070": 1070,
"1071": 1071,
"1072": 1072,
"1073": 1073,
"1074": 1074
}
},
"chunks": {
@ -2415,7 +2445,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"0": 0
"1": 1
}
}
}
@ -2436,7 +2466,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"0": 0
"1": 1
}
}
}

View file

@ -2,49 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
const whatwgUrl = `
(() => {
let factory;
function define(...args) {
if (factory) {
throw new Error("expected a single define call");
}
if (
args.length !== 2 ||
!Array.isArray(args[0]) ||
args[0].length !== 0 ||
typeof args[1] !== "function"
) {
throw new Error("whatwg-url had unexpected factory arguments.");
}
factory = args[1];
}
define.amd = true;
const existingDefine = Object.getOwnPropertyDescriptor(globalThis, "define");
globalThis.define = define;
let err;
try {
importScripts("resource://devtools/client/shared/vendor/whatwg-url.js");
if (!factory) {
throw new Error("Failed to load whatwg-url factory");
}
} finally {
if (existingDefine) {
Object.defineProperty(globalThis, "define", existingDefine);
} else {
delete globalThis.define;
}
}
return factory();
})()
`;
module.exports = {
"./source-editor": "devtools/client/sourceeditor/editor",
"../editor/source-editor": "devtools/client/sourceeditor/editor",
@ -59,5 +16,4 @@ module.exports = {
"devtools-services": "Services",
"wasmparser/dist/cjs/WasmParser": "devtools/client/shared/vendor/WasmParser",
"wasmparser/dist/cjs/WasmDis": "devtools/client/shared/vendor/WasmDis",
"whatwg-url": `var ${whatwgUrl}`,
};

View file

@ -113,11 +113,7 @@ describe("sources-tree", () => {
expect(base.name).toBe("webpack://");
expect(base.contents).toHaveLength(1);
const emptyNode = base.contents[0];
expect(emptyNode.name).toBe("");
expect(emptyNode.contents).toHaveLength(1);
const userNode = emptyNode.contents[0];
const userNode = base.contents[0];
expect(userNode.name).toBe("Users");
expect(userNode.contents).toHaveLength(1);

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
import { URL as URLParser } from "whatwg-url";
const defaultUrl = {
hash: "",
host: "",
@ -57,7 +55,7 @@ export function parse(url) {
let urlObj;
try {
urlObj = new URLParser(url);
urlObj = new URL(url);
} catch (err) {
urlObj = { ...defaultUrl };
// If we're given simply a filename...
@ -89,6 +87,10 @@ export function parse(url) {
urlObj.pathname = url;
}
}
// When provided a special URL like "webpack:///webpack/foo",
// prevents passing the three slashes in the path, and pass only onea.
// This will prevent displaying modules in empty-name sub folders.
urlObj.pathname = urlObj.pathname.replace(/\/+/, "/");
urlObj.path = urlObj.pathname + urlObj.search;
// Cache the result

View file

@ -21,7 +21,6 @@ const mappings = {
"devtools-services": "Services",
"wasmparser/dist/cjs/WasmParser": "devtools/client/shared/vendor/WasmParser",
"wasmparser/dist/cjs/WasmDis": "devtools/client/shared/vendor/WasmDis",
"whatwg-url": "devtools/client/shared/vendor/whatwg-url",
"framework-actions": "devtools/client/framework/actions/index",
"inspector-shared-utils": "devtools/client/inspector/shared/utils",
};

File diff suppressed because one or more lines are too long

View file

@ -23,7 +23,6 @@ DevToolsModules(
'seamless-immutable.js',
'WasmDis.js',
'WasmParser.js',
'whatwg-url.js',
)
# react dev versions are used if enable-debug-js-modules is set in .mozconfig.

File diff suppressed because one or more lines are too long