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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if requests render correct information in the details UI.
*/
function test() {
initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
info("Starting test... ");
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
let { RequestsMenu, NetworkDetails } = NetMonitorView;
RequestsMenu.lazyUpdate = false;
waitForNetworkEvents(aMonitor, 1).then(() => {
is(RequestsMenu.selectedItem, null,
"There shouldn't be any selected item in the requests menu.");
is(RequestsMenu.itemCount, 1,
"The requests menu should not be empty after the first request.");
is(NetMonitorView.detailsPaneHidden, true,
"The details pane should still be hidden after the first request.");
EventUtils.sendMouseEvent({ type: "mousedown" },
document.getElementById("details-pane-toggle"));
isnot(RequestsMenu.selectedItem, null,
"There should be a selected item in the requests menu.");
is(RequestsMenu.selectedIndex, 0,
"The first item should be selected in the requests menu.");
is(NetMonitorView.detailsPaneHidden, false,
"The details pane should not be hidden after toggle button was pressed.");
testHeadersTab();
testCookiesTab();
testParamsTab();
testResponseTab()
.then(() => {
testTimingsTab();
return teardown(aMonitor);
})
.then(finish);
});
function testHeadersTab() {
let tab = document.querySelectorAll("#details-pane tab")[0];
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
is(tab.getAttribute("selected"), "true",
"The headers tab in the network details pane should be selected.");
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
SIMPLE_SJS, "The url summary value is incorrect.");
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"),
SIMPLE_SJS, "The url summary tooltiptext is incorrect.");
is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
"GET", "The method summary value is incorrect.");
is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
"200", "The status summary code is incorrect.");
is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
"200 Och Aye", "The status summary value is incorrect.");
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
"There should be 2 header scopes displayed in this tabpanel.");
ok(tabpanel.querySelectorAll(".variable-or-property").length >= 12,
"There should be at least 12 header values displayed in this tabpanel.");
// Can't test for an exact total number of headers, because it seems to
// vary across pgo/non-pgo builds.
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
"The empty notice should not be displayed in this tabpanel.");
let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
is(responseScope.querySelector(".name").getAttribute("value"),
L10N.getStr("responseHeaders") + " (" +
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(173/1024, 3)) + ")",
"The response headers scope doesn't have the correct title.");
ok(requestScope.querySelector(".name").getAttribute("value").contains(
L10N.getStr("requestHeaders") + " (0"),
"The request headers scope doesn't have the correct title.");
// Can't test for full request headers title because the size may
// vary across platforms ("User-Agent" header differs). We're pretty
// sure it's smaller than 1 MB though, so it starts with a 0.
is(responseScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
"Connection", "The first response header name was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
"\"close\"", "The first response header value was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
"Content-Length", "The second response header name was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
"\"12\"", "The second response header value was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
"Content-Type", "The third response header name was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
"\"text/plain; charset=utf-8\"", "The third response header value was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .name")[5].getAttribute("value"),
"foo-bar", "The last response header name was incorrect.");
is(responseScope.querySelectorAll(".variables-view-variable .value")[5].getAttribute("value"),
"\"baz\"", "The last response header value was incorrect.");
is(requestScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
"Host", "The first request header name was incorrect.");
is(requestScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
"\"example.com\"", "The first request header value was incorrect.");
is(requestScope.querySelectorAll(".variables-view-variable .name")[5].getAttribute("value"),
"Connection", "The penultimate request header name was incorrect.");
is(requestScope.querySelectorAll(".variables-view-variable .value")[5].getAttribute("value"),
"\"keep-alive\"", "The penultimate request header value was incorrect.");
let lastReqHeaderName = requestScope.querySelectorAll(".variables-view-variable .name")[6];
let lastReqHeaderValue = requestScope.querySelectorAll(".variables-view-variable .value")[6];
if (lastReqHeaderName && lastReqHeaderValue) {
is(lastReqHeaderName.getAttribute("value"),
"Cache-Control", "The last request header name was incorrect.");
is(lastReqHeaderValue.getAttribute("value"),
"\"max-age=0\"", "The last request header value was incorrect.");
} else {
info("The number of request headers was 6 instead of 7. Technically, " +
"not a failure in this particular test, but needs investigation.");
}
}
function testCookiesTab() {
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll("#details-pane tab")[1]);
let tab = document.querySelectorAll("#details-pane tab")[1];
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1];
is(tab.getAttribute("selected"), "true",
"The cookies tab in the network details pane should be selected.");
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
"There should be no cookie scopes displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
"There should be no cookie values displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
"The empty notice should be displayed in this tabpanel.");
}
function testParamsTab() {
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll("#details-pane tab")[2]);
let tab = document.querySelectorAll("#details-pane tab")[2];
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
is(tab.getAttribute("selected"), "true",
"The params tab in the network details pane should be selected.");
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
"There should be no param scopes displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
"There should be no param values displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
"The empty notice should be displayed in this tabpanel.");
is(tabpanel.querySelector("#request-params-box")
.hasAttribute("hidden"), false,
"The request params box should not be hidden.");
is(tabpanel.querySelector("#request-post-data-textarea-box")
.hasAttribute("hidden"), true,
"The request post data textarea box should be hidden.");
}
function testResponseTab() {
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll("#details-pane tab")[3]);
let tab = document.querySelectorAll("#details-pane tab")[3];
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
is(tab.getAttribute("selected"), "true",
"The response tab in the network details pane should be selected.");
is(tabpanel.querySelector("#response-content-info-header")
.hasAttribute("hidden"), true,
"The response info header should be hidden.");
is(tabpanel.querySelector("#response-content-json-box")
.hasAttribute("hidden"), true,
"The response content json box should be hidden.");
is(tabpanel.querySelector("#response-content-textarea-box")
.hasAttribute("hidden"), false,
"The response content textarea box should not be hidden.");
is(tabpanel.querySelector("#response-content-image-box")
.hasAttribute("hidden"), true,
"The response content image box should be hidden.");
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
is(aEditor.getText(), "Hello world!",
"The text shown in the source editor is incorrect.");
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
"The mode active in the source editor is incorrect.");
});
}
function testTimingsTab() {
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll("#details-pane tab")[4]);
let tab = document.querySelectorAll("#details-pane tab")[4];
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4];
is(tab.getAttribute("selected"), "true",
"The timings tab in the network details pane should be selected.");
ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The blocked timing info does not appear to be correct.");
ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The dns timing info does not appear to be correct.");
ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The connect timing info does not appear to be correct.");
ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The send timing info does not appear to be correct.");
ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The wait timing info does not appear to be correct.");
ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total")
.getAttribute("value").match(/[0-9]+/),
"The receive timing info does not appear to be correct.");
}
aDebuggee.location.reload();
});
}
|