1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * Tests request details with HTTP/3
10 add_task(async
function () {
11 const { monitor
} = await
initNetMonitor(HTTPS_SIMPLE_SJS
, {
14 info("Starting test... ");
16 const { document
, store
, windowRequire
} = monitor
.panelWin
;
17 const Actions
= windowRequire("devtools/client/netmonitor/src/actions/index");
19 store
.dispatch(Actions
.batchEnable(false));
21 const wait
= waitForNetworkEvents(monitor
, 1);
22 await
reloadBrowser();
25 const waitForHeaders
= waitForDOM(document
, ".headers-overview");
26 store
.dispatch(Actions
.toggleNetworkDetails());
29 info("Assert the content of the headers");
31 const tabpanel
= document
.querySelector("#headers-panel");
34 tabpanel
.querySelector(".url-preview .url").innerText
,
36 "The url summary value is incorrect."
41 tabpanel
.querySelectorAll(".treeLabel")[0].innerText
,
43 "The method summary value is incorrect."
47 tabpanel
.querySelector(".requests-list-status-code").innerText
,
49 "The status summary code is incorrect."
52 tabpanel
.querySelector(".status").childNodes
[1].textContent
,
53 "", // HTTP/2 and 3 send no status text, only a code
54 "The status summary value is incorrect."
58 tabpanel
.querySelectorAll(".tabpanel-summary-value")[1].innerText
,
60 "The HTTP version is incorrect."
63 await
waitForRequestData(store
, ["requestHeaders", "responseHeaders"]);
66 tabpanel
.querySelectorAll(".accordion-item").length
,
68 "There should be 2 header scopes displayed in this tabpanel."
71 const headers
= [...tabpanel
.querySelectorAll(".accordion .treeLabelCell")];
74 // The Text-Encoding header is not consistently displayed, exclude it from
75 // the assertion. See Bug 1830053.
76 headers
.filter(cell
=> cell
.textContent
!= "TE").length
,
78 "There should be 26 header values displayed in this tabpanel."
81 const headersTable
= tabpanel
.querySelector(".accordion");
82 const responseHeaders
= headersTable
.querySelectorAll(
83 "tr[id^='/Response Headers']"
86 const expectedHeaders
= [
88 name
: "cache-control",
89 value
: "no-cache, no-store, must-revalidate",
93 name
: "content-length",
99 value
: "text/plain; charset=utf-8",
108 expectedHeaders
.forEach(header
=> {
110 responseHeaders
[header
.index
].querySelector(".treeLabel").innerHTML
,
112 `The response header at index ${header.index} name was incorrect.`
115 responseHeaders
[header
.index
].querySelector(".objectBox").innerHTML
,
117 `The response header at index ${header.index} value was incorrect.`
121 info("Assert the content of the raw headers");
123 // Click the 'Raw headers' toggle to show original headers source.
124 document
.querySelector("#raw-request-checkbox").click();
125 document
.querySelector("#raw-response-checkbox").click();
127 let rawHeadersElements
;
128 await
waitUntil(() => {
129 rawHeadersElements
= document
.querySelectorAll("textarea.raw-headers");
130 // Both raw headers must be present
131 return rawHeadersElements
.length
> 1;
133 const requestHeadersText
= rawHeadersElements
[1].textContent
;
134 const rawRequestHeaderFirstLine
= requestHeadersText
.split(/\r\n|\n|\r/)[0];
136 rawRequestHeaderFirstLine
,
137 "GET /browser/devtools/client/netmonitor/test/sjs_simple-test-server.sjs HTTP/3"
140 const responseHeadersText
= rawHeadersElements
[0].textContent
;
141 const rawResponseHeaderFirstLine
= responseHeadersText
.split(/\r\n|\n|\r/)[0];
142 is(rawResponseHeaderFirstLine
, "HTTP/3 200 "); // H2/3 send no status text
144 info("Assert the content of the protocol column");
145 const target
= document
.querySelectorAll(".request-list-item")[0];
147 target
.querySelector(".requests-list-protocol").textContent
,
149 "The displayed protocol is correct."
152 return teardown(monitor
);