tor-browser

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

browser_crossGroupOpener.js (1205B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 "use strict";
      7 
      8 const TEST_PATH = getRootDirectory(gTestPath).replace(
      9  "chrome://mochitests/content",
     10  "https://example.com"
     11 );
     12 
     13 add_task(async function test_browsingContextWithNoOpenerHasCrossGroupOpener() {
     14  const onNewTab = BrowserTestUtils.waitForNewTab(gBrowser, TEST_PATH, true);
     15  const openerBrowsingContext = await SpecialPowers.spawn(
     16    gBrowser.selectedBrowser,
     17    [TEST_PATH],
     18    async function (testPath) {
     19      content.open(testPath, "_blank", "noopener");
     20      return content.browsingContext;
     21    }
     22  );
     23  const newTab = await onNewTab;
     24 
     25  const browsingContext = newTab.linkedBrowser.browsingContext;
     26  Assert.equal(
     27    browsingContext.opener,
     28    null,
     29    "A tab opened with noopener shouldn't have an opener"
     30  );
     31  Assert.ok(
     32    browsingContext.crossGroupOpener,
     33    "A cross origin A tab opened with noopener should have a crossGroupOpener"
     34  );
     35  Assert.equal(
     36    browsingContext.crossGroupOpener,
     37    openerBrowsingContext,
     38    "The crossGroupOpener should be the same as the actual opener"
     39  );
     40 
     41  await BrowserTestUtils.removeTab(newTab);
     42 });