Bug 1394053 - Disable download protection on non-official builds
MozReview-Commit-ID: JmpGJ8DOX48
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -1081,44 +1081,52 @@ var gPrivacyPane = {
let blockUnwantedPref = document.getElementById("browser.safebrowsing.downloads.remote.block_potentially_unwanted");
let blockUncommonPref = document.getElementById("browser.safebrowsing.downloads.remote.block_uncommon");
enableSafeBrowsing.addEventListener("command", function() {
safeBrowsingPhishingPref.value = enableSafeBrowsing.checked;
safeBrowsingMalwarePref.value = enableSafeBrowsing.checked;
if (enableSafeBrowsing.checked) {
- blockDownloads.removeAttribute("disabled");
- if (blockDownloads.checked) {
+ if (blockDownloads) {
+ blockDownloads.removeAttribute("disabled");
+ if (blockDownloads.checked) {
+ blockUncommonUnwanted.removeAttribute("disabled");
+ }
+ } else {
blockUncommonUnwanted.removeAttribute("disabled");
}
} else {
- blockDownloads.setAttribute("disabled", "true");
+ if (blockDownloads) {
+ blockDownloads.setAttribute("disabled", "true");
+ }
blockUncommonUnwanted.setAttribute("disabled", "true");
}
});
- blockDownloads.addEventListener("command", function() {
- blockDownloadsPref.value = blockDownloads.checked;
- if (blockDownloads.checked) {
- blockUncommonUnwanted.removeAttribute("disabled");
- } else {
- blockUncommonUnwanted.setAttribute("disabled", "true");
- }
- });
+ if (blockDownloads) {
+ blockDownloads.addEventListener("command", function() {
+ blockDownloadsPref.value = blockDownloads.checked;
+ if (blockDownloads.checked) {
+ blockUncommonUnwanted.removeAttribute("disabled");
+ } else {
+ blockUncommonUnwanted.setAttribute("disabled", "true");
+ }
+ });
+ }
blockUncommonUnwanted.addEventListener("command", function() {
blockUnwantedPref.value = blockUncommonUnwanted.checked;
blockUncommonPref.value = blockUncommonUnwanted.checked;
let malware = malwareTable.value
.split(",")
.filter(x => x !== "goog-unwanted-proto" &&
- x !== "goog-unwanted-shavar" &&
- x !== "test-unwanted-simple");
+ x !== "goog-unwanted-shavar" &&
+ x !== "test-unwanted-simple");
if (blockUncommonUnwanted.checked) {
if (malware.indexOf("goog-malware-shavar") != -1) {
malware.push("goog-unwanted-shavar");
} else {
malware.push("goog-unwanted-proto");
}
@@ -1130,23 +1138,28 @@ var gPrivacyPane = {
malwareTable.value = malware.join(",");
});
// set initial values
enableSafeBrowsing.checked = safeBrowsingPhishingPref.value && safeBrowsingMalwarePref.value;
if (!enableSafeBrowsing.checked) {
- blockDownloads.setAttribute("disabled", "true");
+ if (blockDownloads) {
+ blockDownloads.setAttribute("disabled", "true");
+ }
+
blockUncommonUnwanted.setAttribute("disabled", "true");
}
- blockDownloads.checked = blockDownloadsPref.value;
- if (!blockDownloadsPref.value) {
- blockUncommonUnwanted.setAttribute("disabled", "true");
+ if (blockDownloads) {
+ blockDownloads.checked = blockDownloadsPref.value;
+ if (!blockDownloadsPref.value) {
+ blockUncommonUnwanted.setAttribute("disabled", "true");
+ }
}
blockUncommonUnwanted.checked = blockUnwantedPref.value && blockUncommonPref.value;
},
/**
* Displays the exceptions lists for add-on installation warnings.
*/
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -727,19 +727,21 @@
<!-- addons, forgery (phishing) UI Security -->
<groupbox id="addonsPhishingGroup" data-category="panePrivacy" hidden="true">
<caption><label>&phishingProtection.label;</label></caption>
<checkbox id="enableSafeBrowsing"
label="&enableSafeBrowsing.label;"
accesskey="&enableSafeBrowsing.accesskey;" />
<vbox class="indent">
+#ifdef MOZILLA_OFFICIAL
<checkbox id="blockDownloads"
label="&blockDownloads.label;"
accesskey="&blockDownloads.accesskey;" />
+#endif
<checkbox id="blockUncommonUnwanted"
label="&blockUncommonAndUnwanted.label;"
accesskey="&blockUncommonAndUnwanted.accesskey;" />
</vbox>
</groupbox>
<!-- Certificates -->
<groupbox id="certSelection" data-category="panePrivacy" hidden="true">
--- a/browser/components/preferences/in-content/tests/browser_security-1.js
+++ b/browser/components/preferences/in-content/tests/browser_security-1.js
@@ -35,34 +35,41 @@ add_task(async function() {
gBrowser.reload();
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let doc = gBrowser.selectedBrowser.contentDocument;
let checkbox = doc.getElementById("enableSafeBrowsing");
let blockDownloads = doc.getElementById("blockDownloads");
let blockUncommon = doc.getElementById("blockUncommonUnwanted");
let checked = checkbox.checked;
+ if (!AppConstants.MOZILLA_OFFICIAL) {
+ is(blockDownloads, undefined, "downloads protection is disabled in un-official builds");
+ } else {
+ is(blockDownloads.hasAttribute("disabled"), !checked, "block downloads checkbox is set correctly");
+ }
+
is(checked, val1 && val2, "safebrowsing preference is initialized correctly");
// should be disabled when checked is false (= pref is turned off)
- is(blockDownloads.hasAttribute("disabled"), !checked, "block downloads checkbox is set correctly");
is(blockUncommon.hasAttribute("disabled"), !checked, "block uncommon checkbox is set correctly");
// scroll the checkbox into the viewport and click checkbox
checkbox.scrollIntoView();
EventUtils.synthesizeMouseAtCenter(checkbox, {}, gBrowser.selectedBrowser.contentWindow);
// check that both settings are now turned on or off
is(Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled"), !checked,
"safebrowsing.enabled is set correctly");
is(Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled"), !checked,
"safebrowsing.malware.enabled is set correctly");
// check if the other checkboxes have updated
checked = checkbox.checked;
- is(blockDownloads.hasAttribute("disabled"), !checked, "block downloads checkbox is set correctly");
- is(blockUncommon.hasAttribute("disabled"), !checked || !blockDownloads.checked, "block uncommon checkbox is set correctly");
+ if (blockDownloads) {
+ is(blockDownloads.hasAttribute("disabled"), !checked, "block downloads checkbox is set correctly");
+ is(blockUncommon.hasAttribute("disabled"), !checked || !blockDownloads.checked, "block uncommon checkbox is set correctly");
+ }
}
await checkPrefSwitch(true, true);
await checkPrefSwitch(false, true);
await checkPrefSwitch(true, false);
await checkPrefSwitch(false, false);
});
--- a/browser/components/preferences/in-content/tests/browser_security-2.js
+++ b/browser/components/preferences/in-content/tests/browser_security-2.js
@@ -31,16 +31,21 @@ add_task(async function() {
async function checkPrefSwitch(val) {
Services.prefs.setBoolPref("browser.safebrowsing.downloads.enabled", val);
gBrowser.reload();
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let doc = gBrowser.selectedBrowser.contentDocument;
let checkbox = doc.getElementById("blockDownloads");
+ if (!AppConstants.MOZILLA_OFFICIAL) {
+ is(checkbox, undefined, "downloads protection is disabled in un-official builds");
+ return;
+ }
+
let blockUncommon = doc.getElementById("blockUncommonUnwanted");
let checked = checkbox.checked;
is(checked, val, "downloads preference is initialized correctly");
// should be disabled when val is false (= pref is turned off)
is(blockUncommon.hasAttribute("disabled"), !val, "block uncommon checkbox is set correctly");
// scroll the checkbox into view, otherwise the synthesizeMouseAtCenter will be ignored, and click it
checkbox.scrollIntoView();