tor-browser

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

test_defaultbrowsercheck.js (1485B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 const { ShellService } = ChromeUtils.importESModule(
      6  "moz-src:///browser/components/shell/ShellService.sys.mjs"
      7 );
      8 
      9 add_task(async function test_default_browser_check() {
     10  ShellService._checkedThisSession = false;
     11  // On a normal profile, the default is true. However, this gets set to false on the
     12  // testing profile. Let's start with true for a sanity check.
     13 
     14  ShellService.shouldCheckDefaultBrowser = true;
     15  equal(ShellService.shouldCheckDefaultBrowser, true, "Sanity check");
     16 
     17  await setupPolicyEngineWithJson({
     18    policies: {
     19      DontCheckDefaultBrowser: true,
     20    },
     21  });
     22 
     23  equal(
     24    ShellService.shouldCheckDefaultBrowser,
     25    false,
     26    "Policy changed it to not check"
     27  );
     28 
     29  // Try to change it to true and check that it doesn't take effect
     30  ShellService.shouldCheckDefaultBrowser = true;
     31 
     32  equal(ShellService.shouldCheckDefaultBrowser, false, "Policy is enforced");
     33 });
     34 
     35 add_task(async function test_default_browser_check() {
     36  await setupPolicyEngineWithJson({
     37    policies: {
     38      DontCheckDefaultBrowser: false,
     39    },
     40  });
     41 
     42  equal(
     43    ShellService.shouldCheckDefaultBrowser,
     44    true,
     45    "Policy changed it to check"
     46  );
     47 
     48  // Try to change it to false and check that it doesn't take effect
     49  ShellService.shouldCheckDefaultBrowser = false;
     50 
     51  equal(ShellService.shouldCheckDefaultBrowser, true, "Policy is enforced");
     52 });