Commit ae1ac143 authored by Malte Jürgens's avatar Malte Jürgens
Browse files

Bug 1910312 - Unbreak privacy and security settings when MOZ_DATA_REPORTING is disabled a=RyanVM

Disabling `MOZ_DATA_REPORTING` results in the `PREF_UPLOAD_ENABLED` pref not
being loaded with `Preferences.add`. This means
`Preferences.get(PREF_UPLOAD_ENABLED)` can possibly be `null`, which was
previously not handled and resulted in an error for the whole privacy.js file.

So only call `dataCollectionCheckboxHandler` for the `privateAttribution`
checkbox if `MOZ_DATA_REPORTING` is enabled (otherwise the `privateAttribution`
checkbox also just doesn't exist). Also move the call into separate
`initPrivateAttributionCheckbox` function to be more consistent with previous
code.

Original Revision: https://phabricator.services.mozilla.com/D218265

Differential Revision: https://phabricator.services.mozilla.com/D219597
parent dddc675b
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -1234,17 +1234,8 @@ var gPrivacyPane = {
        this.initOptOutStudyCheckbox();
      }
      this.initAddonRecommendationsCheckbox();
      this.initPrivateAttributionCheckbox();
    }
    dataCollectionCheckboxHandler({
      checkbox: document.getElementById("privateAttribution"),
      pref: PREF_PRIVATE_ATTRIBUTION_ENABLED,
      matchPref() {
        return AppConstants.MOZ_TELEMETRY_REPORTING;
      },
      isDisabled() {
        return !AppConstants.MOZ_TELEMETRY_REPORTING;
      },
    });

    let signonBundle = document.getElementById("signonBundle");
    let pkiBundle = document.getElementById("pkiBundle");
@@ -3519,6 +3510,19 @@ var gPrivacyPane = {
    });
  },

  initPrivateAttributionCheckbox() {
    dataCollectionCheckboxHandler({
      checkbox: document.getElementById("privateAttribution"),
      pref: PREF_PRIVATE_ATTRIBUTION_ENABLED,
      matchPref() {
        return AppConstants.MOZ_TELEMETRY_REPORTING;
      },
      isDisabled() {
        return !AppConstants.MOZ_TELEMETRY_REPORTING;
      },
    });
  },

  observe(aSubject, aTopic) {
    switch (aTopic) {
      case "sitedatamanager:updating-sites":