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
69
70
71
72
73
74
75
76
77
78
79
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests devtools API
var toolbox;
function test() {
addTab("about:blank").then(async function () {
loadWebConsole().then(function () {
console.log("loaded");
});
});
}
function loadWebConsole() {
ok(gDevTools, "gDevTools exists");
const tab = gBrowser.selectedTab;
return gDevTools
.showToolboxForTab(tab, { toolId: "webconsole" })
.then(function (aToolbox) {
toolbox = aToolbox;
checkToolLoading();
});
}
function checkToolLoading() {
is(toolbox.currentToolId, "webconsole", "The web console is selected");
ok(toolbox.isReady, "toolbox is ready");
selectAndCheckById("jsdebugger").then(function () {
selectAndCheckById("styleeditor").then(function () {
testToggle();
});
});
}
function selectAndCheckById(id) {
return toolbox.selectTool(id).then(function () {
const tab = toolbox.doc.getElementById("toolbox-tab-" + id);
is(
tab.classList.contains("selected"),
true,
"The " + id + " tab is selected"
);
is(
tab.getAttribute("aria-pressed"),
"true",
"The " + id + " tab is pressed"
);
});
}
function testToggle() {
toolbox.once("destroyed", async () => {
// Cannot reuse a target after it's destroyed.
gDevTools
.showToolboxForTab(gBrowser.selectedTab, { toolId: "styleeditor" })
.then(function (aToolbox) {
toolbox = aToolbox;
is(
toolbox.currentToolId,
"styleeditor",
"The style editor is selected"
);
finishUp();
});
});
toolbox.destroy();
}
function finishUp() {
toolbox.destroy().then(function () {
toolbox = null;
gBrowser.removeCurrentTab();
finish();
});
}
|