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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Verify that toolbox remains open when opening and closing RDM.
const TEST_URL = "http://example.com/";
function getServerConnections(browser) {
ok(browser.isRemoteBrowser, "Content browser is remote");
return ContentTask.spawn(browser, {}, function* () {
const Cu = Components.utils;
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main");
if (!DebuggerServer._connections) {
return 0;
}
return Object.getOwnPropertyNames(DebuggerServer._connections);
});
}
let checkServerConnectionCount = Task.async(function* (browser, expected, msg) {
let conns = yield getServerConnections(browser);
is(conns.length || 0, expected, "Server connection count: " + msg);
});
let checkToolbox = Task.async(function* (tab, location) {
let target = TargetFactory.forTab(tab);
ok(!!gDevTools.getToolbox(target), `Toolbox exists ${location}`);
});
add_task(function* setup() {
yield SpecialPowers.pushPrefEnv({
set: [["dom.ipc.processCount", 1]]
});
});
add_task(function* () {
let tab = yield addTab(TEST_URL);
let tabsInDifferentProcesses = E10S_MULTI_ENABLED &&
(gBrowser.tabs[0].linkedBrowser.frameLoader.childID !=
gBrowser.tabs[1].linkedBrowser.frameLoader.childID);
info("Open toolbox outside RDM");
{
// 0: No DevTools connections yet
yield checkServerConnectionCount(tab.linkedBrowser, 0,
"0: No DevTools connections yet");
let { toolbox } = yield openInspector();
if (tabsInDifferentProcesses) {
// 1: Two tabs open, but only one per content process
yield checkServerConnectionCount(tab.linkedBrowser, 1,
"1: Two tabs open, but only one per content process");
} else {
// 2: One for each tab (starting tab plus the one we opened)
yield checkServerConnectionCount(tab.linkedBrowser, 2,
"2: One for each tab (starting tab plus the one we opened)");
}
yield checkToolbox(tab, "outside RDM");
let { ui } = yield openRDM(tab);
if (tabsInDifferentProcesses) {
// 2: RDM UI adds an extra connection, 1 + 1 = 2
yield checkServerConnectionCount(ui.getViewportBrowser(), 2,
"2: RDM UI uses an extra connection");
} else {
// 3: RDM UI adds an extra connection, 2 + 1 = 3
yield checkServerConnectionCount(ui.getViewportBrowser(), 3,
"3: RDM UI uses an extra connection");
}
yield checkToolbox(tab, "after opening RDM");
yield closeRDM(tab);
if (tabsInDifferentProcesses) {
// 1: RDM UI closed, return to previous connection count
yield checkServerConnectionCount(tab.linkedBrowser, 1,
"1: RDM UI closed, return to previous connection count");
} else {
// 2: RDM UI closed, return to previous connection count
yield checkServerConnectionCount(tab.linkedBrowser, 2,
"2: RDM UI closed, return to previous connection count");
}
yield checkToolbox(tab, tab.linkedBrowser, "after closing RDM");
yield toolbox.destroy();
// 0: All DevTools usage closed
yield checkServerConnectionCount(tab.linkedBrowser, 0,
"0: All DevTools usage closed");
}
info("Open toolbox inside RDM");
{
// 0: No DevTools connections yet
yield checkServerConnectionCount(tab.linkedBrowser, 0,
"0: No DevTools connections yet");
let { ui } = yield openRDM(tab);
// 1: RDM UI uses an extra connection
yield checkServerConnectionCount(ui.getViewportBrowser(), 1,
"1: RDM UI uses an extra connection");
let { toolbox } = yield openInspector();
if (tabsInDifferentProcesses) {
// 2: Two tabs open, but only one per content process
yield checkServerConnectionCount(ui.getViewportBrowser(), 2,
"2: Two tabs open, but only one per content process");
} else {
// 3: One for each tab (starting tab plus the one we opened)
yield checkServerConnectionCount(ui.getViewportBrowser(), 3,
"3: One for each tab (starting tab plus the one we opened)");
}
yield checkToolbox(tab, ui.getViewportBrowser(), "inside RDM");
yield closeRDM(tab);
if (tabsInDifferentProcesses) {
// 1: RDM UI closed, one less connection
yield checkServerConnectionCount(tab.linkedBrowser, 1,
"1: RDM UI closed, one less connection");
} else {
// 2: RDM UI closed, one less connection
yield checkServerConnectionCount(tab.linkedBrowser, 2,
"2: RDM UI closed, one less connection");
}
yield checkToolbox(tab, tab.linkedBrowser, "after closing RDM");
yield toolbox.destroy();
// 0: All DevTools usage closed
yield checkServerConnectionCount(tab.linkedBrowser, 0,
"0: All DevTools usage closed");
}
yield removeTab(tab);
});
|