tor-browser

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

browser_bug1008941_dismissGeolocationHanger.js (1541B)


      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 "use strict";
      6 
      7 const TEST_URI =
      8  "https://example.com/browser/dom/geolocation/test/browser/position.html";
      9 
     10 add_task(async function testDismissHanger() {
     11  info(
     12    "Check that location is not shared when dismissing the geolocation hanger"
     13  );
     14 
     15  let promisePanelShown = BrowserTestUtils.waitForEvent(
     16    PopupNotifications.panel,
     17    "popupshown",
     18    true
     19  );
     20  await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
     21  await promisePanelShown;
     22 
     23  // We intentionally turn off this a11y check, because the following click
     24  // is sent on the <toolbar> to dismiss the Geolocation hanger using an
     25  // alternative way of the popup dismissal, while the other way like `Esc` key
     26  // is available for assistive technology users, thus this test can be ignored.
     27  AccessibilityUtils.setEnv({ mustHaveAccessibleRule: false });
     28  // click outside the Geolocation hanger to dismiss it
     29  window.document.getElementById("nav-bar").click();
     30  AccessibilityUtils.resetEnv();
     31  info("Clicked outside the Geolocation panel to dismiss it");
     32 
     33  let hasLocation = await SpecialPowers.spawn(
     34    gBrowser.selectedBrowser,
     35    [],
     36    async function () {
     37      return content.document.body.innerHTML.includes("location...");
     38    }
     39  );
     40 
     41  ok(hasLocation, "Location is not shared");
     42 
     43  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     44 });