tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_net_json-empty.js (2047B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Tests if empty JSON responses are properly displayed.
      8 */
      9 
     10 add_task(async function () {
     11  const { tab, monitor } = await initNetMonitor(
     12    JSON_EMPTY_URL + "?name=empty",
     13    { requestCount: 1 }
     14  );
     15  info("Starting test... ");
     16 
     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");
     20 
     21  store.dispatch(Actions.batchEnable(false));
     22 
     23  // Execute requests.
     24  await performRequests(monitor, tab, 1);
     25 
     26  const onResponsePanelReady = waitForDOM(
     27    document,
     28    "#response-panel .data-header"
     29  );
     30 
     31  store.dispatch(Actions.toggleNetworkDetails());
     32  clickOnSidebarTab(document, "response");
     33 
     34  await onResponsePanelReady;
     35 
     36  const codeMirrorReady = waitForDOM(document, "#response-panel .cm-content");
     37 
     38  const header = document.querySelector(
     39    "#response-panel .raw-data-toggle-input .devtools-checkbox-toggle"
     40  );
     41  clickElement(header, monitor);
     42 
     43  await codeMirrorReady;
     44 
     45  const tabpanel = document.querySelector("#response-panel");
     46  is(
     47    tabpanel.querySelectorAll(".empty-notice").length,
     48    0,
     49    "The empty notice should not be displayed in this tabpanel."
     50  );
     51 
     52  is(
     53    tabpanel.querySelector(".response-error-header") === null,
     54    true,
     55    "The response error header doesn't have the intended visibility."
     56  );
     57  is(
     58    tabpanel.querySelector(".cm-content") === null,
     59    false,
     60    "The response editor has the intended visibility."
     61  );
     62  is(
     63    tabpanel.querySelector(".response-image-box") === null,
     64    true,
     65    "The response image box doesn't have the intended visibility."
     66  );
     67 
     68  const jsonView = tabpanel.querySelector(".data-label") || {};
     69  is(
     70    jsonView.textContent === L10N.getStr("jsonScopeName"),
     71    true,
     72    "The response json view has the intended visibility."
     73  );
     74 
     75  await teardown(monitor);
     76 });