tor-browser

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

browser_windows_launch_on_login_msix.js (3443B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 ChromeUtils.defineESModuleGetters(this, {
      7  BackgroundUpdate: "resource://gre/modules/BackgroundUpdate.sys.mjs",
      8  MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
      9  PermissionTestUtils: "resource://testing-common/PermissionTestUtils.sys.mjs",
     10  TestUtils: "resource://testing-common/TestUtils.sys.mjs",
     11  WindowsLaunchOnLogin: "resource://gre/modules/WindowsLaunchOnLogin.sys.mjs",
     12 });
     13 
     14 add_task(async function test_check_uncheck_checkbox() {
     15  await ExperimentAPI.ready();
     16  let doCleanup = await NimbusTestUtils.enrollWithFeatureConfig({
     17    featureId: "windowsLaunchOnLogin",
     18    value: { enabled: true },
     19  });
     20  // Open preferences to general pane
     21  await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
     22    leaveOpen: true,
     23  });
     24  let doc = gBrowser.contentDocument;
     25 
     26  let launchOnLoginCheckbox = doc.getElementById("windowsLaunchOnLogin");
     27  launchOnLoginCheckbox.click();
     28  ok(launchOnLoginCheckbox.checked, "Autostart checkbox checked");
     29 
     30  // Checking whether everything was enabled as expected isn't
     31  // really a problem in-product but we can encounter a race condition
     32  // here as both enabling and checking are asynchronous.
     33  await TestUtils.waitForCondition(async () => {
     34    let enabled = await WindowsLaunchOnLogin.getLaunchOnLoginEnabledMSIX();
     35    return enabled;
     36  }, "Wait for async get enabled operation to return true");
     37 
     38  launchOnLoginCheckbox.click();
     39  ok(!launchOnLoginCheckbox.checked, "Autostart checkbox unchecked");
     40 
     41  await TestUtils.waitForCondition(async () => {
     42    let enabled = await WindowsLaunchOnLogin.getLaunchOnLoginEnabledMSIX();
     43    return !enabled;
     44  }, "Wait for async get enabled operation to return false");
     45 
     46  gBrowser.removeCurrentTab();
     47  await doCleanup();
     48 });
     49 
     50 add_task(async function enable_external_startuptask() {
     51  await ExperimentAPI.ready();
     52  let doCleanup = await NimbusTestUtils.enrollWithFeatureConfig({
     53    featureId: "windowsLaunchOnLogin",
     54    value: { enabled: true },
     55  });
     56  // Ensure the task is disabled before enabling it
     57  await WindowsLaunchOnLogin._disableLaunchOnLoginMSIX();
     58  let enabled = await WindowsLaunchOnLogin.enableLaunchOnLoginMSIX();
     59  ok(enabled, "Task is enabled");
     60 
     61  // Open preferences to general pane
     62  await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
     63    leaveOpen: true,
     64  });
     65  let doc = gBrowser.contentDocument;
     66 
     67  let launchOnLoginCheckbox = doc.getElementById("windowsLaunchOnLogin");
     68  ok(launchOnLoginCheckbox.checked, "Autostart checkbox automatically checked");
     69 
     70  gBrowser.removeCurrentTab();
     71  await doCleanup();
     72 });
     73 
     74 add_task(async function disable_external_startuptask() {
     75  await ExperimentAPI.ready();
     76  let doCleanup = await NimbusTestUtils.enrollWithFeatureConfig({
     77    featureId: "windowsLaunchOnLogin",
     78    value: { enabled: true },
     79  });
     80  // Disable the startup task to ensure it's reflected in the settings
     81  await WindowsLaunchOnLogin._disableLaunchOnLoginMSIX();
     82 
     83  // Open preferences to general pane
     84  await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
     85    leaveOpen: true,
     86  });
     87  let doc = gBrowser.contentDocument;
     88 
     89  let launchOnLoginCheckbox = doc.getElementById("windowsLaunchOnLogin");
     90  ok(
     91    !launchOnLoginCheckbox.checked,
     92    "Launch on login checkbox automatically unchecked"
     93  );
     94 
     95  gBrowser.removeCurrentTab();
     96  await doCleanup();
     97 });