tor-browser

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

browser_popupNotification_hide_after_protections_panel.js (1806B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 add_setup(async function () {
      6  await SpecialPowers.pushPrefEnv({
      7    set: [["browser.urlbar.trustPanel.featureGate", false]],
      8  });
      9 });
     10 
     11 add_task(async function test_hide_popup_with_protections_panel_showing() {
     12  await BrowserTestUtils.withNewTab(
     13    "https://test1.example.com/",
     14    async function (browser) {
     15      // Request location permissions and wait for that prompt to appear.
     16      let popupShownPromise = waitForNotificationPanel();
     17      await SpecialPowers.spawn(browser, [], async function () {
     18        content.navigator.geolocation.getCurrentPosition(() => {});
     19      });
     20      await popupShownPromise;
     21 
     22      // Click on the icon for the protections panel, to show the panel.
     23      popupShownPromise = BrowserTestUtils.waitForEvent(
     24        window,
     25        "popupshown",
     26        true,
     27        event => event.target == gProtectionsHandler._protectionsPopup
     28      );
     29      EventUtils.synthesizeMouseAtCenter(
     30        document.getElementById("tracking-protection-icon-container"),
     31        {}
     32      );
     33      await popupShownPromise;
     34 
     35      // Make sure the location permission prompt closed.
     36      Assert.ok(!PopupNotifications.isPanelOpen, "Geolocation popup is hidden");
     37 
     38      // Close the protections panel.
     39      let popupHidden = BrowserTestUtils.waitForEvent(
     40        gProtectionsHandler._protectionsPopup,
     41        "popuphidden"
     42      );
     43      gProtectionsHandler._protectionsPopup.hidePopup();
     44      await popupHidden;
     45 
     46      // Make sure the location permission prompt came back.
     47      Assert.ok(PopupNotifications.isPanelOpen, "Geolocation popup is showing");
     48    }
     49  );
     50 });