Bug 1358381 - Fix Nightly-only enabled siteDataGroup testing issue beyond Beta build and reorganize tests to the proper test files, r=jaws.

The goal of browser_bug795764_cachedisabled.js is to test elements using nsIApplicationCacheService so always enable siteDataGroup and offlineGroup there.

The goal of browser_bug731866.js is to test loading panes so move the checking of elements pref-on/off state to it.

MozReview-Commit-ID: 9QWMNnuu0OD

--HG--
extra : rebase_source : 323e05c493a575a879aff4cbceb84c332cf3a16f
This commit is contained in:
Fischer.json 2017-04-21 18:15:25 +08:00
Родитель e6b22abf42
Коммит 0956db6c55
4 изменённых файлов: 45 добавлений и 48 удалений

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

@ -4,6 +4,9 @@
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const storageManagerDisabled = !SpecialPowers.getBoolPref("browser.storageManager.enabled");
const offlineGroupDisabled = !SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled");
function test() {
waitForExplicitFinish();
open_preferences(runTest);
@ -20,6 +23,22 @@ function checkElements(expectedPane) {
element.id === "drmGroup") {
continue;
}
// The siteDataGroup in the Storage Management project is currently only pref-on on Nightly for testing purpose.
// During the test and the transition period, we have to check the pref to see if the siteDataGroup
// should be hidden always. This would be a bit bothersome, same as the offlineGroup as below.
// However, this checking is necessary to make sure we don't leak the siteDataGroup into beta/release build
if (element.id == "siteDataGroup" && storageManagerDisabled) {
is_element_hidden(element, "Disabled siteDataGroup should be hidden");
continue;
}
// The siteDataGroup in the Storage Management project will replace the offlineGroup eventually,
// so during the transition period, we have to check the pref to see if the offlineGroup
// should be hidden always. See the bug 1354530 for the details.
if (element.id == "offlineGroup" && offlineGroupDisabled) {
is_element_hidden(element, "Disabled offlineGroup should be hidden");
continue;
}
let attributeValue = element.getAttribute("data-category");
let suffix = " (id=" + element.id + ")";
if (attributeValue == "pane" + expectedPane) {

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

@ -7,28 +7,21 @@ Components.utils.import("resource://gre/modules/NetUtil.jsm");
function test() {
waitForExplicitFinish();
let prefs = [
"browser.cache.offline.enable",
"browser.cache.disk.enable",
"browser.cache.memory.enable",
];
for (let pref of prefs) {
Services.prefs.setBoolPref(pref, false);
}
// Adding one fake site so that the SiteDataManager would run.
// Otherwise, without any site then it would just return so we would end up in not testing SiteDataManager.
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("https://www.foo.com");
Services.perms.addFromPrincipal(principal, "persistent-storage", Ci.nsIPermissionManager.ALLOW_ACTION);
registerCleanupFunction(function() {
for (let pref of prefs) {
Services.prefs.clearUserPref(pref);
}
Services.perms.removeFromPrincipal(principal, "persistent-storage");
});
open_preferences(runTest);
SpecialPowers.pushPrefEnv({set: [
["browser.cache.offline.enable", false],
["browser.cache.disk.enable", false],
["browser.cache.memory.enable", false],
["browser.storageManager.enabled", true],
["browser.preferences.offlineGroup.enabled", true]
]}).then(() => open_preferences(runTest));
}
function runTest(win) {
@ -36,7 +29,6 @@ function runTest(win) {
let tab = win.document;
let elements = tab.getElementById("mainPrefPane").children;
let offlineGroupDisabled = !SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled");
// Test if advanced pane is opened correctly
win.gotoPref("paneAdvanced");
@ -44,13 +36,6 @@ function runTest(win) {
if (element.nodeName == "preferences") {
continue;
}
// The siteDataGroup in the Storage Management project will replace the offlineGroup eventually,
// so during the transition period, we have to check the pref to see if the offlineGroup
// should be hidden always. See the bug 1354530 for the details.
if (element.id == "offlineGroup" && offlineGroupDisabled) {
is_element_hidden(element, "Disabled offlineGroup should be hidden");
continue;
}
let attributeValue = element.getAttribute("data-category");
if (attributeValue == "paneAdvanced") {
is_element_visible(element, "Advanced elements should be visible");

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

@ -4,9 +4,11 @@
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const storageManagerDisabled = !SpecialPowers.getBoolPref("browser.storageManager.enabled");
const offlineGroupDisabled = !SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled");
function test() {
waitForExplicitFinish();
SpecialPowers.pushPrefEnv({set: [["browser.storageManager.enabled", true]]});
open_preferences(runTest);
}
@ -21,12 +23,18 @@ function checkElements(expectedPane) {
element.id === "drmGroup") {
continue;
}
// The siteDataGroup in the Storage Management project is currently only pref-on on Nightly for testing purpose.
// During the test and the transition period, we have to check the pref to see if the siteDataGroup
// should be hidden always. This would be a bit bothersome, same as the offlineGroup as below.
// However, this checking is necessary to make sure we don't leak the siteDataGroup into beta/release build
if (element.id == "siteDataGroup" && storageManagerDisabled) {
is_element_hidden(element, "Disabled siteDataGroup should be hidden");
continue;
}
// The siteDataGroup in the Storage Management project will replace the offlineGroup eventually,
// so during the transition period, we have to check the pref to see if the offlineGroup
// should be hidden always. See the bug 1354530 for the details.
if (element.id == "offlineGroup" &&
!SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled")) {
if (element.id == "offlineGroup" && offlineGroupDisabled) {
is_element_hidden(element, "Disabled offlineGroup should be hidden");
continue;
}

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

@ -8,28 +8,21 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
function test() {
waitForExplicitFinish();
let prefs = [
"browser.cache.offline.enable",
"browser.cache.disk.enable",
"browser.cache.memory.enable",
];
for (let pref of prefs) {
Services.prefs.setBoolPref(pref, false);
}
// Adding one fake site so that the SiteDataManager would run.
// Otherwise, without any site then it would just return so we would end up in not testing SiteDataManager.
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("https://www.foo.com");
Services.perms.addFromPrincipal(principal, "persistent-storage", Ci.nsIPermissionManager.ALLOW_ACTION);
registerCleanupFunction(function() {
for (let pref of prefs) {
Services.prefs.clearUserPref(pref);
}
Services.perms.removeFromPrincipal(principal, "persistent-storage");
});
open_preferences(runTest);
SpecialPowers.pushPrefEnv({set: [
["browser.cache.offline.enable", false],
["browser.cache.disk.enable", false],
["browser.cache.memory.enable", false],
["browser.storageManager.enabled", true],
["browser.preferences.offlineGroup.enabled", true]
]}).then(() => open_preferences(runTest));
}
function runTest(win) {
@ -37,7 +30,6 @@ function runTest(win) {
let tab = win.document;
let elements = tab.getElementById("mainPrefPane").children;
let offlineGroupDisabled = !SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled");
// Test if privacy pane is opened correctly
win.gotoPref("panePrivacy");
@ -45,13 +37,6 @@ function runTest(win) {
if (element.nodeName == "preferences") {
continue;
}
// The siteDataGroup in the Storage Management project will replace the offlineGroup eventually,
// so during the transition period, we have to check the pref to see if the offlineGroup
// should be hidden always. See the bug 1354530 for the details.
if (element.id == "offlineGroup" && offlineGroupDisabled) {
is_element_hidden(element, "Disabled offlineGroup should be hidden");
continue;
}
let attributeValue = element.getAttribute("data-category");
if (attributeValue == "panePrivacy") {
is_element_visible(element, "Privacy elements should be visible");