1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * Tests if JSON responses encoded in base64 are handled correctly.
10 add_task(async
function () {
13 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
14 const { tab
, monitor
} = await
initNetMonitor(JSON_B64_URL
, {
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));
25 await
performRequests(monitor
, tab
, 1);
27 let wait
= waitForDOM(document
, "#response-panel .data-header");
28 const waitForPropsView
= waitForDOM(
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");
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");
51 labels
[0].textContent
,
53 "The first json property name was incorrect."
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
);
70 tabpanel
.querySelector(".response-error-header") === null,
72 "The response error header doesn't have the intended visibility."
74 const jsonView
= tabpanel
.querySelector(".data-label") || {};
76 jsonView
.textContent
=== L10N
.getStr("jsonScopeName"),
78 "The response json view has the intended visibility."
81 tabpanel
.querySelector(".raw-data-toggle-input .devtools-checkbox-toggle")
84 "The raw response toggle should be on."
87 tabpanel
.querySelector(".CodeMirror-code") === null,
89 "The response editor has the intended visibility."
92 tabpanel
.querySelector(".response-image-box") === null,
94 "The response image box doesn't have the intended visibility."
97 tabpanel
.querySelectorAll(".empty-notice").length
,
99 "The empty notice should not be displayed in this tabpanel."
102 await
teardown(monitor
);