[tor-commits] [tor-browser] 11/37: Bug 1568275 - Disable deceptive content prefs when locked. r=Gijs, a=RyanVM
gitolite role
git at cupani.torproject.org
Wed Jun 22 18:27:20 UTC 2022
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.
commit be2cfa3b75bfd5904052e9f71f7ba57ad4f03ffd
Author: Mike Kaply <mozilla at kaply.com>
AuthorDate: Tue May 10 20:13:35 2022 +0000
Bug 1568275 - Disable deceptive content prefs when locked. r=Gijs, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D144476
---
browser/components/preferences/privacy.js | 35 +++---
browser/components/preferences/tests/browser.ini | 1 +
.../preferences/tests/browser_security-3.js | 130 +++++++++++++++++++++
3 files changed, 152 insertions(+), 14 deletions(-)
diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js
index 35b37b099e937..e5d051ea96035 100644
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -2311,24 +2311,21 @@ var gPrivacyPane = {
safeBrowsingPhishingPref.value = enableSafeBrowsing.checked;
safeBrowsingMalwarePref.value = enableSafeBrowsing.checked;
- if (enableSafeBrowsing.checked) {
- blockDownloads.removeAttribute("disabled");
- if (blockDownloads.checked) {
- blockUncommonUnwanted.removeAttribute("disabled");
- }
- } else {
- blockDownloads.setAttribute("disabled", "true");
- blockUncommonUnwanted.setAttribute("disabled", "true");
- }
+ blockDownloads.disabled =
+ !enableSafeBrowsing.checked || blockDownloadsPref.locked;
+ blockUncommonUnwanted.disabled =
+ !blockDownloads.checked ||
+ !enableSafeBrowsing.checked ||
+ blockUnwantedPref.locked ||
+ blockUncommonPref.locked;
});
blockDownloads.addEventListener("command", function() {
blockDownloadsPref.value = blockDownloads.checked;
- if (blockDownloads.checked) {
- blockUncommonUnwanted.removeAttribute("disabled");
- } else {
- blockUncommonUnwanted.setAttribute("disabled", "true");
- }
+ blockUncommonUnwanted.disabled =
+ !blockDownloads.checked ||
+ blockUnwantedPref.locked ||
+ blockUncommonPref.locked;
});
blockUncommonUnwanted.addEventListener("command", function() {
@@ -2378,6 +2375,16 @@ var gPrivacyPane = {
}
blockUncommonUnwanted.checked =
blockUnwantedPref.value && blockUncommonPref.value;
+
+ if (safeBrowsingPhishingPref.locked || safeBrowsingMalwarePref.locked) {
+ enableSafeBrowsing.disabled = true;
+ }
+ if (blockDownloadsPref.locked) {
+ blockDownloads.disabled = true;
+ }
+ if (blockUnwantedPref.locked || blockUncommonPref.locked) {
+ blockUncommonUnwanted.disabled = true;
+ }
},
/**
diff --git a/browser/components/preferences/tests/browser.ini b/browser/components/preferences/tests/browser.ini
index 6f6bcc972d89e..f802bbabd3397 100644
--- a/browser/components/preferences/tests/browser.ini
+++ b/browser/components/preferences/tests/browser.ini
@@ -113,6 +113,7 @@ skip-if =
[browser_searchsuggestions.js]
[browser_security-1.js]
[browser_security-2.js]
+[browser_security-3.js]
[browser_spotlight.js]
[browser_site_login_exceptions.js]
[browser_site_login_exceptions_policy.js]
diff --git a/browser/components/preferences/tests/browser_security-3.js b/browser/components/preferences/tests/browser_security-3.js
new file mode 100644
index 0000000000000..4e7c5a1909105
--- /dev/null
+++ b/browser/components/preferences/tests/browser_security-3.js
@@ -0,0 +1,130 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function setup() {
+ await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
+ registerCleanupFunction(async function() {
+ Services.prefs.unlockPref("browser.safebrowsing.phishing.enabled");
+ Services.prefs.unlockPref("browser.safebrowsing.malware.enabled");
+ Services.prefs.unlockPref("browser.safebrowsing.downloads.enabled");
+ Services.prefs.unlockPref(
+ "browser.safebrowsing.downloads.remote.block_potentially_unwanted"
+ );
+ Services.prefs.unlockPref(
+ "browser.safebrowsing.downloads.remote.block_uncommon"
+ );
+ BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ });
+});
+
+// This test just reloads the preferences page for the various tests.
+add_task(async function() {
+ Services.prefs.lockPref("browser.safebrowsing.phishing.enabled");
+ Services.prefs.lockPref("browser.safebrowsing.malware.enabled");
+ Services.prefs.lockPref("browser.safebrowsing.downloads.enabled");
+ Services.prefs.lockPref(
+ "browser.safebrowsing.downloads.remote.block_potentially_unwanted"
+ );
+ Services.prefs.lockPref(
+ "browser.safebrowsing.downloads.remote.block_uncommon"
+ );
+
+ gBrowser.reload();
+ await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+
+ let doc = gBrowser.selectedBrowser.contentDocument;
+ is(
+ doc.getElementById("enableSafeBrowsing").disabled,
+ true,
+ "Safe browsing should be disabled"
+ );
+ is(
+ doc.getElementById("blockDownloads").disabled,
+ true,
+ "Block downloads should be disabled"
+ );
+ is(
+ doc.getElementById("blockUncommonUnwanted").disabled,
+ true,
+ "Block common unwanted should be disabled"
+ );
+
+ Services.prefs.unlockPref("browser.safebrowsing.phishing.enabled");
+ Services.prefs.unlockPref("browser.safebrowsing.malware.enabled");
+
+ gBrowser.reload();
+ await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+
+ doc = gBrowser.selectedBrowser.contentDocument;
+
+ let checkbox = doc.getElementById("enableSafeBrowsing");
+ checkbox.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(
+ checkbox,
+ {},
+ gBrowser.selectedBrowser.contentWindow
+ );
+
+ is(
+ doc.getElementById("blockDownloads").disabled,
+ true,
+ "Block downloads should be disabled"
+ );
+ is(
+ doc.getElementById("blockUncommonUnwanted").disabled,
+ true,
+ "Block common unwanted should be disabled"
+ );
+
+ EventUtils.synthesizeMouseAtCenter(
+ checkbox,
+ {},
+ gBrowser.selectedBrowser.contentWindow
+ );
+
+ is(
+ doc.getElementById("blockDownloads").disabled,
+ true,
+ "Block downloads should be disabled"
+ );
+ is(
+ doc.getElementById("blockUncommonUnwanted").disabled,
+ true,
+ "Block common unwanted should be disabled"
+ );
+
+ Services.prefs.unlockPref("browser.safebrowsing.downloads.enabled");
+
+ gBrowser.reload();
+ await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+
+ doc = gBrowser.selectedBrowser.contentDocument;
+
+ checkbox = doc.getElementById("blockDownloads");
+ checkbox.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(
+ checkbox,
+ {},
+ gBrowser.selectedBrowser.contentWindow
+ );
+
+ is(
+ doc.getElementById("blockUncommonUnwanted").disabled,
+ true,
+ "Block common unwanted should be disabled"
+ );
+
+ EventUtils.synthesizeMouseAtCenter(
+ checkbox,
+ {},
+ gBrowser.selectedBrowser.contentWindow
+ );
+
+ is(
+ doc.getElementById("blockUncommonUnwanted").disabled,
+ true,
+ "Block common unwanted should be disabled"
+ );
+});
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tor-commits
mailing list