tor-browser

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

browser_contentAreaClick_subframe_javascript.js (1484B)


      1 const gExampleComRoot = getRootDirectory(gTestPath).replace(
      2  "chrome://mochitests/content/",
      3  "https://example.com/"
      4 );
      5 const IFRAME_FILE = "file_contentAreaClick_subframe_javascript.html";
      6 
      7 add_task(async function () {
      8  await SpecialPowers.pushPrefEnv({
      9    set: [["browser.link.alternative_click.block_javascript", false]],
     10  });
     11 
     12  await BrowserTestUtils.withNewTab(
     13    `data:text/html,<iframe src="${gExampleComRoot + IFRAME_FILE}"></iframe>`,
     14    async browser => {
     15      let newTabPromise = BrowserTestUtils.waitForNewTab(
     16        gBrowser,
     17        "about:blank"
     18      );
     19      let javascriptRanPromise = TestUtils.topicObserved(
     20        "contentAreaClick-javascriptRan"
     21      );
     22 
     23      // ctrl/cmd-click the link in the subframe. This should cause it to be
     24      // loaded in a new tab.
     25      info("Clicking link");
     26      let expectedRemoteType =
     27        browser.browsingContext.children[0].currentRemoteType;
     28      await BrowserTestUtils.synthesizeMouseAtCenter(
     29        "a",
     30        { ctrlKey: true, metaKey: true },
     31        browser.browsingContext.children[0]
     32      );
     33 
     34      info("Waiting for new tab");
     35      let newTab = await newTabPromise;
     36 
     37      info("Waiting to be notified that the javascript ran");
     38      await javascriptRanPromise;
     39      is(
     40        newTab.linkedBrowser.remoteType,
     41        expectedRemoteType,
     42        "new tab was loaded in expected process"
     43      );
     44 
     45      info("Removing the tab");
     46      BrowserTestUtils.removeTab(newTab);
     47    }
     48  );
     49 });