Backed out 2 changesets (bug 1943998) for causing wd failures @ phases.py CLOSED...
[gecko.git] / devtools / client / netmonitor / test / browser_net_req-resp-bodies.js
blob49d9bbd2b265fc0101449a3e9dc2b2644ca3bdd2
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Test if request and response body logging stays on after opening the console.
8 */
10 add_task(async function () {
11 const {
12 L10N,
13 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
15 const { tab, monitor } = await initNetMonitor(JSON_LONG_URL, {
16 requestCount: 1,
17 });
18 info("Starting test... ");
20 const { document, store, windowRequire } = monitor.panelWin;
21 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
22 const { getDisplayedRequests, getSortedRequests } = windowRequire(
23 "devtools/client/netmonitor/src/selectors/index"
26 store.dispatch(Actions.batchEnable(false));
28 // Perform first batch of requests.
29 await performRequests(monitor, tab, 1);
31 await verifyRequest(0);
33 // Switch to the webconsole.
34 const onWebConsole = monitor.toolbox.once("webconsole-selected");
35 monitor.toolbox.selectTool("webconsole");
36 await onWebConsole;
38 // Switch back to the netmonitor.
39 const onNetMonitor = monitor.toolbox.once("netmonitor-selected");
40 monitor.toolbox.selectTool("netmonitor");
41 await onNetMonitor;
43 // Reload debugee.
44 const wait = waitForNetworkEvents(monitor, 1);
45 await reloadBrowser();
46 await wait;
48 // Perform another batch of requests.
49 await performRequests(monitor, tab, 1);
51 await verifyRequest(1);
53 return teardown(monitor);
55 async function verifyRequest(index) {
56 const requestItems = document.querySelectorAll(".request-list-item");
57 for (const requestItem of requestItems) {
58 requestItem.scrollIntoView();
59 const requestsListStatus = requestItem.querySelector(".status-code");
60 EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus);
61 await waitUntil(() => requestsListStatus.title);
62 await waitForDOMIfNeeded(requestItem, ".requests-list-timings-total");
64 verifyRequestItemTarget(
65 document,
66 getDisplayedRequests(store.getState()),
67 getSortedRequests(store.getState())[index],
68 "GET",
69 CONTENT_TYPE_SJS + "?fmt=json-long",
71 status: 200,
72 statusText: "OK",
73 type: "json",
74 fullMimeType: "text/json; charset=utf-8",
75 size: L10N.getFormatStr(
76 "networkMenu.size.kB",
77 L10N.numberWithDecimals(85975 / 1000, 2)
79 time: true,
83 });