Bug 1493057 - Make sure test_ext_privacy.js doesn't depend on the default value of the network.cookie.cookieBehavior preference r=rpl

Differential Revision: https://phabricator.services.mozilla.com/D6456

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2018-09-21 15:12:10 +00:00
Родитель 2d5c5a77bb
Коммит f8ef224ee2
3 изменённых файлов: 43 добавлений и 7 удалений

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

@ -18,6 +18,7 @@ const cookieBehaviorValues = new Map([
["reject_third_party", cookieSvc.BEHAVIOR_REJECT_FOREIGN],
["reject_all", cookieSvc.BEHAVIOR_REJECT],
["allow_visited", cookieSvc.BEHAVIOR_LIMIT_FOREIGN],
["reject_trackers", cookieSvc.BEHAVIOR_REJECT_TRACKER],
]);
const checkScope = scope => {

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

@ -82,7 +82,8 @@
"allow_all",
"reject_all",
"reject_third_party",
"allow_visited"
"allow_visited",
"reject_trackers"
],
"description": "The type of cookies to allow."
},

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

@ -247,6 +247,30 @@ add_task(async function test_privacy_other_prefs() {
},
};
let defaultPrefs = new Preferences({defaultBranch: true});
let defaultCookieBehavior = defaultPrefs.get("network.cookie.cookieBehavior");
let defaultBehavior;
switch (defaultCookieBehavior) {
case cookieSvc.BEHAVIOR_ACCEPT:
defaultBehavior = "allow_all";
break;
case cookieSvc.BEHAVIOR_REJECT_FOREIGN:
defaultBehavior = "reject_third_party";
break;
case cookieSvc.BEHAVIOR_REJECT:
defaultBehavior = "reject_all";
break;
case cookieSvc.BEHAVIOR_LIMIT_FOREIGN:
defaultBehavior = "allow_visited";
break;
case cookieSvc.BEHAVIOR_REJECT_TRACKER:
defaultBehavior = "reject_trackers";
break;
default:
ok(false, `Unexpected cookie behavior encountered: ${defaultCookieBehavior}`);
break;
}
async function background() {
browser.test.onMessage.addListener(async (msg, ...args) => {
let data = args[0];
@ -427,10 +451,10 @@ add_task(async function test_privacy_other_prefs() {
"websites.cookieConfig",
{nonPersistentCookies: true},
{
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_ACCEPT,
"network.cookie.cookieBehavior": defaultCookieBehavior,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_SESSION,
},
{behavior: "allow_all", nonPersistentCookies: true},
{behavior: defaultBehavior, nonPersistentCookies: true},
);
await testSetting(
"websites.cookieConfig",
@ -463,20 +487,30 @@ add_task(async function test_privacy_other_prefs() {
"websites.cookieConfig",
{nonPersistentCookies: true},
{
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_ACCEPT,
"network.cookie.cookieBehavior": defaultCookieBehavior,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_SESSION,
},
{behavior: "allow_all", nonPersistentCookies: true},
{behavior: defaultBehavior, nonPersistentCookies: true},
);
await testSetting(
"websites.cookieConfig",
{nonPersistentCookies: false},
{
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_ACCEPT,
"network.cookie.cookieBehavior": defaultCookieBehavior,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_NORMALLY,
},
{behavior: "allow_all", nonPersistentCookies: false},
{behavior: defaultBehavior, nonPersistentCookies: false},
);
await testSetting(
"websites.cookieConfig",
{behavior: "reject_trackers"},
{
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_REJECT_TRACKER,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_NORMALLY,
},
{behavior: "reject_trackers", nonPersistentCookies: false},
);
await extension.unload();