tor-browser

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

browser_net_json-nogrip.js (1473B)


      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 JSON responses with property 'type' are correctly rendered.
      8 * (Reps rendering JSON responses should use `noGrip=true`).
      9 */
     10 add_task(async function () {
     11  const { tab, monitor } = await initNetMonitor(
     12    JSON_BASIC_URL + "?name=nogrip",
     13    { requestCount: 1 }
     14  );
     15  info("Starting test... ");
     16 
     17  const { document, store, windowRequire } = monitor.panelWin;
     18  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     19 
     20  store.dispatch(Actions.batchEnable(false));
     21 
     22  await performRequests(monitor, tab, 1);
     23 
     24  const onResponsePanelReady = waitForDOM(
     25    document,
     26    "#response-panel .data-header"
     27  );
     28 
     29  const onPropsViewReady = waitForDOM(
     30    document,
     31    "#response-panel .properties-view",
     32    1
     33  );
     34 
     35  store.dispatch(Actions.toggleNetworkDetails());
     36  clickOnSidebarTab(document, "response");
     37  await Promise.all([onResponsePanelReady, onPropsViewReady]);
     38 
     39  const tabpanel = document.querySelector("#response-panel");
     40  const labels = tabpanel.querySelectorAll("tr .treeLabelCell .treeLabel");
     41  const values = tabpanel.querySelectorAll("tr .treeValueCell .objectBox");
     42 
     43  is(labels[0].textContent, "obj", "The first json property name is correct.");
     44  is(
     45    values[0].textContent,
     46    '{ type: "string" }',
     47    "The first json property value is correct."
     48  );
     49 
     50  await teardown(monitor);
     51 });