tor-browser

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

browser_jsonview_copy_json.js (1009B)


      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 + "simple_json.json";
      7 
      8 add_task(async function () {
      9  info("Test copy JSON started");
     10 
     11  await addJsonViewTab(TEST_JSON_URL);
     12 
     13  const countBefore = await getElementCount(
     14    ".jsonPanelBox .treeTable .treeRow"
     15  );
     16  Assert.equal(countBefore, 1, "There must be one row");
     17 
     18  const text = await getElementText(".jsonPanelBox .treeTable .treeRow");
     19  is(text, 'name"value"', "There must be proper JSON displayed");
     20 
     21  // Verify JSON copy into the clipboard.
     22  const value = '{ "name": "value" }\n';
     23  const browser = gBrowser.selectedBrowser;
     24  const selector = ".jsonPanelBox .toolbar button.copy";
     25  await waitForClipboardPromise(
     26    function setup() {
     27      BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
     28    },
     29    function validator(result) {
     30      const str = normalizeNewLines(result);
     31      return str == value;
     32    }
     33  );
     34 });