mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1629707 - use StoragePrincipal
for SessionStorage
; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D72765
This commit is contained in:
parent
9d2d8bbeb9
commit
72da9842fb
@ -4370,9 +4370,11 @@ already_AddRefed<nsICSSDeclaration> nsGlobalWindowInner::GetComputedStyleHelper(
|
||||
|
||||
Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
|
||||
nsIPrincipal* principal = GetPrincipal();
|
||||
nsIPrincipal* storagePrincipal = IntrinsicStoragePrincipal();
|
||||
BrowsingContext* browsingContext = GetBrowsingContext();
|
||||
|
||||
if (!principal || !browsingContext || !Storage::StoragePrefIsEnabled()) {
|
||||
if (!principal || !storagePrincipal || !browsingContext ||
|
||||
!Storage::StoragePrefIsEnabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -4380,10 +4382,9 @@ Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
|
||||
MOZ_LOG(gDOMLeakPRLogInner, LogLevel::Debug,
|
||||
("nsGlobalWindowInner %p has %p sessionStorage", this,
|
||||
mSessionStorage.get()));
|
||||
bool canAccess = principal->Subsumes(mSessionStorage->Principal());
|
||||
NS_ASSERTION(canAccess,
|
||||
"This window owned sessionStorage "
|
||||
"that could not be accessed!");
|
||||
bool canAccess =
|
||||
principal->Subsumes(mSessionStorage->Principal()) &&
|
||||
storagePrincipal->Subsumes(mSessionStorage->StoragePrincipal());
|
||||
if (!canAccess) {
|
||||
mSessionStorage = nullptr;
|
||||
}
|
||||
@ -4433,7 +4434,8 @@ Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
|
||||
// BEHAVIOR_LIMIT_FOREIGN and this is a third-party window. This will return
|
||||
// eDeny with a reason of STATE_COOKIES_BLOCKED_FOREIGN.
|
||||
//
|
||||
// 3. Tracking protection (BEHAVIOR_REJECT_TRACKER) is in effect and
|
||||
// 3. Tracking protection (BEHAVIOR_REJECT_TRACKER and
|
||||
// BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN) is in effect and
|
||||
// IsThirdPartyTrackingResourceWindow() returned true and there wasn't a
|
||||
// permission that allows it. This will return ePartitionTrackersOrDeny with
|
||||
// a reason of STATE_COOKIES_BLOCKED_TRACKER or
|
||||
@ -4460,8 +4462,7 @@ Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
|
||||
}
|
||||
|
||||
RefPtr<Storage> storage;
|
||||
// No StoragePrincipal for sessions.
|
||||
aError = storageManager->CreateStorage(this, principal, principal,
|
||||
aError = storageManager->CreateStorage(this, principal, storagePrincipal,
|
||||
documentURI, IsPrivateBrowsing(),
|
||||
getter_AddRefs(storage));
|
||||
if (aError.Failed()) {
|
||||
@ -5049,8 +5050,8 @@ void nsGlobalWindowInner::ObserveStorageNotification(
|
||||
|
||||
if (const RefPtr<SessionStorageManager> storageManager =
|
||||
GetBrowsingContext()->GetSessionStorageManager()) {
|
||||
nsresult rv =
|
||||
storageManager->CheckStorage(principal, changingStorage, &check);
|
||||
nsresult rv = storageManager->CheckStorage(storagePrincipal,
|
||||
changingStorage, &check);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
@ -144,8 +144,8 @@ void SessionStorage::Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) {
|
||||
void SessionStorage::BroadcastChangeNotification(const nsAString& aKey,
|
||||
const nsAString& aOldValue,
|
||||
const nsAString& aNewValue) {
|
||||
NotifyChange(this, Principal(), aKey, aOldValue, aNewValue, u"sessionStorage",
|
||||
mDocumentURI, mIsPrivate, false);
|
||||
NotifyChange(this, StoragePrincipal(), aKey, aOldValue, aNewValue,
|
||||
u"sessionStorage", mDocumentURI, mIsPrivate, false);
|
||||
}
|
||||
|
||||
bool SessionStorage::IsForkOf(const Storage* aOther) const {
|
||||
|
@ -248,7 +248,8 @@ SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal, Storage* aStorage,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!StorageUtils::PrincipalsEqual(aStorage->Principal(), aPrincipal)) {
|
||||
if (!StorageUtils::PrincipalsEqual(aStorage->StoragePrincipal(),
|
||||
aPrincipal)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user