Bug 1510860 - Ensure that the cookie service checks the content blocking allow list even for first-party cookies since that's required when we're blocking all cookies; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D15109
This commit is contained in:
Ehsan Akhgari 2018-12-20 11:09:15 -05:00
Родитель a4d958568d
Коммит aa81b3cc6c
3 изменённых файлов: 74 добавлений и 4 удалений

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

@ -1998,8 +1998,8 @@ nsresult nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
// Check first-party storage access even for non-tracking resources, since
// we will need the result when computing the access rights for the reject
// foreign cookie behavior mode.
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
httpChannel, aHostURI, nullptr)) {
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
httpChannel, aHostURI, nullptr)) {
firstPartyStorageAccessGranted = true;
}
}
@ -2099,8 +2099,8 @@ nsresult nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
// Check first-party storage access even for non-tracking resources, since
// we will need the result when computing the access rights for the reject
// foreign cookie behavior mode.
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
httpChannel, aHostURI, nullptr)) {
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
httpChannel, aHostURI, nullptr)) {
firstPartyStorageAccessGranted = true;
}
}

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

@ -41,6 +41,7 @@ skip-if = (os == "win" && os_version == "6.1" && bits == 32 && !debug) # Bug 149
[browser_blockingNoOpener.js]
[browser_doublyNestedTracker.js]
[browser_existingCookiesForSubresources.js]
[browser_firstPartyCookieRejectionHonoursAllowList.js]
[browser_imageCache4.js]
[browser_imageCache4-1.js]
[browser_imageCache4-2.js]

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

@ -0,0 +1,69 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
add_task(async function() {
info("Starting subResources test");
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.allowlist.annotations.enabled", true],
["browser.contentblocking.allowlist.storage.enabled", true],
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],
["privacy.trackingprotection.annotate_channels", true],
]});
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
info("Disabling content blocking for this page");
ContentBlocking.disableForCurrentPage();
// The previous function reloads the browser, so wait for it to load again!
await BrowserTestUtils.browserLoaded(browser);
await ContentTask.spawn(browser, {},
async function(obj) {
await new content.Promise(async resolve => {
let document = content.document;
let window = document.defaultView;
is(document.cookie, "", "No cookies for me");
await window.fetch("server.sjs").then(r => r.text()).then(text => {
is(text, "cookie-not-present", "We should not have cookies");
});
document.cookie = "name=value";
ok(document.cookie.includes("name=value"), "Some cookies for me");
ok(document.cookie.includes("foopy=1"), "Some cookies for me");
await window.fetch("server.sjs").then(r => r.text()).then(text => {
is(text, "cookie-present", "We should have cookies");
});
ok(document.cookie.length, "Some Cookies for me");
resolve();
});
});
info("Enabling content blocking for this page");
ContentBlocking.enableForCurrentPage();
// The previous function reloads the browser, so wait for it to load again!
await BrowserTestUtils.browserLoaded(browser);
BrowserTestUtils.removeTab(tab);
});
add_task(async function() {
info("Cleaning up.");
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
});
});