Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / netmonitor / test / browser_net_json-empty.js
blob0179a97d49f2590e90d0c3b473632bee12221a37
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Tests if empty JSON responses are properly displayed.
8 */
10 add_task(async function () {
11 const { tab, monitor } = await initNetMonitor(
12 JSON_EMPTY_URL + "?name=empty",
13 { requestCount: 1 }
15 info("Starting test... ");
17 const { document, store, windowRequire } = monitor.panelWin;
18 const { L10N } = windowRequire("devtools/client/netmonitor/src/utils/l10n");
19 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
21 store.dispatch(Actions.batchEnable(false));
23 // Execute requests.
24 await performRequests(monitor, tab, 1);
26 const onResponsePanelReady = waitForDOM(
27 document,
28 "#response-panel .data-header"
31 store.dispatch(Actions.toggleNetworkDetails());
32 clickOnSidebarTab(document, "response");
34 await onResponsePanelReady;
36 const codeMirrorReady = waitForDOM(
37 document,
38 "#response-panel .CodeMirror-code"
41 const header = document.querySelector(
42 "#response-panel .raw-data-toggle-input .devtools-checkbox-toggle"
44 clickElement(header, monitor);
46 await codeMirrorReady;
48 const tabpanel = document.querySelector("#response-panel");
49 is(
50 tabpanel.querySelectorAll(".empty-notice").length,
52 "The empty notice should not be displayed in this tabpanel."
55 is(
56 tabpanel.querySelector(".response-error-header") === null,
57 true,
58 "The response error header doesn't have the intended visibility."
60 is(
61 tabpanel.querySelector(".CodeMirror-code") === null,
62 false,
63 "The response editor has the intended visibility."
65 is(
66 tabpanel.querySelector(".response-image-box") === null,
67 true,
68 "The response image box doesn't have the intended visibility."
71 const jsonView = tabpanel.querySelector(".data-label") || {};
72 is(
73 jsonView.textContent === L10N.getStr("jsonScopeName"),
74 true,
75 "The response json view has the intended visibility."
78 await teardown(monitor);
79 });