зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1873921 - Stop sending third-party cookies except cookies with partitioned attribute in partitioned contexts - r=timhuang,cookie-reviewers
Tiny diff to do it. Also fixes Bug 1873995 when adding testing Differential Revision: https://phabricator.services.mozilla.com/D201266
This commit is contained in:
Родитель
bb715065b1
Коммит
15d140ddbc
|
@ -487,7 +487,8 @@ bool CookieCommons::ShouldIncludeCrossSiteCookieForDocument(
|
|||
aCookie->GetSameSite(&sameSiteAttr);
|
||||
|
||||
if (aDocument->CookieJarSettings()->GetPartitionForeign() &&
|
||||
StaticPrefs::network_cookie_cookieBehavior_optInPartitioning()) {
|
||||
StaticPrefs::network_cookie_cookieBehavior_optInPartitioning() &&
|
||||
!aCookie->IsPartitioned()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
|
||||
"HTTP Cookies",
|
||||
async (win3rdParty, win1stParty, allowed) => {
|
||||
await win3rdParty.fetch("cookies.sjs?3rd").then(r => r.text());
|
||||
await win3rdParty
|
||||
.fetch("cookies.sjs?3rd;Partitioned;Secure")
|
||||
.then(r => r.text());
|
||||
await win3rdParty
|
||||
.fetch("cookies.sjs")
|
||||
.then(r => r.text())
|
||||
|
@ -49,7 +51,7 @@ PartitionedStorageHelper.runTestInNormalAndPrivateMode(
|
|||
PartitionedStorageHelper.runTestInNormalAndPrivateMode(
|
||||
"DOM Cookies",
|
||||
async (win3rdParty, win1stParty, allowed) => {
|
||||
win3rdParty.document.cookie = "foo=3rd";
|
||||
win3rdParty.document.cookie = "foo=3rd;Partitioned;Secure";
|
||||
is(win3rdParty.document.cookie, "foo=3rd", "3rd party cookie set");
|
||||
|
||||
win1stParty.document.cookie = "foo=first";
|
||||
|
@ -90,7 +92,7 @@ PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
|
|||
|
||||
// addDataCallback
|
||||
async (win, value) => {
|
||||
win.document.cookie = value;
|
||||
win.document.cookie = value + ";Partitioned;Secure";
|
||||
return true;
|
||||
},
|
||||
|
||||
|
@ -121,7 +123,9 @@ PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
|
|||
|
||||
// addDataCallback
|
||||
async (win, value) => {
|
||||
await win.fetch("cookies.sjs?" + value).then(r => r.text());
|
||||
await win
|
||||
.fetch("cookies.sjs?" + value + ";Partitioned;Secure")
|
||||
.then(r => r.text());
|
||||
return true;
|
||||
},
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ const TEST_DOMAIN_5 = "http://test/";
|
|||
const TEST_DOMAIN_6 = "http://mochi.test:8888/";
|
||||
const TEST_DOMAIN_7 = "http://example.com/";
|
||||
const TEST_DOMAIN_8 = "http://www.example.com/";
|
||||
const TEST_DOMAIN_9 = "https://example.org:443/";
|
||||
const TEST_3RD_PARTY_DOMAIN = "https://tracking.example.org/";
|
||||
const TEST_3RD_PARTY_DOMAIN_HTTP = "http://tracking.example.org/";
|
||||
const TEST_3RD_PARTY_DOMAIN_TP = "https://tracking.example.com/";
|
||||
|
@ -40,6 +41,7 @@ const TEST_TOP_PAGE_5 = TEST_DOMAIN_5 + TEST_PATH + "page.html";
|
|||
const TEST_TOP_PAGE_6 = TEST_DOMAIN_6 + TEST_PATH + "page.html";
|
||||
const TEST_TOP_PAGE_7 = TEST_DOMAIN_7 + TEST_PATH + "page.html";
|
||||
const TEST_TOP_PAGE_8 = TEST_DOMAIN_8 + TEST_PATH + "page.html";
|
||||
const TEST_TOP_PAGE_9 = TEST_DOMAIN_9 + TEST_PATH + "page.html";
|
||||
const TEST_EMBEDDER_PAGE = TEST_DOMAIN + TEST_PATH + "embedder.html";
|
||||
const TEST_POPUP_PAGE = TEST_DOMAIN + TEST_PATH + "popup.html";
|
||||
const TEST_IFRAME_PAGE = TEST_DOMAIN + TEST_PATH + "iframe.html";
|
||||
|
|
|
@ -141,6 +141,7 @@ this.PartitionedStorageHelper = {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.storage_access.enabled", true],
|
||||
["network.cookie.cookieBehavior.optInPartitioning", true],
|
||||
[
|
||||
"privacy.partition.always_partition_third_party_non_cookie_storage",
|
||||
true,
|
||||
|
@ -164,14 +165,14 @@ this.PartitionedStorageHelper = {
|
|||
}
|
||||
|
||||
info("Creating the first tab");
|
||||
let tab1 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
|
||||
let tab1 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE_HTTPS);
|
||||
win.gBrowser.selectedTab = tab1;
|
||||
|
||||
let browser1 = win.gBrowser.getBrowserForTab(tab1);
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
|
||||
info("Creating the second tab");
|
||||
let tab2 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE_6);
|
||||
let tab2 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE_9);
|
||||
win.gBrowser.selectedTab = tab2;
|
||||
|
||||
let browser2 = win.gBrowser.getBrowserForTab(tab2);
|
||||
|
@ -180,7 +181,7 @@ this.PartitionedStorageHelper = {
|
|||
info("Creating the third tab");
|
||||
let tab3 = BrowserTestUtils.addTab(
|
||||
win.gBrowser,
|
||||
TEST_4TH_PARTY_PARTITIONED_PAGE
|
||||
TEST_4TH_PARTY_PARTITIONED_PAGE_HTTPS
|
||||
);
|
||||
win.gBrowser.selectedTab = tab3;
|
||||
|
||||
|
@ -189,7 +190,7 @@ this.PartitionedStorageHelper = {
|
|||
|
||||
// Use the same URL as first tab to check partitioned data
|
||||
info("Creating the forth tab");
|
||||
let tab4 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
|
||||
let tab4 = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE_HTTPS);
|
||||
win.gBrowser.selectedTab = tab4;
|
||||
|
||||
let browser4 = win.gBrowser.getBrowserForTab(tab4);
|
||||
|
@ -207,7 +208,8 @@ this.PartitionedStorageHelper = {
|
|||
browser,
|
||||
[
|
||||
{
|
||||
page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant,
|
||||
page:
|
||||
TEST_4TH_PARTY_PARTITIONED_PAGE_HTTPS + "?variant=" + variant,
|
||||
getDataCallback: getDataCallback.toString(),
|
||||
result,
|
||||
},
|
||||
|
@ -289,7 +291,8 @@ this.PartitionedStorageHelper = {
|
|||
browser,
|
||||
[
|
||||
{
|
||||
page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant,
|
||||
page:
|
||||
TEST_4TH_PARTY_PARTITIONED_PAGE_HTTPS + "?variant=" + variant,
|
||||
addDataCallback: addDataCallback.toString(),
|
||||
value,
|
||||
},
|
||||
|
@ -382,7 +385,7 @@ this.PartitionedStorageHelper = {
|
|||
|
||||
async function setStorageAccessForThirdParty(browser) {
|
||||
info(`Setting permission for ${browser.currentURI.spec}`);
|
||||
let type = "3rdPartyStorage^http://not-tracking.example.com";
|
||||
let type = "3rdPartyStorage^https://not-tracking.example.com";
|
||||
let permission = Services.perms.ALLOW_ACTION;
|
||||
let expireType = Services.perms.EXPIRE_SESSION;
|
||||
Services.perms.addFromPrincipal(
|
||||
|
|
Загрузка…
Ссылка в новой задаче