tor-browser

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

browser_jsonview_bug_1380828.js (1028B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const VALID_JSON_URL = URL_ROOT + "valid_json.json";
      7 const INVALID_JSON_URL = URL_ROOT + "invalid_json.json";
      8 const prettyPrintButtonClass = ".textPanelBox .toolbar button.prettyprint";
      9 
     10 add_task(async function () {
     11  info("Test 'Pretty Print' button disappears on parsing invalid JSON");
     12 
     13  const count = await testPrettyPrintButton(INVALID_JSON_URL);
     14  is(count, 0, "There must be no pretty-print button for invalid json");
     15 });
     16 
     17 add_task(async function () {
     18  info("Test 'Pretty Print' button is present on parsing valid JSON");
     19 
     20  const count = await testPrettyPrintButton(VALID_JSON_URL);
     21  is(count, 1, "There must be pretty-print button for valid json");
     22 });
     23 
     24 async function testPrettyPrintButton(url) {
     25  await addJsonViewTab(url);
     26 
     27  await selectJsonViewContentTab("rawdata");
     28  info("Switched to Raw Data tab.");
     29 
     30  const count = await getElementCount(prettyPrintButtonClass);
     31  return count;
     32 }