Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / netmonitor / test / browser_net_json-b64.js
blob82679d15efb8f6c06a03ba82a30ccd1f7593aa39
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Tests if JSON responses encoded in base64 are handled correctly.
8 */
10 add_task(async function () {
11 const {
12 L10N,
13 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
14 const { tab, monitor } = await initNetMonitor(JSON_B64_URL, {
15 requestCount: 1,
16 });
17 info("Starting test... ");
19 const { document, store, windowRequire } = monitor.panelWin;
20 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
22 store.dispatch(Actions.batchEnable(false));
24 // Execute requests.
25 await performRequests(monitor, tab, 1);
27 let wait = waitForDOM(document, "#response-panel .data-header");
28 const waitForPropsView = waitForDOM(
29 document,
30 "#response-panel .properties-view",
34 store.dispatch(Actions.toggleNetworkDetails());
36 clickOnSidebarTab(document, "response");
38 await Promise.all([wait, waitForPropsView]);
40 const tabpanel = document.querySelector("#response-panel");
41 is(
42 tabpanel.querySelectorAll(".treeRow").length,
44 "There should be 1 json properties displayed in this tabpanel."
47 const labels = tabpanel.querySelectorAll("tr .treeLabelCell .treeLabel");
48 const values = tabpanel.querySelectorAll("tr .treeValueCell .objectBox");
50 is(
51 labels[0].textContent,
52 "greeting",
53 "The first json property name was incorrect."
55 is(
56 values[0].textContent,
57 `"This is a base 64 string."`,
58 "The first json property value was incorrect."
61 // Open the response payload section, it should hide the json section
62 wait = waitForDOM(document, "#response-panel .CodeMirror-code");
63 const header = document.querySelector(
64 "#response-panel .raw-data-toggle-input .devtools-checkbox-toggle"
66 clickElement(header, monitor);
67 await wait;
69 is(
70 tabpanel.querySelector(".response-error-header") === null,
71 true,
72 "The response error header doesn't have the intended visibility."
74 const jsonView = tabpanel.querySelector(".data-label") || {};
75 is(
76 jsonView.textContent === L10N.getStr("jsonScopeName"),
77 true,
78 "The response json view has the intended visibility."
80 is(
81 tabpanel.querySelector(".raw-data-toggle-input .devtools-checkbox-toggle")
82 .checked,
83 true,
84 "The raw response toggle should be on."
86 is(
87 tabpanel.querySelector(".CodeMirror-code") === null,
88 false,
89 "The response editor has the intended visibility."
91 is(
92 tabpanel.querySelector(".response-image-box") === null,
93 true,
94 "The response image box doesn't have the intended visibility."
96 is(
97 tabpanel.querySelectorAll(".empty-notice").length,
99 "The empty notice should not be displayed in this tabpanel."
102 await teardown(monitor);