tor-browser

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

browser_aboutdebugging_devtoolstoolbox_menubar.js (2285B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /* import-globals-from helper-collapsibilities.js */
      7 Services.scriptloader.loadSubScript(
      8  CHROME_URL_ROOT + "helper-collapsibilities.js",
      9  this
     10 );
     11 
     12 /**
     13 * Test the status of menu items when open about:devtools-toolbox.
     14 */
     15 add_task(async function () {
     16  info("Force all debug target panes to be expanded");
     17  prepareCollapsibilitiesTest();
     18 
     19  const { document, tab, window } = await openAboutDebugging();
     20  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     21  const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
     22    document,
     23    tab,
     24    window
     25  );
     26 
     27  info("Check whether the menu items are disabled");
     28  const rootDocument = devtoolsTab.ownerDocument;
     29  await assertMenusItems(rootDocument, false);
     30 
     31  info("Select the inspector");
     32  const toolbox = getToolbox(devtoolsWindow);
     33  await toolbox.selectTool("inspector");
     34 
     35  info("Force to select about:debugging page");
     36  await updateSelectedTab(gBrowser, tab, window.AboutDebugging.store);
     37 
     38  info("Check whether the menu items are enabled");
     39  await assertMenusItems(rootDocument, true);
     40 
     41  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
     42  await removeTab(tab);
     43 });
     44 
     45 async function assertMenusItems(rootDocument, shouldBeEnabled) {
     46  info("Wait for the Toggle Tools menu-item hidden attribute to change");
     47  const menuItem = rootDocument.getElementById("menu_devToolbox");
     48  await waitUntil(() => menuItem.hidden === !shouldBeEnabled);
     49 
     50  info(
     51    "Check that the state of the Toggle Tools menu-item depends on the page"
     52  );
     53  assertMenuItem(rootDocument, "menu_devToolbox", shouldBeEnabled);
     54 
     55  info(
     56    "Check that the tools menu-items are always enabled regardless of the page"
     57  );
     58  for (const toolDefinition of gDevTools.getToolDefinitionArray()) {
     59    if (!toolDefinition.inMenu) {
     60      continue;
     61    }
     62 
     63    assertMenuItem(rootDocument, "menuitem_" + toolDefinition.id, true);
     64  }
     65 }
     66 
     67 function assertMenuItem(rootDocument, menuItemId, shouldBeEnabled) {
     68  const menuItem = rootDocument.getElementById(menuItemId);
     69  is(
     70    menuItem.hidden,
     71    !shouldBeEnabled,
     72    `"hidden" attribute of menu item(${menuItemId}) should be correct`
     73  );
     74 }