зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1537753 - Drop support for the extensions.cookiesBehavior.overrideOnTopLevel pref. r=Ehsan,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D44693 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
69530522eb
Коммит
40c77fd1d8
|
@ -2717,13 +2717,6 @@
|
|||
value: @IS_ANDROID@
|
||||
mirror: always
|
||||
|
||||
# This pref should be set to true only in case of regression related to the
|
||||
# changes applied in Bug 152591 (to be removed as part of Bug 1537753).
|
||||
- name: extensions.cookiesBehavior.overrideOnTopLevel
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# This pref governs whether we run webextensions in a separate process (true)
|
||||
# or the parent/main process (false)
|
||||
- name: extensions.webextensions.remote
|
||||
|
|
|
@ -178,21 +178,9 @@ uint32_t CheckCookiePermissionForPrincipal(nsICookieSettings* aCookieSettings,
|
|||
return cookiePermission;
|
||||
}
|
||||
|
||||
int32_t CookiesBehavior(Document* aTopLevelDocument,
|
||||
Document* a3rdPartyDocument) {
|
||||
MOZ_ASSERT(aTopLevelDocument);
|
||||
int32_t CookiesBehavior(Document* a3rdPartyDocument) {
|
||||
MOZ_ASSERT(a3rdPartyDocument);
|
||||
|
||||
// Override the cookiebehavior to accept if the top level document has
|
||||
// an extension principal (if the static pref has been set to true
|
||||
// to force the old behavior here, See Bug 1525917).
|
||||
// This block (and the static pref) should be removed as part of
|
||||
// Bug 1537753.
|
||||
if (StaticPrefs::extensions_cookiesBehavior_overrideOnTopLevel() &&
|
||||
BasePrincipal::Cast(aTopLevelDocument->NodePrincipal())->AddonPolicy()) {
|
||||
return nsICookieService::BEHAVIOR_ACCEPT;
|
||||
}
|
||||
|
||||
// WebExtensions principals always get BEHAVIOR_ACCEPT as cookieBehavior
|
||||
// (See Bug 1406675 and Bug 1525917 for rationale).
|
||||
if (BasePrincipal::Cast(a3rdPartyDocument->NodePrincipal())->AddonPolicy()) {
|
||||
|
@ -202,23 +190,10 @@ int32_t CookiesBehavior(Document* aTopLevelDocument,
|
|||
return a3rdPartyDocument->CookieSettings()->GetCookieBehavior();
|
||||
}
|
||||
|
||||
int32_t CookiesBehavior(nsILoadInfo* aLoadInfo,
|
||||
nsIPrincipal* aTopLevelPrincipal,
|
||||
nsIURI* a3rdPartyURI) {
|
||||
int32_t CookiesBehavior(nsILoadInfo* aLoadInfo, nsIURI* a3rdPartyURI) {
|
||||
MOZ_ASSERT(aLoadInfo);
|
||||
MOZ_ASSERT(aTopLevelPrincipal);
|
||||
MOZ_ASSERT(a3rdPartyURI);
|
||||
|
||||
// Override the cookiebehavior to accept if the top level principal is
|
||||
// an extension principal (if the static pref has been turned to true
|
||||
// to force the old behavior here, See Bug 1525917).
|
||||
// This block (and the static pref) should be removed as part of
|
||||
// Bug 1537753.
|
||||
if (StaticPrefs::extensions_cookiesBehavior_overrideOnTopLevel() &&
|
||||
BasePrincipal::Cast(aTopLevelPrincipal)->AddonPolicy()) {
|
||||
return nsICookieService::BEHAVIOR_ACCEPT;
|
||||
}
|
||||
|
||||
// WebExtensions 3rd party URI always get BEHAVIOR_ACCEPT as cookieBehavior,
|
||||
// this is semantically equivalent to the principal having a AddonPolicy().
|
||||
if (a3rdPartyURI->SchemeIs("moz-extension")) {
|
||||
|
@ -1368,7 +1343,6 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
|||
// For out-of-process top frames, we need to be able to access three things
|
||||
// from the top BrowsingContext in order to be able to port this code to
|
||||
// Fission successfully:
|
||||
// * The principal of the top BrowsingContext.
|
||||
// * The CookieSettings of the top BrowsingContext.
|
||||
// * The HasStorageAccessGranted() API on BrowsingContext.
|
||||
// For now, if we face an out-of-process top frame, instead of failing here,
|
||||
|
@ -1399,14 +1373,6 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
|||
return false;
|
||||
}
|
||||
|
||||
Document* toplevelDocument = topInnerWindow->GetExtantDoc();
|
||||
if (!toplevelDocument) {
|
||||
LOG(("No top level document."));
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(toplevelDocument);
|
||||
|
||||
uint32_t cookiePermission = CheckCookiePermissionForPrincipal(
|
||||
document->CookieSettings(), document->NodePrincipal());
|
||||
if (cookiePermission != nsICookiePermission::ACCESS_DEFAULT) {
|
||||
|
@ -1425,7 +1391,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t behavior = CookiesBehavior(toplevelDocument, document);
|
||||
int32_t behavior = CookiesBehavior(document);
|
||||
if (behavior == nsICookieService::BEHAVIOR_ACCEPT) {
|
||||
LOG(("The cookie behavior pref mandates accepting all cookies!"));
|
||||
return true;
|
||||
|
@ -1664,7 +1630,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t behavior = CookiesBehavior(loadInfo, toplevelPrincipal, channelURI);
|
||||
int32_t behavior = CookiesBehavior(loadInfo, channelURI);
|
||||
if (behavior == nsICookieService::BEHAVIOR_ACCEPT) {
|
||||
LOG(("The cookie behavior pref mandates accepting all cookies!"));
|
||||
return true;
|
||||
|
|
|
@ -186,16 +186,7 @@ add_task(async function test_ext_page_allowed_storage() {
|
|||
}
|
||||
});
|
||||
|
||||
add_task(
|
||||
{
|
||||
// Remove this skip_if once we remove this pref for Bug 1537753.
|
||||
skip_if: () =>
|
||||
Services.prefs.getBoolPref(
|
||||
"extensions.cookiesBehavior.overrideOnTopLevel",
|
||||
false
|
||||
),
|
||||
},
|
||||
async function test_ext_page_3rdparty_cookies() {
|
||||
add_task(async function test_ext_page_3rdparty_cookies() {
|
||||
// Disable tracking protection to test cookies on BEHAVIOR_REJECT_TRACKER
|
||||
// (otherwise tracking protection would block the tracker iframe and
|
||||
// we would not be actually checking the cookie behavior).
|
||||
|
@ -396,8 +387,7 @@ add_task(
|
|||
|
||||
await extPage.close();
|
||||
await extension.unload();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Test that a webpage embedded as a subframe of an extension page is not allowed to use
|
||||
// IndexedDB and register a ServiceWorker when it shouldn't be based on the cookieBehavior.
|
||||
|
@ -484,11 +474,6 @@ add_task(
|
|||
}
|
||||
);
|
||||
|
||||
const overrideOnTopLevel = Services.prefs.getBoolPref(
|
||||
"extensions.cookiesBehavior.overrideOnTopLevel",
|
||||
false
|
||||
);
|
||||
|
||||
Assert.deepEqual(
|
||||
results.extTopLevel,
|
||||
{ success: true },
|
||||
|
@ -501,19 +486,6 @@ add_task(
|
|||
"IndexedDB allowed in a subframe extension page with a top level extension page"
|
||||
);
|
||||
|
||||
if (overrideOnTopLevel) {
|
||||
// Remove this branch once we remove the related pref for Bug 1537753.
|
||||
Assert.deepEqual(
|
||||
results.webSubFrame,
|
||||
{ success: true },
|
||||
"IndexedDB allowed in a subframe webpage with a top level extension page"
|
||||
);
|
||||
Assert.deepEqual(
|
||||
results.webServiceWorker,
|
||||
{ success: true },
|
||||
"IndexedDB and Cache allowed in a service worker registered in the subframe webpage extension page"
|
||||
);
|
||||
} else {
|
||||
Assert.deepEqual(
|
||||
results.webSubFrame,
|
||||
{ error: "SecurityError: The operation is insecure." },
|
||||
|
@ -524,7 +496,6 @@ add_task(
|
|||
{ error: "SecurityError: The operation is insecure." },
|
||||
"IndexedDB and Cache not allowed in a service worker registered in the subframe webpage extension page"
|
||||
);
|
||||
}
|
||||
|
||||
Assert.deepEqual(
|
||||
results.extSubFrameContent,
|
||||
|
|
Загрузка…
Ссылка в новой задаче