Bug 1877649 - Remove unused storage access flag `eSessionScoped`. r=pbz,dom-storage-reviewers,janv,webidl,saschanaz

Differential Revision: https://phabricator.services.mozilla.com/D201656
This commit is contained in:
Razvan Cojocaru 2024-03-21 10:18:49 +00:00
Родитель 6b370b2e72
Коммит 1b9ff1e6cc
9 изменённых файлов: 13 добавлений и 31 удалений

Просмотреть файл

@ -100,7 +100,7 @@ void FileSystemManager::BeginRequest(
MOZ_ASSERT(mGlobal);
// Check if we're allowed to use storage
if (mGlobal->GetStorageAccess() < StorageAccess::eSessionScoped) {
if (mGlobal->GetStorageAccess() <= StorageAccess::ePrivateBrowsing) {
aFailure(NS_ERROR_DOM_SECURITY_ERR);
return;
}

Просмотреть файл

@ -1530,9 +1530,7 @@ class Datastore final
uint32_t PrivateBrowsingId() const { return mPrivateBrowsingId; }
bool IsPersistent() const {
// Private-browsing is forbidden from touching disk, but
// StorageAccess::eSessionScoped is allowed to touch disk because
// QuotaManager's storage for such origins is wiped at shutdown.
// Private-browsing is forbidden from touching disk.
return mPrivateBrowsingId == 0;
}

Просмотреть файл

@ -37,8 +37,11 @@ inline uint32_t GetDataSetIndex(bool aPrivateBrowsing,
}
inline uint32_t GetDataSetIndex(const LocalStorage* aStorage) {
// A session only mode doesn't exist anymore, so having a separate data set
// for it here is basically useless. This code is only kept until we remove
// the old / legacy LocalStorage implementation.
return GetDataSetIndex(aStorage->IsPrivateBrowsing(),
aStorage->IsSessionScopedOrLess());
aStorage->IsPrivateBrowsingOrLess());
}
} // namespace
@ -167,8 +170,8 @@ void LocalStorageCache::NotifyObservers(const LocalStorage* aStorage,
}
inline bool LocalStorageCache::Persist(const LocalStorage* aStorage) const {
return mPersistent &&
(aStorage->IsPrivateBrowsing() || !aStorage->IsSessionScopedOrLess());
return mPersistent && (aStorage->IsPrivateBrowsing() ||
!aStorage->IsPrivateBrowsingOrLess());
}
const nsCString LocalStorageCache::Origin() const {

Просмотреть файл

@ -38,18 +38,18 @@ Storage::Storage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
mPrincipal(aPrincipal),
mStoragePrincipal(aStoragePrincipal),
mPrivateBrowsing(false),
mSessionScopedOrLess(false) {
mPrivateBrowsingOrLess(false) {
MOZ_ASSERT(aPrincipal);
if (mPrincipal->IsSystemPrincipal()) {
mPrivateBrowsing = false;
mSessionScopedOrLess = false;
mPrivateBrowsingOrLess = false;
} else if (mWindow) {
uint32_t rejectedReason = 0;
StorageAccess access = StorageAllowedForWindow(mWindow, &rejectedReason);
mPrivateBrowsing = access == StorageAccess::ePrivateBrowsing;
mSessionScopedOrLess = access <= StorageAccess::eSessionScoped;
mPrivateBrowsingOrLess = access <= StorageAccess::ePrivateBrowsing;
}
}

Просмотреть файл

@ -52,7 +52,7 @@ class Storage : public nsISupports, public nsWrapperCache {
bool IsPrivateBrowsing() const { return mPrivateBrowsing; }
bool IsSessionScopedOrLess() const { return mSessionScopedOrLess; }
bool IsPrivateBrowsingOrLess() const { return mPrivateBrowsingOrLess; }
// WebIDL
JSObject* WrapObject(JSContext* aCx,
@ -98,11 +98,6 @@ class Storage : public nsISupports, public nsWrapperCache {
virtual void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) = 0;
// The attribute in the WebIDL interface has rather confusing name. So we
// shouldn't use this method internally. IsSessionScopedOrLess should be used
// directly.
bool IsSessionOnly() const { return IsSessionScopedOrLess(); }
//////////////////////////////////////////////////////////////////////////////
// Testing Methods:
//
@ -172,7 +167,7 @@ class Storage : public nsISupports, public nsWrapperCache {
// Whether storage is set to persist data only per session, may change
// dynamically and is set by CanUseStorage function that is called
// before any operation on the storage.
bool mSessionScopedOrLess : 1;
bool mPrivateBrowsingOrLess : 1;
};
} // namespace mozilla::dom

Просмотреть файл

@ -1,8 +0,0 @@
<!doctype html>
<html>
<body>
<script>
parent.postMessage(SpecialPowers.wrap(localStorage).isSessionOnly, "*");
</script>
</body>
</html>

Просмотреть файл

@ -15,7 +15,6 @@ support-files = [
"interOriginTest.js",
"interOriginTest2.js",
"localStorageCommon.js",
"frameLocalStorageSessionOnly.html",
"file_tryAccessSessionStorage.html",
"windowProxy.html",
]

Просмотреть файл

@ -30,9 +30,6 @@ interface Storage {
[Throws, NeedsSubjectPrincipal]
undefined clear();
[ChromeOnly]
readonly attribute boolean isSessionOnly;
};
/**

Просмотреть файл

@ -40,8 +40,6 @@ enum class StorageAccess {
// Allow access to the storage, but only if it is secure to do so in a
// private browsing context.
ePrivateBrowsing = 1,
// Allow access to the storage, but only persist it for the current session
eSessionScoped = 2,
// Allow access to the storage
eAllow = 3,
// Keep this at the end. Used for serialization, but not a valid value.