mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Backed out 3 changesets (bug 1622212) for causing wpt failures on requestStorageAccess.sub.window.html on central.
Backed out changeset a20db87bec25 (bug 1622212) Backed out changeset 783ef2b63ef8 (bug 1622212) Backed out changeset ece4c5394185 (bug 1622212)
This commit is contained in:
parent
b707f6e54b
commit
16c941758d
@ -2460,12 +2460,51 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||
|
||||
PreloadLocalStorage();
|
||||
|
||||
mStorageAccessPermissionGranted = ContentBlocking::ShouldAllowAccessFor(
|
||||
newInnerWindow, aDocument->GetDocumentURI(), nullptr);
|
||||
mStorageAccessPermissionGranted =
|
||||
CheckStorageAccessPermission(aDocument, newInnerWindow);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsGlobalWindowOuter::CheckStorageAccessPermission(
|
||||
Document* aDocument, nsGlobalWindowInner* aInnerWindow) {
|
||||
if (!aInnerWindow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIURI* uri = aDocument->GetDocumentURI();
|
||||
if (!aDocument->CookieJarSettings()->GetRejectThirdPartyContexts() ||
|
||||
!nsContentUtils::IsThirdPartyWindowOrChannel(aInnerWindow, nullptr,
|
||||
uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t cookieBehavior = aDocument->CookieJarSettings()->GetCookieBehavior();
|
||||
|
||||
// Grant storage access by default if the first-party storage access
|
||||
// permission has been granted already. Don't notify in this case, since we
|
||||
// would be notifying the user needlessly.
|
||||
bool checkStorageAccess = false;
|
||||
if (net::CookieJarSettings::IsRejectThirdPartyWithExceptions(
|
||||
cookieBehavior)) {
|
||||
checkStorageAccess = true;
|
||||
} else {
|
||||
MOZ_ASSERT(
|
||||
cookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
|
||||
cookieBehavior ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN);
|
||||
if (nsContentUtils::IsThirdPartyTrackingResourceWindow(aInnerWindow)) {
|
||||
checkStorageAccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkStorageAccess) {
|
||||
return ContentBlocking::ShouldAllowAccessFor(aInnerWindow, uri, nullptr);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsGlobalWindowOuter::PrepareForProcessChange(JSObject* aProxy) {
|
||||
JS::Rooted<JSObject*> localProxy(RootingCx(), aProxy);
|
||||
|
@ -1035,6 +1035,9 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
||||
|
||||
bool IsOnlyTopLevelDocumentInSHistory();
|
||||
|
||||
bool CheckStorageAccessPermission(Document* aDocument,
|
||||
nsGlobalWindowInner* aInnerWindow);
|
||||
|
||||
public:
|
||||
// Dispatch a runnable related to the global.
|
||||
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
|
||||
|
@ -81,7 +81,6 @@ skip-if = os == "linux" && asan
|
||||
[browser_doublyNestedTracker.js]
|
||||
[browser_existingCookiesForSubresources.js]
|
||||
[browser_firstPartyCookieRejectionHonoursAllowList.js]
|
||||
[browser_hasStorageAccess.js]
|
||||
[browser_imageCache4.js]
|
||||
[browser_imageCache8.js]
|
||||
[browser_onBeforeRequestNotificationForTrackingResources.js]
|
||||
|
@ -120,7 +120,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
// Non blocking callback
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
|
||||
|
@ -70,7 +70,11 @@ AntiTracking.runTest(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => {
|
||||
|
@ -70,7 +70,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
|
@ -86,7 +86,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
}
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
@ -65,7 +65,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
|
@ -142,7 +142,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
new BroadcastChannel("hello");
|
||||
ok(true, "BroadcastChanneli can be used");
|
||||
@ -252,7 +256,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
}
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
let blob = new Blob([nonBlockingCode.toString() + "; nonBlockingCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
@ -65,7 +65,11 @@ AntiTracking.runTest(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
await navigator.serviceWorker
|
||||
.register("empty.js")
|
||||
|
@ -88,7 +88,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
|
@ -65,7 +65,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
|
@ -1,183 +0,0 @@
|
||||
// This test ensures HasStorageAccess API returns the right value under different
|
||||
// scenarios.
|
||||
|
||||
/* import-globals-from antitracking_head.js */
|
||||
|
||||
var settings = [
|
||||
// 3rd-party no-tracker
|
||||
{
|
||||
name: "Test whether 3rd-party non-tracker frame has storage access",
|
||||
topPage: TEST_TOP_PAGE,
|
||||
thirdPartyPage: TEST_4TH_PARTY_PAGE,
|
||||
},
|
||||
// 3rd-party no-tracker with permission
|
||||
{
|
||||
name:
|
||||
"Test whether 3rd-party non-tracker frame has storage access when storage permission is granted before",
|
||||
topPage: TEST_TOP_PAGE,
|
||||
thirdPartyPage: TEST_4TH_PARTY_PAGE,
|
||||
setup: () => {
|
||||
let type = "3rdPartyStorage^http://not-tracking.example.com";
|
||||
let permission = Services.perms.ALLOW_ACTION;
|
||||
let expireType = Services.perms.EXPIRE_SESSION;
|
||||
PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0);
|
||||
|
||||
registerCleanupFunction(_ => {
|
||||
Services.perms.removeAll();
|
||||
});
|
||||
},
|
||||
},
|
||||
// 3rd-party tracker
|
||||
{
|
||||
name: "Test whether 3rd-party tracker frame has storage access",
|
||||
topPage: TEST_TOP_PAGE,
|
||||
thirdPartyPage: TEST_3RD_PARTY_PAGE,
|
||||
},
|
||||
// 3rd-party tracker with permission
|
||||
{
|
||||
name:
|
||||
"Test whether 3rd-party tracker frame has storage access when storage access permission is granted before",
|
||||
topPage: TEST_TOP_PAGE,
|
||||
thirdPartyPage: TEST_3RD_PARTY_PAGE,
|
||||
setup: () => {
|
||||
let type = "3rdPartyStorage^https://tracking.example.org";
|
||||
let permission = Services.perms.ALLOW_ACTION;
|
||||
let expireType = Services.perms.EXPIRE_SESSION;
|
||||
PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0);
|
||||
|
||||
registerCleanupFunction(_ => {
|
||||
Services.perms.removeAll();
|
||||
});
|
||||
},
|
||||
},
|
||||
// same-site 3rd-party tracker
|
||||
{
|
||||
name: "Test whether same-site 3rd-party tracker frame has storage access",
|
||||
topPage: TEST_TOP_PAGE,
|
||||
thirdPartyPage: TEST_ANOTHER_3RD_PARTY_PAGE,
|
||||
},
|
||||
// same-origin 3rd-party tracker
|
||||
{
|
||||
name: "Test whether same-origin 3rd-party tracker frame has storage access",
|
||||
topPage: TEST_ANOTHER_3RD_PARTY_DOMAIN + TEST_PATH + "page.html",
|
||||
thirdPartyPage: TEST_ANOTHER_3RD_PARTY_PAGE,
|
||||
},
|
||||
];
|
||||
|
||||
var testCases = [
|
||||
{
|
||||
behavior: BEHAVIOR_ACCEPT, // 0
|
||||
hasStorageAccess: [
|
||||
true /* 3rd-party non-tracker */,
|
||||
true /* 3rd-party non-tracker with permission */,
|
||||
true /* 3rd-party tracker */,
|
||||
true /* 3rd-party tracker with permission */,
|
||||
true /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
{
|
||||
behavior: BEHAVIOR_REJECT_FOREIGN, // 1
|
||||
hasStorageAccess: [
|
||||
false /* 3rd-party non-tracker */,
|
||||
true /* 3rd-party non-tracker with permission */,
|
||||
false /* 3rd-party tracker */,
|
||||
true /* 3rd-party tracker with permission */,
|
||||
true /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
{
|
||||
behavior: BEHAVIOR_REJECT, // 2
|
||||
hasStorageAccess: [
|
||||
false /* 3rd-party non-tracker */,
|
||||
false /* 3rd-party non-tracker with permission */,
|
||||
false /* 3rd-party tracker */,
|
||||
false /* 3rd-party tracker with permission */,
|
||||
false /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
{
|
||||
behavior: BEHAVIOR_LIMIT_FOREIGN, // 3
|
||||
hasStorageAccess: [
|
||||
false /* 3rd-party non-tracker */,
|
||||
false /* 3rd-party non-tracker with permission */,
|
||||
false /* 3rd-party tracker */,
|
||||
false /* 3rd-party tracker with permission */,
|
||||
true /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
{
|
||||
behavior: BEHAVIOR_REJECT_TRACKER, // 4
|
||||
hasStorageAccess: [
|
||||
true /* 3rd-party non-tracker */,
|
||||
true /* 3rd-party non-tracker with permission */,
|
||||
false /* 3rd-party tracker */,
|
||||
true /* 3rd-party tracker with permission */,
|
||||
true /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
{
|
||||
behavior: BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN, // 5
|
||||
hasStorageAccess: [
|
||||
false /* 3rd-party non-tracker */,
|
||||
true /* 3rd-party non-tracker with permission */,
|
||||
false /* 3rd-party tracker */,
|
||||
true /* 3rd-party tracker with permission */,
|
||||
true /* same-site tracker */,
|
||||
true /* same-origin tracker */,
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
(function() {
|
||||
settings.forEach(setting => {
|
||||
if (setting.setup) {
|
||||
add_task(async _ => {
|
||||
setting.setup();
|
||||
});
|
||||
}
|
||||
|
||||
testCases.forEach(test => {
|
||||
//if (test.behavior != 3) {
|
||||
//return;
|
||||
//}
|
||||
|
||||
let callback = test.hasStorageAccess[settings.indexOf(setting)]
|
||||
? async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
}
|
||||
: async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await noStorageAccessInitially();
|
||||
};
|
||||
|
||||
AntiTracking._createTask({
|
||||
name: setting.name,
|
||||
cookieBehavior: test.behavior,
|
||||
allowList: false,
|
||||
callback,
|
||||
extraPrefs: null,
|
||||
expectedBlockingNotifications: 0,
|
||||
runInPrivateWindow: false,
|
||||
iframeSandbox: null,
|
||||
accessRemoval: null,
|
||||
callbackAfterRemoval: null,
|
||||
topPage: setting.topPage,
|
||||
thirdPartyPage: setting.thirdPartyPage,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value =>
|
||||
resolve()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
@ -53,7 +53,11 @@ AntiTracking.runTestInNormalAndPrivateMode(
|
||||
},
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
|
@ -11,7 +11,11 @@ AntiTracking.runTest(
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
let [threw, rejected] = await callRequestStorageAccess();
|
||||
@ -36,8 +40,6 @@ AntiTracking.runTest(
|
||||
// after-removal callback
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
// TODO: this is just a temporarily fixed, we should update the testcase
|
||||
// in Bug 1649399
|
||||
await hasStorageAccessInitially();
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
);
|
||||
|
@ -11,7 +11,11 @@ AntiTracking.runTest(
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
await hasStorageAccessInitially();
|
||||
if (allowListed) {
|
||||
await hasStorageAccessInitially();
|
||||
} else {
|
||||
await noStorageAccessInitially();
|
||||
}
|
||||
|
||||
/* import-globals-from storageAccessAPIHelpers.js */
|
||||
let [threw, rejected] = await callRequestStorageAccess();
|
||||
|
Loading…
x
Reference in New Issue
Block a user