Bug 1544474 - Remove unnecessary projectRoot field.
authorJason Laster <jlaster@mozilla.com>
Mon, 15 Apr 2019 18:37:50 +0000
changeset 469537 fbfe890035ac
parent 469536 93fd4cd59efb
child 469538 ddf29d68efb2
push id35874
push userccoroiu@mozilla.com
push dateTue, 16 Apr 2019 04:04:58 +0000
treeherdermozilla-central@be3f40425b52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1544474
milestone68.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 1544474 - Remove unnecessary projectRoot field. Differential Revision: https://phabricator.services.mozilla.com/D27548
devtools/client/debugger/src/components/PrimaryPanes/SourcesTree.js
devtools/client/debugger/src/utils/sources-tree/addToTree.js
devtools/client/debugger/src/utils/sources-tree/createTree.js
devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js
devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
devtools/client/debugger/src/utils/sources-tree/updateTree.js
--- a/devtools/client/debugger/src/components/PrimaryPanes/SourcesTree.js
+++ b/devtools/client/debugger/src/components/PrimaryPanes/SourcesTree.js
@@ -113,18 +113,17 @@ class SourcesTree extends Component<Prop
       debuggeeUrl != nextProps.debuggeeUrl ||
       nextProps.sourceCount === 0
     ) {
       // early recreate tree because of changes
       // to project root, debugee url or lack of sources
       return this.setState(
         createTree({
           sources: nextProps.sources,
-          debuggeeUrl: nextProps.debuggeeUrl,
-          projectRoot: nextProps.projectRoot
+          debuggeeUrl: nextProps.debuggeeUrl
         })
       );
     }
 
     if (nextProps.shownSource && nextProps.shownSource != shownSource) {
       const listItems = getDirectories(nextProps.shownSource, sourceTree);
       return this.setState({ listItems });
     }
@@ -143,17 +142,16 @@ class SourcesTree extends Component<Prop
     // NOTE: do not run this every time a source is clicked,
     // only when a new source is added
     if (nextProps.sources != this.props.sources) {
       this.setState(
         updateTree({
           newSources: nextProps.sources,
           prevSources: sources,
           debuggeeUrl,
-          projectRoot,
           uncollapsedTree,
           sourceTree
         })
       );
     }
   }
 
   selectItem = (item: TreeNode) => {
--- a/devtools/client/debugger/src/utils/sources-tree/addToTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/addToTree.js
@@ -152,18 +152,17 @@ function addSourceToNode(
 
 /**
  * @memberof utils/sources-tree
  * @static
  */
 export function addToTree(
   tree: TreeDirectory,
   source: Source,
-  debuggeeHost: ?string,
-  projectRoot: string
+  debuggeeHost: ?string
 ) {
   const url = getURL(source, debuggeeHost);
 
   if (isInvalidUrl(url, source)) {
     return;
   }
 
   const finalNode = traverseTree(url, tree, debuggeeHost);
--- a/devtools/client/debugger/src/utils/sources-tree/createTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/createTree.js
@@ -9,27 +9,26 @@ import { collapseTree } from "./collapse
 import { createDirectoryNode, createParentMap } from "./utils";
 import { getDomain } from "./treeOrder";
 
 import type { SourcesMap } from "../../reducers/types";
 import type { TreeDirectory } from "./types";
 
 type Params = {
   sources: SourcesMap,
-  debuggeeUrl: string,
-  projectRoot: string
+  debuggeeUrl: string
 };
 
-export function createTree({ sources, debuggeeUrl, projectRoot }: Params) {
+export function createTree({ sources, debuggeeUrl }: Params) {
   const uncollapsedTree = createDirectoryNode("root", "", []);
   const debuggeeHost = getDomain(debuggeeUrl);
 
   for (const sourceId in sources) {
     const source = sources[sourceId];
-    addToTree(uncollapsedTree, source, debuggeeHost, projectRoot);
+    addToTree(uncollapsedTree, source, debuggeeHost);
   }
 
   const sourceTree = collapseTree((uncollapsedTree: TreeDirectory));
 
   return {
     uncollapsedTree,
     sourceTree,
     parentMap: createParentMap(sourceTree)
--- a/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
@@ -58,17 +58,17 @@ describe("sources-tree", () => {
 
     it("builds a path-based tree", () => {
       const source1 = makeMockSource(
         "http://example.com/foo/source1.js",
         "actor1"
       );
       const tree = createDirectoryNode("root", "", []);
 
-      addToTree(tree, source1, "http://example.com/", "");
+      addToTree(tree, source1, "http://example.com/");
       expect(tree.contents).toHaveLength(1);
 
       const base = tree.contents[0];
       expect(base.name).toBe("example.com");
       expect(base.contents).toHaveLength(1);
 
       const fooNode = base.contents[0];
       expect(fooNode.name).toBe("foo");
@@ -84,33 +84,33 @@ describe("sources-tree", () => {
 
       const source1 = makeMockSource(
         `https://example.com/foo/${sourceName}`,
         "actor1"
       );
 
       const tree = createDirectoryNode("root", "", []);
 
-      addToTree(tree, source1, "http://example.com/", "");
+      addToTree(tree, source1, "http://example.com/");
       const childNode = getChildNode(tree, 0, 0, 0);
       expect(childNode.name).toEqual(sourceName);
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("name does not include query params", () => {
       const sourceName = "name.js?bar=3";
 
       const source1 = makeMockSource(
         `https://example.com/foo/${sourceName}`,
         "actor1"
       );
 
       const tree = createDirectoryNode("root", "", []);
 
-      addToTree(tree, source1, "http://example.com/", "");
+      addToTree(tree, source1, "http://example.com/");
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("does not attempt to add two of the same directory", () => {
       const sources = [
         {
           id: "server1.conn13.child1/39",
           url: "https://davidwalsh.name/wp-content/prism.js"
@@ -181,33 +181,33 @@ describe("sources-tree", () => {
       );
       const source2 = makeMockSource("http://example.com/source1.js", "actor2");
       const source3 = makeMockSource(
         "javascript:let i = 10; while (i > 0) i--; console.log(i);",
         "actor3"
       );
       const tree = createDirectoryNode("root", "", []);
 
-      addToTree(tree, source1, "http://example.com/", "");
-      addToTree(tree, source2, "http://example.com/", "");
-      addToTree(tree, source3, "http://example.com/", "");
+      addToTree(tree, source1, "http://example.com/");
+      addToTree(tree, source2, "http://example.com/");
+      addToTree(tree, source3, "http://example.com/");
 
       const base = tree.contents[0];
       expect(tree.contents).toHaveLength(1);
 
       const source1Node = base.contents[0];
       expect(source1Node.name).toBe("source1.js");
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("correctly parses file sources", () => {
       const source = makeMockSource("file:///a/b.js", "actor1");
       const tree = createDirectoryNode("root", "", []);
 
-      addToTree(tree, source, "file:///a/index.html", "");
+      addToTree(tree, source, "file:///a/index.html");
       expect(tree.contents).toHaveLength(1);
 
       const base = tree.contents[0];
       expect(base.name).toBe("file://");
       expect(base.contents).toHaveLength(1);
 
       const aNode = base.contents[0];
       expect(aNode.name).toBe("a");
@@ -227,19 +227,17 @@ describe("sources-tree", () => {
         {
           id: "server1.conn13.child1/37",
           url: "https://unpkg.com/codemirror@5.1"
         }
       ];
 
       const sources = createSourcesList(testData);
       const tree = createDirectoryNode("root", "", []);
-      sources.forEach(source =>
-        addToTree(tree, source, "https://unpkg.com/", "")
-      );
+      sources.forEach(source => addToTree(tree, source, "https://unpkg.com/"));
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("replaces a file with a directory", () => {
       const testData = [
         {
           id: "server1.conn13.child1/37",
           url: "https://unpkg.com/codemirror@5.1"
@@ -248,19 +246,17 @@ describe("sources-tree", () => {
         {
           id: "server1.conn13.child1/39",
           url: "https://unpkg.com/codemirror@5.1/mode/xml/xml.js"
         }
       ];
 
       const sources = createSourcesList(testData);
       const tree = createDirectoryNode("root", "", []);
-      sources.forEach(source =>
-        addToTree(tree, source, "https://unpkg.com/", "")
-      );
+      sources.forEach(source => addToTree(tree, source, "https://unpkg.com/"));
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     xit("uses debuggeeUrl as default", () => {
       const testData = [
         {
           url: "components/TodoTextInput.js"
         },
@@ -283,13 +279,13 @@ describe("sources-tree", () => {
         {
           url: "index.js"
         }
       ];
 
       const domain = "http://localhost:4242";
       const sources = createSourcesList(testData);
       const tree = createDirectoryNode("root", "", []);
-      sources.forEach(source => addToTree(tree, source, domain, ""));
+      sources.forEach(source => addToTree(tree, source, domain));
       expect(formatTree(tree)).toMatchSnapshot();
     });
   });
 });
--- a/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
@@ -17,17 +17,17 @@ import {
 const abcSource = makeMockSource("http://example.com/a/b/c.js", "actor1");
 const abcdeSource = makeMockSource("http://example.com/a/b/c/d/e.js", "actor2");
 const abxSource = makeMockSource("http://example.com/a/b/x.js", "actor3");
 
 describe("sources tree", () => {
   describe("collapseTree", () => {
     it("can collapse a single source", () => {
       const fullTree = createDirectoryNode("root", "", []);
-      addToTree(fullTree, abcSource, "http://example.com/", "");
+      addToTree(fullTree, abcSource, "http://example.com/");
       expect(fullTree.contents).toHaveLength(1);
       const tree = collapseTree(fullTree);
 
       const host = tree.contents[0];
       expect(host.name).toBe("example.com");
       expect(host.contents).toHaveLength(1);
 
       const abFolder = host.contents[0];
@@ -37,18 +37,18 @@ describe("sources tree", () => {
       const abcNode = abFolder.contents[0];
       expect(abcNode.name).toBe("c.js");
       expect(abcNode.path).toBe("example.com/a/b/c.js");
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("correctly merges in a collapsed source with a deeper level", () => {
       const fullTree = createDirectoryNode("root", "", []);
-      addToTree(fullTree, abcSource, "http://example.com/", "");
-      addToTree(fullTree, abcdeSource, "http://example.com/", "");
+      addToTree(fullTree, abcSource, "http://example.com/");
+      addToTree(fullTree, abcdeSource, "http://example.com/");
       const tree = collapseTree(fullTree);
 
       sortEntireTree(tree);
       expect(tree.contents).toHaveLength(1);
 
       const host = tree.contents[0];
       expect(host.name).toBe("example.com");
       expect(host.contents).toHaveLength(1);
@@ -65,18 +65,18 @@ describe("sources tree", () => {
       const [abcdeNode] = cdFolder.contents;
       expect(abcdeNode.name).toBe("e.js");
       expect(abcdeNode.path).toBe("example.com/a/b/c/d/e.js");
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("correctly merges in a collapsed source with a shallower level", () => {
       const fullTree = createDirectoryNode("root", "", []);
-      addToTree(fullTree, abcSource, "http://example.com/", "");
-      addToTree(fullTree, abxSource, "http://example.com/", "");
+      addToTree(fullTree, abcSource, "http://example.com/");
+      addToTree(fullTree, abxSource, "http://example.com/");
       const tree = collapseTree(fullTree);
 
       expect(tree.contents).toHaveLength(1);
 
       const host = tree.contents[0];
       expect(host.name).toBe("example.com");
       expect(host.contents).toHaveLength(1);
 
@@ -89,18 +89,18 @@ describe("sources tree", () => {
       expect(abcNode.path).toBe("example.com/a/b/c.js");
       expect(abxNode.name).toBe("x.js");
       expect(abxNode.path).toBe("example.com/a/b/x.js");
       expect(formatTree(tree)).toMatchSnapshot();
     });
 
     it("correctly merges in a collapsed source with the same level", () => {
       const fullTree = createDirectoryNode("root", "", []);
-      addToTree(fullTree, abcdeSource, "http://example.com/", "");
-      addToTree(fullTree, abcSource, "http://example.com/", "");
+      addToTree(fullTree, abcdeSource, "http://example.com/");
+      addToTree(fullTree, abcSource, "http://example.com/");
       const tree = collapseTree(fullTree);
 
       expect(tree.contents).toHaveLength(1);
 
       const host = tree.contents[0];
       expect(host.name).toBe("example.com");
       expect(host.contents).toHaveLength(1);
 
--- a/devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js
@@ -23,19 +23,19 @@ describe("sources-tree", () => {
         "actor2"
       );
       const source3 = makeMockSource(
         "http://example.com/foo/a_source3.js",
         "actor3"
       );
       const _tree = createDirectoryNode("root", "", []);
 
-      addToTree(_tree, source1, "http://example.com/", "");
-      addToTree(_tree, source2, "http://example.com/", "");
-      addToTree(_tree, source3, "http://example.com/", "");
+      addToTree(_tree, source1, "http://example.com/");
+      addToTree(_tree, source2, "http://example.com/");
+      addToTree(_tree, source3, "http://example.com/");
       const tree = sortEntireTree(_tree);
 
       const base = tree.contents[0];
       const fooNode = base.contents[0];
       expect(fooNode.name).toBe("foo");
       expect(fooNode.contents).toHaveLength(2);
 
       const source1Node = base.contents[1];
@@ -56,17 +56,17 @@ describe("sources-tree", () => {
         makeMockSource("http://example.com/c.js", "actor3"),
         makeMockSource("http://example.com", "actor4"),
         makeMockSource("http://example.com/d/d_source.js", "actor5"),
         makeMockSource("http://example.com/b2", "actor6")
       ];
 
       const _tree = createDirectoryNode("root", "", []);
       sources.forEach(source =>
-        addToTree(_tree, source, "http://example.com/", "")
+        addToTree(_tree, source, "http://example.com/")
       );
       const tree = sortEntireTree(_tree);
       const domain = tree.contents[0];
 
       const [
         indexNode,
         bFolderNode,
         dFolderNode,
@@ -97,17 +97,17 @@ describe("sources-tree", () => {
       const sources = [
         makeMockSource("http://example.com/folder/a.js", "actor1"),
         makeMockSource("http://example.com/folder/b/b.js", "actor2"),
         makeMockSource("http://example.com/folder/c/", "actor3")
       ];
 
       const _tree = createDirectoryNode("root", "", []);
       sources.forEach(source =>
-        addToTree(_tree, source, "http://example.com/", "")
+        addToTree(_tree, source, "http://example.com/")
       );
       const tree = sortEntireTree(_tree);
       const [
         bFolderNode,
         cFolderNode,
         aFileNode
       ] = tree.contents[0].contents[0].contents;
 
@@ -130,18 +130,18 @@ describe("sources-tree", () => {
         makeMockSource("http://demo.com/c.js", "actor3")
       ];
 
       const rootA = "http://example.com/path/to/file.html";
       const rootB = "https://www.demo.com/index.html";
       const _treeA = createDirectoryNode("root", "", []);
       const _treeB = createDirectoryNode("root", "", []);
       sources.forEach(source => {
-        addToTree(_treeA, source, rootA, "");
-        addToTree(_treeB, source, rootB, "");
+        addToTree(_treeA, source, rootA);
+        addToTree(_treeB, source, rootB);
       });
       const treeA = sortEntireTree(_treeA, rootA);
       const treeB = sortEntireTree(_treeB, rootB);
 
       expect(treeA.contents[0].contents[0].name).toBe("b.js");
       expect(treeA.contents[1].contents[0].name).toBe("a.js");
 
       expect(treeB.contents[0].contents[0].name).toBe("c.js");
--- a/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
@@ -42,19 +42,17 @@ describe("sources tree", () => {
   describe("isDirectory", () => {
     it("identifies directories correctly", () => {
       const sources = [
         makeMockSource("http://example.com/a.js", "actor1"),
         makeMockSource("http://example.com/b/c/d.js", "actor2")
       ];
 
       const tree = createDirectoryNode("root", "", []);
-      sources.forEach(source =>
-        addToTree(tree, source, "http://example.com/", "")
-      );
+      sources.forEach(source => addToTree(tree, source, "http://example.com/"));
       sortEntireTree(tree);
       const [bFolderNode, aFileNode] = tree.contents[0].contents;
       const [cFolderNode] = bFolderNode.contents;
       const [dFileNode] = cFolderNode.contents;
 
       expect(isDirectory(bFolderNode)).toBe(true);
       expect(isDirectory(aFileNode)).toBe(false);
       expect(isDirectory(cFolderNode)).toBe(true);
--- a/devtools/client/debugger/src/utils/sources-tree/updateTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/updateTree.js
@@ -21,33 +21,31 @@ function newSourcesSet(newSources, prevS
   return uniqSources;
 }
 
 type Params = {
   newSources: SourcesMap,
   prevSources: SourcesMap,
   uncollapsedTree: TreeDirectory,
   sourceTree: TreeDirectory,
-  debuggeeUrl: string,
-  projectRoot: string
+  debuggeeUrl: string
 };
 
 export function updateTree({
   newSources,
   prevSources,
   debuggeeUrl,
-  projectRoot,
   uncollapsedTree,
   sourceTree
 }: Params) {
   const newSet = newSourcesSet(newSources, prevSources);
   const debuggeeHost = getDomain(debuggeeUrl);
 
   for (const source of newSet) {
-    addToTree(uncollapsedTree, source, debuggeeHost, projectRoot);
+    addToTree(uncollapsedTree, source, debuggeeHost);
   }
 
   const newSourceTree = collapseTree(uncollapsedTree);
 
   return {
     uncollapsedTree,
     sourceTree: newSourceTree,
     parentMap: createParentMap(newSourceTree)