@@ -1234,7 +1377,7 @@ Object {
"item": Object {
"contents": Array [],
"name": "folder",
- "path": "folder/",
+ "path": "domain/subfolder",
"type": "directory",
},
"projectRoot": "",
@@ -1242,6 +1385,11 @@ Object {
"setExpanded": [MockFunction],
"setProjectDirectoryRoot": [MockFunction],
"source": null,
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
"refs": Object {},
@@ -1259,7 +1407,7 @@ Object {
Object {
"contents": Array [],
"name": "folder",
- "path": "folder/",
+ "path": "domain/subfolder",
"type": "directory",
}
}
@@ -1268,6 +1416,13 @@ Object {
setExpanded={[MockFunction]}
setProjectDirectoryRoot={[MockFunction]}
source={null}
+ threads={
+ Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ]
+ }
toggleBlackBox={[MockFunction]}
/>,
"_forcedUpdate": false,
@@ -1305,7 +1460,7 @@ Object {
"item": Object {
"contents": Array [],
"name": "folder",
- "path": "folder/",
+ "path": "domain/subfolder",
"type": "directory",
},
"projectRoot": "",
@@ -1313,6 +1468,11 @@ Object {
"setExpanded": [MockFunction],
"setProjectDirectoryRoot": [MockFunction],
"source": null,
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
}
@@ -1322,7 +1482,7 @@ exports[`SourceTreeItem renderItem should show icon for folder with expanded arr
Object {
"component":
@@ -1330,7 +1490,7 @@ Object {
className="arrow expanded"
/>
,
"_forcedUpdate": false,
@@ -1406,7 +1578,7 @@ Object {
className="arrow expanded"
/>
,
"_forcedUpdate": false,
@@ -1552,7 +1741,7 @@ Object {
className="arrow"
/>
,
"_forcedUpdate": false,
@@ -1746,6 +1952,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
}
@@ -1827,6 +2038,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
"refs": Object {},
@@ -1875,6 +2091,13 @@ Object {
"url": "http://mdn.com/one.js",
}
}
+ threads={
+ Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ]
+ }
toggleBlackBox={[MockFunction]}
/>,
"_forcedUpdate": false,
@@ -1952,6 +2175,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
}
@@ -2034,6 +2262,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
"refs": Object {},
@@ -2083,6 +2316,13 @@ Object {
"url": "http://mdn.com/one.js",
}
}
+ threads={
+ Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ]
+ }
toggleBlackBox={[MockFunction]}
/>,
"_forcedUpdate": false,
@@ -2161,6 +2401,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
}
@@ -2242,6 +2487,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
"refs": Object {},
@@ -2290,6 +2540,13 @@ Object {
"url": "http://mdn.com/one.js",
}
}
+ threads={
+ Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ]
+ }
toggleBlackBox={[MockFunction]}
/>,
"_forcedUpdate": false,
@@ -2367,6 +2624,11 @@ Object {
"relativeUrl": "http://mdn.com/one.js",
"url": "http://mdn.com/one.js",
},
+ "threads": Array [
+ Object {
+ "name": "Main Thread",
+ },
+ ],
"toggleBlackBox": [MockFunction],
},
}
diff --git a/devtools/client/debugger/src/components/QuickOpenModal.js b/devtools/client/debugger/src/components/QuickOpenModal.js
index 76501100a2d5..bd98b9e59c06 100644
--- a/devtools/client/debugger/src/components/QuickOpenModal.js
+++ b/devtools/client/debugger/src/components/QuickOpenModal.js
@@ -430,11 +430,12 @@ export class QuickOpenModal extends Component
{
/* istanbul ignore next: ignoring testing of redux connection stuff */
function mapStateToProps(state) {
const selectedSource = getSelectedSource(state);
+ const displayedSources = getDisplayedSourcesList(state);
return {
cx: getContext(state),
enabled: getQuickOpenEnabled(state),
- sources: formatSources(getDisplayedSourcesList(state), getTabs(state)),
+ sources: formatSources(displayedSources, getTabs(state)),
selectedSource,
selectedContentLoaded: selectedSource
? !!getSourceContent(state, selectedSource.id)
diff --git a/devtools/client/debugger/src/components/SecondaryPanes/Worker.js b/devtools/client/debugger/src/components/SecondaryPanes/Worker.js
index 3910c821804b..397e46b48931 100644
--- a/devtools/client/debugger/src/components/SecondaryPanes/Worker.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Worker.js
@@ -44,7 +44,7 @@ export class Worker extends Component {
onClick={this.onSelectThread}
>
{label}
{isPaused ? (
diff --git a/devtools/client/debugger/src/components/shared/AccessibleImage.css b/devtools/client/debugger/src/components/shared/AccessibleImage.css
index 308f238c7114..c463f3b57e8e 100644
--- a/devtools/client/debugger/src/components/shared/AccessibleImage.css
+++ b/devtools/client/debugger/src/components/shared/AccessibleImage.css
@@ -80,6 +80,11 @@ html[dir="rtl"] .img.arrow {
mask-size: 12px 12px;
}
+.img.window {
+ mask-image: url(resource://devtools/client/debugger/images/window.svg);
+ mask-size: 12px 12px;
+}
+
.img.file {
mask-image: url(resource://devtools/client/debugger/images/file-small.svg);
mask-size: 12px 12px;
diff --git a/devtools/client/debugger/src/reducers/debuggee.js b/devtools/client/debugger/src/reducers/debuggee.js
index f3df260a662c..110ee943a147 100644
--- a/devtools/client/debugger/src/reducers/debuggee.js
+++ b/devtools/client/debugger/src/reducers/debuggee.js
@@ -10,9 +10,12 @@
*/
import { sortBy } from "lodash";
+import { createSelector } from "reselect";
+
import { getDisplayName } from "../utils/workers";
-import type { MainThread, WorkerList } from "../types";
+import type { Selector } from "./types";
+import type { MainThread, WorkerList, Thread } from "../types";
import type { Action } from "../actions/types";
export type DebuggeeState = {
@@ -21,7 +24,10 @@ export type DebuggeeState = {
};
export function initialDebuggeeState(): DebuggeeState {
- return { workers: [], mainThread: { actor: "", url: "", type: -1 } };
+ return {
+ workers: [],
+ mainThread: { actor: "", url: "", type: -1, name: "" }
+ };
}
export default function debuggee(
@@ -32,13 +38,10 @@ export default function debuggee(
case "CONNECT":
return {
...state,
- mainThread: action.mainThread
+ mainThread: { ...action.mainThread, name: L10N.getStr("mainThread") }
};
case "INSERT_WORKERS":
- return {
- ...state,
- workers: [...state.workers, ...action.workers]
- };
+ return insertWorkers(state, action.workers);
case "REMOVE_WORKERS":
const { workers } = action;
return {
@@ -55,6 +58,18 @@ export default function debuggee(
}
}
+function insertWorkers(state, workers) {
+ const formatedWorkers = workers.map(worker => ({
+ ...worker,
+ name: getDisplayName(worker)
+ }));
+
+ return {
+ ...state,
+ workers: [...state.workers, ...formatedWorkers]
+ };
+}
+
export const getWorkers = (state: OuterState) => state.debuggee.workers;
export const getWorkerCount = (state: OuterState) => getWorkers(state).length;
@@ -71,8 +86,10 @@ export function getDebuggeeUrl(state: OuterState): string {
return getMainThread(state).url;
}
-export function getThreads(state: OuterState) {
- return [getMainThread(state), ...sortBy(getWorkers(state), getDisplayName)];
-}
+export const getThreads: Selector = createSelector(
+ getMainThread,
+ getWorkers,
+ (mainThread, workers) => [mainThread, ...sortBy(workers, getDisplayName)]
+);
type OuterState = { debuggee: DebuggeeState };
diff --git a/devtools/client/debugger/src/reducers/source-tree.js b/devtools/client/debugger/src/reducers/source-tree.js
index 764df5fa2d90..4a0f69e3e0e4 100644
--- a/devtools/client/debugger/src/reducers/source-tree.js
+++ b/devtools/client/debugger/src/reducers/source-tree.js
@@ -9,15 +9,17 @@
* @module reducers/source-tree
*/
-import type { SourceTreeAction } from "../actions/types";
+import type { SourceTreeAction, FocusItem } from "../actions/types";
export type SourceTreeState = {
- expanded: { [string]: Set }
+ expanded: Set,
+ focusedItem: ?FocusItem
};
export function InitialState(): SourceTreeState {
return {
- expanded: {}
+ expanded: new Set(),
+ focusedItem: null
};
}
@@ -28,6 +30,9 @@ export default function update(
switch (action.type) {
case "SET_EXPANDED_STATE":
return updateExpanded(state, action);
+
+ case "SET_FOCUSED_SOURCE_ITEM":
+ return { ...state, focusedItem: action.item };
}
return state;
@@ -36,7 +41,7 @@ export default function update(
function updateExpanded(state, action) {
return {
...state,
- expanded: { ...state.expanded, [action.thread]: new Set(action.expanded) }
+ expanded: new Set(action.expanded)
};
}
@@ -44,6 +49,10 @@ type OuterState = {
sourceTree: SourceTreeState
};
-export function getExpandedState(state: OuterState, thread: string) {
- return state.sourceTree.expanded[thread];
+export function getExpandedState(state: OuterState) {
+ return state.sourceTree.expanded;
+}
+
+export function getFocusedSourceItem(state: OuterState): ?FocusItem {
+ return state.sourceTree.focusedItem;
}
diff --git a/devtools/client/debugger/src/reducers/sources.js b/devtools/client/debugger/src/reducers/sources.js
index 2b6d1301aa27..fecc8a729373 100644
--- a/devtools/client/debugger/src/reducers/sources.js
+++ b/devtools/client/debugger/src/reducers/sources.js
@@ -68,8 +68,9 @@ export type SourcesMap = { [SourceId]: Source };
type SourcesContentMap = {
[SourceId]: AsyncValue | null
};
-export type BreakpointPositionsMap = { [SourceId]: BreakpointPositions };
export type SourcesMapByThread = { [ThreadId]: SourcesMap };
+
+export type BreakpointPositionsMap = { [SourceId]: BreakpointPositions };
type SourceActorMap = { [SourceId]: Array };
type UrlsMap = { [string]: SourceId[] };
@@ -852,9 +853,10 @@ const getDisplayedSourceIDs: GetDisplayedSourceIDsSelector = createSelector(
return sourceIDsByThread;
}
);
+
type GetDisplayedSourcesSelector = (
OuterState & SourceActorOuterState
-) => { [ThreadId]: { [SourceId]: Source } };
+) => SourcesMapByThread;
export const getDisplayedSources: GetDisplayedSourcesSelector = createSelector(
state => state.sources.sources,
getDisplayedSourceIDs,
@@ -874,17 +876,6 @@ export const getDisplayedSources: GetDisplayedSourcesSelector = createSelector(
}
);
-export function getDisplayedSourcesForThread(
- state: OuterState & SourceActorOuterState,
- thread: string
-): SourcesMap {
- return getDisplayedSources(state)[thread] || {};
-}
-
-export function getFocusedSourceItem(state: OuterState): ?FocusItem {
- return state.sources.focusedItem;
-}
-
export function getSourceActorsForSource(
state: OuterState & SourceActorOuterState,
id: SourceId
diff --git a/devtools/client/debugger/src/reducers/tests/sources.spec.js b/devtools/client/debugger/src/reducers/tests/sources.spec.js
index 92f44c96c4ab..7a03fe96344b 100644
--- a/devtools/client/debugger/src/reducers/tests/sources.spec.js
+++ b/devtools/client/debugger/src/reducers/tests/sources.spec.js
@@ -81,7 +81,6 @@ describe("sources selectors", () => {
sources: update(state, {
type: "ADD_SOURCES",
cx: mockcx,
- // coercing to a Source for the purpose of this test
sources: ((mockedSources: any): Source[])
}),
sourceActors: undefined
@@ -94,9 +93,8 @@ describe("sources selectors", () => {
sources: update(state.sources, insertAction),
sourceActors: updateSourceActors(state.sourceActors, insertAction)
};
- const selectedDisplayedSources = getDisplayedSources(state);
- const threadSources = selectedDisplayedSources.foo;
- expect(Object.values(threadSources)).toHaveLength(3);
+ const threadSources = getDisplayedSources(state);
+ expect(Object.values(threadSources.foo)).toHaveLength(3);
});
it("should omit all extensions when chrome preference enabled", () => {
@@ -106,7 +104,6 @@ describe("sources selectors", () => {
sources: update(state, {
type: "ADD_SOURCES",
cx: mockcx,
- // coercing to a Source for the purpose of this test
sources: ((mockedSources: any): Source[])
}),
sourceActors: undefined
@@ -121,8 +118,7 @@ describe("sources selectors", () => {
sources: update(state.sources, insertAction),
sourceActors: updateSourceActors(state.sourceActors, insertAction)
};
- const selectedDisplayedSources = getDisplayedSources(state);
- const threadSources = selectedDisplayedSources.foo;
- expect(Object.values(threadSources)).toHaveLength(1);
+ const threadSources = getDisplayedSources(state);
+ expect(Object.values(threadSources.foo)).toHaveLength(1);
});
});
diff --git a/devtools/client/debugger/src/types.js b/devtools/client/debugger/src/types.js
index 8c1da9d8fa5a..7e8bda074087 100644
--- a/devtools/client/debugger/src/types.js
+++ b/devtools/client/debugger/src/types.js
@@ -447,13 +447,15 @@ export type Scope = {|
export type MainThread = {
+actor: ThreadId,
+url: string,
- +type: number
+ +type: number,
+ +name: string
};
export type Worker = {
+actor: ThreadId,
+url: string,
- +type: number
+ +type: number,
+ +name: string
};
export type Thread = MainThread & Worker;
diff --git a/devtools/client/debugger/src/utils/source.js b/devtools/client/debugger/src/utils/source.js
index 8c2298d2ed72..bd89b7db6c4d 100644
--- a/devtools/client/debugger/src/utils/source.js
+++ b/devtools/client/debugger/src/utils/source.js
@@ -491,7 +491,7 @@ export function getSourceQueryString(source: ?Source) {
}
export function isUrlExtension(url: string) {
- return /^(chrome|moz)-extension:\//.test(url);
+ return /\/?(chrome|moz)-extension:\//.test(url);
}
export function getPlainUrl(url: string): string {
diff --git a/devtools/client/debugger/src/utils/sources-tree/addToTree.js b/devtools/client/debugger/src/utils/sources-tree/addToTree.js
index d4c01a67bad2..a9c2ff037c37 100644
--- a/devtools/client/debugger/src/utils/sources-tree/addToTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/addToTree.js
@@ -90,15 +90,25 @@ function traverseTree(
url: ParsedURL,
tree: TreeDirectory,
debuggeeHost: ?string,
- source: Source
+ source: Source,
+ thread: string
): TreeNode {
const parts = url.path.split("/").filter(p => p !== "");
parts.unshift(url.group);
+ if (thread) {
+ parts.unshift(thread);
+ }
let path = "";
return parts.reduce((subTree, part, index) => {
- path = path ? `${path}/${part}` : part;
- const debuggeeHostIfRoot = index === 0 ? debuggeeHost : null;
+ if (index == 0 && thread) {
+ path = thread;
+ } else {
+ path = `${path}/${part}`;
+ }
+
+ const debuggeeHostIfRoot = index === 1 ? debuggeeHost : null;
+
return findOrCreateNode(
parts,
subTree,
@@ -165,7 +175,8 @@ function addSourceToNode(
export function addToTree(
tree: TreeDirectory,
source: Source,
- debuggeeHost: ?string
+ debuggeeHost: ?string,
+ thread: string
) {
const url = getURL(source, debuggeeHost);
@@ -173,7 +184,7 @@ export function addToTree(
return;
}
- const finalNode = traverseTree(url, tree, debuggeeHost, source);
+ const finalNode = traverseTree(url, tree, debuggeeHost, source, thread);
// $FlowIgnore
finalNode.contents = addSourceToNode(finalNode, url, source);
diff --git a/devtools/client/debugger/src/utils/sources-tree/collapseTree.js b/devtools/client/debugger/src/utils/sources-tree/collapseTree.js
index 4ff81613267e..57d3e898496d 100644
--- a/devtools/client/debugger/src/utils/sources-tree/collapseTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/collapseTree.js
@@ -18,8 +18,9 @@ function _collapseTree(node: TreeNode, depth: number): TreeNode {
console.log(`Expected array at: ${node.path}`);
}
- // Node is not a root/domain node, and only contains 1 item.
- if (depth > 1 && node.contents.length === 1) {
+ // Node is not a (1) thread and (2) root/domain node,
+ // and only contains 1 item.
+ if (depth > 2 && node.contents.length === 1) {
const next = node.contents[0];
// Do not collapse if the next node is a leaf node.
if (next.type === "directory") {
diff --git a/devtools/client/debugger/src/utils/sources-tree/createTree.js b/devtools/client/debugger/src/utils/sources-tree/createTree.js
deleted file mode 100644
index 7eed7b6cdf1f..000000000000
--- a/devtools/client/debugger/src/utils/sources-tree/createTree.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 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 . */
-
-// @flow
-
-import { addToTree } from "./addToTree";
-import { collapseTree } from "./collapseTree";
-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
-};
-
-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);
- }
-
- const sourceTree = collapseTree((uncollapsedTree: TreeDirectory));
-
- return {
- uncollapsedTree,
- sourceTree,
- parentMap: createParentMap(sourceTree)
- };
-}
diff --git a/devtools/client/debugger/src/utils/sources-tree/index.js b/devtools/client/debugger/src/utils/sources-tree/index.js
index 335e2fd61f5a..102e73a70ace 100644
--- a/devtools/client/debugger/src/utils/sources-tree/index.js
+++ b/devtools/client/debugger/src/utils/sources-tree/index.js
@@ -11,11 +11,10 @@
export { addToTree } from "./addToTree";
export { collapseTree } from "./collapseTree";
-export { createTree } from "./createTree";
export { formatTree } from "./formatTree";
export { getDirectories } from "./getDirectories";
export { getFilenameFromPath, getURL } from "./getURL";
-export { sortEntireTree, sortTree } from "./sortTree";
-export { updateTree } from "./updateTree";
+export { sortTree } from "./sortTree";
+export { createTree, updateTree } from "./updateTree";
export * from "./utils";
diff --git a/devtools/client/debugger/src/utils/sources-tree/moz.build b/devtools/client/debugger/src/utils/sources-tree/moz.build
index 4550973c166b..0288b56d311a 100644
--- a/devtools/client/debugger/src/utils/sources-tree/moz.build
+++ b/devtools/client/debugger/src/utils/sources-tree/moz.build
@@ -10,7 +10,6 @@ DIRS += [
CompiledModules(
'addToTree.js',
'collapseTree.js',
- 'createTree.js',
'formatTree.js',
'getDirectories.js',
'getURL.js',
diff --git a/devtools/client/debugger/src/utils/sources-tree/sortTree.js b/devtools/client/debugger/src/utils/sources-tree/sortTree.js
index 77eff3aba324..5bf8f0e92201 100644
--- a/devtools/client/debugger/src/utils/sources-tree/sortTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/sortTree.js
@@ -8,25 +8,6 @@ import { nodeHasChildren, isExactUrlMatch } from "./utils";
import type { TreeDirectory } from "./types";
-/**
- * Look at the nodes in the source tree, and determine the index of where to
- * insert a new node. The ordering is index -> folder -> file.
- * @memberof utils/sources-tree
- * @static
- */
-export function sortEntireTree(
- tree: TreeDirectory,
- debuggeeUrl: string = ""
-): TreeDirectory {
- if (nodeHasChildren(tree)) {
- const contents = sortTree(tree, debuggeeUrl).map((subtree: any) =>
- sortEntireTree(subtree)
- );
- return { ...tree, contents };
- }
- return tree;
-}
-
/**
* Look at the nodes in the source tree, and determine the index of where to
* insert a new node. The ordering is index -> folder -> file.
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/addToTree.spec.js.snap b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/addToTree.spec.js.snap
index e31a7543420c..7059aced63f5 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/addToTree.spec.js.snap
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/addToTree.spec.js.snap
@@ -2,77 +2,90 @@
exports[`sources-tree addToTree can add a file to an intermediate directory 1`] = `
" - root path=
- - unpkg.com path=unpkg.com
- - codemirror@5.1 path=unpkg.com/codemirror@5.1
- - mode path=unpkg.com/codemirror@5.1/mode
- - xml path=unpkg.com/codemirror@5.1/mode/xml
- - xml.js path=unpkg.com/codemirror@5.1/mode/xml/xml.js source_id=server1.conn13.child1/39
- - codemirror@5.1 path=unpkg.com/codemirror@5.1 source_id=server1.conn13.child1/37
+ - FakeThread path=FakeThread
+ - unpkg.com path=FakeThread/unpkg.com
+ - codemirror@5.1 path=FakeThread/unpkg.com/codemirror@5.1
+ - mode path=FakeThread/unpkg.com/codemirror@5.1/mode
+ - xml path=FakeThread/unpkg.com/codemirror@5.1/mode/xml
+ - xml.js path=FakeThread/unpkg.com/codemirror@5.1/mode/xml/xml.js source_id=server1.conn13.child1/39
+ - codemirror@5.1 path=FakeThread/unpkg.com/codemirror@5.1 source_id=server1.conn13.child1/37
"
`;
exports[`sources-tree addToTree correctly parses file sources 1`] = `
" - root path=
- - file:// path=file://
- - a path=file:///a
- - b.js path=file:///a/b.js source_id=actor1
+ - FakeThread path=FakeThread
+ - file:// path=FakeThread/file://
+ - a path=FakeThread/file:///a
+ - b.js path=FakeThread/file:///a/b.js source_id=actor1
"
`;
exports[`sources-tree addToTree does not attempt to add two of the same directory 1`] = `
" - root path=
- - davidwalsh.name path=davidwalsh.name
- - (index) path=https://davidwalsh.name/ source_id=server1.conn13.child1/37
- - wp-content path=davidwalsh.name/wp-content
- - prism.js path=davidwalsh.name/wp-content/prism.js source_id=server1.conn13.child1/39
+ - FakeThread path=FakeThread
+ - davidwalsh.name path=FakeThread/davidwalsh.name
+ - (index) path=https://davidwalsh.name/ source_id=server1.conn13.child1/37
+ - wp-content path=FakeThread/davidwalsh.name/wp-content
+ - prism.js path=FakeThread/davidwalsh.name/wp-content/prism.js source_id=server1.conn13.child1/39
"
`;
exports[`sources-tree addToTree does not attempt to add two of the same file 1`] = `
" - root path=
- - davidwalsh.name path=davidwalsh.name
- - (index) path=https://davidwalsh.name/ source_id=server1.conn13.child1/37
+ - FakeThread path=FakeThread
+ - davidwalsh.name path=FakeThread/davidwalsh.name
+ - (index) path=https://davidwalsh.name/ source_id=server1.conn13.child1/39
+ - util.js path=FakeThread/davidwalsh.name/util.js source_id=server1.conn13.child1/37
+ - FakeThread2 path=FakeThread2
+ - davidwalsh.name path=FakeThread2/davidwalsh.name
+ - util.js path=FakeThread2/davidwalsh.name/util.js source_id=server1.conn13.child1/37
"
`;
exports[`sources-tree addToTree does not mangle encoded URLs 1`] = `
" - root path=
- - example.com path=example.com
- - foo path=example.com/foo
- - B9724220.131821496;dc_ver=42.111;sz=468x60;u_sd=2;dc_adk=2020465299;ord=a53rpc;dc_rfl=1,https%3A%2F%2Fdavidwalsh.name%2F$0;xdt=1 path=example.com/foo/B9724220.131821496;dc_ver=42.111;sz=468x60;u_sd=2;dc_adk=2020465299;ord=a53rpc;dc_rfl=1,https%3A%2F%2Fdavidwalsh.name%2F$0;xdt=1 source_id=actor1
+ - FakeThread path=FakeThread
+ - example.com path=FakeThread/example.com
+ - foo path=FakeThread/example.com/foo
+ - B9724220.131821496;dc_ver=42.111;sz=468x60;u_sd=2;dc_adk=2020465299;ord=a53rpc;dc_rfl=1,https%3A%2F%2Fdavidwalsh.name%2F$0;xdt=1 path=FakeThread/example.com/foo/B9724220.131821496;dc_ver=42.111;sz=468x60;u_sd=2;dc_adk=2020465299;ord=a53rpc;dc_rfl=1,https%3A%2F%2Fdavidwalsh.name%2F$0;xdt=1 source_id=actor1
"
`;
exports[`sources-tree addToTree excludes javascript: URLs from the tree 1`] = `
" - root path=
- - example.com path=example.com
- - source1.js path=example.com/source1.js source_id=actor2
+ - FakeThread path=FakeThread
+ - example.com path=FakeThread/example.com
+ - source1.js path=FakeThread/example.com/source1.js source_id=actor2
"
`;
exports[`sources-tree addToTree name does not include query params 1`] = `
" - root path=
- - example.com path=example.com
- - foo path=example.com/foo
- - name.js path=example.com/foo/name.js source_id=actor1
+ - FakeThread path=FakeThread
+ - example.com path=FakeThread/example.com
+ - foo path=FakeThread/example.com/foo
+ - name.js path=FakeThread/example.com/foo/name.js source_id=actor1
"
`;
exports[`sources-tree addToTree replaces a file with a directory 1`] = `
" - root path=
- - unpkg.com path=unpkg.com
- - codemirror@5.1 path=unpkg.com/codemirror@5.1
- - mode path=unpkg.com/codemirror@5.1/mode
- - xml path=unpkg.com/codemirror@5.1/mode/xml
- - xml.js path=unpkg.com/codemirror@5.1/mode/xml/xml.js source_id=server1.conn13.child1/39
- - codemirror@5.1 path=unpkg.com/codemirror@5.1 source_id=server1.conn13.child1/37
+ - FakeThread path=FakeThread
+ - unpkg.com path=FakeThread/unpkg.com
+ - codemirror@5.1 path=FakeThread/unpkg.com/codemirror@5.1
+ - mode path=FakeThread/unpkg.com/codemirror@5.1/mode
+ - xml path=FakeThread/unpkg.com/codemirror@5.1/mode/xml
+ - xml.js path=FakeThread/unpkg.com/codemirror@5.1/mode/xml/xml.js source_id=server1.conn13.child1/39
+ - codemirror@5.1 path=FakeThread/unpkg.com/codemirror@5.1 source_id=server1.conn13.child1/37
"
`;
exports[`sources-tree addToTree supports data URLs 1`] = `
" - root path=
- - (no domain) path=(no domain)
- - data:text/html, path=data:text/html, source_id=server1.conn13.child1/39
+ - FakeThread path=FakeThread
+ - (no domain) path=FakeThread/(no domain)
+ - data:text/html, path=data:text/html, source_id=server1.conn13.child1/39
"
`;
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/collapseTree.spec.js.snap b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/collapseTree.spec.js.snap
index bdad26c16fc0..529874f8bdc6 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/collapseTree.spec.js.snap
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/collapseTree.spec.js.snap
@@ -2,37 +2,41 @@
exports[`sources tree collapseTree can collapse a single source 1`] = `
" - root path=
- - example.com path=example.com
- - a/b path=example.com/a/b
- - c.js path=example.com/a/b/c.js source_id=actor1
+ - Main Thread path=Main Thread
+ - example.com path=Main Thread/example.com
+ - a/b path=Main Thread/example.com/a/b
+ - c.js path=Main Thread/example.com/a/b/c.js source_id=actor1
"
`;
exports[`sources tree collapseTree correctly merges in a collapsed source with a deeper level 1`] = `
" - root path=
- - example.com path=example.com
- - a/b path=example.com/a/b
- - c/d path=example.com/a/b/c/d
- - e.js path=example.com/a/b/c/d/e.js source_id=actor2
- - c.js path=example.com/a/b/c.js source_id=actor1
+ - Main Thread path=Main Thread
+ - example.com path=Main Thread/example.com
+ - a/b path=Main Thread/example.com/a/b
+ - c/d path=Main Thread/example.com/a/b/c/d
+ - e.js path=Main Thread/example.com/a/b/c/d/e.js source_id=actor2
+ - c.js path=Main Thread/example.com/a/b/c.js source_id=actor1
"
`;
exports[`sources tree collapseTree correctly merges in a collapsed source with a shallower level 1`] = `
" - root path=
- - example.com path=example.com
- - a/b path=example.com/a/b
- - c.js path=example.com/a/b/c.js source_id=actor1
- - x.js path=example.com/a/b/x.js source_id=actor3
+ - Main Thread path=Main Thread
+ - example.com path=Main Thread/example.com
+ - a/b path=Main Thread/example.com/a/b
+ - c.js path=Main Thread/example.com/a/b/c.js source_id=actor1
+ - x.js path=Main Thread/example.com/a/b/x.js source_id=actor3
"
`;
exports[`sources tree collapseTree correctly merges in a collapsed source with the same level 1`] = `
" - root path=
- - example.com path=example.com
- - a/b path=example.com/a/b
- - c/d path=example.com/a/b/c/d
- - e.js path=example.com/a/b/c/d/e.js source_id=actor2
- - c.js path=example.com/a/b/c.js source_id=actor1
+ - Main Thread path=Main Thread
+ - example.com path=Main Thread/example.com
+ - a/b path=Main Thread/example.com/a/b
+ - c/d path=Main Thread/example.com/a/b/c/d
+ - e.js path=Main Thread/example.com/a/b/c/d/e.js source_id=actor2
+ - c.js path=Main Thread/example.com/a/b/c.js source_id=actor1
"
`;
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/sortTree.spec.js.snap b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/sortTree.spec.js.snap
deleted file mode 100644
index e8120f8cb3d9..000000000000
--- a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/sortTree.spec.js.snap
+++ /dev/null
@@ -1,73 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`sources-tree sortEntireTree alphabetically sorts children 1`] = `
-" - root path=
- - example.com path=example.com
- - foo path=example.com/foo
- - a_source3.js path=example.com/foo/a_source3.js source_id=actor3
- - b_source2.js path=example.com/foo/b_source2.js source_id=actor2
- - source1.js path=example.com/source1.js source_id=actor1
-"
-`;
-
-exports[`sources-tree sortEntireTree puts folder at the top of the sort 1`] = `
-" - root path=
- - example.com path=example.com
- - folder path=example.com/folder
- - b path=example.com/folder/b
- - b.js path=example.com/folder/b/b.js source_id=actor2
- - c path=example.com/folder/c
- - (index) path=http://example.com/folder/c/ source_id=actor3
- - a.js path=example.com/folder/a.js source_id=actor1
-"
-`;
-
-exports[`sources-tree sortEntireTree puts root debugee url at the top of the sort 1`] = `
-" - root path=
- - example.com path=example.com
- - b.js path=example.com/b.js source_id=actor2
- - api.example.com path=api.example.com
- - a.js path=api.example.com/a.js source_id=actor1
- - demo.com path=demo.com
- - c.js path=demo.com/c.js source_id=actor3
-"
-`;
-
-exports[`sources-tree sortEntireTree puts root debugee url at the top of the sort 2`] = `
-" - root path=
- - demo.com path=demo.com
- - c.js path=demo.com/c.js source_id=actor3
- - api.example.com path=api.example.com
- - a.js path=api.example.com/a.js source_id=actor1
- - example.com path=example.com
- - b.js path=example.com/b.js source_id=actor2
-"
-`;
-
-exports[`sources-tree sortEntireTree sorts folders first 1`] = `
-" - root path=
- - example.com path=example.com
- - (index) path=http://example.com source_id=actor4
- - b.js path=example.com/b.js
- - b_source.js path=example.com/b.js/b_source.js source_id=actor2
- - d path=example.com/d
- - d_source.js path=example.com/d/d_source.js source_id=actor5
- - a.js path=example.com/a.js source_id=actor1
- - b2 path=example.com/b2 source_id=actor6
- - c.js path=example.com/c.js source_id=actor3
-"
-`;
-
-exports[`sources-tree sortEntireTree sorts folders first 2`] = `
-" - root path=
- - example.com path=example.com
- - (index) path=http://example.com source_id=actor4
- - b.js path=example.com/b.js
- - b_source.js path=example.com/b.js/b_source.js source_id=actor2
- - d path=example.com/d
- - d_source.js path=example.com/d/d_source.js source_id=actor5
- - a.js path=example.com/a.js source_id=actor1
- - b2 path=example.com/b2 source_id=actor6
- - c.js path=example.com/c.js source_id=actor3
-"
-`;
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/updateTree.spec.js.snap b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/updateTree.spec.js.snap
index f2c2e0ee07bc..1de925f0864a 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/updateTree.spec.js.snap
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/__snapshots__/updateTree.spec.js.snap
@@ -8,38 +8,45 @@ exports[`calls updateTree.js adds one source 1`] = `
\\"contents\\": [
{
\\"type\\": \\"directory\\",
- \\"name\\": \\"davidwalsh.name\\",
- \\"path\\": \\"davidwalsh.name\\",
+ \\"name\\": \\"FakeThread\\",
+ \\"path\\": \\"FakeThread\\",
\\"contents\\": [
{
- \\"type\\": \\"source\\",
- \\"name\\": \\"(index)\\",
- \\"path\\": \\"https://davidwalsh.name/\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/39\\",
- \\"url\\": \\"https://davidwalsh.name/\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
- },
- {
- \\"type\\": \\"source\\",
- \\"name\\": \\"source1.js\\",
- \\"path\\": \\"davidwalsh.name/source1.js\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/37\\",
- \\"url\\": \\"https://davidwalsh.name/source1.js\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/source1.js\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
+ \\"type\\": \\"directory\\",
+ \\"name\\": \\"davidwalsh.name\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name\\",
+ \\"contents\\": [
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"(index)\\",
+ \\"path\\": \\"https://davidwalsh.name/\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/39\\",
+ \\"url\\": \\"https://davidwalsh.name/\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ },
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"source1.js\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name/source1.js\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/37\\",
+ \\"url\\": \\"https://davidwalsh.name/source1.js\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/source1.js\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ }
+ ]
}
]
}
@@ -55,53 +62,60 @@ exports[`calls updateTree.js adds two sources 1`] = `
\\"contents\\": [
{
\\"type\\": \\"directory\\",
- \\"name\\": \\"davidwalsh.name\\",
- \\"path\\": \\"davidwalsh.name\\",
+ \\"name\\": \\"FakeThread\\",
+ \\"path\\": \\"FakeThread\\",
\\"contents\\": [
{
- \\"type\\": \\"source\\",
- \\"name\\": \\"(index)\\",
- \\"path\\": \\"https://davidwalsh.name/\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/39\\",
- \\"url\\": \\"https://davidwalsh.name/\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
- },
- {
- \\"type\\": \\"source\\",
- \\"name\\": \\"source1.js\\",
- \\"path\\": \\"davidwalsh.name/source1.js\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/37\\",
- \\"url\\": \\"https://davidwalsh.name/source1.js\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/source1.js\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
- },
- {
- \\"type\\": \\"source\\",
- \\"name\\": \\"source2.js\\",
- \\"path\\": \\"davidwalsh.name/source2.js\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/40\\",
- \\"url\\": \\"https://davidwalsh.name/source2.js\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/source2.js\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
+ \\"type\\": \\"directory\\",
+ \\"name\\": \\"davidwalsh.name\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name\\",
+ \\"contents\\": [
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"(index)\\",
+ \\"path\\": \\"https://davidwalsh.name/\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/39\\",
+ \\"url\\": \\"https://davidwalsh.name/\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ },
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"source1.js\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name/source1.js\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/37\\",
+ \\"url\\": \\"https://davidwalsh.name/source1.js\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/source1.js\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ },
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"source2.js\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name/source2.js\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/40\\",
+ \\"url\\": \\"https://davidwalsh.name/source2.js\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/source2.js\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ }
+ ]
}
]
}
@@ -117,38 +131,30 @@ exports[`calls updateTree.js shows all the sources 1`] = `
\\"contents\\": [
{
\\"type\\": \\"directory\\",
- \\"name\\": \\"davidwalsh.name\\",
- \\"path\\": \\"davidwalsh.name\\",
+ \\"name\\": \\"FakeThread\\",
+ \\"path\\": \\"FakeThread\\",
\\"contents\\": [
{
- \\"type\\": \\"source\\",
- \\"name\\": \\"(index)\\",
- \\"path\\": \\"https://davidwalsh.name/\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/39\\",
- \\"url\\": \\"https://davidwalsh.name/\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
- },
- {
- \\"type\\": \\"source\\",
- \\"name\\": \\"source1.js\\",
- \\"path\\": \\"davidwalsh.name/source1.js\\",
- \\"contents\\": {
- \\"id\\": \\"server1.conn13.child1/37\\",
- \\"url\\": \\"https://davidwalsh.name/source1.js\\",
- \\"isBlackBoxed\\": false,
- \\"isPrettyPrinted\\": false,
- \\"relativeUrl\\": \\"https://davidwalsh.name/source1.js\\",
- \\"introductionUrl\\": null,
- \\"isWasm\\": false,
- \\"isExtension\\": false
- }
+ \\"type\\": \\"directory\\",
+ \\"name\\": \\"davidwalsh.name\\",
+ \\"path\\": \\"FakeThread/davidwalsh.name\\",
+ \\"contents\\": [
+ {
+ \\"type\\": \\"source\\",
+ \\"name\\": \\"(index)\\",
+ \\"path\\": \\"https://davidwalsh.name/\\",
+ \\"contents\\": {
+ \\"id\\": \\"server1.conn13.child1/39\\",
+ \\"url\\": \\"https://davidwalsh.name/\\",
+ \\"isBlackBoxed\\": false,
+ \\"isPrettyPrinted\\": false,
+ \\"relativeUrl\\": \\"https://davidwalsh.name/\\",
+ \\"introductionUrl\\": null,
+ \\"isWasm\\": false,
+ \\"isExtension\\": false
+ }
+ }
+ ]
}
]
}
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
index 37daf84da674..ea5cccb41f90 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/addToTree.spec.js
@@ -17,7 +17,7 @@ import {
nodeHasChildren
} from "../index";
-type RawSource = {| url: string, id: string |};
+type RawSource = {| url: string, id: string, actors?: any |};
function createSourcesMap(sources: RawSource[]) {
const sourcesMap = sources.reduce((map, source) => {
@@ -63,10 +63,10 @@ describe("sources-tree", () => {
);
const tree = createDirectoryNode("root", "", []);
- addToTree(tree, source1, "http://example.com/");
+ addToTree(tree, source1, "http://example.com/", "FakeThread");
expect(tree.contents).toHaveLength(1);
- const base = tree.contents[0];
+ const base = tree.contents[0].contents[0];
expect(base.name).toBe("example.com");
expect(base.contents).toHaveLength(1);
@@ -89,8 +89,8 @@ describe("sources-tree", () => {
const tree = createDirectoryNode("root", "", []);
- addToTree(tree, source1, "http://example.com/");
- const childNode = getChildNode(tree, 0, 0, 0);
+ addToTree(tree, source1, "http://example.com/", "FakeThread");
+ const childNode = getChildNode(tree, 0, 0, 0, 0);
expect(childNode.name).toEqual(sourceName);
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -105,7 +105,7 @@ describe("sources-tree", () => {
const tree = createDirectoryNode("root", "", []);
- addToTree(tree, source1, "http://example.com/");
+ addToTree(tree, source1, "http://example.com/", "FakeThread");
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -121,14 +121,22 @@ describe("sources-tree", () => {
}
];
- const sourceMap = createSourcesMap(sources);
+ const sourceMap = { FakeThread: createSourcesMap(sources) };
const tree = createTree({
sources: sourceMap,
debuggeeUrl: "",
- projectRoot: ""
+ threads: [
+ {
+ actor: "FakeThread",
+ name: "FakeThread",
+ url: "https://davidwalsh.name",
+ type: 1
+ }
+ ]
}).sourceTree;
- // expect(tree.contents).toHaveLength(1);
- const subtree = tree.contents[0];
+
+ expect(tree.contents[0].contents).toHaveLength(1);
+ const subtree = tree.contents[0].contents[0];
expect(subtree.contents).toHaveLength(2);
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -141,11 +149,18 @@ describe("sources-tree", () => {
}
];
- const sourceMap = createSourcesMap(sources);
+ const sourceMap = { FakeThread: createSourcesMap(sources) };
const tree = createTree({
sources: sourceMap,
debuggeeUrl: "",
- projectRoot: ""
+ threads: [
+ {
+ actor: "FakeThread",
+ url: "https://davidwalsh.name",
+ type: 1,
+ name: "FakeThread"
+ }
+ ]
}).sourceTree;
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -158,19 +173,39 @@ describe("sources-tree", () => {
},
{
id: "server1.conn13.child1/37",
- url: "https://davidwalsh.name/"
+ url: "https://davidwalsh.name/util.js"
}
];
- const sourceMap = createSourcesMap(sources);
+ const sourceMap = {
+ FakeThread: createSourcesMap(sources),
+ FakeThread2: createSourcesMap([sources[1]])
+ };
+
const tree = createTree({
sources: sourceMap,
- debuggeeUrl: "",
- projectRoot: ""
+ debuggeeUrl: "https://davidwalsh.name",
+ threads: [
+ {
+ actor: "FakeThread",
+ name: "FakeThread",
+ url: "https://davidwalsh.name",
+ type: 1
+ },
+ {
+ actor: "FakeThread2",
+ name: "FakeThread2",
+ url: "https://davidwalsh.name/WorkerA.js",
+ type: 2
+ }
+ ]
}).sourceTree;
- expect(tree.contents).toHaveLength(1);
- const subtree = tree.contents[0];
- expect(subtree.contents).toHaveLength(1);
+
+ expect(tree.contents[0].contents).toHaveLength(1);
+ const subtree = tree.contents[0].contents[0];
+ expect(subtree.contents).toHaveLength(2);
+ const subtree2 = tree.contents[1].contents[0];
+ expect(subtree2.contents).toHaveLength(1);
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -186,11 +221,11 @@ describe("sources-tree", () => {
);
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/", "FakeThread");
+ addToTree(tree, source2, "http://example.com/", "FakeThread");
+ addToTree(tree, source3, "http://example.com/", "FakeThread");
- const base = tree.contents[0];
+ const base = tree.contents[0].contents[0];
expect(tree.contents).toHaveLength(1);
const source1Node = base.contents[0];
@@ -202,10 +237,10 @@ describe("sources-tree", () => {
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", "FakeThread");
expect(tree.contents).toHaveLength(1);
- const base = tree.contents[0];
+ const base = tree.contents[0].contents[0];
expect(base.name).toBe("file://");
expect(base.contents).toHaveLength(1);
@@ -232,7 +267,9 @@ describe("sources-tree", () => {
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/", "FakeThread")
+ );
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -251,7 +288,9 @@ describe("sources-tree", () => {
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/", "FakeThread")
+ );
expect(formatTree(tree)).toMatchSnapshot();
});
@@ -284,7 +323,7 @@ describe("sources-tree", () => {
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, "FakeThread"));
expect(formatTree(tree)).toMatchSnapshot();
});
});
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
index 5a9dbcf3e285..ad7dce2985a3 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/collapseTree.spec.js
@@ -8,7 +8,6 @@ import { makeMockSource } from "../../../utils/test-mockup";
import {
collapseTree,
- sortEntireTree,
formatTree,
addToTree,
createDirectoryNode
@@ -22,11 +21,11 @@ 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/", "Main Thread");
expect(fullTree.contents).toHaveLength(1);
const tree = collapseTree(fullTree);
- const host = tree.contents[0];
+ const host = tree.contents[0].contents[0];
expect(host.name).toBe("example.com");
expect(host.contents).toHaveLength(1);
@@ -36,20 +35,17 @@ 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(abcNode.path).toBe("Main Thread/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/", "Main Thread");
+ addToTree(fullTree, abcdeSource, "http://example.com/", "Main Thread");
const tree = collapseTree(fullTree);
- sortEntireTree(tree);
- expect(tree.contents).toHaveLength(1);
-
- const host = tree.contents[0];
+ const host = tree.contents[0].contents[0];
expect(host.name).toBe("example.com");
expect(host.contents).toHaveLength(1);
@@ -59,24 +55,24 @@ describe("sources tree", () => {
const [cdFolder, abcNode] = abFolder.contents;
expect(abcNode.name).toBe("c.js");
- expect(abcNode.path).toBe("example.com/a/b/c.js");
+ expect(abcNode.path).toBe("Main Thread/example.com/a/b/c.js");
expect(cdFolder.name).toBe("c/d");
const [abcdeNode] = cdFolder.contents;
expect(abcdeNode.name).toBe("e.js");
- expect(abcdeNode.path).toBe("example.com/a/b/c/d/e.js");
+ expect(abcdeNode.path).toBe("Main Thread/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/", "Main Thread");
+ addToTree(fullTree, abxSource, "http://example.com/", "Main Thread");
const tree = collapseTree(fullTree);
expect(tree.contents).toHaveLength(1);
- const host = tree.contents[0];
+ const host = tree.contents[0].contents[0];
expect(host.name).toBe("example.com");
expect(host.contents).toHaveLength(1);
@@ -86,21 +82,21 @@ describe("sources tree", () => {
const [abcNode, abxNode] = abFolder.contents;
expect(abcNode.name).toBe("c.js");
- expect(abcNode.path).toBe("example.com/a/b/c.js");
+ expect(abcNode.path).toBe("Main Thread/example.com/a/b/c.js");
expect(abxNode.name).toBe("x.js");
- expect(abxNode.path).toBe("example.com/a/b/x.js");
+ expect(abxNode.path).toBe("Main Thread/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/", "Main Thread");
+ addToTree(fullTree, abcSource, "http://example.com/", "Main Thread");
const tree = collapseTree(fullTree);
expect(tree.contents).toHaveLength(1);
- const host = tree.contents[0];
+ const host = tree.contents[0].contents[0];
expect(host.name).toBe("example.com");
expect(host.contents).toHaveLength(1);
@@ -110,12 +106,12 @@ describe("sources tree", () => {
const [cdFolder, abcNode] = abFolder.contents;
expect(abcNode.name).toBe("c.js");
- expect(abcNode.path).toBe("example.com/a/b/c.js");
+ expect(abcNode.path).toBe("Main Thread/example.com/a/b/c.js");
expect(cdFolder.name).toBe("c/d");
const [abcdeNode] = cdFolder.contents;
expect(abcdeNode.name).toBe("e.js");
- expect(abcdeNode.path).toBe("example.com/a/b/c/d/e.js");
+ expect(abcdeNode.path).toBe("Main Thread/example.com/a/b/c/d/e.js");
expect(formatTree(tree)).toMatchSnapshot();
});
});
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/getDirectories.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/getDirectories.spec.js
index ccc499eae2ee..c3c472fe42d1 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/getDirectories.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/getDirectories.spec.js
@@ -14,11 +14,13 @@ function formatDirectories(source, tree) {
}
function createSources(urls) {
- return urls.reduce((sources, url, index) => {
- const id = `a${index}`;
- sources[id] = makeMockSource(url, id);
- return sources;
- }, {});
+ return {
+ FakeThread: urls.reduce((sources, url, index) => {
+ const id = `a${index}`;
+ sources[id] = makeMockSource(url, id);
+ return sources;
+ }, {})
+ };
}
describe("getDirectories", () => {
@@ -29,14 +31,36 @@ describe("getDirectories", () => {
"http://b/c.js"
]);
+ const threads = [
+ {
+ actor: "FakeThread",
+ url: "http://a",
+ type: 1,
+ name: "FakeThread"
+ }
+ ];
+
const debuggeeUrl = "http://a/";
const { sourceTree } = createTree({
sources,
debuggeeUrl,
- projectRoot: ""
+ threads
});
- expect(formatDirectories(sources.a0, sourceTree)).toEqual(["a/b.js", "a"]);
- expect(formatDirectories(sources.a1, sourceTree)).toEqual(["a/c.js", "a"]);
- expect(formatDirectories(sources.a2, sourceTree)).toEqual(["b/c.js", "b"]);
+
+ expect(formatDirectories(sources.FakeThread.a0, sourceTree)).toEqual([
+ "FakeThread/a/b.js",
+ "FakeThread/a",
+ "FakeThread"
+ ]);
+ expect(formatDirectories(sources.FakeThread.a1, sourceTree)).toEqual([
+ "FakeThread/a/c.js",
+ "FakeThread/a",
+ "FakeThread"
+ ]);
+ expect(formatDirectories(sources.FakeThread.a2, sourceTree)).toEqual([
+ "FakeThread/b/c.js",
+ "FakeThread/b",
+ "FakeThread"
+ ]);
});
});
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js
deleted file mode 100644
index 99cf1c5970e6..000000000000
--- a/devtools/client/debugger/src/utils/sources-tree/tests/sortTree.spec.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/* eslint max-nested-callbacks: ["error", 4]*/
-/* 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 . */
-
-// @flow
-
-import { makeMockSource } from "../../../utils/test-mockup";
-
-import {
- addToTree,
- sortEntireTree,
- createDirectoryNode,
- formatTree
-} from "../index";
-
-describe("sources-tree", () => {
- describe("sortEntireTree", () => {
- it("alphabetically sorts children", () => {
- const source1 = makeMockSource("http://example.com/source1.js", "actor1");
- const source2 = makeMockSource(
- "http://example.com/foo/b_source2.js",
- "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/");
- 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];
- expect(source1Node.name).toBe("source1.js");
-
- // source2 should be after source1 alphabetically
- const source2Node = fooNode.contents[1];
- const source3Node = fooNode.contents[0];
- expect(source2Node.name).toBe("b_source2.js");
- expect(source3Node.name).toBe("a_source3.js");
- expect(formatTree(tree)).toMatchSnapshot();
- });
-
- it("sorts folders first", () => {
- const sources = [
- makeMockSource("http://example.com/a.js", "actor1"),
- makeMockSource("http://example.com/b.js/b_source.js", "actor2"),
- 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/")
- );
- const tree = sortEntireTree(_tree);
- const domain = tree.contents[0];
-
- const [
- indexNode,
- bFolderNode,
- dFolderNode,
- aFileNode,
- b2FileNode,
- cFileNode
- ] = domain.contents;
-
- expect(formatTree(tree)).toMatchSnapshot();
- expect(indexNode.name).toBe("(index)");
- expect(bFolderNode.name).toBe("b.js");
- expect(bFolderNode.contents).toHaveLength(1);
- expect(bFolderNode.contents[0].name).toBe("b_source.js");
-
- expect(b2FileNode.name).toBe("b2");
-
- expect(dFolderNode.name).toBe("d");
- expect(dFolderNode.contents).toHaveLength(1);
- expect(dFolderNode.contents[0].name).toBe("d_source.js");
-
- expect(aFileNode.name).toBe("a.js");
-
- expect(cFileNode.name).toBe("c.js");
- expect(formatTree(tree)).toMatchSnapshot();
- });
-
- it("puts folder at the top of the sort", () => {
- 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/")
- );
- const tree = sortEntireTree(_tree);
- const [
- bFolderNode,
- cFolderNode,
- aFileNode
- ] = tree.contents[0].contents[0].contents;
-
- expect(bFolderNode.name).toBe("b");
- expect(bFolderNode.contents).toHaveLength(1);
- expect(bFolderNode.contents[0].name).toBe("b.js");
-
- expect(cFolderNode.name).toBe("c");
- expect(cFolderNode.contents).toHaveLength(1);
- expect(cFolderNode.contents[0].name).toBe("(index)");
-
- expect(aFileNode.name).toBe("a.js");
- expect(formatTree(tree)).toMatchSnapshot();
- });
-
- it("puts root debugee url at the top of the sort", () => {
- const sources = [
- makeMockSource("http://api.example.com/a.js", "actor1"),
- makeMockSource("http://example.com/b.js", "actor2"),
- 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);
- });
- 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");
- expect(treeB.contents[1].contents[0].name).toBe("a.js");
- expect(formatTree(treeA)).toMatchSnapshot();
- expect(formatTree(treeB)).toMatchSnapshot();
- });
- });
-});
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/updateTree.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/updateTree.spec.js
index bd09adcac8f5..386b177fc866 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/updateTree.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/updateTree.spec.js
@@ -7,7 +7,7 @@
import { makeMockSource } from "../../../utils/test-mockup";
import { updateTree, createTree } from "../index";
-type RawSource = {| url: string, id: string |};
+type RawSource = {| url: string, id: string, actors?: any |};
function createSourcesMap(sources: RawSource[]) {
const sourcesMap = sources.reduce((map, source) => {
@@ -15,7 +15,7 @@ function createSourcesMap(sources: RawSource[]) {
return map;
}, {});
- return sourcesMap;
+ return { FakeThread: sourcesMap };
}
function formatTree(tree) {
@@ -37,25 +37,32 @@ const sources = [
}
];
+const threads = [
+ {
+ actor: "FakeThread",
+ url: "https://davidwalsh.name",
+ type: 1,
+ name: "FakeThread"
+ }
+];
+
const debuggeeUrl = "blah";
describe("calls updateTree.js", () => {
it("adds one source", () => {
const prevSources = createSourcesMap([sources[0]]);
-
const { sourceTree, uncollapsedTree } = createTree({
debuggeeUrl,
sources: prevSources,
- projectRoot: ""
+ threads
});
-
const newTree = updateTree({
debuggeeUrl,
prevSources,
newSources: createSourcesMap([sources[0], sources[1]]),
uncollapsedTree,
sourceTree,
- projectRoot: ""
+ threads
});
expect(formatTree(newTree)).toMatchSnapshot();
@@ -67,7 +74,7 @@ describe("calls updateTree.js", () => {
const { sourceTree, uncollapsedTree } = createTree({
debuggeeUrl,
sources: prevSources,
- projectRoot: ""
+ threads
});
const newTree = updateTree({
@@ -76,7 +83,8 @@ describe("calls updateTree.js", () => {
newSources: createSourcesMap([sources[0], sources[1], sources[2]]),
uncollapsedTree,
sourceTree,
- projectRoot: ""
+ projectRoot: "",
+ threads
});
expect(formatTree(newTree)).toMatchSnapshot();
@@ -90,7 +98,7 @@ describe("calls updateTree.js", () => {
const { sourceTree, uncollapsedTree } = createTree({
debuggeeUrl,
sources: prevSources,
- projectRoot: ""
+ threads
});
const newTree = updateTree({
@@ -99,7 +107,8 @@ describe("calls updateTree.js", () => {
newSources: createSourcesMap([sources[1]]),
uncollapsedTree,
sourceTree,
- projectRoot: ""
+ projectRoot: "",
+ threads
});
expect(formatTree(newTree)).toMatchSnapshot();
diff --git a/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js b/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
index 4169d922a6c1..a6e6129e781d 100644
--- a/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
+++ b/devtools/client/debugger/src/utils/sources-tree/tests/utils.spec.js
@@ -13,7 +13,6 @@ import {
isExactUrlMatch,
isDirectory,
addToTree,
- sortEntireTree,
isNotJavaScript
} from "../index";
@@ -47,9 +46,10 @@ describe("sources tree", () => {
];
const tree = createDirectoryNode("root", "", []);
- sources.forEach(source => addToTree(tree, source, "http://example.com/"));
- sortEntireTree(tree);
- const [bFolderNode, aFileNode] = tree.contents[0].contents;
+ sources.forEach(source =>
+ addToTree(tree, source, "http://example.com/", "Main Thread")
+ );
+ const [bFolderNode, aFileNode] = tree.contents[0].contents[0].contents;
const [cFolderNode] = bFolderNode.contents;
const [dFileNode] = cFolderNode.contents;
diff --git a/devtools/client/debugger/src/utils/sources-tree/updateTree.js b/devtools/client/debugger/src/utils/sources-tree/updateTree.js
index c211ad038fa2..1085abdccd08 100644
--- a/devtools/client/debugger/src/utils/sources-tree/updateTree.js
+++ b/devtools/client/debugger/src/utils/sources-tree/updateTree.js
@@ -6,42 +6,82 @@
import { addToTree } from "./addToTree";
import { collapseTree } from "./collapseTree";
-import { createParentMap } from "./utils";
-import { difference } from "lodash";
+import { createDirectoryNode, createParentMap } from "./utils";
import { getDomain } from "./treeOrder";
-import type { SourcesMap } from "../../reducers/types";
+
+import type { SourcesMapByThread } from "../../reducers/types";
+import type { Thread, Source } from "../../types";
import type { TreeDirectory } from "./types";
-function newSourcesSet(newSources, prevSources) {
- const newSourceIds = difference(
- Object.keys(newSources),
- Object.keys(prevSources)
- );
- const uniqSources = newSourceIds.map(id => newSources[id]);
- return uniqSources;
+function getSourcesToAdd(newSources, prevSources): Source[] {
+ const sourcesToAdd = [];
+
+ for (const sourceId in newSources) {
+ const newSource = newSources[sourceId];
+ const prevSource = prevSources ? prevSources[sourceId] : null;
+ if (!prevSource) {
+ sourcesToAdd.push(newSource);
+ }
+ }
+
+ return sourcesToAdd;
}
-type Params = {
- newSources: SourcesMap,
- prevSources: SourcesMap,
+type UpdateTreeParams = {
+ newSources: SourcesMapByThread,
+ prevSources: SourcesMapByThread,
uncollapsedTree: TreeDirectory,
- sourceTree: TreeDirectory,
- debuggeeUrl: string
+ debuggeeUrl: string,
+ threads: Thread[]
};
+type CreateTreeParams = {
+ sources: SourcesMapByThread,
+ debuggeeUrl: string,
+ threads: Thread[]
+};
+
+export function createTree({
+ debuggeeUrl,
+ sources,
+ threads
+}: CreateTreeParams) {
+ const uncollapsedTree = createDirectoryNode("root", "", []);
+
+ return updateTree({
+ debuggeeUrl,
+ newSources: sources,
+ prevSources: {},
+ threads,
+ uncollapsedTree
+ });
+}
+
export function updateTree({
newSources,
prevSources,
debuggeeUrl,
uncollapsedTree,
- sourceTree
-}: Params) {
- const newSet = newSourcesSet(newSources, prevSources);
+ threads
+}: UpdateTreeParams) {
const debuggeeHost = getDomain(debuggeeUrl);
+ const contexts = (Object.keys(newSources): any);
- for (const source of newSet) {
- addToTree(uncollapsedTree, source, debuggeeHost);
- }
+ contexts.forEach(context => {
+ const thread = threads.find(t => t.actor === context);
+ if (!thread) {
+ return;
+ }
+
+ const sourcesToAdd = getSourcesToAdd(
+ (Object.values(newSources[context]): any),
+ prevSources[context] ? (Object.values(prevSources[context]): any) : null
+ );
+
+ for (const source of sourcesToAdd) {
+ addToTree(uncollapsedTree, source, debuggeeHost, thread.actor);
+ }
+ });
const newSourceTree = collapseTree(uncollapsedTree);
diff --git a/devtools/client/debugger/src/utils/sources-tree/utils.js b/devtools/client/debugger/src/utils/sources-tree/utils.js
index d032a1bd8c89..4cf3dbe47e23 100644
--- a/devtools/client/debugger/src/utils/sources-tree/utils.js
+++ b/devtools/client/debugger/src/utils/sources-tree/utils.js
@@ -13,7 +13,7 @@ import { getURL } from "./getURL";
const IGNORED_URLS = ["debugger eval code", "XStringBundle"];
export function nodeHasChildren(item: TreeNode): boolean {
- return Array.isArray(item.contents) && item.type === "directory";
+ return Array.isArray(item.contents) && item.type == "directory";
}
export function isExactUrlMatch(pathPart: string, debuggeeUrl: string) {
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-asm.js b/devtools/client/debugger/test/mochitest/browser_dbg-asm.js
index 84308de6f930..751710e75ebc 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-asm.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-asm.js
@@ -10,7 +10,7 @@ add_task(async function() {
await waitForSources(dbg, "doc-asm.html", "asm.js");
// Make sure sources appear.
- is(findAllElements(dbg, "sourceNodes").length, 2);
+ is(findAllElements(dbg, "sourceNodes").length, 3);
await selectSource(dbg, "asm.js");
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js b/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js
index df5d8fc3b680..23bf2d0ecfb6 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js
@@ -49,6 +49,9 @@ add_task(async function() {
const extension = await installAndStartExtension();
let dbg = await initDebugger("doc-content-script-sources.html");
+ await clickElement(dbg, "sourceDirectoryLabel", 2);
+
+
await selectContentScriptSources(dbg);
await closeTab(dbg, "content_script.js");
@@ -57,6 +60,9 @@ add_task(async function() {
await dbg.toolbox.destroy();
const toolbox = await openToolboxForTab(gBrowser.selectedTab, "jsdebugger");
dbg = createDebuggerContext(toolbox);
+
+ await clickElement(dbg, "sourceDirectoryLabel", 2);
+
await selectContentScriptSources(dbg);
await addBreakpoint(dbg, "content_script.js", 2);
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js
index 3acb76d39285..5aa9c8b41a3b 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js
@@ -66,8 +66,8 @@ add_task(async function() {
const bundleSrc = findSource(dbg, "bundle.js");
// Check that the original sources appear in the source tree
- await clickElement(dbg, "sourceDirectoryLabel", 3);
- await assertSourceCount(dbg, 8);
+ await clickElement(dbg, "sourceDirectoryLabel", 4);
+ await assertSourceCount(dbg, 9);
await selectSource(dbg, bundleSrc);
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sources-arrow-keys.js b/devtools/client/debugger/test/mochitest/browser_dbg-sources-arrow-keys.js
index 286e618f191a..2f3decdab5dc 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-sources-arrow-keys.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-sources-arrow-keys.js
@@ -5,8 +5,8 @@
add_task(async function() {
const dbg = await initDebugger("doc-sources.html", "simple1", "simple2", "nested-source", "long.js");
- await clickElement(dbg, "sourceDirectoryLabel", 2);
- await assertSourceCount(dbg, 7);
+ await clickElement(dbg, "sourceDirectoryLabel", 3);
+ await assertSourceCount(dbg, 8);
// Right key on open dir
await pressKey(dbg, "Right");
@@ -15,12 +15,12 @@ add_task(async function() {
// Right key on closed dir
await pressKey(dbg, "Right");
await assertSourceCount(dbg, 8);
- await assertNodeIsFocused(dbg, 3);
+ await assertNodeIsFocused(dbg, 4);
// Left key on a open dir
await pressKey(dbg, "Left");
- await assertSourceCount(dbg, 7);
- await assertNodeIsFocused(dbg, 3);
+ await assertSourceCount(dbg, 8);
+ await assertNodeIsFocused(dbg, 4);
// Down key on a closed dir
await pressKey(dbg, "Down");
@@ -28,32 +28,33 @@ add_task(async function() {
// Right key on a source
await pressKey(dbg, "Right");
- await assertNodeIsFocused(dbg, 5);
+ await assertNodeIsFocused(dbg, 4);
// Down key on a source
+ await waitForSourceCount(dbg, 9);
await pressKey(dbg, "Down");
- await assertNodeIsFocused(dbg, 6);
+ await assertNodeIsFocused(dbg, 5);
// Go to bottom of tree and press down key
await pressKey(dbg, "Down");
await pressKey(dbg, "Down");
- await assertNodeIsFocused(dbg, 7);
+ await assertNodeIsFocused(dbg, 6);
// Up key on a source
await pressKey(dbg, "Up");
- await assertNodeIsFocused(dbg, 6);
+ await assertNodeIsFocused(dbg, 5);
// Left key on a source
await pressKey(dbg, "Left");
- await assertNodeIsFocused(dbg, 2);
+ await assertNodeIsFocused(dbg, 4);
// Left key on a closed dir
await pressKey(dbg, "Left");
- await assertSourceCount(dbg, 2);
+ await assertSourceCount(dbg, 8);
await pressKey(dbg, "Left");
- await assertNodeIsFocused(dbg, 1);
+ await assertNodeIsFocused(dbg, 3);
// Up Key at the top of the source tree
await pressKey(dbg, "Up");
- await assertNodeIsFocused(dbg, 1);
+ await assertNodeIsFocused(dbg, 2);
});
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sources.js b/devtools/client/debugger/test/mochitest/browser_dbg-sources.js
index f6d73bb0b4c5..93941b5afe86 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-sources.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-sources.js
@@ -18,15 +18,15 @@ add_task(async function() {
} = dbg;
// Expand nodes and make sure more sources appear.
- await assertSourceCount(dbg, 2);
- await clickElement(dbg, "sourceDirectoryLabel", 2);
-
- await assertSourceCount(dbg, 7);
+ await assertSourceCount(dbg, 3);
await clickElement(dbg, "sourceDirectoryLabel", 3);
+
await assertSourceCount(dbg, 8);
+ await clickElement(dbg, "sourceDirectoryLabel", 4);
+ await assertSourceCount(dbg, 9);
const selected = waitForDispatch(dbg, "SET_SELECTED_LOCATION");
- await clickElement(dbg, "sourceNode", 4);
+ await clickElement(dbg, "sourceNode", 5);
await selected;
await waitForSelectedSource(dbg);
@@ -34,12 +34,12 @@ add_task(async function() {
await waitForElementWithSelector(dbg, ".sources-list .focused");
const focusedNode = findElementWithSelector(dbg, ".sources-list .focused");
- const fourthNode = findElement(dbg, "sourceNode", 4);
+ const fourthNode = findElement(dbg, "sourceNode", 5);
const selectedSource = getSelectedSource().url;
ok(fourthNode.classList.contains("focused"), "4th node is focused");
ok(selectedSource.includes("nested-source.js"), "nested-source is selected");
- await assertNodeIsFocused(dbg, 4);
+ await assertNodeIsFocused(dbg, 5);
await waitForSelectedSource(dbg, "nested-source");
// Make sure new sources appear in the list.
@@ -49,10 +49,10 @@ add_task(async function() {
content.document.body.appendChild(script);
});
- await waitForSourceCount(dbg, 9);
- await assertNodeIsFocused(dbg, 4);
+ await waitForSourceCount(dbg, 10);
+ await assertNodeIsFocused(dbg, 5);
is(
- getSourceNodeLabel(dbg, 7),
+ getSourceNodeLabel(dbg, 8),
"math.min.js",
"math.min.js - The dynamic script exists"
);
diff --git a/devtools/client/framework/test/test_browser_toolbox_debugger.js b/devtools/client/framework/test/test_browser_toolbox_debugger.js
index f06f56988677..3512b1dbd2e8 100644
--- a/devtools/client/framework/test/test_browser_toolbox_debugger.js
+++ b/devtools/client/framework/test/test_browser_toolbox_debugger.js
@@ -15,12 +15,11 @@ info(`START: ${new Error().lineNumber}`);
const document = window.document;
await waitForSources(dbg, testUrl);
-// yield waitForSourceCount(dbg, 6);
info("Loaded, selecting the test script to debug");
// First expand the domain
const domain = [...document.querySelectorAll(".tree-node")].find(node => {
- return node.textContent.trim() == "mozilla.org";
+ return node.querySelector(".label").textContent.trim() == "mozilla.org";
});
const arrow = domain.querySelector(".arrow");
arrow.click();