Title: [245698] trunk
Revision
245698
Author
[email protected]
Date
2019-05-23 11:08:01 -0700 (Thu, 23 May 2019)

Log Message

Set default WebsiteDataStore storage quota based on StorageQuotaManager
https://bugs.webkit.org/show_bug.cgi?id=198133
<rdar://problem/51031436>

Reviewed by Geoffrey Garen.

Source/WebKit:

* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm:
(doTest):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (245697 => 245698)


--- trunk/Source/WebKit/ChangeLog	2019-05-23 18:07:49 UTC (rev 245697)
+++ trunk/Source/WebKit/ChangeLog	2019-05-23 18:08:01 UTC (rev 245698)
@@ -1,3 +1,13 @@
+2019-05-23  Youenn Fablet  <[email protected]>
+
+        Set default WebsiteDataStore storage quota based on StorageQuotaManager
+        https://bugs.webkit.org/show_bug.cgi?id=198133
+        <rdar://problem/51031436>
+
+        Reviewed by Geoffrey Garen.
+
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+
 2019-05-23  Alex Christensen  <[email protected]>
 
         Deprecate more preview API

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h (245697 => 245698)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2019-05-23 18:07:49 UTC (rev 245697)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2019-05-23 18:08:01 UTC (rev 245698)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "APIObject.h"
+#include <WebCore/StorageQuotaManager.h>
 #include <wtf/URL.h>
 #include <wtf/text/WTFString.h>
 
@@ -97,13 +98,11 @@
     const URL& httpsProxy() const { return m_httpsProxy; }
     void setHTTPSProxy(URL&& proxy) { m_httpsProxy = WTFMove(proxy); }
 
-    constexpr static uint64_t defaultPerOriginStorageQuota = 50 * 1024 * 1024;
-
 private:
     WebsiteDataStoreConfiguration();
 
     String m_cacheStorageDirectory;
-    uint64_t m_perOriginStorageQuota { defaultPerOriginStorageQuota };
+    uint64_t m_perOriginStorageQuota { WebCore::StorageQuotaManager::defaultQuota() };
     String m_networkCacheDirectory;
     String m_applicationCacheDirectory;
     String m_applicationCacheFlatFileSubdirectoryName;

Modified: trunk/Tools/ChangeLog (245697 => 245698)


--- trunk/Tools/ChangeLog	2019-05-23 18:07:49 UTC (rev 245697)
+++ trunk/Tools/ChangeLog	2019-05-23 18:08:01 UTC (rev 245698)
@@ -1,3 +1,14 @@
+2019-05-23  Youenn Fablet  <[email protected]>
+
+        Set default WebsiteDataStore storage quota based on StorageQuotaManager
+        https://bugs.webkit.org/show_bug.cgi?id=198133
+        <rdar://problem/51031436>
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm:
+        (doTest):
+
 2019-05-23  Keith Rollin  <[email protected]>
 
         generate-xcfilelists should not store temporary build files in /tmp

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm (245697 => 245698)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm	2019-05-23 18:07:49 UTC (rev 245697)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm	2019-05-23 18:08:01 UTC (rev 245698)
@@ -28,6 +28,7 @@
 
 #import "PlatformUtilities.h"
 #import "Test.h"
+#import "TestNavigationDelegate.h"
 #import "TestWKWebView.h"
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKProcessPoolPrivate.h>
@@ -41,11 +42,14 @@
 #import <wtf/HashMap.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
+#include <wtf/text/StringConcatenateNumbers.h>
 #import <wtf/text/StringHash.h>
 #import <wtf/text/WTFString.h>
 
 using namespace TestWebKitAPI;
 
+static bool didFinishNavigation;
+
 @interface QuotaDelegate : NSObject <WKUIDelegate>
 -(bool)quotaDelegateCalled;
 -(void)grantQuota;
@@ -182,6 +186,31 @@
 </script>
 )SWRESOURCE";
 
+static const char* TestUrlBytes = R"SWRESOURCE(
+<script>
+
+var index = 0;
+async function test(num)
+{
+    index++;
+    url = "" + index;
+
+    const cache = await window.caches.open("mycache");
+    const promise = cache.put(url, new Response(new ArrayBuffer(num * 1024 * 1024)));
+    promise.then(() => {
+        window.webkit.messageHandlers.qt.postMessage("pass");
+    }, () => {
+        window.webkit.messageHandlers.qt.postMessage("fail");
+    });
+}
+
+function doTest(num)
+{
+    test(num);
+}
+</script>
+)SWRESOURCE";
+
 static bool done;
 
 static inline void setVisible(TestWKWebView *webView)
@@ -349,3 +378,48 @@
 
     EXPECT_FALSE(receivedQuotaDelegateCalled);
 }
+
+TEST(WebKit, DefaultQuota)
+{
+    done = false;
+    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+    auto messageHandler = adoptNS([[QuotaMessageHandler alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"qt"];
+
+    auto handler = adoptNS([[StorageSchemes alloc] init]);
+    handler->resources.set("qt://test1.html", ResourceInfo { @"text/html", TestUrlBytes });
+    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"QT"];
+    [configuration.get().processPool _registerURLSchemeServiceWorkersCanHandle:@"qt"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get() addToWindow:YES]);
+    auto delegate = adoptNS([[QuotaDelegate alloc] init]);
+    [webView setUIDelegate:delegate.get()];
+    setVisible(webView.get());
+
+    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
+    [navigationDelegate setDidFinishNavigation:^(WKWebView *, WKNavigation *) {
+        didFinishNavigation = true;
+    }];
+    [webView setNavigationDelegate:navigationDelegate.get()];
+
+    didFinishNavigation = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"qt://test1.html"]]];
+    Util::run(&didFinishNavigation);
+
+    receivedQuotaDelegateCalled = false;
+
+    // Storing 10 entries of 10 MB should not hit the default quota which is 1GB
+    for (int i = 0; i < 10; ++i) {
+        [webView stringByEvaluatingJavaScript:makeString("doTest(10)")];
+        [messageHandler setExpectedMessage: @"pass"];
+        receivedMessage = false;
+        Util::run(&receivedMessage);
+    }
+    EXPECT_FALSE(receivedQuotaDelegateCalled);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to