Resource Load Statistics: Clear web processes' state on history removal
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 17:18:24 +0000 (17:18 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 17:18:24 +0000 (17:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175271
<rdar://problem/33756560>

Reviewed by Chris Dumez.

Source/WebKit:

https://bugs.webkit.org/show_bug.cgi?id=175090 introduced state
in the web process and that state needs to be cleared when the
UI process' statistics are cleared as part of history removal.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::clearResourceLoadStatistics):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::removeData):
(WebKit::WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses):
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::clearResourceLoadStatistics):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Tools:

Test infrastructure for asynchronous tests of website data
removal for _WKWebsiteDataTypeResourceLoadStatistics.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::statisticsClearThroughWebsiteDataRemoval):
(WTR::TestRunner::statisticsCallClearThroughWebsiteDataRemovalCallback):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::didClearStatisticsThroughWebsiteDataRemoval):
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::statisticsClearThroughWebsiteDataRemoval):

LayoutTests:

* http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html: Added.
* platform/mac-wk2/TestExpectations:
    user-interaction-reported-after-website-data-removal.html marked as [ Pass ].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220412 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 8542e1a6865932f53b591d9ec05efe1662888f97..c15c70b6271bb63a2364eef698398c0da80aa52d 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-08  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Clear web processes' state on history removal
+        https://bugs.webkit.org/show_bug.cgi?id=175271
+        <rdar://problem/33756560>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html: Added.
+        * platform/mac-wk2/TestExpectations:
+            user-interaction-reported-after-website-data-removal.html marked as [ Pass ].
+
 2017-08-08  Ryan Haddad  <ryanhaddad@apple.com>
 
         Fix baseline for http/tests/security/set-domain-remove-subdomain-for-ip-address.html.
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-expected.txt
new file mode 100644 (file)
index 0000000..b46f57b
--- /dev/null
@@ -0,0 +1,22 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+Tests that user interaction is reported after history removal since that means all statistics have been reset.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.location.origin is topFrameOrigin
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is true
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is true
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is the test element
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html
new file mode 100644 (file)
index 0000000..684f515
--- /dev/null
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script src="/js-test-resources/ui-helper.js"></script>
+<script>
+    description("Tests that user interaction is reported after history removal since that means all statistics have been reset.");
+    jsTestIsAsync = true;
+
+    const topFrameOrigin = "http://127.0.0.1:8000";
+    const subFrameOrigin = "http://localhost:8000";
+
+    function activateElement(elementId, callback) {
+        var element = document.getElementById(elementId);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function() {
+                callback();
+            },
+            function() {
+                testFailed("Promise rejected.");
+                finishJSTest();
+            }
+        );
+    }
+
+    function firstInteraction() {
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+        activateElement("testElement", clearWebsiteData);
+    }
+
+    function clearWebsiteData() {
+        shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+        if (testRunner)
+            testRunner.statisticsClearThroughWebsiteDataRemoval(secondInteraction);
+    }
+
+    function secondInteraction() {
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        activateElement("testElement", finishTest);
+    }
+
+    function finishTest() {
+        shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+        finishJSTest();
+    }
+
+    onload = function() {
+        if (internals)
+            internals.setResourceLoadStatisticsEnabled(true);
+
+        shouldBe("document.location.origin", "topFrameOrigin");
+
+        firstInteraction();
+    };
+</script>
+<div id="testElement">This is the test element</div>
+</body>
+</html>
\ No newline at end of file
index 35ae61401929b67957ebaad17347f2c7ec9eab89..e8b2a6397115a1df3f17510b0ae4d74859a7a2f1 100644 (file)
@@ -731,6 +731,7 @@ webkit.org/b/172397 [ Sierra Debug ] animations/needs-layout.html [ Pass ImageOn
 # Move to general wk2 expectations once webkit.org/b/175170 is resolved.
 http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Pass ]
 http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html [ Pass ]
 
 webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html [ Pass Timeout ]
 webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html [ Pass Timeout ]
index c5e6393a4f76f64defd26d7ce34e00e5767e7426..d42fdeae2b18f8cf51c34a87a961f3da667e9a3d 100644 (file)
@@ -1,3 +1,27 @@
+2017-08-08  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Clear web processes' state on history removal
+        https://bugs.webkit.org/show_bug.cgi?id=175271
+        <rdar://problem/33756560>
+
+        Reviewed by Chris Dumez.
+
+        https://bugs.webkit.org/show_bug.cgi?id=175090 introduced state
+        in the web process and that state needs to be cleared when the
+        UI process' statistics are cleared as part of history removal.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::clearResourceLoadStatistics):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::removeData):
+        (WebKit::WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::clearResourceLoadStatistics):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2017-08-08  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE] Implement WebsiteDataStore::defaultApplicationCacheDirectory() and friends
index 83f3a673f724b6fb8b99b15d1163fd06d09431f6..4651c924b279519ef5f6a9b286e6d9e2f445d1a4 100644 (file)
@@ -1099,6 +1099,11 @@ void WebProcessPool::setResourceLoadStatisticsEnabled(bool enabled)
     sendToAllProcesses(Messages::WebProcess::SetResourceLoadStatisticsEnabled(enabled));
 }
 
+void WebProcessPool::clearResourceLoadStatistics()
+{
+    sendToAllProcesses(Messages::WebProcess::ClearResourceLoadStatistics());
+}
+
 void WebProcessPool::registerURLSchemeAsEmptyDocument(const String& urlScheme)
 {
     m_schemesToRegisterAsEmptyDocument.add(urlScheme);
index d8ca634e1daa2dc056077b7737526098c8e817a9..c7007da5d0f8fb777c66713712558732dcf4576e 100644 (file)
@@ -388,6 +388,7 @@ public:
 
     bool resourceLoadStatisticsEnabled() { return m_resourceLoadStatisticsEnabled; }
     void setResourceLoadStatisticsEnabled(bool);
+    void clearResourceLoadStatistics();
 
     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
index 91c03e60d8b26431bd181a82b8f1cf93cde1dfe9..c6fec6f43ff96cd5c14443eae4bd0aca5dc7c1dc 100644 (file)
@@ -821,6 +821,8 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chr
             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::No);
         else
             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::Yes);
+
+        clearResourceLoadStatisticsInWebProcesses();
     }
 
     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
@@ -1099,6 +1101,8 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::No);
         else
             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::Yes);
+
+        clearResourceLoadStatisticsInWebProcesses();
     }
 
     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
@@ -1315,6 +1319,15 @@ void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Functio
         processPool->setResourceLoadStatisticsEnabled(true);
 }
 
+void WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses()
+{
+    if (!resourceLoadStatisticsEnabled())
+        return;
+
+    for (auto& processPool : processPools())
+        processPool->clearResourceLoadStatistics();
+}
+
 StorageProcessCreationParameters WebsiteDataStore::storageProcessParameters()
 {
     resolveDirectoriesIfNecessary();
index 53e621f4ea2237ceadccf3949e1d026ca481532a..80e8f07e2502b5d56a992ae0b0689a257d498ab5 100644 (file)
@@ -92,6 +92,7 @@ public:
     bool resourceLoadStatisticsEnabled() const;
     void setResourceLoadStatisticsEnabled(bool);
     WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
+    void clearResourceLoadStatisticsInWebProcesses();
 
     static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage);
 
index 18031a1a388c83f2b9e56d82ec8a28d3fb2c8306..f9aed5f0699ca9e7fa028498081df824593c304c 100644 (file)
@@ -1451,6 +1451,11 @@ void WebProcess::setResourceLoadStatisticsEnabled(bool enabled)
     WebCore::Settings::setResourceLoadStatisticsEnabled(enabled);
 }
 
+void WebProcess::clearResourceLoadStatistics()
+{
+    ResourceLoadObserver::shared().clearState();
+}
+
 RefPtr<API::Object> WebProcess::transformHandlesToObjects(API::Object* object)
 {
     struct Transformer final : UserData::Transformer {
index e0bf86a632df78df5cfd7ca3dddd36a4c91c5102..cf2ab813b3790373b2da0fa6fabf7bac47b2f497 100644 (file)
@@ -255,6 +255,7 @@ private:
     void setAlwaysUsesComplexTextCodePath(bool);
     void setShouldUseFontSmoothing(bool);
     void setResourceLoadStatisticsEnabled(bool);
+    void clearResourceLoadStatistics();
     void userPreferredLanguagesChanged(const Vector<String>&) const;
     void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
 
index 84f55e0050293e8feb283ec0c40a156345660642..81f887d1b4e2935f4c4e52075778a7765532b044 100644 (file)
@@ -41,6 +41,7 @@ messages -> WebProcess LegacyReceiver {
     SetAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
     SetShouldUseFontSmoothing(bool useFontSmoothing)
     SetResourceLoadStatisticsEnabled(bool resourceLoadStatisticsEnabled);
+    ClearResourceLoadStatistics();
     UserPreferredLanguagesChanged(Vector<String> languages)
     FullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
 
index a7eb68921ae9d78895ad8e9185b6344173209042..a1cf12ac69ec90c30066ebb1198aef1702e9d208 100644 (file)
@@ -1,3 +1,31 @@
+2017-08-08  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Clear web processes' state on history removal
+        https://bugs.webkit.org/show_bug.cgi?id=175271
+        <rdar://problem/33756560>
+
+        Reviewed by Chris Dumez.
+
+        Test infrastructure for asynchronous tests of website data
+        removal for _WKWebsiteDataTypeResourceLoadStatistics.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::statisticsClearThroughWebsiteDataRemoval):
+        (WTR::TestRunner::statisticsCallClearThroughWebsiteDataRemovalCallback):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        (WTR::TestInvocation::didClearStatisticsThroughWebsiteDataRemoval):
+        * WebKitTestRunner/TestInvocation.h:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
+
 2017-08-08  Alicia Boya García  <aboya@igalia.com>
 
         Add Alicia Boya García as contributor
index f9290084e105be654ca0cca370a1d8a393d240bb..2357bb13999aa40ef7158b61f01a3859f66800eb 100644 (file)
@@ -279,6 +279,7 @@ interface TestRunner {
     void setStatisticsPruneEntriesDownTo(unsigned long entries);
     void statisticsClearInMemoryAndPersistentStore();
     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned long hours);
+    void statisticsClearThroughWebsiteDataRemoval(object callback);
     void statisticsResetToConsistentState();
 
     // Open panel
index 357ee0ea6f8240bc1c2989f5cdb8648bfaef4171..662ff5a210e8afa5fca777f2e2d28e650105ac2e 100644 (file)
@@ -240,6 +240,11 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidClearStatisticsThroughWebsiteDataRemoval")) {
+        m_testRunner->statisticsCallClearThroughWebsiteDataRemovalCallback();
+        return;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveAllSessionCredentialsCallback")) {
         m_testRunner->callDidRemoveAllSessionCredentialsCallback();
         return;
index e722e47c69fd4b2ad06169adc324d84a48c3a98d..7a629731b104ad0f5770c5f958dd6542dadb9585 100644 (file)
@@ -645,6 +645,7 @@ enum {
     StatisticsDidModifyDataRecordsCallbackID,
     StatisticsDidScanDataRecordsCallbackID,
     StatisticsDidRunTelemetryCallbackID,
+    StatisticsDidClearThroughWebsiteDataRemovalCallbackID,
     DidRemoveAllSessionCredentialsCallbackID,
     FirstUIScriptCallbackID = 100
 };
@@ -1552,6 +1553,19 @@ void TestRunner::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(uns
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::statisticsClearThroughWebsiteDataRemoval(JSValueRef callback)
+{
+    cacheTestRunnerCallback(StatisticsDidClearThroughWebsiteDataRemovalCallbackID, callback);
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsClearThroughWebsiteDataRemoval"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+}
+
+void TestRunner::statisticsCallClearThroughWebsiteDataRemovalCallback()
+{
+    callTestRunnerCallback(StatisticsDidClearThroughWebsiteDataRemovalCallbackID);
+}
+
 void TestRunner::statisticsResetToConsistentState()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsResetToConsistentState"));
index cd4d5f299ed47c9f6396f0cce9b4db1137686474..3716e6f6b99f2a6bde6b8ef13d450cd921ea9009 100644 (file)
@@ -379,6 +379,8 @@ public:
     void setStatisticsPruneEntriesDownTo(unsigned);
     void statisticsClearInMemoryAndPersistentStore();
     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours);
+    void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
+    void statisticsCallClearThroughWebsiteDataRemovalCallback();
     void statisticsResetToConsistentState();
 
     // Open panel
index a35a70d3642aed959e765e7f5b06cfdbaa73fe18..b7a3d21743d99d3d86da369981050d776dc5b791 100644 (file)
@@ -2357,6 +2357,10 @@ void TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours
 {
 }
 
+void TestController::statisticsClearThroughWebsiteDataRemoval()
+{
+}
+
 void TestController::statisticsResetToConsistentState()
 {
 }
index ed904e3a7aad346b12d929af27f8966fee69cc26..03c733357dbd0644495eb762c072b872a1350108 100644 (file)
@@ -175,6 +175,7 @@ public:
     void setStatisticsPruneEntriesDownTo(unsigned);
     void statisticsClearInMemoryAndPersistentStore();
     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned);
+    void statisticsClearThroughWebsiteDataRemoval();
     void statisticsResetToConsistentState();
 
     WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
index 9e2141f9e7551fafe72c7e37c808daa1f7d1efbd..f5a8f5f3488bf1fff43b9c48530435d75431a804 100644 (file)
@@ -1142,6 +1142,11 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return nullptr;
     }
     
+    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsClearThroughWebsiteDataRemoval")) {
+        TestController::singleton().statisticsClearThroughWebsiteDataRemoval();
+        return nullptr;
+    }
+    
     if (WKStringIsEqualToUTF8CString(messageName, "StatisticsResetToConsistentState")) {
         TestController::singleton().statisticsResetToConsistentState();
         return nullptr;
@@ -1226,6 +1231,12 @@ void TestInvocation::notifyDownloadDone()
     WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
 }
 
+void TestInvocation::didClearStatisticsThroughWebsiteDataRemoval()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidClearStatisticsThroughWebsiteDataRemoval"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
 void TestInvocation::didRemoveAllSessionCredentials()
 {
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidRemoveAllSessionCredentialsCallback"));
index 199636abd05db118f3ffb13b130dfa37012bab23..42cf965ae00f8d3be526428ad1d8d6ad0ebef34d 100644 (file)
@@ -71,6 +71,8 @@ public:
 
     void notifyDownloadDone();
 
+    void didClearStatisticsThroughWebsiteDataRemoval();
+
     void didRemoveAllSessionCredentials();
     
 private:
index 2e3d07439612d2e4640b0d3145f169d724255ddf..02fc86381435e6a13431b91ce37049dc9f6c1463 100644 (file)
@@ -371,6 +371,16 @@ void TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours
     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:hours];
 }
 
+void TestController::statisticsClearThroughWebsiteDataRemoval()
+{
+#if WK_API_ENABLED
+    auto types = adoptNS([[NSSet alloc] initWithObjects:_WKWebsiteDataTypeResourceLoadStatistics, nil]);
+    [globalWebViewConfiguration.websiteDataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:^() {
+        m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
+    }];
+#endif
+}
+
 void TestController::statisticsResetToConsistentState()
 {
     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState];