Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / netmonitor / test / browser_net_http3_request_details.js
blob6a6c5973c937c41a2d42651beda76d92136b89dc
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Tests request details with HTTP/3
8 */
10 add_task(async function () {
11 const { monitor } = await initNetMonitor(HTTPS_SIMPLE_SJS, {
12 requestCount: 1,
13 });
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();
23 await wait;
25 const waitForHeaders = waitForDOM(document, ".headers-overview");
26 store.dispatch(Actions.toggleNetworkDetails());
27 await waitForHeaders;
29 info("Assert the content of the headers");
31 const tabpanel = document.querySelector("#headers-panel");
32 // Request URL
33 is(
34 tabpanel.querySelector(".url-preview .url").innerText,
35 HTTPS_SIMPLE_SJS,
36 "The url summary value is incorrect."
39 // Request method
40 is(
41 tabpanel.querySelectorAll(".treeLabel")[0].innerText,
42 "GET",
43 "The method summary value is incorrect."
45 // Status code
46 is(
47 tabpanel.querySelector(".requests-list-status-code").innerText,
48 "200",
49 "The status summary code is incorrect."
51 is(
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."
56 // Version
57 is(
58 tabpanel.querySelectorAll(".tabpanel-summary-value")[1].innerText,
59 "HTTP/3",
60 "The HTTP version is incorrect."
63 await waitForRequestData(store, ["requestHeaders", "responseHeaders"]);
65 is(
66 tabpanel.querySelectorAll(".accordion-item").length,
68 "There should be 2 header scopes displayed in this tabpanel."
71 const headers = [...tabpanel.querySelectorAll(".accordion .treeLabelCell")];
73 is(
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,
77 26,
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",
90 index: 0,
93 name: "content-length",
94 value: "12",
95 index: 1,
98 name: "content-type",
99 value: "text/plain; charset=utf-8",
100 index: 2,
103 name: "foo-bar",
104 value: "baz",
105 index: 6,
108 expectedHeaders.forEach(header => {
110 responseHeaders[header.index].querySelector(".treeLabel").innerHTML,
111 header.name,
112 `The response header at index ${header.index} name was incorrect.`
115 responseHeaders[header.index].querySelector(".objectBox").innerHTML,
116 `${header.value}`,
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,
148 "HTTP/3",
149 "The displayed protocol is correct."
152 return teardown(monitor);