Bug 1668117 - [devtools] do not load getUnicode helpers from devtools-modules in debugger r=nchevobbe
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 02 Oct 2020 15:38:44 +0000
changeset 551342 2f79e4c83bb65279220046978a24a01120049258
parent 551341 6f00b5773bb4c636f9bbbdc6e1186f636363ee61
child 551343 9ecab39fd6d4059072d3231df445d586ebb9772a
push id37830
push usernbeleuzu@mozilla.com
push dateSat, 03 Oct 2020 10:23:35 +0000
treeherdermozilla-central@7d7faf0b6d7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1668117
milestone83.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1668117 - [devtools] do not load getUnicode helpers from devtools-modules in debugger r=nchevobbe Depends on D91854 Differential Revision: https://phabricator.services.mozilla.com/D91855
devtools/client/debugger/jest-test.config.js
devtools/client/debugger/src/test/fixtures/unicode-url.js
devtools/client/debugger/src/utils/source.js
devtools/client/debugger/src/utils/sources-tree/getURL.js
devtools/client/debugger/src/utils/tests/source.spec.js
devtools/client/shared/unicode-url.js
--- a/devtools/client/debugger/jest-test.config.js
+++ b/devtools/client/debugger/jest-test.config.js
@@ -39,12 +39,13 @@ module.exports = {
   ],
   moduleNameMapper: {
     "\\.css$": "<rootDir>/src/test/__mocks__/styleMock.js",
     "\\.svg$": "<rootDir>/src/test/__mocks__/svgMock.js",
     "^Services": "<rootDir>/src/test/fixtures/Services",
     "^chrome": "<rootDir>/src/test/fixtures/Chrome",
     "^ChromeUtils": "<rootDir>/src/test/fixtures/ChromeUtils",
     "\\/plural-form$": "<rootDir>/src/test/fixtures/plural-form",
+    "\\/unicode-url$": "<rootDir>/src/test/fixtures/unicode-url",
     // Map all require("devtools/...") to the real devtools root.
     "^devtools\\/(.*)": "<rootDir>/../../$1",
   },
 };
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/src/test/fixtures/unicode-url.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/>. */
+
+"use strict";
+
+function getUnicodeHostname(hostname) {
+  return hostname;
+}
+
+function getUnicodeUrlPath(urlPath) {
+  return decodeURIComponent(urlPath);
+}
+
+function getUnicodeUrl(url) {
+  return decodeURIComponent(url);
+}
+
+module.exports = {
+  getUnicodeHostname,
+  getUnicodeUrlPath,
+  getUnicodeUrl,
+};
--- a/devtools/client/debugger/src/utils/source.js
+++ b/devtools/client/debugger/src/utils/source.js
@@ -4,17 +4,18 @@
 
 // @flow
 
 /**
  * Utils for working with Source URLs
  * @module utils/source
  */
 
-import { getUnicodeUrl } from "devtools-modules";
+// $FlowIgnore
+const { getUnicodeUrl } = require("devtools/client/shared/unicode-url");
 
 import { isOriginalSource } from "../utils/source-maps";
 import { endTruncateStr } from "./utils";
 import { truncateMiddleText } from "../utils/text";
 import { parse as parseURL } from "../utils/url";
 import { memoizeLast } from "../utils/memoizeLast";
 import { renderWasmText } from "./wasm";
 import { toEditorLine } from "./editor";
--- a/devtools/client/debugger/src/utils/sources-tree/getURL.js
+++ b/devtools/client/debugger/src/utils/sources-tree/getURL.js
@@ -1,16 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/>. */
 
 // @flow
 
 import { parse } from "../url";
-import { getUnicodeHostname, getUnicodeUrlPath } from "devtools-modules";
+
+const {
+  getUnicodeHostname,
+  getUnicodeUrlPath,
+  // $FlowIgnore
+} = require("devtools/client/shared/unicode-url");
 
 import type { DisplaySource, Source } from "../../types";
 export type ParsedURL = {
   path: string,
   search: string,
   group: string,
   filename: string,
 };
--- a/devtools/client/debugger/src/utils/tests/source.spec.js
+++ b/devtools/client/debugger/src/utils/tests/source.spec.js
@@ -45,17 +45,16 @@ const defaultSymbolDeclarations = {
   hasTypes: false,
   loading: false,
   framework: undefined,
 };
 
 describe("sources", () => {
   const unicode = "\u6e2c";
   const encodedUnicode = encodeURIComponent(unicode);
-  const punycode = "xn--g6w";
 
   describe("getFilename", () => {
     it("should give us a default of (index)", () => {
       expect(
         getFilename(makeMockSource("http://localhost.com:7999/increment/"))
       ).toBe("(index)");
     });
     it("should give us the filename", () => {
@@ -212,25 +211,16 @@ describe("sources", () => {
   describe("getFileURL", () => {
     it("should give us the file url", () => {
       expect(
         getFileURL(
           makeMockSource("http://localhost.com:7999/increment/hello.html")
         )
       ).toBe("http://localhost.com:7999/increment/hello.html");
     });
-    it("should give us the readable Unicode file URL if encoded", () => {
-      expect(
-        getFileURL(
-          makeMockSource(
-            `http://${punycode}.${punycode}:7999/increment/${encodedUnicode}.html`
-          )
-        )
-      ).toBe(`http://${unicode}.${unicode}:7999/increment/${unicode}.html`);
-    });
     it("should truncate the file url when it is more than 50 chars", () => {
       expect(
         getFileURL(
           makeMockSource("http://localhost-long.com:7999/increment/hello.html")
         )
       ).toBe("…ttp://localhost-long.com:7999/increment/hello.html");
     });
     it("should first decode the file URL and then truncate it", () => {
--- a/devtools/client/shared/unicode-url.js
+++ b/devtools/client/shared/unicode-url.js
@@ -1,25 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 "use strict";
 
-// This file is a chrome-API-dependent version of the file
-// packages/devtools-modules/src/unicode-url.js at
-// https://github.com/firefox-devtools/devtools-core, so that this
-// chrome-API-dependent version can take advantage of utilizing chrome APIs. But
-// because of this, it isn't intended to be used in Chrome-API-free
-// applications, such as the Launchpad.
-//
-// Please keep in mind that if the feature in this file has changed, don't
-// forget to also change that accordingly in the file
-// packages/devtools-modules/src/unicode-url.js at
-// https://github.com/firefox-devtools/devtools-core
-
 const { Cc, Ci } = require("chrome");
 const idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
   Ci.nsIIDNService
 );
 
 /**
  * Gets a readble Unicode hostname from a hostname.
  *