tor-browser

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

browser_closeTabSpecificPanels.js (1836B)


      1 "use strict";
      2 
      3 /*
      4 * This test creates multiple panels, one that has been tagged as specific to its tab's content
      5 * and one that isn't. When a tab loses focus, panel specific to that tab should close.
      6 * The non-specific panel should remain open.
      7 *
      8 */
      9 
     10 add_task(async function () {
     11  let tab1 = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/#0");
     12  let tab2 = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/#1");
     13  let specificPanel = document.createXULElement("panel");
     14  specificPanel.setAttribute("tabspecific", "true");
     15  specificPanel.setAttribute("noautohide", "true");
     16  let generalPanel = document.createXULElement("panel");
     17  generalPanel.setAttribute("noautohide", "true");
     18  let anchor = document.getElementById(CustomizableUI.AREA_NAVBAR);
     19 
     20  anchor.appendChild(specificPanel);
     21  anchor.appendChild(generalPanel);
     22  is(specificPanel.state, "closed", "specificPanel starts as closed");
     23  is(generalPanel.state, "closed", "generalPanel starts as closed");
     24 
     25  let specificPanelPromise = BrowserTestUtils.waitForEvent(
     26    specificPanel,
     27    "popupshown"
     28  );
     29  specificPanel.openPopupAtScreen(210, 210);
     30  await specificPanelPromise;
     31  is(specificPanel.state, "open", "specificPanel has been opened");
     32 
     33  let generalPanelPromise = BrowserTestUtils.waitForEvent(
     34    generalPanel,
     35    "popupshown"
     36  );
     37  generalPanel.openPopupAtScreen(510, 510);
     38  await generalPanelPromise;
     39  is(generalPanel.state, "open", "generalPanel has been opened");
     40 
     41  gBrowser.tabContainer.advanceSelectedTab(-1, true);
     42  is(
     43    specificPanel.state,
     44    "closed",
     45    "specificPanel panel is closed after its tab loses focus"
     46  );
     47  is(generalPanel.state, "open", "generalPanel is still open after tab switch");
     48 
     49  specificPanel.remove();
     50  generalPanel.remove();
     51  gBrowser.removeTab(tab1);
     52  gBrowser.removeTab(tab2);
     53 });