tor-browser

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

browser_UITour5.js (1799B)


      1 "use strict";
      2 
      3 var gTestTab;
      4 var gContentAPI;
      5 
      6 add_task(setup_UITourTest);
      7 
      8 add_UITour_task(async function test_highlight_help_and_show_help_subview() {
      9  let highlight = document.getElementById("UITourHighlight");
     10  is_element_hidden(highlight, "Highlight should initially be hidden");
     11 
     12  // Test highlighting the library button
     13  let appMenu = PanelUI.panel;
     14  let appMenuShownPromise = promisePanelElementShown(window, appMenu);
     15  let highlightVisiblePromise = elementVisiblePromise(
     16    highlight,
     17    "Should show highlight"
     18  );
     19  gContentAPI.showHighlight("help");
     20  await appMenuShownPromise;
     21  await highlightVisiblePromise;
     22  is(
     23    appMenu.state,
     24    "open",
     25    "Should open the app menu to highlight the help button"
     26  );
     27  is(
     28    getShowHighlightTargetName(),
     29    "help",
     30    "Should highlight the help button on the app menu"
     31  );
     32 
     33  // Click the help button to show the subview
     34  let ViewShownPromise = new Promise(resolve => {
     35    appMenu.addEventListener("ViewShown", resolve, { once: true });
     36  });
     37  let highlightHiddenPromise = elementHiddenPromise(
     38    highlight,
     39    "Should hide highlight"
     40  );
     41 
     42  let helpButtonID = "appMenu-help-button2";
     43  let helpBtn = document.getElementById(helpButtonID);
     44  helpBtn.dispatchEvent(new Event("command", { bubbles: true }));
     45  await highlightHiddenPromise;
     46  await ViewShownPromise;
     47  let helpView = document.getElementById("PanelUI-helpView");
     48  ok(PanelView.forNode(helpView).active, "Should show the help subview");
     49  is(
     50    appMenu.state,
     51    "open",
     52    "Should still open the app menu for the help subview"
     53  );
     54 
     55  // Clean up
     56  let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu);
     57  gContentAPI.hideMenu("appMenu");
     58  await appMenuHiddenPromise;
     59  is(appMenu.state, "closed", "Should close the app menu");
     60 });