tor-browser

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

browser_jsonview_valid_json.js (1540B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_JSON_URL = URL_ROOT + "valid_json.json";
      7 
      8 add_task(async function () {
      9  info("Test valid JSON started");
     10 
     11  const tab = await addJsonViewTab(TEST_JSON_URL);
     12 
     13  is(
     14    tab.linkedBrowser.contentPrincipal.origin,
     15    "resource://devtools",
     16    "JSON document ends up having a privileged principal in order to load DevTools URIs"
     17  );
     18 
     19  is(await countRows(), 3, "There must be three rows");
     20 
     21  const objectCellCount = await getElementCount(
     22    ".jsonPanelBox .treeTable .objectCell"
     23  );
     24  is(objectCellCount, 1, "There must be one object cell");
     25 
     26  const objectCellText = await getElementText(
     27    ".jsonPanelBox .treeTable .objectCell"
     28  );
     29  is(objectCellText, "", "The summary is hidden when object is expanded");
     30 
     31  // Clicking the value does not collapse it (so that it can be selected and copied).
     32  await clickJsonNode(".jsonPanelBox .treeTable .treeValueCell");
     33  is(await countRows(), 3, "There must still be three rows");
     34 
     35  // Clicking the label collapses the auto-expanded node.
     36  await clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
     37  is(await countRows(), 1, "There must be one row");
     38 
     39  // Collapsed nodes are preserved when switching panels.
     40  await selectJsonViewContentTab("headers");
     41  await selectJsonViewContentTab("json");
     42  is(await countRows(), 1, "There must still be one row");
     43 });
     44 
     45 function countRows() {
     46  return getElementCount(".jsonPanelBox .treeTable .treeRow");
     47 }