Bug 1365133 - Update tests - Part 2. r=jaws

MozReview-Commit-ID: GoOXdJ4RfY9

--HG--
rename : browser/components/preferences/in-content-new/tests/browser_security.js => browser/components/preferences/in-content-new/tests/browser_security-1.js
rename : browser/components/preferences/in-content-new/tests/browser_security.js => browser/components/preferences/in-content-new/tests/browser_security-2.js
extra : rebase_source : fa03f9260fd1d99be58064bcd712b1d3259511b3
This commit is contained in:
Evan Tseng 2017-06-20 15:11:46 +08:00
Родитель 9a3ef7b776
Коммит b53b288ecc
18 изменённых файлов: 111 добавлений и 76 удалений

Просмотреть файл

@ -39,7 +39,6 @@ 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();
@ -48,7 +47,7 @@ add_task(async function test_settingsOpen_button() {
let tab = await tabPromise;
ok(tab, "The notification settings tab opened");
await closePromise;
await promiseWindowClosed(alertWindow);
await BrowserTestUtils.removeTab(tab);
});
} finally {

Просмотреть файл

@ -288,6 +288,11 @@ 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,7 +52,8 @@ skip-if = e10s
[browser_privacypane_8.js]
[browser_sanitizeOnShutdown_prefLocked.js]
[browser_searchsuggestions.js]
[browser_security.js]
[browser_security-1.js]
[browser_security-2.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("applications", {leaveOpen: true});
info("Preferences page opened on the applications pane.");
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
info("Preferences page opened on the paneGeneral 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("paneApplications", {leaveOpen: true});
is(prefs.selectedPane, "paneApplications", "Applications pane was selected");
let prefs = await openPreferencesViaOpenPreferencesAPI("paneSearch", {leaveOpen: true});
is(prefs.selectedPane, "paneSearch", "Search 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,4 +21,3 @@ add_task(async function() {
is(mainContent.scrollTop, 0,
"Switching to a different category should reset the scroll position");
});

Просмотреть файл

@ -11,8 +11,6 @@ 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");
@ -26,7 +24,6 @@ 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");
@ -54,7 +51,6 @@ 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" }, async function(browser) {
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:preferences#search" }, 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("applications", {leaveOpen: true}).then(
openPreferencesViaOpenPreferencesAPI("general", {leaveOpen: true}).then(
() => runTest(gBrowser.selectedBrowser.contentWindow)
);
}

Просмотреть файл

@ -62,8 +62,8 @@ function runTest(win) {
gElements = tab.getElementById("mainPrefPane").children;
let panes = [
"General", "Applications",
"Privacy", "Sync", "Advanced",
"General", "Search",
"Privacy", "Sync",
];
for (let pane of panes) {

Просмотреть файл

@ -16,7 +16,7 @@ function setupFakeHandler() {
add_task(async function() {
setupFakeHandler();
await openPreferencesViaOpenPreferencesAPI("applications", {leaveOpen: true});
await openPreferencesViaOpenPreferencesAPI("general", {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("general-search", {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
let prefs = await openPreferencesViaOpenPreferencesAPI("search", {leaveOpen: true});
is(prefs.selectedPane, "paneSearch", "Search 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", "notificationsGroup");
evaluateSearchResults("request permission again", "permissionsGroup");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

Просмотреть файл

@ -116,16 +116,24 @@ 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 == "startupGroup"
|| child.id == "defaultEngineGroup"
|| child.id == "oneClickSearchProvidersGroup"
|| child.id == "paneGeneral"
|| child.id == "accessibilityGroup"
if (child.id == "paneGeneral"
|| child.id == "startupGroup"
|| 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 == "header-general") {
|| child.id == "connectionGroup"
|| child.id == "generalCategory"
|| child.id == "languageAndAppearanceCategory"
|| child.id == "filesAndApplicationsCategory"
|| child.id == "updatesCategory"
|| child.id == "performanceCategory"
|| child.id == "browsingCategory"
|| child.id == "networkProxyCategory") {
is_element_visible(child, "Should be in general tab");
} else if (child.id) {
is_element_hidden(child, "Should not be in general tab");
@ -170,7 +178,7 @@ add_task(async function() {
*/
add_task(async function() {
await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
let generalPane = gBrowser.contentDocument.getElementById("header-general");
let generalPane = gBrowser.contentDocument.getElementById("generalCategory");
is_element_hidden(generalPane, "Should not be in general");
@ -200,7 +208,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("header-general");
let generalPane = gBrowser.contentDocument.getElementById("generalCategory");
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("general", { leaveOpen: true });
await openPreferencesViaOpenPreferencesAPI("search", { 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("general", { leaveOpen: true });
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
let urlbarBox = doc.getElementById("urlBarSuggestion");

Просмотреть файл

@ -0,0 +1,68 @@
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,47 +26,6 @@ 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("paneAdvanced", {origin: "experimentsOpenPref"});
mainWindow.openPreferences("panePrivacy", {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, "advanced-pane-loaded");
info("Advanced preference pane opened.");
Services.obs.removeObserver(observer, "privacy-pane-loaded");
info("Privacy 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("header-advanced");
let el = prefWin.document.getElementById("dataCollectionCategory");
is_element_visible(el);
prefWin.close();
@ -183,7 +183,7 @@ add_task(async function testOpenPreferences() {
deferred.resolve();
});
}, "advanced-pane-loaded");
}, "privacy-pane-loaded");
info("Loading preferences pane.");
// We need to focus before synthesizing the mouse event (bug 1240052) as