2 "browser.safebrowsing.phishing.enabled",
3 "browser.safebrowsing.malware.enabled",
5 "browser.safebrowsing.downloads.enabled",
7 "browser.safebrowsing.downloads.remote.block_potentially_unwanted",
8 "browser.safebrowsing.downloads.remote.block_uncommon",
11 let originals = PREFS.map(pref => [pref, Services.prefs.getBoolPref(pref)]);
12 let originalMalwareTable = Services.prefs.getCharPref(
13 "urlclassifier.malwareTable"
15 registerCleanupFunction(function () {
16 originals.forEach(([pref, val]) => Services.prefs.setBoolPref(pref, val));
17 Services.prefs.setCharPref(
18 "urlclassifier.malwareTable",
23 // This test only opens the Preferences once, and then reloads the page
24 // each time that it wants to test various preference combinations. We
25 // only use one tab (instead of opening/closing for each test) for all
26 // to help improve test times on debug builds.
27 add_setup(async function () {
28 await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
29 registerCleanupFunction(async function () {
30 BrowserTestUtils.removeTab(gBrowser.selectedTab);
34 // test the safebrowsing preference
35 add_task(async function () {
36 async function checkPrefSwitch(val1, val2) {
37 Services.prefs.setBoolPref("browser.safebrowsing.phishing.enabled", val1);
38 Services.prefs.setBoolPref("browser.safebrowsing.malware.enabled", val2);
41 await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
43 let doc = gBrowser.selectedBrowser.contentDocument;
44 let checkbox = doc.getElementById("enableSafeBrowsing");
45 let blockDownloads = doc.getElementById("blockDownloads");
46 let blockUncommon = doc.getElementById("blockUncommonUnwanted");
47 let checked = checkbox.checked;
49 blockDownloads.hasAttribute("disabled"),
51 "block downloads checkbox is set correctly"
57 "safebrowsing preference is initialized correctly"
59 // should be disabled when checked is false (= pref is turned off)
61 blockUncommon.hasAttribute("disabled"),
63 "block uncommon checkbox is set correctly"
66 // scroll the checkbox into the viewport and click checkbox
67 checkbox.scrollIntoView();
68 EventUtils.synthesizeMouseAtCenter(
71 gBrowser.selectedBrowser.contentWindow
74 // check that both settings are now turned on or off
76 Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled"),
78 "safebrowsing.enabled is set correctly"
81 Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled"),
83 "safebrowsing.malware.enabled is set correctly"
86 // check if the other checkboxes have updated
87 checked = checkbox.checked;
90 blockDownloads.hasAttribute("disabled"),
92 "block downloads checkbox is set correctly"
95 blockUncommon.hasAttribute("disabled"),
96 !checked || !blockDownloads.checked,
97 "block uncommon checkbox is set correctly"
102 await checkPrefSwitch(true, true);
103 await checkPrefSwitch(false, true);
104 await checkPrefSwitch(true, false);
105 await checkPrefSwitch(false, false);