tor-browser

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

browser_toolbox_options_panel_toggle.js (2522B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test whether options panel toggled by key event and "Settings" on the meatball menu.
      7 
      8 const { Toolbox } = require("resource://devtools/client/framework/toolbox.js");
      9 
     10 add_task(async function () {
     11  const tab = await addTab("about:blank");
     12  const toolbox = await openToolboxForTab(
     13    tab,
     14    "webconsole",
     15    Toolbox.HostType.BOTTOM
     16  );
     17 
     18  info("Check the option panel was selected after sending F1 key event");
     19  await sendOptionsKeyEvent(toolbox);
     20  is(toolbox.currentToolId, "options", "The options panel should be selected");
     21 
     22  info("Check the last selected panel was selected after sending F1 key event");
     23  await sendOptionsKeyEvent(toolbox);
     24  is(
     25    toolbox.currentToolId,
     26    "webconsole",
     27    "The webconsole panel should be selected"
     28  );
     29 
     30  info("Check the option panel was selected after clicking 'Settings' menu");
     31  await clickSettingsMenu(toolbox);
     32  is(toolbox.currentToolId, "options", "The options panel should be selected");
     33 
     34  info(
     35    "Check the last selected panel was selected after clicking 'Settings' menu"
     36  );
     37  await sendOptionsKeyEvent(toolbox);
     38  is(
     39    toolbox.currentToolId,
     40    "webconsole",
     41    "The webconsole panel should be selected"
     42  );
     43 
     44  info("Check the combination of key event and 'Settings' menu");
     45  await sendOptionsKeyEvent(toolbox);
     46  await clickSettingsMenu(toolbox);
     47  is(
     48    toolbox.currentToolId,
     49    "webconsole",
     50    "The webconsole panel should be selected"
     51  );
     52  await clickSettingsMenu(toolbox);
     53  await sendOptionsKeyEvent(toolbox);
     54  is(
     55    toolbox.currentToolId,
     56    "webconsole",
     57    "The webconsole panel should be selected"
     58  );
     59 });
     60 
     61 async function sendOptionsKeyEvent(toolbox) {
     62  const onReady = toolbox.once("select");
     63  EventUtils.synthesizeKey("VK_F1", {}, toolbox.win);
     64  await onReady;
     65 }
     66 
     67 async function clickSettingsMenu(toolbox) {
     68  const onPopupShown = () => {
     69    toolbox.doc.removeEventListener("popupshown", onPopupShown);
     70    const menuItem = toolbox.doc.getElementById(
     71      "toolbox-meatball-menu-settings"
     72    );
     73    EventUtils.synthesizeMouseAtCenter(menuItem, {}, menuItem.ownerGlobal);
     74  };
     75  toolbox.doc.addEventListener("popupshown", onPopupShown);
     76 
     77  const button = toolbox.doc.getElementById("toolbox-meatball-menu-button");
     78  await waitUntil(() => button.style.pointerEvents !== "none");
     79  EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerGlobal);
     80 
     81  await toolbox.once("select");
     82 }