зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset da290b2edb66 (bug 1365133)
--HG-- rename : browser/components/preferences/in-content-new/tests/browser_security-2.js => browser/components/preferences/in-content-new/tests/browser_security.js
This commit is contained in:
Родитель
76029cba99
Коммит
a8b6e495f3
|
@ -39,6 +39,7 @@ add_task(async function test_settingsOpen_button() {
|
|||
return;
|
||||
}
|
||||
|
||||
let closePromise = promiseWindowClosed(alertWindow);
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:preferences#privacy");
|
||||
let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem");
|
||||
openSettingsMenuItem.click();
|
||||
|
@ -47,7 +48,7 @@ add_task(async function test_settingsOpen_button() {
|
|||
let tab = await tabPromise;
|
||||
ok(tab, "The notification settings tab opened");
|
||||
|
||||
await promiseWindowClosed(alertWindow);
|
||||
await closePromise;
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
} finally {
|
||||
|
|
|
@ -288,11 +288,6 @@ var gPrivacyPane = {
|
|||
bundlePrefs.getString("removeAllCookies.label"),
|
||||
bundlePrefs.getString("removeSelectedCookies.label"),
|
||||
]);
|
||||
|
||||
// Notify observers that the UI is now ready
|
||||
Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.notifyObservers(window, "privacy-pane-loaded");
|
||||
},
|
||||
|
||||
// TRACKING PROTECTION MODE
|
||||
|
|
|
@ -52,8 +52,7 @@ skip-if = e10s
|
|||
[browser_privacypane_8.js]
|
||||
[browser_sanitizeOnShutdown_prefLocked.js]
|
||||
[browser_searchsuggestions.js]
|
||||
[browser_security-1.js]
|
||||
[browser_security-2.js]
|
||||
[browser_security.js]
|
||||
[browser_siteData.js]
|
||||
[browser_siteData2.js]
|
||||
[browser_site_login_exceptions.js]
|
||||
|
|
|
@ -5,8 +5,8 @@ var container;
|
|||
SimpleTest.requestCompleteLog();
|
||||
|
||||
add_task(async function setup() {
|
||||
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
|
||||
info("Preferences page opened on the paneGeneral pane.");
|
||||
await openPreferencesViaOpenPreferencesAPI("applications", {leaveOpen: true});
|
||||
info("Preferences page opened on the applications pane.");
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
gBrowser.removeCurrentTab();
|
||||
|
|
|
@ -11,8 +11,8 @@ registerCleanupFunction(function() {
|
|||
add_task(async function() {
|
||||
originalWindowHeight = window.outerHeight;
|
||||
window.resizeTo(window.outerWidth, 300);
|
||||
let prefs = await openPreferencesViaOpenPreferencesAPI("paneSearch", {leaveOpen: true});
|
||||
is(prefs.selectedPane, "paneSearch", "Search pane was selected");
|
||||
let prefs = await openPreferencesViaOpenPreferencesAPI("paneApplications", {leaveOpen: true});
|
||||
is(prefs.selectedPane, "paneApplications", "Applications pane was selected");
|
||||
let mainContent = gBrowser.contentDocument.querySelector(".main-content");
|
||||
mainContent.scrollTop = 50;
|
||||
is(mainContent.scrollTop, 50, "main-content should be scrolled 50 pixels");
|
||||
|
@ -21,3 +21,4 @@ add_task(async function() {
|
|||
is(mainContent.scrollTop, 0,
|
||||
"Switching to a different category should reset the scroll position");
|
||||
});
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ registerCleanupFunction(function() {
|
|||
add_task(async function() {
|
||||
let prefs = await openPreferencesViaOpenPreferencesAPI("panePrivacy");
|
||||
is(prefs.selectedPane, "panePrivacy", "Privacy pane was selected");
|
||||
prefs = await openPreferencesViaOpenPreferencesAPI("advanced");
|
||||
is(prefs.selectedPane, "paneAdvanced", "Advanced pane was selected");
|
||||
prefs = await openPreferencesViaHash("privacy");
|
||||
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected when hash is 'privacy'");
|
||||
prefs = await openPreferencesViaOpenPreferencesAPI("nonexistant-category");
|
||||
|
@ -24,6 +26,7 @@ add_task(async function() {
|
|||
let doc = gBrowser.contentDocument;
|
||||
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
|
||||
ok(doc.querySelector("#locationBarGroup").hidden, "Location Bar prefs should be hidden when only Reports are requested");
|
||||
ok(!doc.querySelector("#header-privacy").hidden, "The header should be visible when a subcategory is requested");
|
||||
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
prefs = await openPreferencesViaOpenPreferencesAPI("general-search", {leaveOpen: true});
|
||||
is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
|
||||
|
@ -51,6 +54,7 @@ add_task(async function() {
|
|||
is(selectedPane, "panePrivacy", "Privacy pane should be selected");
|
||||
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
|
||||
ok(doc.querySelector("#locationBarGroup").hidden, "Location Bar prefs should be hidden when only Reports are requested");
|
||||
ok(!doc.querySelector("#header-privacy").hidden, "The header should be visible when a subcategory is requested");
|
||||
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ add_task(async function() {
|
|||
await checkPageScrolling(container, "radio");
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:preferences#search" }, async function(browser) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:preferences" }, async function(browser) {
|
||||
let doc = browser.contentDocument;
|
||||
let container = doc.getElementsByClassName("main-content")[0];
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ function test() {
|
|||
getService(Ci.nsIHandlerService);
|
||||
hserv.store(info);
|
||||
|
||||
openPreferencesViaOpenPreferencesAPI("general", {leaveOpen: true}).then(
|
||||
openPreferencesViaOpenPreferencesAPI("applications", {leaveOpen: true}).then(
|
||||
() => runTest(gBrowser.selectedBrowser.contentWindow)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ function runTest(win) {
|
|||
gElements = tab.getElementById("mainPrefPane").children;
|
||||
|
||||
let panes = [
|
||||
"General", "Search",
|
||||
"Privacy", "Sync",
|
||||
"General", "Applications",
|
||||
"Privacy", "Sync", "Advanced",
|
||||
];
|
||||
|
||||
for (let pane of panes) {
|
||||
|
|
|
@ -16,7 +16,7 @@ function setupFakeHandler() {
|
|||
|
||||
add_task(async function() {
|
||||
setupFakeHandler();
|
||||
await openPreferencesViaOpenPreferencesAPI("general", {leaveOpen: true});
|
||||
await openPreferencesViaOpenPreferencesAPI("applications", {leaveOpen: true});
|
||||
info("Preferences page opened on the applications pane.");
|
||||
let win = gBrowser.selectedBrowser.contentWindow;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Test Engine list
|
||||
add_task(async function() {
|
||||
let prefs = await openPreferencesViaOpenPreferencesAPI("search", {leaveOpen: true});
|
||||
is(prefs.selectedPane, "paneSearch", "Search pane is selected by default");
|
||||
let prefs = await openPreferencesViaOpenPreferencesAPI("general-search", {leaveOpen: true});
|
||||
is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
|
||||
let doc = gBrowser.contentDocument;
|
||||
|
||||
let tree = doc.querySelector("#engineList");
|
||||
|
|
|
@ -51,6 +51,6 @@ add_task(async function() {
|
|||
*/
|
||||
add_task(async function() {
|
||||
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
|
||||
evaluateSearchResults("request permission again", "permissionsGroup");
|
||||
evaluateSearchResults("request permission again", "notificationsGroup");
|
||||
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
|
|
@ -116,24 +116,16 @@ add_task(async function() {
|
|||
// Checks if back to generalPane
|
||||
for (let i = 0; i < mainPrefTag.childElementCount; i++) {
|
||||
let child = mainPrefTag.children[i]
|
||||
if (child.id == "paneGeneral"
|
||||
|| child.id == "startupGroup"
|
||||
if (child.id == "startupGroup"
|
||||
|| child.id == "defaultEngineGroup"
|
||||
|| child.id == "oneClickSearchProvidersGroup"
|
||||
|| child.id == "paneGeneral"
|
||||
|| child.id == "accessibilityGroup"
|
||||
|| child.id == "languagesGroup"
|
||||
|| child.id == "fontsGroup"
|
||||
|| child.id == "downloadsGroup"
|
||||
|| child.id == "applicationsGroup"
|
||||
|| child.id == "drmGroup"
|
||||
|| child.id == "updateApp"
|
||||
|| child.id == "browsingGroup"
|
||||
|| child.id == "performanceGroup"
|
||||
|| child.id == "connectionGroup"
|
||||
|| child.id == "generalCategory"
|
||||
|| child.id == "languageAndAppearanceCategory"
|
||||
|| child.id == "filesAndApplicationsCategory"
|
||||
|| child.id == "updatesCategory"
|
||||
|| child.id == "performanceCategory"
|
||||
|| child.id == "browsingCategory"
|
||||
|| child.id == "networkProxyCategory") {
|
||||
|| child.id == "header-general") {
|
||||
is_element_visible(child, "Should be in general tab");
|
||||
} else if (child.id) {
|
||||
is_element_hidden(child, "Should not be in general tab");
|
||||
|
@ -178,7 +170,7 @@ add_task(async function() {
|
|||
*/
|
||||
add_task(async function() {
|
||||
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
|
||||
let generalPane = gBrowser.contentDocument.getElementById("generalCategory");
|
||||
let generalPane = gBrowser.contentDocument.getElementById("header-general");
|
||||
|
||||
is_element_hidden(generalPane, "Should not be in general");
|
||||
|
||||
|
@ -208,7 +200,7 @@ add_task(async function() {
|
|||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["browser.storageManager.enabled", false]]});
|
||||
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
|
||||
let generalPane = gBrowser.contentDocument.getElementById("generalCategory");
|
||||
let generalPane = gBrowser.contentDocument.getElementById("header-general");
|
||||
|
||||
is_element_hidden(generalPane, "Should not be in general");
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ registerCleanupFunction(() => {
|
|||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("browser.search.suggest.enabled", true);
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
|
||||
await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
|
||||
|
||||
let doc = gBrowser.selectedBrowser.contentDocument;
|
||||
let urlbarBox = doc.getElementById("urlBarSuggestion");
|
||||
|
@ -25,7 +25,7 @@ add_task(async function() {
|
|||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
|
||||
await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
|
||||
|
||||
let doc = gBrowser.selectedBrowser.contentDocument;
|
||||
let urlbarBox = doc.getElementById("urlBarSuggestion");
|
||||
|
|
|
@ -1,68 +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);
|
||||
});
|
||||
|
||||
// This test only opens the Preferences once, and then reloads the page
|
||||
// each time that it wants to test various preference combinations. We
|
||||
// only use one tab (instead of opening/closing for each test) for all
|
||||
// to help improve test times on debug builds.
|
||||
add_task(async function setup() {
|
||||
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
|
||||
registerCleanupFunction(async function() {
|
||||
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
});
|
||||
|
||||
// test the safebrowsing preference
|
||||
add_task(async function() {
|
||||
async function checkPrefSwitch(val1, val2) {
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.phishing.enabled", val1);
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.malware.enabled", val2);
|
||||
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
||||
await checkPrefSwitch(true, true);
|
||||
await checkPrefSwitch(false, true);
|
||||
await checkPrefSwitch(true, false);
|
||||
await checkPrefSwitch(false, false);
|
||||
});
|
|
@ -26,6 +26,47 @@ add_task(async function setup() {
|
|||
});
|
||||
});
|
||||
|
||||
// test the safebrowsing preference
|
||||
add_task(async function() {
|
||||
async function checkPrefSwitch(val1, val2) {
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.phishing.enabled", val1);
|
||||
Services.prefs.setBoolPref("browser.safebrowsing.malware.enabled", val2);
|
||||
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
||||
await checkPrefSwitch(true, true);
|
||||
await checkPrefSwitch(false, true);
|
||||
await checkPrefSwitch(true, false);
|
||||
await checkPrefSwitch(false, false);
|
||||
});
|
||||
|
||||
// test the download protection preference
|
||||
add_task(async function() {
|
||||
async function checkPrefSwitch(val) {
|
|
@ -1584,7 +1584,7 @@ var gViewController = {
|
|||
if (Preferences.get("browser.preferences.useOldOrganization")) {
|
||||
mainWindow.openAdvancedPreferences("dataChoicesTab", {origin: "experimentsOpenPref"});
|
||||
} else {
|
||||
mainWindow.openPreferences("panePrivacy", {origin: "experimentsOpenPref"});
|
||||
mainWindow.openPreferences("paneAdvanced", {origin: "experimentsOpenPref"});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -169,13 +169,13 @@ add_task(async function testOpenPreferences() {
|
|||
|
||||
let deferred = Promise.defer();
|
||||
Services.obs.addObserver(function observer(prefWin, topic, data) {
|
||||
Services.obs.removeObserver(observer, "privacy-pane-loaded");
|
||||
info("Privacy preference pane opened.");
|
||||
Services.obs.removeObserver(observer, "advanced-pane-loaded");
|
||||
info("Advanced preference pane opened.");
|
||||
executeSoon(function() {
|
||||
// We want this test to fail if the preferences pane changes,
|
||||
// but we can't check if the data-choices button is visible
|
||||
// since it is only in the DOM when MOZ_TELEMETRY_REPORTING=1.
|
||||
let el = prefWin.document.getElementById("dataCollectionCategory");
|
||||
let el = prefWin.document.getElementById("header-advanced");
|
||||
is_element_visible(el);
|
||||
|
||||
prefWin.close();
|
||||
|
@ -183,7 +183,7 @@ add_task(async function testOpenPreferences() {
|
|||
|
||||
deferred.resolve();
|
||||
});
|
||||
}, "privacy-pane-loaded");
|
||||
}, "advanced-pane-loaded");
|
||||
|
||||
info("Loading preferences pane.");
|
||||
// We need to focus before synthesizing the mouse event (bug 1240052) as
|
||||
|
|
Загрузка…
Ссылка в новой задаче