tor-browser

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

browser_styleeditor_copyurl.js (1337B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test to check the 'Copy URL' functionality in the context menu item for stylesheets.
      7 
      8 const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html";
      9 
     10 add_task(async function () {
     11  const { panel, ui } = await openStyleEditorForURL(TESTCASE_URI);
     12 
     13  const doc = panel.panelWindow.document;
     14  const contextMenu = getContextMenuElement(panel);
     15  const copyUrlItem = doc.getElementById("context-copyurl");
     16 
     17  const onContextMenuShown = new Promise(resolve => {
     18    contextMenu.addEventListener("popupshown", resolve, { once: true });
     19  });
     20 
     21  info("Right-click the first stylesheet editor.");
     22  const editor = ui.editors[0];
     23 
     24  is(editor.friendlyName, "simple.css", "editor is the expected one");
     25 
     26  const stylesheetEl = editor.summary.querySelector(".stylesheet-name");
     27  await EventUtils.synthesizeMouseAtCenter(
     28    stylesheetEl,
     29    { button: 2, type: "contextmenu" },
     30    panel.panelWindow
     31  );
     32  await onContextMenuShown;
     33 
     34  ok(!copyUrlItem.hidden, "Copy URL menu item should be showing.");
     35 
     36  info(
     37    "Click on Copy URL menu item and wait for the URL to be copied to the clipboard."
     38  );
     39  await waitForClipboardPromise(
     40    () => contextMenu.activateItem(copyUrlItem),
     41    `${TEST_BASE_HTTPS}simple.css`
     42  );
     43 });