Title: [243247] trunk
Revision
243247
Author
[email protected]
Date
2019-03-20 15:15:03 -0700 (Wed, 20 Mar 2019)

Log Message

Have smaller default quotas for third party frames
https://bugs.webkit.org/show_bug.cgi?id=195841

Reviewed by Geoffrey Garen.

Source/WebCore:

Test: http/wpt/cache-storage/quota-third-party.https.html

* storage/StorageQuotaManager.h:
(WebCore::StorageQuotaManager::defaultQuota):
Change default quota to 1GB.

Source/WebKit:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::storageQuotaManager):
For third party iframes, use the default quota divided by 10.

LayoutTests:

* http/wpt/cache-storage/quota-third-party.https-expected.txt: Added.
* http/wpt/cache-storage/quota-third-party.https.html: Added.
* http/wpt/cache-storage/resources/quota-third-party-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243246 => 243247)


--- trunk/LayoutTests/ChangeLog	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/LayoutTests/ChangeLog	2019-03-20 22:15:03 UTC (rev 243247)
@@ -1,3 +1,14 @@
+2019-03-20  Youenn Fablet  <[email protected]>
+
+        Have smaller default quotas for third party frames
+        https://bugs.webkit.org/show_bug.cgi?id=195841
+
+        Reviewed by Geoffrey Garen.
+
+        * http/wpt/cache-storage/quota-third-party.https-expected.txt: Added.
+        * http/wpt/cache-storage/quota-third-party.https.html: Added.
+        * http/wpt/cache-storage/resources/quota-third-party-iframe.html: Added.
+
 2019-03-20  Devin Rousso  <[email protected]>
 
         Web Inspector: DOM: include window as part of any event listener chain

Added: trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https-expected.txt (0 => 243247)


--- trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https-expected.txt	2019-03-20 22:15:03 UTC (rev 243247)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Cache API operation failed: Quota exceeded
+  
+
+PASS same origin iframe has regular quota 
+PASS cross origin iframe has reduced quota 
+

Added: trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https.html (0 => 243247)


--- trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/cache-storage/quota-third-party.https.html	2019-03-20 22:15:03 UTC (rev 243247)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Cache Storage: third party iframes</title>
+        <script src=""
+        <script src=""
+    </head>
+<body>
+    <script>
+function load_iframe(url) {
+    return new Promise(function(resolve) {
+        var frame = document.createElement('iframe');
+        frame.src = ""
+        window._onmessage_ = (event) => resolve(event.data);
+        document.body.appendChild(frame);
+    });
+}
+
+promise_test(async () => {
+    assert_equals(await load_iframe("resources/quota-third-party-iframe.html"), "PASS");
+}, "same origin iframe has regular quota");
+
+promise_test(async () => {
+    assert_equals(await load_iframe("https://127.0.0.1:9443/WebKit/cache-storage/resources/quota-third-party-iframe.html"), "FAIL");
+}, "cross origin iframe has reduced quota");
+
+    </script>
+</body>
+</html>
+

Added: trunk/LayoutTests/http/wpt/cache-storage/resources/quota-third-party-iframe.html (0 => 243247)


--- trunk/LayoutTests/http/wpt/cache-storage/resources/quota-third-party-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/cache-storage/resources/quota-third-party-iframe.html	2019-03-20 22:15:03 UTC (rev 243247)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <script>
+if (window.testRunner)
+    testRunner.setAllowStorageQuotaIncrease(false);
+
+async function doTest() {
+    const cache = await self.caches.open("test");
+    const response30ko = new Response(new ArrayBuffer(30 * 1024));
+    try {
+        await cache.put("30ko", response30ko.clone());
+    } catch (e) {
+        window.parent.postMessage("UNEXPECTED", "*");
+    }
+    cache.put("30ko2", response30ko.clone()).then(() => {
+        window.parent.postMessage("PASS", "*");
+    }, () => {
+        window.parent.postMessage("FAIL", "*");
+    })
+}
+doTest();
+    </script>
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (243246 => 243247)


--- trunk/Source/WebCore/ChangeLog	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/Source/WebCore/ChangeLog	2019-03-20 22:15:03 UTC (rev 243247)
@@ -1,3 +1,16 @@
+2019-03-20  Youenn Fablet  <[email protected]>
+
+        Have smaller default quotas for third party frames
+        https://bugs.webkit.org/show_bug.cgi?id=195841
+
+        Reviewed by Geoffrey Garen.
+
+        Test: http/wpt/cache-storage/quota-third-party.https.html
+
+        * storage/StorageQuotaManager.h:
+        (WebCore::StorageQuotaManager::defaultQuota):
+        Change default quota to 1GB.
+
 2019-03-20  Devin Rousso  <[email protected]>
 
         Web Inspector: DOM: include window as part of any event listener chain

Modified: trunk/Source/WebCore/storage/StorageQuotaManager.h (243246 => 243247)


--- trunk/Source/WebCore/storage/StorageQuotaManager.h	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/Source/WebCore/storage/StorageQuotaManager.h	2019-03-20 22:15:03 UTC (rev 243247)
@@ -46,7 +46,8 @@
     }
     WEBCORE_EXPORT ~StorageQuotaManager();
 
-    static constexpr uint64_t defaultQuota() { return 500 * MB; }
+    static constexpr uint64_t defaultQuota() { return 1000 * MB; }
+    static constexpr uint64_t defaultThirdPartyQuota() { return 100 * MB; }
 
     WEBCORE_EXPORT void addUser(StorageQuotaUser&);
     void removeUser(StorageQuotaUser& user)

Modified: trunk/Source/WebKit/ChangeLog (243246 => 243247)


--- trunk/Source/WebKit/ChangeLog	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/Source/WebKit/ChangeLog	2019-03-20 22:15:03 UTC (rev 243247)
@@ -1,3 +1,14 @@
+2019-03-20  Youenn Fablet  <[email protected]>
+
+        Have smaller default quotas for third party frames
+        https://bugs.webkit.org/show_bug.cgi?id=195841
+
+        Reviewed by Geoffrey Garen.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::storageQuotaManager):
+        For third party iframes, use the default quota divided by 10.
+
 2019-03-20  Dean Jackson  <[email protected]>
 
         [iOS] Enable fast clicking everywhere

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (243246 => 243247)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-03-20 22:15:03 UTC (rev 243247)
@@ -2029,9 +2029,12 @@
 
 void NetworkProcess::setCacheStorageParameters(PAL::SessionID sessionID, uint64_t quota, String&& cacheStorageDirectory, SandboxExtension::Handle&& handle)
 {
-    m_storageQuotaManagers.ensure(sessionID, [] {
+    auto& managers =  m_storageQuotaManagers.ensure(sessionID, [] {
         return StorageQuotaManagers { };
-    }).iterator->value.defaultQuota = quota;
+    }).iterator->value;
+    managers.defaultQuota = quota;
+    // FIXME: Pass default third party quota as a parameter.
+    managers.defaultThirdPartyQuota = quota / 10;
 
     auto iterator = m_cacheStorageParametersCallbacks.find(sessionID);
     if (iterator == m_cacheStorageParametersCallbacks.end())
@@ -2390,7 +2393,8 @@
         return StorageQuotaManagers { };
     }).iterator->value;
     return *storageQuotaManagers.managersPerOrigin.ensure(origin, [this, &storageQuotaManagers, sessionID, &origin] {
-        return std::make_unique<StorageQuotaManager>(storageQuotaManagers.defaultQuota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) {
+        auto quota = origin.topOrigin == origin.clientOrigin ? storageQuotaManagers.defaultQuota : storageQuotaManagers.defaultThirdPartyQuota;
+        return std::make_unique<StorageQuotaManager>(quota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) {
             this->requestStorageSpace(sessionID, origin, quota, currentSpace, spaceIncrease, WTFMove(callback));
         });
     }).iterator->value;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (243246 => 243247)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-03-20 22:12:12 UTC (rev 243246)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-03-20 22:15:03 UTC (rev 243247)
@@ -534,6 +534,7 @@
 
     struct StorageQuotaManagers {
         uint64_t defaultQuota { WebCore::StorageQuotaManager::defaultQuota() };
+        uint64_t defaultThirdPartyQuota { WebCore::StorageQuotaManager::defaultThirdPartyQuota() };
         HashMap<WebCore::ClientOrigin, std::unique_ptr<WebCore::StorageQuotaManager>> managersPerOrigin;
     };
     HashMap<PAL::SessionID, StorageQuotaManagers> m_storageQuotaManagers;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to