Bug 1491061 - Part 3: Update existing tests that require the content blocking prefs r=baku

Depends on D5888

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2018-09-20 15:45:55 +00:00
Родитель 05602760e1
Коммит da0aaecdb7
8 изменённых файлов: 41 добавлений и 7 удалений

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

@ -62,7 +62,12 @@
iframe.addEventListener("load", iframeLoaded); iframe.addEventListener("load", iframeLoaded);
} }
SpecialPowers.pushPrefEnv({ SpecialPowers.pushPrefEnv({
"set": [["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior]] "set": [
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior],
]
}, () => { }, () => {
iframe.src = testData[testIndex].host + iframe1Path; iframe.src = testData[testIndex].host + iframe1Path;
}); });

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

@ -84,6 +84,9 @@ function runTest(aExpectedResponses) {
// the given cookie policy. // the given cookie policy.
function testShouldIntercept(behavior, lifetime, done) { function testShouldIntercept(behavior, lifetime, done) {
SpecialPowers.pushPrefEnv({"set": [ SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", behavior], ["network.cookie.cookieBehavior", behavior],
["network.cookie.lifetimePolicy", lifetime], ["network.cookie.lifetimePolicy", lifetime],
]}, function() { ]}, function() {

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

@ -27,8 +27,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1022869
"http://example.org/tests/dom/tests/mochitest/bugs/file_prime_cookie.html"; "http://example.org/tests/dom/tests/mochitest/bugs/file_prime_cookie.html";
waitForLoad().then(function() { waitForLoad().then(function() {
// Cookies are set up, disallow third-party cookies and start the test. // Cookies are set up, disallow third-party cookies and start the test.
SpecialPowers.pushPrefEnv({ set: [[ 'network.cookie.cookieBehavior', 1 ]] }, SpecialPowers.pushPrefEnv({ set: [
() => { continueTest(); }); ["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", 1],
]}, () => { continueTest(); });
}).catch((e) => { ok(false, `Got exception: ${e}`) }); }).catch((e) => { ok(false, `Got exception: ${e}`) });
} }

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

@ -26,7 +26,12 @@ if (inFrame) {
} }
function setCookieBehavior(behavior) { function setCookieBehavior(behavior) {
return SpecialPowers.pushPrefEnv({"set": [[kPrefName, behavior]]}); return SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
[kPrefName, behavior],
]});
} }
function runIFrame(url) { function runIFrame(url) {

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

@ -15,8 +15,12 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
// Set cookies behavior to "always reject". // Set cookies behavior to "always reject".
SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]}, SpecialPowers.pushPrefEnv({"set": [
test1); ["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", 2],
]}, test1);
function test1() { function test1() {
try { try {

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

@ -47,6 +47,9 @@
add_task(async function blocked() { add_task(async function blocked() {
await SpecialPowers.pushPrefEnv({ set: [ await SpecialPowers.pushPrefEnv({ set: [
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_REJECTFOREIGN] ["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_REJECTFOREIGN]
]}); ]});
let result = await testThirdPartyFrame('blocked'); let result = await testThirdPartyFrame('blocked');

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

@ -13,7 +13,12 @@ function setupTest(uri, cookies, loads) {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var prefSet = new Promise(resolve => { var prefSet = new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", 1]] }, resolve); SpecialPowers.pushPrefEnv({ set: [
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["network.cookie.cookieBehavior", 1],
]}, resolve);
}); });
gScript = SpecialPowers.loadChromeScript(SCRIPT_URL); gScript = SpecialPowers.loadChromeScript(SCRIPT_URL);

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

@ -6,6 +6,11 @@
// 2) with channel, but with no docshell parent // 2) with channel, but with no docshell parent
function run_test() { function run_test() {
// Set the needed content blocking prefs
Services.prefs.setBoolPref("browser.contentblocking.enabled", true);
Services.prefs.setBoolPref("browser.contentblocking.ui.enabled", true);
Services.prefs.setBoolPref("browser.contentblocking.rejecttrackers.ui.enabled", true);
// Create URIs and channels pointing to foo.com and bar.com. // Create URIs and channels pointing to foo.com and bar.com.
// We will use these to put foo.com into first and third party contexts. // We will use these to put foo.com into first and third party contexts.
var spec1 = "http://foo.com/foo.html"; var spec1 = "http://foo.com/foo.html";