commit 14bb07f325984e2c84541781a0e74dbd4ee9628d
parent cf240c0c38e4ce07c345ee8344bd61efaa3a306b
Author: Jan Varga <jvarga@igalia.com>
Date: Mon, 5 Jan 2026 10:22:26 +0000
Bug 2007824 [wpt PR 56933] - storage: Scope `WebStorage` quota per storage type instead of per origin total, a=testonly
Automatic update from web-platform-tests
wpt: Add tests for independent localStorage/sessionStorage quotas
The new tests verify that exhausting the quota of one Web Storage area does
not significantly reduce the capacity available to the other one.
Each test first measures the baseline capacity of one storage type by filling
it until QuotaExceededError is thrown, then clears it, exhausts the other
storage type, and measures the capacity again. Independence is verified by
requiring that the second measurement remains broadly comparable to the
baseline rather than collapsing to near-zero capacity, which would indicate
a shared quota.
Two directional tests are added:
- sessionStorage retains comparable quota after localStorage exhaustion
- localStorage retains comparable quota after sessionStorage exhaustion
Gecko currently fails these new tests. This is consistent with the fact that
the existing quota exhaustion tests also currently fail in Gecko.
Signed-off-by: Jan Varga <jvarga@igalia.com>
--
wpt-commits: cfb14991790b45b4162d98dc1fed4a43349afcd0
wpt-pr: 56933
Diffstat:
2 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/webstorage/storage_local_quota_independent_from_session.window.js b/testing/web-platform/tests/webstorage/storage_local_quota_independent_from_session.window.js
@@ -0,0 +1,43 @@
+test(t => {
+ localStorage.clear();
+ sessionStorage.clear();
+
+ var key = "name";
+ var val = "x".repeat(4 * 1024);
+
+ t.add_cleanup(() => {
+ localStorage.clear();
+ sessionStorage.clear();
+ });
+
+ let indexBefore = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ localStorage.setItem("" + key + indexBefore, "" + val + indexBefore);
+ indexBefore++;
+ }
+ }, null, null);
+
+ localStorage.clear();
+
+ let indexLocal = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ sessionStorage.setItem("" + key + indexLocal, "" + val + indexLocal);
+ indexLocal++;
+ }
+ }, null, null);
+
+ let indexAfter = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ localStorage.setItem("" + key + indexAfter, "" + val + indexAfter);
+ indexAfter++;
+ }
+ }, null, null);
+
+ assert_greater_than_equal(
+ indexAfter,
+ Math.floor(indexBefore / 2)
+ );
+}, "localStorage retains comparable quota after sessionStorage exhaustion");
diff --git a/testing/web-platform/tests/webstorage/storage_session_quota_independent_from_local.window.js b/testing/web-platform/tests/webstorage/storage_session_quota_independent_from_local.window.js
@@ -0,0 +1,43 @@
+test(t => {
+ sessionStorage.clear();
+ localStorage.clear();
+
+ var key = "name";
+ var val = "x".repeat(4 * 1024);
+
+ t.add_cleanup(() => {
+ sessionStorage.clear();
+ localStorage.clear();
+ });
+
+ let indexBefore = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ sessionStorage.setItem("" + key + indexBefore, "" + val + indexBefore);
+ indexBefore++;
+ }
+ }, null, null);
+
+ sessionStorage.clear();
+
+ let indexLocal = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ localStorage.setItem("" + key + indexLocal, "" + val + indexLocal);
+ indexLocal++;
+ }
+ }, null, null);
+
+ let indexAfter = 0;
+ assert_throws_quotaexceedederror(() => {
+ while (true) {
+ sessionStorage.setItem("" + key + indexAfter, "" + val + indexAfter);
+ indexAfter++;
+ }
+ }, null, null);
+
+ assert_greater_than_equal(
+ indexAfter,
+ Math.floor(indexBefore / 2)
+ );
+}, "sessionStorage retains comparable quota after localStorage exhaustion");