зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1602440 - [devtools] Use actor instead of url for worker targets r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D98074
This commit is contained in:
Родитель
dd7de907be
Коммит
d8a1890e91
|
@ -306,8 +306,8 @@ export function newGeneratedSources(sourceInfo: Array<GeneratedSourceData>) {
|
|||
const newSourcesObj = {};
|
||||
const newSourceActors: Array<SourceActor> = [];
|
||||
|
||||
for (const { thread, isServiceWorker, source, id } of sourceInfo) {
|
||||
const newId = id || makeSourceId(source, isServiceWorker);
|
||||
for (const { thread, isWorkerTarget, source, id } of sourceInfo) {
|
||||
const newId = id || makeSourceId(source, isWorkerTarget);
|
||||
|
||||
if (!getSource(getState(), newId) && !newSourcesObj[newId]) {
|
||||
newSourcesObj[newId] = {
|
||||
|
|
|
@ -20,7 +20,7 @@ export function prepareSourcePayload(
|
|||
threadFront: ThreadFront,
|
||||
source: SourcePayload
|
||||
): GeneratedSourceData {
|
||||
const { isServiceWorker } = threadFront.parentFront;
|
||||
const { isWorkerTarget } = threadFront.parentFront;
|
||||
|
||||
// We populate the set of sources as soon as we hear about them. Note that
|
||||
// this means that we have seen an actor, but it might still be in the
|
||||
|
@ -28,7 +28,7 @@ export function prepareSourcePayload(
|
|||
// a source actor with this ID yet.
|
||||
clientCommands.registerSourceActor(
|
||||
source.actor,
|
||||
makeSourceId(source, isServiceWorker)
|
||||
makeSourceId(source, isWorkerTarget)
|
||||
);
|
||||
|
||||
source = { ...source };
|
||||
|
@ -44,7 +44,11 @@ export function prepareSourcePayload(
|
|||
delete (source: any).introductionUrl;
|
||||
}
|
||||
|
||||
return { thread: threadFront.actor, isServiceWorker, source };
|
||||
return {
|
||||
thread: threadFront.actor,
|
||||
isWorkerTarget,
|
||||
source,
|
||||
};
|
||||
}
|
||||
|
||||
export function createFrame(
|
||||
|
@ -77,13 +81,12 @@ export function createFrame(
|
|||
};
|
||||
}
|
||||
|
||||
export function makeSourceId(source: SourcePayload, isServiceWorker: boolean) {
|
||||
export function makeSourceId(source: SourcePayload, isWorkerTarget: boolean) {
|
||||
// Source actors with the same URL will be given the same source ID and
|
||||
// grouped together under the same source in the client. There is an exception
|
||||
// for sources from service workers, where there may be multiple service
|
||||
// worker threads running at the same time which use different versions of the
|
||||
// same URL.
|
||||
return source.url && !isServiceWorker
|
||||
// for sources from workers, where there may be multiple worker threads running
|
||||
// at the same time which use different versions of the same URL.
|
||||
return source.url && !isWorkerTarget
|
||||
? `sourceURL-${source.url}`
|
||||
: `source-${source.actor}`;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ export type Target = {
|
|||
chrome: boolean,
|
||||
url: URL,
|
||||
isParentProcess: boolean,
|
||||
isServiceWorker: boolean,
|
||||
isWorkerTarget: boolean,
|
||||
targetForm: Object,
|
||||
reconfigure: Object,
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ export type OriginalSourceData = {|
|
|||
export type GeneratedSourceData = {
|
||||
thread: ThreadId,
|
||||
source: SourcePayload,
|
||||
isServiceWorker: boolean,
|
||||
isWorkerTarget: boolean,
|
||||
|
||||
// Many of our tests rely on being able to set a specific ID for the Source
|
||||
// object. We may want to consider avoiding that eventually.
|
||||
|
|
|
@ -159,7 +159,7 @@ function createMakeSource(): (
|
|||
isBlackBoxed: !!props.isBlackBoxed,
|
||||
extensionName: null,
|
||||
},
|
||||
isServiceWorker: false,
|
||||
isWorkerTarget: false,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ skip-if = os == 'linux' && !asan # bug 1447118
|
|||
[browser_dbg-sources-arrow-keys.js]
|
||||
[browser_dbg-sources-named-eval.js]
|
||||
[browser_dbg-sources-querystring.js]
|
||||
[browser_dbg-sources-same-urls.js]
|
||||
skip-if = true
|
||||
[browser_dbg-stepping.js]
|
||||
skip-if = debug || (verify && (os == 'win')) || (os == "win" && os_version == "6.1")
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
// Tests that the source tree with multiple worker threads which use
|
||||
// different versions of the same url select source nodes correctly.
|
||||
|
||||
add_task(async function () {
|
||||
const dbg = await initDebugger(
|
||||
"doc-sources-multiple-workers.html",
|
||||
"shared-worker",
|
||||
"simple-worker",
|
||||
"simple-worker",
|
||||
);
|
||||
|
||||
const {
|
||||
selectors: { getSelectedSource },
|
||||
getState,
|
||||
} = dbg;
|
||||
|
||||
// Make sure all the sources are loaded
|
||||
/*
|
||||
* The output looks like the following:
|
||||
* =====================================
|
||||
* ▼[Main Thread]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* ▶︎[shared-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
*/
|
||||
await assertSourceCount(dbg, 6);
|
||||
|
||||
// Expand the shared worker source.
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 4);
|
||||
await assertSourceCount(dbg, 8);
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 6);
|
||||
/*
|
||||
* The output looks like the following:
|
||||
* =====================================
|
||||
* ▼[Main Thread]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* ▶︎[shared-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [shared-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
*/
|
||||
await assertSourceCount(dbg, 9);
|
||||
|
||||
// Expand the first simple worker source
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 8);
|
||||
await assertSourceCount(dbg, 11);
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 10);
|
||||
/*
|
||||
* The output looks like the following:
|
||||
* =====================================
|
||||
* ▼[Main Thread]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* ▶︎[shared-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [shared-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [simple-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
*/
|
||||
await assertSourceCount(dbg, 12);
|
||||
|
||||
// Expand the second simple worker source
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 12);
|
||||
await assertSourceCount(dbg, 14);
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 14);
|
||||
/*
|
||||
* The output looks like the following:
|
||||
* =====================================
|
||||
* ▼[Main Thread]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* ▶︎[shared-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [shared-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [simple-worker.js]
|
||||
* ▶︎[simple-worker.js]
|
||||
* | ▼[example.com]
|
||||
* | | ▶︎[browser/.../examples]
|
||||
* | | | [simple-worker.js]
|
||||
*/
|
||||
await assertSourceCount(dbg, 15);
|
||||
|
||||
// Select the shared worker source
|
||||
const selectedSharedWorkerSource = waitForDispatch(dbg, "SET_FOCUSED_SOURCE_ITEM");
|
||||
await clickElement(dbg, "sourceNode", 7);
|
||||
await selectedSharedWorkerSource;
|
||||
const sharedWorkerSource = getSelectedSource().url;
|
||||
ok(sharedWorkerSource.includes("shared-worker.js"), "shared worker source is selected");
|
||||
|
||||
// Select the second simple worker source
|
||||
const selectedSimpleWorkerSource = waitForDispatch(dbg, "SET_FOCUSED_SOURCE_ITEM");
|
||||
await clickElement(dbg, "sourceNode", 15);
|
||||
await selectedSimpleWorkerSource;
|
||||
|
||||
// Assert that the correct simple worker source is selected
|
||||
const firstSimpleWorkerSourceNode = findElement(dbg, "sourceNode", 11);
|
||||
ok(!firstSimpleWorkerSourceNode.classList.contains("focused"),
|
||||
`The first simple worker source is not selected`);
|
||||
|
||||
const secondSimpleWorkerSourceNode = findElement(dbg, "sourceNode", 15);
|
||||
ok(secondSimpleWorkerSourceNode.classList.contains("focused"),
|
||||
`The second simple worker source is selected`);
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Debugger test page with Web worker scripts</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const a = new Worker('shared-worker.js');
|
||||
const b = new Worker('simple-worker.js');
|
||||
const c = new Worker('simple-worker.js');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче