tor-browser

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

browser_fullscreen_menus.js (2364B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 add_task(async function test_shortcut_key_label_in_fullscreen_menu_item() {
      7  await SpecialPowers.pushPrefEnv({
      8    set: [
      9      ["test.wait300msAfterTabSwitch", true],
     10      ["full-screen-api.transition-duration.enter", "0 0"],
     11      ["full-screen-api.transition-duration.leave", "0 0"],
     12    ],
     13  });
     14 
     15  const isMac = AppConstants.platform == "macosx";
     16  const shortCutKeyLabel = isMac ? "\u2303\u2318F" : "F11";
     17  const enterMenuItemId = isMac ? "enterFullScreenItem" : "fullScreenItem";
     18  const exitMenuItemId = isMac ? "exitFullScreenItem" : "fullScreenItem";
     19  const accelKeyLabelSelector = ".menu-accel";
     20 
     21  const tab = await BrowserTestUtils.openNewForegroundTab(
     22    gBrowser,
     23    "https://example.org/browser/browser/base/content/test/fullscreen/fullscreen.html"
     24  );
     25 
     26  await SimpleTest.promiseFocus(tab.linkedBrowser);
     27 
     28  document.getElementById(enterMenuItemId).render();
     29  Assert.equal(
     30    document
     31      .getElementById(enterMenuItemId)
     32      .querySelector(accelKeyLabelSelector)
     33      ?.getAttribute("value"),
     34    shortCutKeyLabel,
     35    `The menu item to enter into the fullscreen mode should show a shortcut key`
     36  );
     37 
     38  const fullScreenEntered = BrowserTestUtils.waitForEvent(window, "fullscreen");
     39 
     40  EventUtils.synthesizeKey("KEY_F11", {});
     41 
     42  info(`Waiting for entering the fullscreen mode...`);
     43  await fullScreenEntered;
     44 
     45  document.getElementById(exitMenuItemId).render();
     46  Assert.equal(
     47    document
     48      .getElementById(exitMenuItemId)
     49      .querySelector(accelKeyLabelSelector)
     50      ?.getAttribute("value"),
     51    shortCutKeyLabel,
     52    `The menu item to exiting from the fullscreen mode should show a shortcut key`
     53  );
     54 
     55  const fullScreenExited = BrowserTestUtils.waitForEvent(window, "fullscreen");
     56 
     57  EventUtils.synthesizeKey("KEY_F11", {});
     58 
     59  info(`Waiting for exiting from the fullscreen mode...`);
     60  await fullScreenExited;
     61 
     62  document.getElementById(enterMenuItemId).render();
     63  Assert.equal(
     64    document
     65      .getElementById(enterMenuItemId)
     66      .querySelector(accelKeyLabelSelector)
     67      ?.getAttribute("value"),
     68    shortCutKeyLabel,
     69    `After exiting from the fullscreen mode, the menu item to enter the fullscreen mode should show a shortcut key`
     70  );
     71 
     72  BrowserTestUtils.removeTab(tab);
     73 });