Title: [278498] trunk
Revision
278498
Author
beid...@apple.com
Date
2021-06-04 14:21:48 -0700 (Fri, 04 Jun 2021)

Log Message

Enforce a quota in window.sessionStorage
rdar://78507096 and https://bugs.webkit.org/show_bug.cgi?id=226337

Reviewed by Chris Dumez.

Source/WebCore:

Covered by change to existing test.

* page/Page.cpp:
(WebCore::Page::sessionStorage): Make sure the quota for session storage is not "noQuota"

* page/Settings.yaml: Default to 5mb instead of noQuota to match other browsers.

LayoutTests:

* platform/ios-wk1/TestExpectations:
* platform/ios/ios/storage/domstorage/5mb-quota.html: Removed.
* storage/domstorage/quota-expected.txt:
* storage/domstorage/quota.html:

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278497 => 278498)


--- trunk/LayoutTests/ChangeLog	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/LayoutTests/ChangeLog	2021-06-04 21:21:48 UTC (rev 278498)
@@ -1,3 +1,15 @@
+2021-06-04  Brady Eidson  <beid...@apple.com>
+
+        Enforce a quota in window.sessionStorage
+        rdar://78507096 and https://bugs.webkit.org/show_bug.cgi?id=226337
+
+        Reviewed by Chris Dumez.
+
+        * platform/ios-wk1/TestExpectations:
+        * platform/ios/ios/storage/domstorage/5mb-quota.html: Removed.
+        * storage/domstorage/quota-expected.txt:
+        * storage/domstorage/quota.html:
+
 2021-06-04  Antti Koivisto  <an...@apple.com>
 
         REGRESSION (maybe r276882): custom properties not available on host on initial paint

Deleted: trunk/LayoutTests/platform/ios/ios/storage/domstorage/5mb-quota.html (278497 => 278498)


--- trunk/LayoutTests/platform/ios/ios/storage/domstorage/5mb-quota.html	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/LayoutTests/platform/ios/ios/storage/domstorage/5mb-quota.html	2021-06-04 21:21:48 UTC (rev 278498)
@@ -1,66 +0,0 @@
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script>
-description("Test a 5MB DOM Storage quota for localStorage and sessionStorage.");
-
-function testQuota(storageString)
-{
-    storage = eval(storageString);
-    if (!storage) {
-        testFailed(storageString + " DOES NOT exist");
-        return;
-    }
-
-    debug("Testing " + storageString);
-
-    evalAndLog("storage.clear()");
-    shouldBe("storage.length", "0");
-
-    debug("Creating 'data' which contains 64K of data");
-    data = ""
-    for (var i=0; i<16; i++)
-        data += data;
-    shouldBe("data.length", "65536");
-
-    debug("Putting 'data' into 39 " + storageString + " buckets.");
-    for (var i=0; i<39; i++)
-        storage[i] = data;
-
-    debug("Putting 'data' into another bucket.h");
-    try {
-        storage[39] = data;
-        testFailed("Did not hit quota error.");
-    } catch (e) {
-        testPassed("Hit exception as expected");
-    }
-
-    debug("Verify that data was never inserted.");
-    shouldBeNull("storage.getItem(39)");
-
-    debug("Removing bucket 38.");
-    storage.removeItem('38');
-
-    debug("Adding 'Hello!' into a new bucket.");
-    try {
-        storage['foo'] = "Hello!";
-        testPassed("Insertion worked.");
-    } catch (e) {
-        testFailed("Exception: " + e);
-    }
-}
-
-testQuota("sessionStorage");
-debug("");
-debug("");
-testQuota("localStorage");
-
-window.successfullyParsed = true;
-isSuccessfullyParsed();
-</script>
-</body>
-</html>

Modified: trunk/LayoutTests/platform/ios-wk1/TestExpectations (278497 => 278498)


--- trunk/LayoutTests/platform/ios-wk1/TestExpectations	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/LayoutTests/platform/ios-wk1/TestExpectations	2021-06-04 21:21:48 UTC (rev 278498)
@@ -899,9 +899,6 @@
 # _javascript_s tests that fail:
 js/dom/deep-recursion-test.html [ Failure ]
 
-# iOS-specific tests that fail:
-platform/ios/ios/storage/domstorage/5mb-quota.html [ Failure ]
-
 # LayoutTests/fast test that time out:
 fast/block/positioning/vertical-rl/001.html
 fast/body-propagation/background-color/001-xhtml.xhtml

Modified: trunk/LayoutTests/storage/domstorage/quota-expected.txt (278497 => 278498)


--- trunk/LayoutTests/storage/domstorage/quota-expected.txt	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/LayoutTests/storage/domstorage/quota-expected.txt	2021-06-04 21:21:48 UTC (rev 278498)
@@ -10,6 +10,11 @@
 PASS data.length is 65536
 Putting 'data' into 39 sessionStorage buckets.
 Putting 'data' into another bucket.h
+PASS Hit exception as expected
+Verify that data was never inserted.
+PASS storage.getItem(39) is null
+Removing bucket 38.
+Adding 'Hello!' into a new bucket.
 PASS Insertion worked.
 
 

Modified: trunk/LayoutTests/storage/domstorage/quota.html (278497 => 278498)


--- trunk/LayoutTests/storage/domstorage/quota.html	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/LayoutTests/storage/domstorage/quota.html	2021-06-04 21:21:48 UTC (rev 278498)
@@ -54,39 +54,7 @@
     }
 }
 
-function testNoQuota(storageString)
-{
-    storage = eval(storageString);
-    if (!storage) {
-        testFailed(storageString + " DOES NOT exist");
-        return;
-    }
-
-    debug("Testing " + storageString);
-
-    evalAndLog("storage.clear()");
-    shouldBe("storage.length", "0");
-
-    debug("Creating 'data' which contains 64K of data");
-    data = ""
-    for (var i=0; i<16; i++)
-        data += data;
-    shouldBe("data.length", "65536");
-
-    debug("Putting 'data' into 39 " + storageString + " buckets.");
-    for (var i=0; i<39; i++)
-        storage[i] = data;
-
-    debug("Putting 'data' into another bucket.h");
-    try {
-        storage[39] = data;
-        testPassed("Insertion worked.");
-    } catch (e) {
-        testFailed("Exception: " + e);
-    }
-}
-
-testNoQuota("sessionStorage");
+testQuota("sessionStorage");
 debug("");
 debug("");
 testQuota("localStorage");

Modified: trunk/Source/WebCore/ChangeLog (278497 => 278498)


--- trunk/Source/WebCore/ChangeLog	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/Source/WebCore/ChangeLog	2021-06-04 21:21:48 UTC (rev 278498)
@@ -1,3 +1,17 @@
+2021-06-04  Brady Eidson  <beid...@apple.com>
+
+        Enforce a quota in window.sessionStorage
+        rdar://78507096 and https://bugs.webkit.org/show_bug.cgi?id=226337
+
+        Reviewed by Chris Dumez.
+
+        Covered by change to existing test.
+
+        * page/Page.cpp:
+        (WebCore::Page::sessionStorage): Make sure the quota for session storage is not "noQuota"
+
+        * page/Settings.yaml: Default to 5mb instead of noQuota to match other browsers.
+
 2021-06-03  Darin Adler  <da...@apple.com>
 
         Move from WebCore::SuccessOr to WTF::Expected

Modified: trunk/Source/WebCore/page/Page.cpp (278497 => 278498)


--- trunk/Source/WebCore/page/Page.cpp	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/Source/WebCore/page/Page.cpp	2021-06-04 21:21:48 UTC (rev 278498)
@@ -1955,8 +1955,10 @@
 
 StorageNamespace* Page::sessionStorage(bool optionalCreate)
 {
-    if (!m_sessionStorage && optionalCreate)
+    if (!m_sessionStorage && optionalCreate) {
+        ASSERT(m_settings->sessionStorageQuota() != StorageMap::noQuota);
         m_sessionStorage = m_storageNamespaceProvider->createSessionStorageNamespace(*this, m_settings->sessionStorageQuota());
+    }
 
     return m_sessionStorage.get();
 }

Modified: trunk/Source/WebCore/page/Settings.yaml (278497 => 278498)


--- trunk/Source/WebCore/page/Settings.yaml	2021-06-04 21:04:14 UTC (rev 278497)
+++ trunk/Source/WebCore/page/Settings.yaml	2021-06-04 21:21:48 UTC (rev 278498)
@@ -475,7 +475,7 @@
   type: uint32_t
   defaultValue:
     WebCore:
-      default: StorageMap::noQuota
+      default: 5242880
 
 ShouldDispatchSyntheticMouseEventsWhenModifyingSelection:
   type: bool
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to