tor-browser

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

browser_utility_geolocation_crashed.js (1925B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 async function getGeolocation() {
      7  info("Requesting geolocation");
      8 
      9  let resolve;
     10  let promise = new Promise((_resolve, _reject) => {
     11    resolve = _resolve;
     12  });
     13 
     14  navigator.geolocation.getCurrentPosition(
     15    () => {
     16      ok(true, "geolocation succeeded");
     17      resolve(undefined);
     18    },
     19    () => {
     20      ok(false, "geolocation failed");
     21      resolve(undefined);
     22    }
     23  );
     24 
     25  return promise;
     26 }
     27 
     28 add_setup(async function () {
     29  // Avoid the permission doorhanger and cache that would trigger instead
     30  // of re-requesting location. Setting geo.timeout to 0 causes it to
     31  // retry the system geolocation (incl. recreating the utility process)
     32  // instead of reusing the MLS geolocation fallback it found the first time.
     33  await SpecialPowers.pushPrefEnv({
     34    set: [
     35      ["geo.prompt.testing", true],
     36      ["geo.prompt.testing.allow", true],
     37      ["geo.provider.network.debug.requestCache.enabled", false],
     38      ["geo.provider.testing", false],
     39      ["geo.timeout", 0],
     40    ],
     41  });
     42 });
     43 
     44 add_task(async function testGeolocationProcessCrash() {
     45  info("Start the Windows utility process");
     46  await getGeolocation();
     47 
     48  info("Crash the utility process");
     49  await crashSomeUtilityActor("windowsUtils");
     50 
     51  info("Restart the Windows utility process");
     52  await getGeolocation();
     53 
     54  info("Confirm the restarted process");
     55  await checkUtilityExists("windowsUtils");
     56 
     57  info("Kill the utility process");
     58  await cleanUtilityProcessShutdown("windowsUtils", true);
     59 
     60  info("Restart the Windows utility process again");
     61  await getGeolocation();
     62 
     63  info("Confirm the restarted process");
     64  await checkUtilityExists("windowsUtils");
     65 });
     66 
     67 add_task(async function testCleanup() {
     68  info("Clean up to avoid confusing future tests");
     69  await cleanUtilityProcessShutdown("windowsUtils", true);
     70 });