tor-browser

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

browser_panel_locationSpecific.js (2246B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /*
      7 * This test creates multiple panels, one that has been tagged as location specific
      8 * and one that isn't. When the location changes, the specific panel should close.
      9 * The non-specific panel should remain open.
     10 *
     11 */
     12 
     13 add_task(async function () {
     14  let specificPanel = document.createXULElement("panel");
     15  specificPanel.setAttribute("locationspecific", "true");
     16  specificPanel.setAttribute("noautohide", "true");
     17  specificPanel.style.height = "100px";
     18  specificPanel.style.width = "100px";
     19 
     20  let generalPanel = document.createXULElement("panel");
     21  generalPanel.setAttribute("noautohide", "true");
     22  generalPanel.style.height = "100px";
     23  generalPanel.style.width = "100px";
     24 
     25  let anchor = document.getElementById(CustomizableUI.AREA_NAVBAR);
     26 
     27  anchor.appendChild(specificPanel);
     28  anchor.appendChild(generalPanel);
     29  is(specificPanel.state, "closed", "specificPanel starts as closed");
     30  is(generalPanel.state, "closed", "generalPanel starts as closed");
     31 
     32  let specificPanelPromise = BrowserTestUtils.waitForEvent(
     33    specificPanel,
     34    "popupshown"
     35  );
     36 
     37  specificPanel.openPopupAtScreen(0, 0);
     38 
     39  await specificPanelPromise;
     40  is(specificPanel.state, "open", "specificPanel has been opened");
     41 
     42  let generalPanelPromise = BrowserTestUtils.waitForEvent(
     43    generalPanel,
     44    "popupshown"
     45  );
     46 
     47  generalPanel.openPopupAtScreen(100, 0);
     48 
     49  await generalPanelPromise;
     50  is(generalPanel.state, "open", "generalPanel has been opened");
     51 
     52  let specificPanelHiddenPromise = BrowserTestUtils.waitForEvent(
     53    specificPanel,
     54    "popuphidden"
     55  );
     56 
     57  // Simulate a location change, and check which panel closes.
     58  let browser = gBrowser.selectedBrowser;
     59  let loaded = BrowserTestUtils.browserLoaded(browser);
     60  BrowserTestUtils.startLoadingURIString(browser, "http://mochi.test:8888/#0");
     61  await loaded;
     62 
     63  await specificPanelHiddenPromise;
     64 
     65  is(
     66    specificPanel.state,
     67    "closed",
     68    "specificPanel panel is closed after location change"
     69  );
     70  is(
     71    generalPanel.state,
     72    "open",
     73    "generalPanel is still open after location change"
     74  );
     75 
     76  specificPanel.remove();
     77  generalPanel.remove();
     78 });