tor-browser

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

browser_etp_customize_1.js (2781B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const CAT_PREF = "browser.contentblocking.category";
      7 const BASELINE_PREF = "privacy.trackingprotection.allow_list.baseline.enabled";
      8 const CONVENIENCE_PREF =
      9  "privacy.trackingprotection.allow_list.convenience.enabled";
     10 
     11 add_setup(async function () {
     12  await SpecialPowers.pushPrefEnv({
     13    set: [["browser.settings-redesign.enabled", true]],
     14  });
     15 });
     16 
     17 add_task(async function test_etp_reset_buttons_update_category() {
     18  await SpecialPowers.pushPrefEnv({
     19    set: [[CAT_PREF, "standard"]],
     20  });
     21 
     22  let { doc } = await openEtpCustomizePage();
     23  let standardButton = getControl(doc, "etpResetStandardButton");
     24  let strictButton = getControl(doc, "etpResetStrictButton");
     25 
     26  ok(standardButton.disabled, "Standard reset button disabled on standard");
     27  ok(!strictButton.disabled, "Strict reset button enabled");
     28 
     29  let prefChange = waitForAndAssertPrefState(
     30    CAT_PREF,
     31    "strict",
     32    "ETP category pref switched to strict"
     33  );
     34  synthesizeClick(strictButton);
     35  await prefChange;
     36 
     37  ok(strictButton.disabled, "Strict reset button disabled after use");
     38  ok(
     39    !standardButton.disabled,
     40    "Standard reset button enabled after switching to strict"
     41  );
     42 
     43  prefChange = waitForAndAssertPrefState(
     44    CAT_PREF,
     45    "standard",
     46    "ETP category pref switched back to standard"
     47  );
     48  synthesizeClick(standardButton);
     49  await prefChange;
     50 
     51  gBrowser.removeCurrentTab();
     52 });
     53 
     54 add_task(async function test_custom_allow_list_controls_match_old_behavior() {
     55  await SpecialPowers.pushPrefEnv({
     56    set: [
     57      [CAT_PREF, "custom"],
     58      [BASELINE_PREF, true],
     59      [CONVENIENCE_PREF, true],
     60    ],
     61  });
     62 
     63  let { doc } = await openEtpCustomizePage();
     64  let baselineCheckbox = getControl(doc, "etpAllowListBaselineEnabledCustom");
     65  let convenienceCheckbox = getControl(
     66    doc,
     67    "etpAllowListConvenienceEnabledCustom"
     68  );
     69 
     70  ok(baselineCheckbox.checked, "Custom baseline checkbox starts checked");
     71 
     72  await clickEtpBaselineCheckboxWithConfirm(
     73    doc,
     74    "etpAllowListBaselineEnabledCustom",
     75    BASELINE_PREF,
     76    false,
     77    1
     78  );
     79 
     80  ok(
     81    !Services.prefs.getBoolPref(BASELINE_PREF),
     82    "Baseline pref disabled from custom controls"
     83  );
     84  ok(
     85    convenienceCheckbox.parentDisabled,
     86    "Custom convenience checkbox disabled when baseline unchecked"
     87  );
     88 
     89  let baselinePrefChange = waitForAndAssertPrefState(
     90    BASELINE_PREF,
     91    true,
     92    "Baseline pref restored"
     93  );
     94  synthesizeClick(baselineCheckbox);
     95  await baselinePrefChange;
     96  await BrowserTestUtils.waitForCondition(
     97    () => !convenienceCheckbox.parentDisabled,
     98    "Custom convenience checkbox enabled once baseline rechecked"
     99  );
    100 
    101  gBrowser.removeCurrentTab();
    102 });