Changeset 245698 in webkit


Ignore:
Timestamp:
May 23, 2019 11:08:01 AM (5 years ago)
Author:
youenn@apple.com
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r245691 r245698  
     12019-05-23  Youenn Fablet  <youenn@apple.com>
     2
     3        Set default WebsiteDataStore storage quota based on StorageQuotaManager
     4        https://bugs.webkit.org/show_bug.cgi?id=198133
     5        <rdar://problem/51031436>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
     10
    1112019-05-23  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h

    r243911 r245698  
    2727
    2828#include "APIObject.h"
     29#include <WebCore/StorageQuotaManager.h>
    2930#include <wtf/URL.h>
    3031#include <wtf/text/WTFString.h>
     
    9899    void setHTTPSProxy(URL&& proxy) { m_httpsProxy = WTFMove(proxy); }
    99100
    100     constexpr static uint64_t defaultPerOriginStorageQuota = 50 * 1024 * 1024;
    101 
    102101private:
    103102    WebsiteDataStoreConfiguration();
    104103
    105104    String m_cacheStorageDirectory;
    106     uint64_t m_perOriginStorageQuota { defaultPerOriginStorageQuota };
     105    uint64_t m_perOriginStorageQuota { WebCore::StorageQuotaManager::defaultQuota() };
    107106    String m_networkCacheDirectory;
    108107    String m_applicationCacheDirectory;
  • trunk/Tools/ChangeLog

    r245692 r245698  
     12019-05-23  Youenn Fablet  <youenn@apple.com>
     2
     3        Set default WebsiteDataStore storage quota based on StorageQuotaManager
     4        https://bugs.webkit.org/show_bug.cgi?id=198133
     5        <rdar://problem/51031436>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm:
     10        (doTest):
     11
    1122019-05-23  Keith Rollin  <krollin@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm

    r245328 r245698  
    2929#import "PlatformUtilities.h"
    3030#import "Test.h"
     31#import "TestNavigationDelegate.h"
    3132#import "TestWKWebView.h"
    3233#import <WebKit/WKPreferencesPrivate.h>
     
    4243#import <wtf/RetainPtr.h>
    4344#import <wtf/Vector.h>
     45#include <wtf/text/StringConcatenateNumbers.h>
    4446#import <wtf/text/StringHash.h>
    4547#import <wtf/text/WTFString.h>
    4648
    4749using namespace TestWebKitAPI;
     50
     51static bool didFinishNavigation;
    4852
    4953@interface QuotaDelegate : NSObject <WKUIDelegate>
     
    183187)SWRESOURCE";
    184188
     189static const char* TestUrlBytes = R"SWRESOURCE(
     190<script>
     191
     192var index = 0;
     193async function test(num)
     194{
     195    index++;
     196    url = "http://example.org/test" + index;
     197
     198    const cache = await window.caches.open("mycache");
     199    const promise = cache.put(url, new Response(new ArrayBuffer(num * 1024 * 1024)));
     200    promise.then(() => {
     201        window.webkit.messageHandlers.qt.postMessage("pass");
     202    }, () => {
     203        window.webkit.messageHandlers.qt.postMessage("fail");
     204    });
     205}
     206
     207function doTest(num)
     208{
     209    test(num);
     210}
     211</script>
     212)SWRESOURCE";
     213
    185214static bool done;
    186215
     
    350379    EXPECT_FALSE(receivedQuotaDelegateCalled);
    351380}
     381
     382TEST(WebKit, DefaultQuota)
     383{
     384    done = false;
     385    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
     386        done = true;
     387    }];
     388    TestWebKitAPI::Util::run(&done);
     389
     390    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     391
     392    auto messageHandler = adoptNS([[QuotaMessageHandler alloc] init]);
     393    [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"qt"];
     394
     395    auto handler = adoptNS([[StorageSchemes alloc] init]);
     396    handler->resources.set("qt://test1.html", ResourceInfo { @"text/html", TestUrlBytes });
     397    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"QT"];
     398    [configuration.get().processPool _registerURLSchemeServiceWorkersCanHandle:@"qt"];
     399
     400    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get() addToWindow:YES]);
     401    auto delegate = adoptNS([[QuotaDelegate alloc] init]);
     402    [webView setUIDelegate:delegate.get()];
     403    setVisible(webView.get());
     404
     405    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
     406    [navigationDelegate setDidFinishNavigation:^(WKWebView *, WKNavigation *) {
     407        didFinishNavigation = true;
     408    }];
     409    [webView setNavigationDelegate:navigationDelegate.get()];
     410
     411    didFinishNavigation = false;
     412    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"qt://test1.html"]]];
     413    Util::run(&didFinishNavigation);
     414
     415    receivedQuotaDelegateCalled = false;
     416
     417    // Storing 10 entries of 10 MB should not hit the default quota which is 1GB
     418    for (int i = 0; i < 10; ++i) {
     419        [webView stringByEvaluatingJavaScript:makeString("doTest(10)")];
     420        [messageHandler setExpectedMessage: @"pass"];
     421        receivedMessage = false;
     422        Util::run(&receivedMessage);
     423    }
     424    EXPECT_FALSE(receivedQuotaDelegateCalled);
     425}
Note: See TracChangeset for help on using the changeset viewer.