зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1762462 - Tests do not reflect Always Partitioning Storage, r=twisniewski
Depends on D143627 Differential Revision: https://phabricator.services.mozilla.com/D144731
This commit is contained in:
Родитель
37c3de998a
Коммит
7560dc381a
|
@ -69,6 +69,7 @@ skip-if = true # Bug 1448484 - sameSite1 is "Unset" - Got undefined, expected Un
|
|||
[browser_storage_delete_usercontextid.js]
|
||||
tags = usercontextid
|
||||
[browser_storage_dfpi.js]
|
||||
[browser_storage_dfpi_always_partition_storage.js]
|
||||
[browser_storage_dom_cache_disabled.js]
|
||||
[browser_storage_dynamic_updates_cookies.js]
|
||||
[browser_storage_dynamic_updates_localStorage.js]
|
||||
|
|
|
@ -33,6 +33,11 @@ add_task(async function() {
|
|||
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
|
||||
);
|
||||
|
||||
await pushPref(
|
||||
"privacy.partition.always_partition_non_cookie_storage",
|
||||
false
|
||||
);
|
||||
|
||||
registerCleanupFunction(SiteDataTestUtils.clear);
|
||||
|
||||
// `Services.qms.listOrigins()` may or contain results created by other tests.
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
// Basic test to assert that the storage tree and table corresponding to each
|
||||
// item in the storage tree is correctly displayed
|
||||
|
||||
"use strict";
|
||||
|
||||
const { SiteDataTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SiteDataTestUtils.jsm"
|
||||
);
|
||||
|
||||
// Ensure iframe.src in storage-dfpi.html starts with PREFIX.
|
||||
const PREFIX = "https://sub1.test1.example";
|
||||
const ORIGIN = `${PREFIX}.org`;
|
||||
const ORIGIN_PARTITIONED = `${PREFIX}.com^partitionKey=%28https%2Cexample.org%29`;
|
||||
const TEST_URL = `${ORIGIN}/${PATH}storage-dfpi.html`;
|
||||
|
||||
function listOrigins() {
|
||||
return new Promise(resolve => {
|
||||
SpecialPowers.Services.qms.listOrigins().callback = req => {
|
||||
resolve(req.result);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
await pushPref(
|
||||
"network.cookie.cookieBehavior",
|
||||
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
|
||||
);
|
||||
|
||||
await pushPref("privacy.partition.always_partition_non_cookie_storage", true);
|
||||
|
||||
registerCleanupFunction(SiteDataTestUtils.clear);
|
||||
|
||||
const expectedOrigins = [ORIGIN, ORIGIN_PARTITIONED];
|
||||
|
||||
// `Services.qms.listOrigins()` may or contain results created by other tests.
|
||||
// And it's unsafe to clear existing origins by `Services.qms.clear()`.
|
||||
// In order to obtain correct results, we need to compare the results before
|
||||
// and after `openTabAndSetupStorage` is called.
|
||||
// To ensure more accurate results, try choosing a uncommon origin for PREFIX.
|
||||
const EXISTING_ORIGINS = await listOrigins();
|
||||
expectedOrigins.forEach(expected => {
|
||||
ok(!EXISTING_ORIGINS.includes(expected), `${expected} doesn't exist`);
|
||||
});
|
||||
|
||||
await openTabAndSetupStorage(TEST_URL);
|
||||
|
||||
const origins = await listOrigins();
|
||||
for (const origin of origins) {
|
||||
ok(
|
||||
EXISTING_ORIGINS.includes(origin) || expectedOrigins.includes(origin),
|
||||
`check origin: ${origin}`
|
||||
);
|
||||
}
|
||||
expectedOrigins.forEach(expected => {
|
||||
ok(origins.includes(expected), `${expected} is added`);
|
||||
});
|
||||
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
|
@ -22,6 +22,10 @@ add_task(async function() {
|
|||
`cross-origin site and then navigating back`
|
||||
);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["privacy.partition.always_partition_non_cookie_storage", false]],
|
||||
});
|
||||
|
||||
BrowserTestUtils.loadURI(browser, URL1);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
|
@ -258,5 +262,7 @@ add_task(async function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -75,3 +75,5 @@ user_pref("layout.css.prefers-color-scheme.content-override", 1);
|
|||
// Force OffscreenCanvas support
|
||||
user_pref("gfx.offscreencanvas.enabled", true);
|
||||
user_pref("dom.workers.requestAnimationFrame", true);
|
||||
// Disable always partitioning storage with the Storage Access API
|
||||
user_pref("privacy.partition.always_partition_non_cookie_storage", false);
|
|
@ -491,6 +491,7 @@ this.AntiTracking = {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.storage_access.enabled", true],
|
||||
["privacy.partition.non_cookie_storage", true],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["dom.security.https_first_pbm", false],
|
||||
|
|
|
@ -41,6 +41,12 @@ support-files =
|
|||
|
||||
[browser_blockingCookies.js]
|
||||
skip-if = socketprocess_networking
|
||||
[browser_blockingDOMCacheSAA.js]
|
||||
skip-if = socketprocess_networking
|
||||
[browser_blockingDOMCacheAlwaysPartition.js]
|
||||
skip-if = socketprocess_networking
|
||||
[browser_blockingDOMCacheAlwaysPartitionSAA.js]
|
||||
skip-if = socketprocess_networking
|
||||
[browser_blockingDOMCache.js]
|
||||
[browser_blockingIndexedDb.js]
|
||||
skip-if = os == 'linux' && socketprocess_networking
|
||||
|
|
|
@ -31,83 +31,8 @@ AntiTracking.runTest(
|
|||
);
|
||||
});
|
||||
},
|
||||
[["dom.caches.testing.enabled", true]]
|
||||
);
|
||||
|
||||
AntiTracking.runTest(
|
||||
"DOM Cache and Storage Access API",
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await noStorageAccessInitially();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(false, "DOM Cache cannot be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(true, "DOM Cache cannot be used!");
|
||||
}
|
||||
);
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await callRequestStorageAccess();
|
||||
|
||||
let effectiveCookieBehavior = SpecialPowers.isContentWindowPrivate(window)
|
||||
? SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior.pbmode"
|
||||
)
|
||||
: SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior"
|
||||
);
|
||||
|
||||
let shouldThrow = [
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT,
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,
|
||||
].includes(effectiveCookieBehavior);
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(!shouldThrow, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(shouldThrow, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await callRequestStorageAccess();
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
},
|
||||
[["dom.caches.testing.enabled", true]],
|
||||
false,
|
||||
false
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", false],
|
||||
]
|
||||
);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* import-globals-from antitracking_head.js */
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
AntiTracking.runTest(
|
||||
"DOM Cache Always Partition Storage",
|
||||
async _ => {
|
||||
let effectiveCookieBehavior = SpecialPowers.isContentWindowPrivate(window)
|
||||
? SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior.pbmode"
|
||||
)
|
||||
: SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior"
|
||||
);
|
||||
|
||||
let shouldThrow =
|
||||
effectiveCookieBehavior ==
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT ||
|
||||
(effectiveCookieBehavior ==
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN &&
|
||||
!document.location.href.includes("3rdPartyWO") &&
|
||||
!document.location.href.includes("3rdPartyUI"));
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(!shouldThrow, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(shouldThrow, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
},
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", true],
|
||||
]
|
||||
);
|
|
@ -0,0 +1,82 @@
|
|||
/* import-globals-from antitracking_head.js */
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
AntiTracking.runTest(
|
||||
"DOM Cache Always Partition Storage and Storage Access API",
|
||||
async _ => {
|
||||
await noStorageAccessInitially();
|
||||
|
||||
let effectiveCookieBehavior = SpecialPowers.isContentWindowPrivate(window)
|
||||
? SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior.pbmode"
|
||||
)
|
||||
: SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior"
|
||||
);
|
||||
|
||||
let shouldThrow = [
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT,
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,
|
||||
].includes(effectiveCookieBehavior);
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(!shouldThrow, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(shouldThrow, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
|
||||
await callRequestStorageAccess();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(!shouldThrow, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(shouldThrow, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await callRequestStorageAccess();
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
},
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", true],
|
||||
],
|
||||
false,
|
||||
false
|
||||
);
|
|
@ -0,0 +1,84 @@
|
|||
/* import-globals-from antitracking_head.js */
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
AntiTracking.runTest(
|
||||
"DOM Cache and Storage Access API",
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await noStorageAccessInitially();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(false, "DOM Cache cannot be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(true, "DOM Cache cannot be used!");
|
||||
}
|
||||
);
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await callRequestStorageAccess();
|
||||
|
||||
let effectiveCookieBehavior = SpecialPowers.isContentWindowPrivate(window)
|
||||
? SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior.pbmode"
|
||||
)
|
||||
: SpecialPowers.Services.prefs.getIntPref(
|
||||
"network.cookie.cookieBehavior"
|
||||
);
|
||||
|
||||
let shouldThrow = [
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT,
|
||||
SpecialPowers.Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,
|
||||
].includes(effectiveCookieBehavior);
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(!shouldThrow, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(shouldThrow, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await callRequestStorageAccess();
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache can be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
},
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", false],
|
||||
],
|
||||
false,
|
||||
false
|
||||
);
|
|
@ -103,7 +103,8 @@ PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
|
|||
resolve()
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
|
||||
|
@ -133,5 +134,6 @@ PartitionedStorageHelper.runPartitioningTestInNormalAndPrivateMode(
|
|||
resolve()
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
PartitionedStorageHelper.runTest(
|
||||
"DOMCache",
|
||||
async (win3rdParty, win1stParty, allowed) => {
|
||||
// DOM Cache is not supported. Always blocked.
|
||||
await win3rdParty.caches.open("wow").then(
|
||||
_ => {
|
||||
ok(allowed, "DOM Cache cannot be used!");
|
||||
|
@ -30,6 +29,46 @@ PartitionedStorageHelper.runTest(
|
|||
);
|
||||
});
|
||||
},
|
||||
|
||||
[["dom.caches.testing.enabled", true]]
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", false],
|
||||
]
|
||||
);
|
||||
|
||||
PartitionedStorageHelper.runTest(
|
||||
"DOMCache",
|
||||
async (win3rdParty, win1stParty, allowed) => {
|
||||
await win1stParty.caches.open("wow").then(
|
||||
async cache => {
|
||||
ok(true, "DOM Cache should be available");
|
||||
await cache.add("/");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache should be available");
|
||||
}
|
||||
);
|
||||
|
||||
await win3rdParty.caches.open("wow").then(
|
||||
async cache => {
|
||||
ok(true, "DOM Cache can be used!");
|
||||
is(undefined, await cache.match("/"), "DOM Cache is partitioned");
|
||||
},
|
||||
_ => {
|
||||
ok(false, "DOM Cache cannot be used!");
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
[
|
||||
["dom.caches.testing.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", true],
|
||||
]
|
||||
);
|
||||
|
|
|
@ -28,12 +28,7 @@ PartitionedStorageHelper.runTest(
|
|||
a.onsuccess = e => {
|
||||
let db = e.target.result;
|
||||
|
||||
if (allowed) {
|
||||
is(db.objectStoreNames.length, 1, "We have 1 objectStore");
|
||||
is(db.objectStoreNames[0], "foobar", "We have 'foobar' objectStore");
|
||||
} else {
|
||||
is(db.objectStoreNames.length, 0, "We have 0 objectStore");
|
||||
}
|
||||
is(db.objectStoreNames.length, 0, "We have 0 objectStore");
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
|
|
|
@ -26,11 +26,7 @@ PartitionedStorageHelper.runTestInNormalAndPrivateMode(
|
|||
let sh3 = new win3rdParty.SharedWorker("sharedWorker.js");
|
||||
await new Promise(resolve => {
|
||||
sh3.port.onmessage = e => {
|
||||
is(
|
||||
e.data,
|
||||
allowed ? 2 : 1,
|
||||
`We expected ${allowed ? 2 : 1} connection for 3rd party SharedWorker`
|
||||
);
|
||||
is(e.data, 1, `We expected 1 connection for 3rd party SharedWorker`);
|
||||
resolve();
|
||||
};
|
||||
sh3.onerror = _ => {
|
||||
|
|
|
@ -43,7 +43,8 @@ this.PartitionedStorageHelper = {
|
|||
testCategory,
|
||||
getDataCallback,
|
||||
addDataCallback,
|
||||
cleanupFunction
|
||||
cleanupFunction,
|
||||
expectUnpartition = false
|
||||
) {
|
||||
// Normal mode
|
||||
this.runPartitioningTest(
|
||||
|
@ -52,6 +53,7 @@ this.PartitionedStorageHelper = {
|
|||
getDataCallback,
|
||||
addDataCallback,
|
||||
cleanupFunction,
|
||||
expectUnpartition,
|
||||
false
|
||||
);
|
||||
|
||||
|
@ -62,6 +64,7 @@ this.PartitionedStorageHelper = {
|
|||
getDataCallback,
|
||||
addDataCallback,
|
||||
cleanupFunction,
|
||||
expectUnpartition,
|
||||
true
|
||||
);
|
||||
},
|
||||
|
@ -72,6 +75,7 @@ this.PartitionedStorageHelper = {
|
|||
getDataCallback,
|
||||
addDataCallback,
|
||||
cleanupFunction,
|
||||
expectUnpartition,
|
||||
runInPrivateWindow = false
|
||||
) {
|
||||
for (let variant of ["normal", "initial-aboutblank"]) {
|
||||
|
@ -84,7 +88,8 @@ this.PartitionedStorageHelper = {
|
|||
cleanupFunction,
|
||||
variant,
|
||||
runInPrivateWindow,
|
||||
limitForeignContexts
|
||||
limitForeignContexts,
|
||||
expectUnpartition
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +103,8 @@ this.PartitionedStorageHelper = {
|
|||
cleanupFunction,
|
||||
variant,
|
||||
runInPrivateWindow,
|
||||
limitForeignContexts
|
||||
limitForeignContexts,
|
||||
expectUnpartition
|
||||
) {
|
||||
add_task(async _ => {
|
||||
info(
|
||||
|
@ -123,6 +129,7 @@ this.PartitionedStorageHelper = {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.storage_access.enabled", true],
|
||||
["privacy.partition.always_partition_non_cookie_storage", true],
|
||||
["privacy.dynamic_firstparty.limitForeign", limitForeignContexts],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
@ -358,6 +365,63 @@ this.PartitionedStorageHelper = {
|
|||
info("Forth tab should still have just 'D'");
|
||||
await getDataFromThirdParty(browser4, "D");
|
||||
|
||||
async function setStorageAccessForThirdParty(browser) {
|
||||
info(`Setting permission for ${browser.currentURI.spec}`);
|
||||
let type = "3rdPartyStorage^http://not-tracking.example.com";
|
||||
let permission = Services.perms.ALLOW_ACTION;
|
||||
let expireType = Services.perms.EXPIRE_SESSION;
|
||||
Services.perms.addFromPrincipal(
|
||||
browser.contentPrincipal,
|
||||
type,
|
||||
permission,
|
||||
expireType,
|
||||
0
|
||||
);
|
||||
// Wait for permission to be set successfully
|
||||
let originAttributes = runInPrivateWindow
|
||||
? { privateBrowsingId: 1 }
|
||||
: {};
|
||||
await new Promise(resolve => {
|
||||
let id = setInterval(async _ => {
|
||||
if (
|
||||
await SpecialPowers.testPermission(type, permission, {
|
||||
url: browser.currentURI.spec,
|
||||
originAttributes,
|
||||
})
|
||||
) {
|
||||
clearInterval(id);
|
||||
resolve();
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
||||
if (!expectUnpartition) {
|
||||
info("Setting Storage access for third parties");
|
||||
|
||||
await setStorageAccessForThirdParty(browser1);
|
||||
await setStorageAccessForThirdParty(browser2);
|
||||
await setStorageAccessForThirdParty(browser3);
|
||||
await setStorageAccessForThirdParty(browser4);
|
||||
|
||||
info("Done setting Storage access for third parties");
|
||||
|
||||
// read all tabs
|
||||
info("First tab should still have just 'D'");
|
||||
await getDataFromThirdParty(browser1, "D");
|
||||
|
||||
info("Second tab should still have just 'B'");
|
||||
await getDataFromThirdParty(browser2, "B");
|
||||
|
||||
info("Third tab should still have just 'C'");
|
||||
await getDataFromFirstParty(browser3, "C");
|
||||
|
||||
info("Forth tab should still have just 'D'");
|
||||
await getDataFromThirdParty(browser4, "D");
|
||||
}
|
||||
|
||||
info("Done checking departitioned state");
|
||||
|
||||
info("Removing the tabs");
|
||||
BrowserTestUtils.removeTab(tab1);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче