tor-browser

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

browser_privacy_uploadEnabled.js (1293B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Tests the submitHealthReportBox checkbox is automatically updated when the
      5 // corresponding datareporting.healthreport.uploadEnabled pref is changed.
      6 
      7 const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
      8 
      9 add_task(async function test_updatePageFromPref() {
     10  if (!AppConstants.MOZ_TELEMETRY_REPORTING) {
     11    ok(true, "Skipping test because telemetry reporting is disabled");
     12    return;
     13  }
     14 
     15  await SpecialPowers.pushPrefEnv({
     16    set: [[PREF_UPLOAD_ENABLED, false]],
     17  });
     18 
     19  await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
     20    leaveOpen: true,
     21  });
     22 
     23  const doc = gBrowser.selectedBrowser.contentDocument;
     24  const checkbox = doc.getElementById("submitHealthReportBox");
     25  Assert.ok(!checkbox.checked, "checkbox should match pref state on page load");
     26 
     27  await SpecialPowers.pushPrefEnv({
     28    set: [[PREF_UPLOAD_ENABLED, true]],
     29  });
     30 
     31  let checkboxUpdated = BrowserTestUtils.waitForMutationCondition(
     32    checkbox,
     33    { attributeFilter: ["checked"] },
     34    () => checkbox.checked
     35  );
     36  await checkboxUpdated;
     37 
     38  Assert.ok(checkbox.checked, "pref change should trigger checkbox update");
     39 
     40  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     41 });