зеркало из 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 "nsContentUtils.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#define DATASET \
|
||||
|
@ -163,5 +164,11 @@ bool SessionStorage::IsForkOf(const Storage* aOther) const {
|
|||
return mCache == static_cast<const SessionStorage*>(aOther)->mCache;
|
||||
}
|
||||
|
||||
bool SessionStorage::ShouldThrowWhenStorageAccessDenied(
|
||||
uint32_t aRejectedReason) {
|
||||
return aRejectedReason !=
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -65,6 +65,8 @@ class SessionStorage final : public Storage {
|
|||
const nsAString& aOldValue,
|
||||
const nsAString& aNewValue);
|
||||
|
||||
bool ShouldThrowWhenStorageAccessDenied(uint32_t aRejectedReason) override;
|
||||
|
||||
RefPtr<SessionStorageCache> mCache;
|
||||
RefPtr<SessionStorageManager> mManager;
|
||||
|
||||
|
|
|
@ -43,15 +43,23 @@ bool Storage::CanUseStorage(nsIPrincipal& aSubjectPrincipal) {
|
|||
return false;
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess access =
|
||||
nsContentUtils::StorageAllowedForPrincipal(Principal());
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
mIsSessionOnly = false;
|
||||
} else if (mWindow) {
|
||||
uint32_t rejectedReason = 0;
|
||||
nsContentUtils::StorageAccess access =
|
||||
nsContentUtils::StorageAllowedForWindow(mWindow, &rejectedReason);
|
||||
|
||||
if (access <= nsContentUtils::StorageAccess::eDeny) {
|
||||
return false;
|
||||
// Note that we allow StorageAccess::ePartitionedOrDeny because we want
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,13 @@ class Storage : public nsISupports, public nsWrapperCache {
|
|||
|
||||
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:
|
||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
|
Загрузка…
Ссылка в новой задаче