mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
Bug 1483378 - Part 3: Add tests for the new Cookies and Site Data UI; r=johannh
These tests extend the existing tests for the old UI, and ensure the new states in the new UI work properly.
This commit is contained in:
parent
feedc4c304
commit
f2f49b13b3
@ -69,6 +69,7 @@ run-if = nightly_build
|
||||
# which is disabled outside Nightly. Remove this once non-Nightly tests are
|
||||
# added.
|
||||
[browser_privacypane_1.js]
|
||||
[browser_privacypane_2.js]
|
||||
[browser_privacypane_3.js]
|
||||
[browser_privacypane_5.js]
|
||||
[browser_sanitizeOnShutdown_prefLocked.js]
|
||||
|
@ -7,6 +7,10 @@ if (jar) {
|
||||
/* import-globals-from privacypane_tests_perwindow.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set":
|
||||
[["browser.contentblocking.cookies-site-data.ui.enabled", false]]
|
||||
});
|
||||
|
||||
run_test_subset([
|
||||
test_pane_visibility,
|
||||
test_dependent_elements,
|
||||
|
@ -0,0 +1,20 @@
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from privacypane_tests_perwindow.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set":
|
||||
[["browser.contentblocking.cookies-site-data.ui.enabled", true]]
|
||||
});
|
||||
|
||||
run_test_subset([
|
||||
test_pane_visibility,
|
||||
test_dependent_elements,
|
||||
test_dependent_cookie_elements,
|
||||
test_dependent_clearonclose_elements,
|
||||
test_dependent_prefs,
|
||||
]);
|
@ -54,7 +54,9 @@ function test_dependent_elements(win) {
|
||||
ok(control, "the dependent controls should exist");
|
||||
});
|
||||
let independents = [
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.contentBlockingCookiesAndSiteDataUiEnabled ?
|
||||
win.document.getElementById("blockCookies") :
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.document.getElementById("acceptThirdPartyLabel"),
|
||||
win.document.getElementById("acceptThirdPartyMenu")
|
||||
];
|
||||
@ -120,13 +122,24 @@ function test_dependent_cookie_elements(win) {
|
||||
let keepCookiesUntil = win.document.getElementById("keepCookiesUntil");
|
||||
let acceptThirdPartyLabel = win.document.getElementById("acceptThirdPartyLabel");
|
||||
let acceptThirdPartyMenu = win.document.getElementById("acceptThirdPartyMenu");
|
||||
let blockCookiesLabel = win.document.getElementById("blockCookiesLabel");
|
||||
let blockCookiesMenu = win.document.getElementById("blockCookiesMenu");
|
||||
|
||||
let controls = [acceptThirdPartyLabel, acceptThirdPartyMenu, keepUntil, keepCookiesUntil];
|
||||
const newUI = win.contentBlockingCookiesAndSiteDataUiEnabled;
|
||||
let controls = newUI ?
|
||||
[blockCookiesLabel, blockCookiesMenu, keepUntil, keepCookiesUntil] :
|
||||
[acceptThirdPartyLabel, acceptThirdPartyMenu, keepUntil, keepCookiesUntil];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the dependent cookie controls should exist");
|
||||
});
|
||||
let acceptcookies = win.document.getElementById("acceptCookies");
|
||||
ok(acceptcookies, "the accept cookies checkbox should exist");
|
||||
let acceptcookies, blockcookies;
|
||||
if (newUI) {
|
||||
blockcookies = win.document.getElementById("blockCookies");
|
||||
ok(blockcookies, "the block cookies checkbox should exist");
|
||||
} else {
|
||||
acceptcookies = win.document.getElementById("acceptCookies");
|
||||
ok(acceptcookies, "the accept cookies checkbox should exist");
|
||||
}
|
||||
|
||||
function expect_disabled(disabled, c = controls) {
|
||||
c.forEach(function(control) {
|
||||
@ -135,13 +148,33 @@ function test_dependent_cookie_elements(win) {
|
||||
});
|
||||
}
|
||||
|
||||
acceptcookies.value = "2";
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
if (newUI) {
|
||||
blockcookies.value = "disallow";
|
||||
controlChanged(blockcookies);
|
||||
expect_disabled(false);
|
||||
|
||||
acceptcookies.value = "1";
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
blockcookies.value = "allow";
|
||||
controlChanged(blockcookies);
|
||||
expect_disabled(true, [blockCookiesLabel, blockCookiesMenu]);
|
||||
expect_disabled(false, [keepUntil, keepCookiesUntil]);
|
||||
|
||||
blockCookiesMenu.value = "always";
|
||||
controlChanged(blockCookiesMenu);
|
||||
expect_disabled(true, [keepUntil, keepCookiesUntil]);
|
||||
expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
|
||||
|
||||
blockCookiesMenu.value = "trackers";
|
||||
controlChanged(blockCookiesMenu);
|
||||
expect_disabled(false);
|
||||
} else {
|
||||
acceptcookies.value = "2";
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
|
||||
acceptcookies.value = "1";
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
}
|
||||
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
|
||||
@ -150,7 +183,11 @@ function test_dependent_cookie_elements(win) {
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(true, [keepUntil, keepCookiesUntil]);
|
||||
expect_disabled(false, [acceptThirdPartyLabel, acceptThirdPartyMenu]);
|
||||
if (newUI) {
|
||||
expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
|
||||
} else {
|
||||
expect_disabled(false, [acceptThirdPartyLabel, acceptThirdPartyMenu]);
|
||||
}
|
||||
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
|
Loading…
Reference in New Issue
Block a user