tor-browser

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

browser_fullscreen-window-open-race.js (2201B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 requestLongerTimeout(2);
      7 
      8 // Import helpers
      9 Services.scriptloader.loadSubScript(
     10  "chrome://mochitests/content/browser/dom/base/test/fullscreen/fullscreen_helpers.js",
     11  this
     12 );
     13 
     14 add_setup(async function () {
     15  await pushPrefs(
     16    ["full-screen-api.transition-duration.enter", "0 0"],
     17    ["full-screen-api.transition-duration.leave", "0 0"],
     18    ["full-screen-api.allow-trusted-requests-only", false]
     19  );
     20 });
     21 
     22 add_task(async () => {
     23  const url =
     24    "https://example.com/browser/dom/base/test/fullscreen/dummy_page.html";
     25  const name = "foo";
     26 
     27  await BrowserTestUtils.withNewTab(
     28    {
     29      gBrowser,
     30      url,
     31    },
     32    async function (browser) {
     33      info("open new window");
     34      SpecialPowers.spawn(browser, [url, name], function (u, n) {
     35        content.document.notifyUserGestureActivation();
     36        content.window.open(u, n, "width=100,height=100");
     37      });
     38      let newWin = await BrowserTestUtils.waitForNewWindow({ url });
     39      await SimpleTest.promiseFocus(newWin);
     40 
     41      info("re-focusing main window");
     42      await SimpleTest.promiseFocus(window);
     43 
     44      info("open an existing window and request fullscreen");
     45      await SpecialPowers.spawn(browser, [url, name], function (u, n) {
     46        content.document.notifyUserGestureActivation();
     47        content.window.open(u, n);
     48        content.document.body.requestFullscreen();
     49      });
     50 
     51      // We call window.open() first than requestFullscreen() in a row on
     52      // content page, but given that focus sync-up takes several IPC exchanges,
     53      // so parent process ends up processing the requests in a reverse order,
     54      // which should reject the fullscreen request and leave fullscreen.
     55      await waitWidgetFullscreenEvent(window, false, true);
     56 
     57      // Ensure the browser exits fullscreen state.
     58      ok(!window.fullScreen, "The chrome window should not be in fullscreen");
     59      ok(
     60        !document.documentElement.hasAttribute("inDOMFullscreen"),
     61        "The chrome document should not be in fullscreen"
     62      );
     63 
     64      await BrowserTestUtils.closeWindow(newWin);
     65    }
     66  );
     67 });