зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1515665 - SessionStorage should be allowed when StorageAccess is ePartitionedOrDeny, r=ehsan
This commit is contained in:
Родитель
e563896a47
Коммит
c433a88518
|
@ -12,6 +12,7 @@
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
|
#include "nsIWebProgressListener.h"
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
|
|
||||||
#define DATASET \
|
#define DATASET \
|
||||||
|
@ -163,5 +164,11 @@ bool SessionStorage::IsForkOf(const Storage* aOther) const {
|
||||||
return mCache == static_cast<const SessionStorage*>(aOther)->mCache;
|
return mCache == static_cast<const SessionStorage*>(aOther)->mCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SessionStorage::ShouldThrowWhenStorageAccessDenied(
|
||||||
|
uint32_t aRejectedReason) {
|
||||||
|
return aRejectedReason !=
|
||||||
|
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -65,6 +65,8 @@ class SessionStorage final : public Storage {
|
||||||
const nsAString& aOldValue,
|
const nsAString& aOldValue,
|
||||||
const nsAString& aNewValue);
|
const nsAString& aNewValue);
|
||||||
|
|
||||||
|
bool ShouldThrowWhenStorageAccessDenied(uint32_t aRejectedReason) override;
|
||||||
|
|
||||||
RefPtr<SessionStorageCache> mCache;
|
RefPtr<SessionStorageCache> mCache;
|
||||||
RefPtr<SessionStorageManager> mManager;
|
RefPtr<SessionStorageManager> mManager;
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,23 @@ bool Storage::CanUseStorage(nsIPrincipal& aSubjectPrincipal) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsContentUtils::StorageAccess access =
|
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||||
nsContentUtils::StorageAllowedForPrincipal(Principal());
|
mIsSessionOnly = false;
|
||||||
|
} else if (mWindow) {
|
||||||
|
uint32_t rejectedReason = 0;
|
||||||
|
nsContentUtils::StorageAccess access =
|
||||||
|
nsContentUtils::StorageAllowedForWindow(mWindow, &rejectedReason);
|
||||||
|
|
||||||
if (access <= nsContentUtils::StorageAccess::eDeny) {
|
// Note that we allow StorageAccess::ePartitionedOrDeny because we want
|
||||||
return false;
|
// tracker to have access to their sessionStorage.
|
||||||
|
if (access == nsContentUtils::StorageAccess::eDeny &&
|
||||||
|
ShouldThrowWhenStorageAccessDenied(rejectedReason)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mIsSessionOnly = access <= nsContentUtils::StorageAccess::eSessionScoped;
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsSessionOnly = access <= nsContentUtils::StorageAccess::eSessionScoped;
|
|
||||||
|
|
||||||
return aSubjectPrincipal.Subsumes(mPrincipal);
|
return aSubjectPrincipal.Subsumes(mPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,13 @@ class Storage : public nsISupports, public nsWrapperCache {
|
||||||
|
|
||||||
virtual void LastRelease() {}
|
virtual void LastRelease() {}
|
||||||
|
|
||||||
|
// This method is called when StorageAccess is not granted for the owning
|
||||||
|
// window. aRejectedReason is one of the possible blocking states from
|
||||||
|
// nsIWebProgressListener.
|
||||||
|
virtual bool ShouldThrowWhenStorageAccessDenied(uint32_t aRejectedReason) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче