tor-browser

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

browser_cmd_click.js (839B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Ensure Cmd/Ctrl-clicking link opens a new tab
      7 
      8 const TAB_URL = "https://example.com/";
      9 const TEST_URL = `data:text/html,<a href="${TAB_URL}">Click me</a>`.replace(
     10  / /g,
     11  "%20"
     12 );
     13 
     14 addRDMTask(
     15  TEST_URL,
     16  async function ({ ui }) {
     17    // Cmd-click the link and wait for a new tab
     18    await waitForFrameLoad(ui, TEST_URL);
     19    const newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
     20    BrowserTestUtils.synthesizeMouseAtCenter(
     21      "a",
     22      {
     23        ctrlKey: true,
     24        metaKey: true,
     25      },
     26      ui.getViewportBrowser()
     27    );
     28    const newTab = await newTabPromise;
     29    ok(newTab, "New tab opened from link");
     30    await removeTab(newTab);
     31  },
     32  { waitForDeviceList: true }
     33 );