summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/in-content/tests/browser_security.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
commit8148615da179fdd60f19018e13b4e94b95609cc6 (patch)
tree771fccdd99fa3adf35fdd2c81d8197b415a89b91 /browser/components/preferences/in-content/tests/browser_security.js
parent494802c1be7888025b95260d23db187467d2b9dd (diff)
downloadUXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.gz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.lz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.xz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.zip
Remove browser tests - Part 1: The Tests (except for experiments)
Diffstat (limited to 'browser/components/preferences/in-content/tests/browser_security.js')
-rw-r--r--browser/components/preferences/in-content/tests/browser_security.js130
1 files changed, 0 insertions, 130 deletions
diff --git a/browser/components/preferences/in-content/tests/browser_security.js b/browser/components/preferences/in-content/tests/browser_security.js
deleted file mode 100644
index e6eb2a91d..000000000
--- a/browser/components/preferences/in-content/tests/browser_security.js
+++ /dev/null
@@ -1,130 +0,0 @@
-const PREFS = [
- "browser.safebrowsing.phishing.enabled",
- "browser.safebrowsing.malware.enabled",
-
- "browser.safebrowsing.downloads.enabled",
-
- "browser.safebrowsing.downloads.remote.block_potentially_unwanted",
- "browser.safebrowsing.downloads.remote.block_uncommon"
-];
-
-let originals = PREFS.map(pref => [pref, Services.prefs.getBoolPref(pref)])
-let originalMalwareTable = Services.prefs.getCharPref("urlclassifier.malwareTable");
-registerCleanupFunction(function() {
- originals.forEach(([pref, val]) => Services.prefs.setBoolPref(pref, val))
- Services.prefs.setCharPref("urlclassifier.malwareTable", originalMalwareTable);
-});
-
-// test the safebrowsing preference
-add_task(function*() {
- function* checkPrefSwitch(val1, val2) {
- Services.prefs.setBoolPref("browser.safebrowsing.phishing.enabled", val1);
- Services.prefs.setBoolPref("browser.safebrowsing.malware.enabled", val2);
-
- yield openPreferencesViaOpenPreferencesAPI("security", undefined, { leaveOpen: true });
-
- let doc = gBrowser.selectedBrowser.contentDocument;
- let checkbox = doc.getElementById("enableSafeBrowsing");
- let blockDownloads = doc.getElementById("blockDownloads");
- let blockUncommon = doc.getElementById("blockUncommonUnwanted");
- let checked = checkbox.checked;
- 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");
-
- // click the checkbox
- 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");
-
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- }
-
- yield checkPrefSwitch(true, true);
- yield checkPrefSwitch(false, true);
- yield checkPrefSwitch(true, false);
- yield checkPrefSwitch(false, false);
-});
-
-// test the download protection preference
-add_task(function*() {
- function* checkPrefSwitch(val) {
- Services.prefs.setBoolPref("browser.safebrowsing.downloads.enabled", val);
-
- yield openPreferencesViaOpenPreferencesAPI("security", undefined, { leaveOpen: true });
-
- let doc = gBrowser.selectedBrowser.contentDocument;
- let checkbox = doc.getElementById("blockDownloads");
- 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");
-
- // click the checkbox
- EventUtils.synthesizeMouseAtCenter(checkbox, {}, gBrowser.selectedBrowser.contentWindow);
-
- // check that setting is now turned on or off
- is(Services.prefs.getBoolPref("browser.safebrowsing.downloads.enabled"), !checked,
- "safebrowsing.downloads preference is set correctly");
-
- // check if the uncommon warning checkbox has updated
- is(blockUncommon.hasAttribute("disabled"), val, "block uncommon checkbox is set correctly");
-
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- }
-
- yield checkPrefSwitch(true);
- yield checkPrefSwitch(false);
-});
-
-// test the unwanted/uncommon software warning preference
-add_task(function*() {
- function* checkPrefSwitch(val1, val2) {
- Services.prefs.setBoolPref("browser.safebrowsing.downloads.remote.block_potentially_unwanted", val1);
- Services.prefs.setBoolPref("browser.safebrowsing.downloads.remote.block_uncommon", val2);
-
- yield openPreferencesViaOpenPreferencesAPI("security", undefined, { leaveOpen: true });
-
- let doc = gBrowser.selectedBrowser.contentDocument;
- let checkbox = doc.getElementById("blockUncommonUnwanted");
- let checked = checkbox.checked;
- is(checked, val1 && val2, "unwanted/uncommon preference is initialized correctly");
-
- // click the checkbox
- EventUtils.synthesizeMouseAtCenter(checkbox, {}, gBrowser.selectedBrowser.contentWindow);
-
- // check that both settings are now turned on or off
- is(Services.prefs.getBoolPref("browser.safebrowsing.downloads.remote.block_potentially_unwanted"), !checked,
- "block_potentially_unwanted is set correctly");
- is(Services.prefs.getBoolPref("browser.safebrowsing.downloads.remote.block_uncommon"), !checked,
- "block_uncommon is set correctly");
-
- // when the preference is on, the malware table should include these ids
- let malwareTable = Services.prefs.getCharPref("urlclassifier.malwareTable").split(",");
- is(malwareTable.includes("goog-unwanted-shavar"), !checked,
- "malware table doesn't include goog-unwanted-shavar");
- is(malwareTable.includes("test-unwanted-simple"), !checked,
- "malware table doesn't include test-unwanted-simple");
- let sortedMalware = malwareTable.slice(0);
- sortedMalware.sort();
- Assert.deepEqual(malwareTable, sortedMalware, "malware table has been sorted");
-
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- }
-
- yield* checkPrefSwitch(true, true);
- yield* checkPrefSwitch(false, true);
- yield* checkPrefSwitch(true, false);
- yield* checkPrefSwitch(false, false);
-});