tor-browser

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

browser_rules_url-click-opens-new-tab.js (1057B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Bug 1326626 - Tests that clicking a background url opens a new tab
      7 // even when the devtools is opened in a separate window.
      8 
      9 const TEST_URL =
     10  "data:text/html,<style>body{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGD4DwABBAEAfbLI3wAAAABJRU5ErkJggg==) no-repeat}";
     11 
     12 add_task(async function () {
     13  const { inspector } = await openInspectorForURL(TEST_URL, "window");
     14  const view = selectRuleView(inspector);
     15 
     16  await selectNode("body", inspector);
     17 
     18  const anchor = view.styleDocument.querySelector(
     19    ".ruleview-propertyvaluecontainer a"
     20  );
     21  ok(anchor, "Link exists for style tag node");
     22 
     23  const onTabOpened = waitForTab();
     24  anchor.click();
     25 
     26  info("Wait for the image to open in a new tab");
     27  const tab = await onTabOpened;
     28  ok(tab, "A new tab opened");
     29 
     30  is(
     31    tab.linkedBrowser.currentURI.spec,
     32    anchor.href,
     33    "The new tab has the expected URL"
     34  );
     35 });