Bug 1529680 - [release 127] Ensure consistent filenames throughout tabs, tree, and search (#7957). r=dwalsh
authorDavid Walsh <davidwalsh83@gmail.com>
Mon, 25 Feb 2019 10:01:17 -0500
changeset 461085 6b5b546aac14484f94eecb8a776460357f5a9cea
parent 461084 183f1a860db46789f2bda30951c61e49c01cb9f6
child 461086 065b2e8fef2bd8d77a18e41ddc6ca02402278f7a
push id35618
push usershindli@mozilla.com
push dateTue, 26 Feb 2019 16:54:44 +0000
treeherdermozilla-central@d326a9d5f77b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwalsh
bugs1529680
milestone67.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 1529680 - [release 127] Ensure consistent filenames throughout tabs, tree, and search (#7957). r=dwalsh
devtools/client/debugger/new/src/components/PrimaryPanes/SourcesTreeItem.js
devtools/client/debugger/new/src/components/PrimaryPanes/tests/SourcesTreeItem.spec.js
devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTreeItem.spec.js.snap
devtools/client/debugger/new/src/utils/sources-tree/getURL.js
devtools/client/debugger/new/src/utils/sources-tree/tests/getUrl.spec.js
--- a/devtools/client/debugger/new/src/components/PrimaryPanes/SourcesTreeItem.js
+++ b/devtools/client/debugger/new/src/components/PrimaryPanes/SourcesTreeItem.js
@@ -210,17 +210,17 @@ class SourceTreeItem extends Component<P
     const { item } = this.props;
 
     switch (item.name) {
       case "ng://":
         return "Angular";
       case "webpack://":
         return "Webpack";
       default:
-        return `${item.name}`;
+        return `${unescape(item.name)}`;
     }
   }
 
   render() {
     const {
       item,
       depth,
       source,
--- a/devtools/client/debugger/new/src/components/PrimaryPanes/tests/SourcesTreeItem.spec.js
+++ b/devtools/client/debugger/new/src/components/PrimaryPanes/tests/SourcesTreeItem.spec.js
@@ -332,16 +332,27 @@ describe("SourceTreeItem", () => {
         focused: true,
         expanded: false,
         selectItem
       });
 
       component.simulate("click", { event: "click" });
       expect(props.selectItem).not.toHaveBeenCalled();
     });
+
+    it("should unescape escaped source URLs", async () => {
+      const item = createMockItem({
+        path: "mdn.com/external%20file",
+        name: "external%20file"
+      });
+
+      const node = render({ item });
+
+      expect(node).toMatchSnapshot();
+    });
   });
 });
 
 function generateDefaults(overrides) {
   const source = makeMockSource(
     "http://mdn.com/one.js",
     "server1.conn13.child1/39"
   );
--- a/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTreeItem.spec.js.snap
+++ b/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTreeItem.spec.js.snap
@@ -2319,8 +2319,230 @@ Object {
       "relativeUrl": "http://mdn.com/one.js",
       "text": "",
       "url": "http://mdn.com/one.js",
     },
     "toggleBlackBox": [MockFunction],
   },
 }
 `;
+
+exports[`SourceTreeItem renderItem should unescape escaped source URLs 1`] = `
+Object {
+  "component": <div
+    className="node"
+    key="mdn.com/external%20file"
+    onClick={[Function]}
+    onContextMenu={[Function]}
+  >
+    <span
+      className="img no-arrow"
+    />
+    <Connect(SourceIcon)
+      source={
+        Object {
+          "contentType": "",
+          "error": undefined,
+          "id": "server1.conn13.child1/39",
+          "isBlackBoxed": false,
+          "isExtension": false,
+          "isPrettyPrinted": false,
+          "isWasm": false,
+          "loadedState": "unloaded",
+          "sourceMapURL": undefined,
+          "text": undefined,
+          "url": "http://mdn.com/one.js",
+        }
+      }
+    />
+    <span
+      className="label"
+    >
+       
+      external file
+       
+    </span>
+  </div>,
+  "defaultState": null,
+  "instance": SourceTreeItem {
+    "addCollapseExpandAllOptions": [Function],
+    "context": Object {},
+    "onClick": [Function],
+    "onContextMenu": [Function],
+    "props": Object {
+      "clearProjectDirectoryRoot": [MockFunction],
+      "debuggeeUrl": "http://mdn.com",
+      "expanded": false,
+      "focusItem": [MockFunction],
+      "item": Object {
+        "contents": Object {
+          "contentType": "",
+          "error": undefined,
+          "id": "server1.conn13.child1/39",
+          "isBlackBoxed": false,
+          "isExtension": false,
+          "isPrettyPrinted": false,
+          "isWasm": false,
+          "loadedState": "unloaded",
+          "sourceMapURL": undefined,
+          "text": undefined,
+          "url": undefined,
+        },
+        "name": "external%20file",
+        "path": "mdn.com/external%20file",
+        "type": "source",
+      },
+      "projectRoot": "",
+      "selectItem": [MockFunction],
+      "setExpanded": [MockFunction],
+      "setProjectDirectoryRoot": [MockFunction],
+      "source": Object {
+        "contentType": "",
+        "error": undefined,
+        "id": "server1.conn13.child1/39",
+        "isBlackBoxed": false,
+        "isExtension": false,
+        "isPrettyPrinted": false,
+        "isWasm": false,
+        "loadedState": "unloaded",
+        "sourceMapURL": undefined,
+        "text": undefined,
+        "url": "http://mdn.com/one.js",
+      },
+      "toggleBlackBox": [MockFunction],
+    },
+    "refs": Object {},
+    "state": null,
+    "updater": Updater {
+      "_callbacks": Array [],
+      "_renderer": ReactShallowRenderer {
+        "_context": Object {},
+        "_element": <SourceTreeItem
+          clearProjectDirectoryRoot={[MockFunction]}
+          debuggeeUrl="http://mdn.com"
+          expanded={false}
+          focusItem={[MockFunction]}
+          item={
+            Object {
+              "contents": Object {
+                "contentType": "",
+                "error": undefined,
+                "id": "server1.conn13.child1/39",
+                "isBlackBoxed": false,
+                "isExtension": false,
+                "isPrettyPrinted": false,
+                "isWasm": false,
+                "loadedState": "unloaded",
+                "sourceMapURL": undefined,
+                "text": undefined,
+                "url": undefined,
+              },
+              "name": "external%20file",
+              "path": "mdn.com/external%20file",
+              "type": "source",
+            }
+          }
+          projectRoot=""
+          selectItem={[MockFunction]}
+          setExpanded={[MockFunction]}
+          setProjectDirectoryRoot={[MockFunction]}
+          source={
+            Object {
+              "contentType": "",
+              "error": undefined,
+              "id": "server1.conn13.child1/39",
+              "isBlackBoxed": false,
+              "isExtension": false,
+              "isPrettyPrinted": false,
+              "isWasm": false,
+              "loadedState": "unloaded",
+              "sourceMapURL": undefined,
+              "text": undefined,
+              "url": "http://mdn.com/one.js",
+            }
+          }
+          toggleBlackBox={[MockFunction]}
+        />,
+        "_forcedUpdate": false,
+        "_instance": [Circular],
+        "_newState": null,
+        "_rendered": <div
+          className="node"
+          onClick={[Function]}
+          onContextMenu={[Function]}
+        >
+          <span
+            className="img no-arrow"
+          />
+          <Connect(SourceIcon)
+            source={
+              Object {
+                "contentType": "",
+                "error": undefined,
+                "id": "server1.conn13.child1/39",
+                "isBlackBoxed": false,
+                "isExtension": false,
+                "isPrettyPrinted": false,
+                "isWasm": false,
+                "loadedState": "unloaded",
+                "sourceMapURL": undefined,
+                "text": undefined,
+                "url": "http://mdn.com/one.js",
+              }
+            }
+          />
+          <span
+            className="label"
+          >
+             
+            external file
+             
+          </span>
+        </div>,
+        "_rendering": false,
+        "_updater": [Circular],
+      },
+    },
+  },
+  "props": Object {
+    "clearProjectDirectoryRoot": [MockFunction],
+    "debuggeeUrl": "http://mdn.com",
+    "expanded": false,
+    "focusItem": [MockFunction],
+    "item": Object {
+      "contents": Object {
+        "contentType": "",
+        "error": undefined,
+        "id": "server1.conn13.child1/39",
+        "isBlackBoxed": false,
+        "isExtension": false,
+        "isPrettyPrinted": false,
+        "isWasm": false,
+        "loadedState": "unloaded",
+        "sourceMapURL": undefined,
+        "text": undefined,
+        "url": undefined,
+      },
+      "name": "external%20file",
+      "path": "mdn.com/external%20file",
+      "type": "source",
+    },
+    "projectRoot": "",
+    "selectItem": [MockFunction],
+    "setExpanded": [MockFunction],
+    "setProjectDirectoryRoot": [MockFunction],
+    "source": Object {
+      "contentType": "",
+      "error": undefined,
+      "id": "server1.conn13.child1/39",
+      "isBlackBoxed": false,
+      "isExtension": false,
+      "isPrettyPrinted": false,
+      "isWasm": false,
+      "loadedState": "unloaded",
+      "sourceMapURL": undefined,
+      "text": undefined,
+      "url": "http://mdn.com/one.js",
+    },
+    "toggleBlackBox": [MockFunction],
+  },
+}
+`;
--- a/devtools/client/debugger/new/src/utils/sources-tree/getURL.js
+++ b/devtools/client/debugger/new/src/utils/sources-tree/getURL.js
@@ -14,17 +14,17 @@ export type ParsedURL = {
   filename: string
 };
 
 export function getFilenameFromPath(pathname?: string) {
   let filename = "";
   if (pathname) {
     filename = pathname.substring(pathname.lastIndexOf("/") + 1);
     // This file does not have a name. Default should be (index).
-    if (filename == "" || !filename.includes(".")) {
+    if (filename == "") {
       filename = "(index)";
     }
   }
   return filename;
 }
 
 const NoDomain = "(no domain)";
 const def = { path: "", group: "", filename: "" };
--- a/devtools/client/debugger/new/src/utils/sources-tree/tests/getUrl.spec.js
+++ b/devtools/client/debugger/new/src/utils/sources-tree/tests/getUrl.spec.js
@@ -54,23 +54,33 @@ describe("getUrl", () => {
     const urlObject = getURL(
       createMockSource({
         url: "https://a/b.js#specialSection"
       })
     );
     expect(urlObject.filename).toBe("b.js");
   });
 
-  it("handles url with no filename for filename", function() {
+  it("handles url with no file extension for filename", function() {
     const urlObject = getURL(
       createMockSource({
         url: "https://a/c",
         id: "c"
       })
     );
+    expect(urlObject.filename).toBe("c");
+  });
+
+  it("handles url with no name for filename", function() {
+    const urlObject = getURL(
+      createMockSource({
+        url: "https://a/",
+        id: "c"
+      })
+    );
     expect(urlObject.filename).toBe("(index)");
   });
 
   it("separates resources by protocol and host", () => {
     const urlObject = getURL(
       createMockSource({
         url: "moz-extension://xyz/123",
         id: "c2"