1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function () {
const thisFirefoxClient = createThisFirefoxClientMock();
// Prepare a worker mock.
const testWorker = {
id: "test-worker-id",
name: "Test Worker",
};
// Add a worker mock as other worker.
thisFirefoxClient.listWorkers = () => ({
otherWorkers: [testWorker],
serviceWorkers: [],
sharedWorkers: [],
});
thisFirefoxClient.client.mainRoot = {
getWorker: id => {
return id === testWorker.id ? testWorker : null;
},
};
const runtimeClientFactoryMock = createRuntimeClientFactoryMock();
runtimeClientFactoryMock.createClientForRuntime = runtime => {
const {
RUNTIMES,
} = require("resource://devtools/client/aboutdebugging/src/constants.js");
if (runtime.id === RUNTIMES.THIS_FIREFOX) {
return thisFirefoxClient;
}
throw new Error("Unexpected runtime id " + runtime.id);
};
info("Enable mocks");
enableRuntimeClientFactoryMock(runtimeClientFactoryMock);
registerCleanupFunction(() => {
disableRuntimeClientFactoryMock();
});
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
info("Open a toolbox to debug the worker");
const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
document,
tab,
window,
testWorker.name,
false
);
info(
"Check whether the correct actor front will be opened in worker toolbox"
);
const url = new window.URL(devtoolsWindow.location.href);
const workerID = url.searchParams.get("id");
is(
workerID,
testWorker.id,
"Correct actor front will be opened in worker toolbox"
);
await removeTab(devtoolsTab);
await waitUntil(() => !findDebugTargetByText("Toolbox - ", document));
await removeTab(tab);
});
|