tor-browser

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

browser_copy_link_to_highlight_viewsource.js (1586B)


      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_PAGE =
      7  "data:text/html,<p id='p'>lorem&nbsp;ipsum&nbsp;dolor&nbsp;sit&nbsp;amet</p>";
      8 
      9 add_task(async function copyLinkHiddenInViewSource() {
     10  const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE);
     11 
     12  const viewSrcURI = "view-source:" + TEST_PAGE;
     13  const viewTab = await BrowserTestUtils.openNewForegroundTab(
     14    gBrowser,
     15    viewSrcURI
     16  );
     17  const browser = viewTab.linkedBrowser;
     18 
     19  await SpecialPowers.spawn(browser, [], () => {
     20    const sel = content.getSelection();
     21    sel.removeAllRanges();
     22    const range = content.document.createRange();
     23    range.selectNodeContents(content.document.body);
     24    sel.addRange(range);
     25  });
     26 
     27  const contextMenu = document.getElementById("contentAreaContextMenu");
     28  const popupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
     29  await BrowserTestUtils.synthesizeMouseAtCenter(
     30    "pre",
     31    { type: "contextmenu", button: 2 },
     32    browser
     33  );
     34  await popupShown;
     35 
     36  ok(
     37    contextMenu.querySelector("#context-copy-link-to-highlight").hidden,
     38    "Copy Link to Highlight is hidden in view-source"
     39  );
     40  ok(
     41    contextMenu.querySelector("#context-copy-clean-link-to-highlight").hidden,
     42    "Copy Clean Link to Highlight is hidden in view-source"
     43  );
     44 
     45  const popupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
     46  contextMenu.hidePopup();
     47  await popupHidden;
     48  BrowserTestUtils.removeTab(viewTab);
     49  BrowserTestUtils.removeTab(tab);
     50 });