tor-browser

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

browser_popup_keyNav.js (1834B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_PATH = getRootDirectory(gTestPath).replace(
      7  "chrome://mochitests/content",
      8  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      9  "http://example.com"
     10 );
     11 
     12 /**
     13 * Keyboard navigation has some edgecases in popups because
     14 * there is no tabstrip or menubar. Check that tabbing forward
     15 * and backward to/from the content document works:
     16 */
     17 add_task(async function test_popup_keynav() {
     18  await SpecialPowers.pushPrefEnv({
     19    set: [
     20      ["browser.toolbars.keyboard_navigation", true],
     21      ["accessibility.tabfocus", 7],
     22    ],
     23  });
     24 
     25  const kURL = TEST_PATH + "focusableContent.html";
     26  await BrowserTestUtils.withNewTab(kURL, async browser => {
     27    let windowPromise = BrowserTestUtils.waitForNewWindow({
     28      url: kURL,
     29    });
     30    SpecialPowers.spawn(browser, [], () => {
     31      content.window.open(
     32        content.location.href,
     33        "_blank",
     34        "height=500,width=500,menubar=no,toolbar=no,status=1,resizable=1"
     35      );
     36    });
     37    let win = await windowPromise;
     38    let hamburgerButton = win.document.getElementById("PanelUI-menu-button");
     39    await focusAndActivateElement(hamburgerButton, () =>
     40      expectFocusAfterKey("Tab", win.gBrowser.selectedBrowser, false, win)
     41    );
     42    // Focus the button inside the webpage.
     43    EventUtils.synthesizeKey("KEY_Tab", {}, win);
     44    // Focus the first visible item in the URL bar
     45    let buttons = win.document
     46      .getElementById("urlbar-container")
     47      .querySelectorAll("toolbarbutton, [role=button]");
     48    let firstButton = [...buttons].find(button =>
     49      BrowserTestUtils.isVisible(button)
     50    );
     51    await expectFocusAfterKey("Tab", firstButton, false, win);
     52    await BrowserTestUtils.closeWindow(win);
     53  });
     54 });