Bug 1543314 - Cookies should be sent to the content process also for first-party channels when cookieBehavior is set to 2, r=Ehsan

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-04-10 15:25:13 +00:00
parent 6ac6c635da
commit ddda66db66
4 changed files with 49 additions and 2 deletions

View File

@ -140,8 +140,8 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel) {
// 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, uri, nullptr)) {
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel,
uri, nullptr)) {
storageAccessGranted = true;
}
}

View File

@ -19,6 +19,7 @@ support-files =
3rdPartyOpen.html
3rdPartyOpenUI.html
empty.js
empty.html
popup.html
server.sjs
storageAccessAPIHelpers.js
@ -85,3 +86,4 @@ support-files = localStorage.html
support-files = localStorageEvents.html
[browser_workerPropagation.js]
support-files = workerIframe.html
[browser_cookieBetweenTabs.js]

View File

@ -0,0 +1,44 @@
add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["dom.storage_access.enabled", true],
["network.cookie.cookieBehavior", BEHAVIOR_REJECT],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],
["privacy.trackingprotection.annotate_channels", true],
["dom.ipc.processCount", 4],
]});
info("First tab opened");
let tab = BrowserTestUtils.addTab(gBrowser, TEST_DOMAIN + TEST_PATH + "empty.html");
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
info("Disabling content blocking for this page");
ContentBlocking.disableForCurrentPage();
await BrowserTestUtils.browserLoaded(browser);
await ContentTask.spawn(browser, null, async _ => {
is(content.document.cookie, "", "No cookie set");
content.document.cookie = "a=b";
is(content.document.cookie, "a=b", "Cookie set");
});
info("Second tab opened");
let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_DOMAIN + TEST_PATH + "empty.html");
gBrowser.selectedTab = tab2;
let browser2 = gBrowser.getBrowserForTab(tab2);
await BrowserTestUtils.browserLoaded(browser2);
await ContentTask.spawn(browser2, null, async _ => {
is(content.document.cookie, "a=b", "Cookie set");
});
info("Removing tabs");
BrowserTestUtils.removeTab(tab);
BrowserTestUtils.removeTab(tab2);
});

View File

@ -0,0 +1 @@
<h1>Empty</h1>