Resource Load Statistics: Introduce shorter time-to-live for cookie partition whiteli...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 01:22:55 +0000 (01:22 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 01:22:55 +0000 (01:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171295
<rdar://problem/31823818>

Reviewed by Brent Fulgham.

Source/WebCore:

Test: http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html

* loader/ResourceLoadObserver.cpp:
(WebCore::reduceTimeResolutionToOneDay): Deleted.
(WebCore::reduceTimeResolution):
    Changed name to no longer lock this to a specific resolution.
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
    Now calls WebCore::reduceTimeResolution().
(WebCore::ResourceLoadObserver::setTimeToLiveCookiePartitionFree):
    Added for testing purposes.
(WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
    Added for testing purposes.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::shouldPartitionCookies):
    Static inline convenience function.
(WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
    Now decides whether a domain should get partitioned cookies
    based on timeToLiveCookiePartitionFree.
    Removed clearFirst parameter since it's not needed here
    and it introduced complexity in keeping the store and the
    network process cache in sync.
(WebCore::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
    Added for testing purposes.
* loader/ResourceLoadStatisticsStore.h:

Source/WebKit2:

* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
(WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
(WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain):
    Changes and additions to test infrastructure.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
(WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
(WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain):
(WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
    Changes and additions to test infrastructure.
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
    No longer sends a boolean parameter to
    WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsTimeToLiveCookiePartitionFree):
(WTR::TestRunner::statisticsFireShouldPartitionCookiesHandler):
(WTR::TestRunner::statisticsFireShouldPartitionCookiesHandlerForOneDomain):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree):
(WTR::TestController::statisticsFireShouldPartitionCookiesHandler):
(WTR::TestController::statisticsFireShouldPartitionCookiesHandlerForOneDomain):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html:
    Changed a TestRunner function name to
    statisticsFireShouldPartitionCookiesHandlerForOneDomain().
* http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html: Added.
* http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
    Changed a TestRunner function name to
    statisticsFireShouldPartitionCookiesHandlerForOneDomain().

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebCore/loader/ResourceLoadStatisticsStore.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index e0a1e98..238c3dc 100644 (file)
@@ -1,3 +1,20 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Introduce shorter time-to-live for cookie partition whitelisting
+        https://bugs.webkit.org/show_bug.cgi?id=171295
+        <rdar://problem/31823818>
+
+        Reviewed by Brent Fulgham.
+
+        * http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html:
+            Changed a TestRunner function name to
+            statisticsFireShouldPartitionCookiesHandlerForOneDomain().
+        * http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html: Added.
+        * http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
+            Changed a TestRunner function name to
+            statisticsFireShouldPartitionCookiesHandlerForOneDomain().
+
 2017-04-25  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r215476.
index 69d4840..798cd05 100644 (file)
@@ -93,7 +93,7 @@
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
         testRunner.setStatisticsMinimumTimeBetweeenDataRecordsRemoval(0);
 
-        testRunner.statisticsFireShouldPartitionCookiesHandler("localhost", true);
+        testRunner.statisticsFireShouldPartitionCookiesHandlerForOneDomain("localhost", true);
         testRunner.setStatisticsPrevalentResource("http://localhost", true);
         if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
             testFailed("Host did not get set as prevalent resource.");
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt
new file mode 100644 (file)
index 0000000..190013b
--- /dev/null
@@ -0,0 +1,108 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Test for Partitioned and Unpartitioned Cookie With User Interaction
+main frame - didChangeLocationWithinPageForFrame
+CONSOLE MESSAGE: line 63: Step 1
+main frame - willPerformClientRedirectToURL: http://localhost:8000/loading/resourceLoadStatistics/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html#step2 
+main frame - didFinishDocumentLoadForFrame
+main frame - didFinishLoadForFrame
+main frame - didStartProvisionalLoadForFrame
+main frame - didCancelClientRedirectForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+main frame - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html#step2 
+main frame - didStartProvisionalLoadForFrame
+main frame - didCancelClientRedirectForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Test for Partitioned and Unpartitioned Cookie With User Interaction
+CONSOLE MESSAGE: line 68: Step 2
+main frame - didChangeLocationWithinPageForFrame
+frame "<!--framePath //<!--frame0-->-->" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 75: Step 3
+main frame - didHandleOnloadEventsForFrame
+main frame - didChangeLocationWithinPageForFrame
+frame "<!--framePath //<!--frame1-->-->" - didStartProvisionalLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
+frame "<!--framePath //<!--frame1-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame1-->-->" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 82: Step 4
+main frame - didChangeLocationWithinPageForFrame
+frame "<!--framePath //<!--frame2-->-->" - didStartProvisionalLoadForFrame
+frame "<!--framePath //<!--frame1-->-->" - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame1-->-->" - didFinishLoadForFrame
+frame "<!--framePath //<!--frame2-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame2-->-->" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 89: Step 5
+main frame - didChangeLocationWithinPageForFrame
+frame "<!--framePath //<!--frame3-->-->" - didStartProvisionalLoadForFrame
+frame "<!--framePath //<!--frame2-->-->" - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame2-->-->" - didFinishLoadForFrame
+frame "<!--framePath //<!--frame3-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame3-->-->" - didFinishDocumentLoadForFrame
+frame "<!--framePath //<!--frame3-->-->" - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame3-->-->" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+CONSOLE MESSAGE: line 96: Step 6
+main frame - didChangeLocationWithinPageForFrame
+frame "<!--framePath //<!--frame4-->-->" - didStartProvisionalLoadForFrame
+frame "<!--framePath //<!--frame4-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame4-->-->" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 103: Step 7
+frame "<!--framePath //<!--frame5-->-->" - didStartProvisionalLoadForFrame
+frame "<!--framePath //<!--frame4-->-->" - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame4-->-->" - didFinishLoadForFrame
+frame "<!--framePath //<!--frame5-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame5-->-->" - didFinishDocumentLoadForFrame
+  
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+Should receive no cookies.
+Did not receive cookie named 'firstPartyCookie'.
+Did not receive cookie named 'thirdPartyCookie'.
+Client-side document.cookie:
+
+--------
+Frame: '<!--framePath //<!--frame1-->-->'
+--------
+Setting partitioned, third-party cookie.
+
+
+--------
+Frame: '<!--framePath //<!--frame2-->-->'
+--------
+Should only receive partitioned, third-party cookie.
+Did not receive cookie named 'firstPartyCookie'.
+Received cookie named 'thirdPartyCookie'.
+Client-side document.cookie: thirdPartyCookie=value
+
+--------
+Frame: '<!--framePath //<!--frame3-->-->'
+--------
+After first user interaction, should only receive un-partitioned cookie.
+Received cookie named 'firstPartyCookie'.
+Did not receive cookie named 'thirdPartyCookie'.
+Client-side document.cookie: firstPartyCookie=value
+
+--------
+Frame: '<!--framePath //<!--frame4-->-->'
+--------
+Should only receive partitioned, third-party cookie.
+Did not receive cookie named 'firstPartyCookie'.
+Received cookie named 'thirdPartyCookie'.
+Client-side document.cookie: thirdPartyCookie=value
+
+--------
+Frame: '<!--framePath //<!--frame5-->-->'
+--------
+After second user interaction, should only receive un-partitioned cookie.
+Received cookie named 'firstPartyCookie'.
+Did not receive cookie named 'thirdPartyCookie'.
+Client-side document.cookie: firstPartyCookie=value
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
new file mode 100644 (file)
index 0000000..ef52674
--- /dev/null
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Test for Partitioned and Unpartitioned Cookie With User Interaction</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const partitionHost = "127.0.0.1:8000";
+    const thirdPartyOrigin = "http://localhost:8000";
+    const thirdPartyBaseUrl = thirdPartyOrigin + "/loading/resourceLoadStatistics/resources";
+    const firstPartyCookieName = "firstPartyCookie";
+    const subPathToSetFirstPartyCookie = "/set-cookie.php?name=" + firstPartyCookieName + "&value=value";
+    const thirdPartyCookieName = "thirdPartyCookie";
+    const subPathToSetThirdPartyCookie = "/set-cookie.php?name=" + thirdPartyCookieName + "&value=value";
+    const fragmentWithReturnUrl = "http://" + partitionHost + "/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html";
+    const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName + "&name2=" + thirdPartyCookieName;
+
+    function setEnableFeature(enable) {
+        if (!enable) {
+            testRunner.statisticsResetToConsistentState();
+        }
+        internals.setResourceLoadStatisticsEnabled(enable);
+        testRunner.setCookieStoragePartitioningEnabled(enable);
+    }
+
+    function finishTest() {
+        setEnableFeature(false);
+        testRunner.notifyDone();
+    }
+
+    function openIframe(url, onLoadHandler) {
+        const element = document.createElement("iframe");
+        element.src = url;
+        if (onLoadHandler) {
+            element.onload = onLoadHandler;
+        }
+        document.body.appendChild(element);
+    }
+
+    function fireShouldPartitionCookiesHandlerAndContinue() {
+        testRunner.statisticsFireShouldPartitionCookiesHandler();
+        runTest();
+    }
+
+    function setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue() {
+        testRunner.setStatisticsTimeToLiveCookiePartitionFree(1);
+        setTimeout(fireShouldPartitionCookiesHandlerAndContinue, 2000);
+    }
+
+    function setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue() {
+        testRunner.setStatisticsTimeToLiveCookiePartitionFree(86400);
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
+        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
+            testFailed("Third party did not get logged for user interaction.");
+        runTest();
+    }
+
+    function runTest() {
+        switch (document.location.hash) {
+            case "#step1":
+                console.log("Step 1");
+                // Set first-party cookie for http://localhost:8000
+                document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + fragmentWithReturnUrl + "#step2";
+                break;
+            case "#step2":
+                console.log("Step 2");
+                // Check that the first-party cookie is not sent in partition 127.0.0.1:8000
+                document.location.hash = "step3";
+                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive no cookies.",
+                    runTest);
+                break;
+            case "#step3":
+                console.log("Step 3");
+                // Set third-party cookie for http://localhost:8000 in partition 127.0.0.1:8000
+                document.location.hash = "step4";
+                openIframe(thirdPartyBaseUrl + subPathToSetThirdPartyCookie + "&message=Setting partitioned, third-party cookie.",
+                    runTest);
+                break;
+            case "#step4":
+                console.log("Step 4");
+                // Check that only partitioned cookie get sent in partition 127.0.0.1:8000
+                document.location.hash = "step5";
+                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should only receive partitioned, third-party cookie.",
+                    setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue);
+                break;
+            case "#step5":
+                console.log("Step 5");
+                // http://localhost:8000 now has user interaction, check that un-partitioned cookie is sent for third-party
+                document.location.hash = "step6";
+                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After first user interaction, should only receive un-partitioned cookie.",
+                    setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue);
+                break;
+            case "#step6":
+                console.log("Step 6");
+                // Cookie partitioning should be applied again
+                document.location.hash = "step7";
+                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should only receive partitioned, third-party cookie.",
+                    setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue);
+                break;
+            case "#step7":
+                console.log("Step 7");
+                // http://localhost:8000 now has fresh user interaction, check that un-partitioned cookie is sent for third-party
+                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After second user interaction, should only receive un-partitioned cookie.",
+                    finishTest);
+                break;
+        }
+    }
+
+    if (document.location.hash === "" && window.testRunner && window.internals) {
+        setEnableFeature(true);
+
+        testRunner.setStatisticsPrevalentResource("http://localhost", true);
+        if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+            testFailed("Host did not get set as prevalent resource.");
+
+        testRunner.statisticsFireShouldPartitionCookiesHandler();
+
+        testRunner.waitUntilDone();
+        testRunner.dumpChildFramesAsText();
+        document.location.hash = "step1";
+    }
+
+    runTest();
+</script>
+</body>
+</html>
\ No newline at end of file
index ee0fbad..f03fa46 100644 (file)
@@ -72,7 +72,7 @@
     if (document.location.host === partitionHost && document.location.hash == "" && window.testRunner && window.internals) {
         setEnableFeature(true);
 
-        testRunner.statisticsFireShouldPartitionCookiesHandler("localhost", true);
+        testRunner.statisticsFireShouldPartitionCookiesHandlerForOneDomain("localhost", true);
 
         testRunner.waitUntilDone();
         testRunner.dumpChildFramesAsText();
index a7c910b..3cbbd3b 100644 (file)
@@ -1,3 +1,37 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Introduce shorter time-to-live for cookie partition whitelisting
+        https://bugs.webkit.org/show_bug.cgi?id=171295
+        <rdar://problem/31823818>
+
+        Reviewed by Brent Fulgham.
+
+        Test: http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::reduceTimeResolutionToOneDay): Deleted.
+        (WebCore::reduceTimeResolution):
+            Changed name to no longer lock this to a specific resolution.
+        (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+            Now calls WebCore::reduceTimeResolution().
+        (WebCore::ResourceLoadObserver::setTimeToLiveCookiePartitionFree):
+            Added for testing purposes.
+        (WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
+            Added for testing purposes.
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::shouldPartitionCookies):
+            Static inline convenience function.
+        (WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
+            Now decides whether a domain should get partitioned cookies
+            based on timeToLiveCookiePartitionFree.
+            Removed clearFirst parameter since it's not needed here
+            and it introduced complexity in keeping the store and the
+            network process cache in sync.
+        (WebCore::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
+            Added for testing purposes.
+        * loader/ResourceLoadStatisticsStore.h:
+
 2017-04-25  Saam Barati  <sbarati@apple.com>
 
         JSArray::isArrayPrototypeIteratorProtocolFastAndNonObservable is wrong because it does not do the necessary checks on the base object
index 9d2eece..2559d61 100644 (file)
@@ -48,8 +48,8 @@
 
 namespace WebCore {
 
-// One day in seconds.
-static auto timestampResolution = 86400;
+// One hour in seconds.
+static auto timestampResolution = 3600;
 
 ResourceLoadObserver& ResourceLoadObserver::sharedObserver()
 {
@@ -301,7 +301,7 @@ void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL& ta
         m_store->fireDataModificationHandler();
 }
 
-static double reduceTimeResolutionToOneDay(double seconds)
+static double reduceTimeResolution(double seconds)
 {
     return std::floor(seconds / timestampResolution) * timestampResolution;
 }
@@ -320,7 +320,7 @@ void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Doc
     auto primaryDomainStr = primaryDomain(url);
 
     auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomainStr);
-    double newTimestamp = reduceTimeResolutionToOneDay(WTF::currentTime());
+    double newTimestamp = reduceTimeResolution(WTF::currentTime());
     if (newTimestamp == statistics.mostRecentUserInteraction)
         return;
 
@@ -427,11 +427,21 @@ void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds)
     m_store->setTimeToLiveUserInteraction(seconds);
 }
 
+void ResourceLoadObserver::setTimeToLiveCookiePartitionFree(double seconds)
+{
+    m_store->setTimeToLiveCookiePartitionFree(seconds);
+}
+
 void ResourceLoadObserver::fireDataModificationHandler()
 {
     m_store->fireDataModificationHandler();
 }
 
+void ResourceLoadObserver::fireShouldPartitionCookiesHandler()
+{
+    m_store->fireShouldPartitionCookiesHandler();
+}
+
 void ResourceLoadObserver::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
     m_store->fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
index c27e907..e85402b 100644 (file)
@@ -63,9 +63,11 @@ public:
     WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
 
     WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds);
+    WEBCORE_EXPORT void setTimeToLiveCookiePartitionFree(double seconds);
     WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
 
     WEBCORE_EXPORT void fireDataModificationHandler();
+    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();
     WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 
     WEBCORE_EXPORT void setStatisticsStore(Ref<ResourceLoadStatisticsStore>&&);
index 182ec4b..088103b 100644 (file)
@@ -41,6 +41,8 @@ namespace WebCore {
 static const auto statisticsModelVersion = 3;
 // 30 days in seconds
 static auto timeToLiveUserInteraction = 2592000;
+// 1 day in seconds
+static auto timeToLiveCookiePartitionFree = 86400;
 
 Ref<ResourceLoadStatisticsStore> ResourceLoadStatisticsStore::create()
 {
@@ -179,23 +181,33 @@ void ResourceLoadStatisticsStore::fireDataModificationHandler()
         m_dataAddedHandler();
 }
 
-void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(bool clearFirst)
+static inline bool shouldPartitionCookies(const ResourceLoadStatistics& statistic)
+{
+    return statistic.isPrevalentResource
+        && (!statistic.hadUserInteraction || currentTime() > statistic.mostRecentUserInteraction + timeToLiveCookiePartitionFree);
+}
+
+void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
 {
     Vector<String> domainsToRemove;
     Vector<String> domainsToAdd;
     
     for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
-        bool recentUserInteraction = hasHadRecentUserInteraction(resourceStatistic);
-        if (resourceStatistic.isMarkedForCookiePartitioning && recentUserInteraction) {
+        bool shouldPartition = shouldPartitionCookies(resourceStatistic);
+        if (resourceStatistic.isMarkedForCookiePartitioning && !shouldPartition) {
             resourceStatistic.isMarkedForCookiePartitioning = false;
             domainsToRemove.append(resourceStatistic.highLevelDomain);
-        } else if (!resourceStatistic.isMarkedForCookiePartitioning && !recentUserInteraction && resourceStatistic.isPrevalentResource) {
+        } else if (!resourceStatistic.isMarkedForCookiePartitioning && shouldPartition) {
             resourceStatistic.isMarkedForCookiePartitioning = true;
             domainsToAdd.append(resourceStatistic.highLevelDomain);
         }
     }
     
-    fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
+    if (domainsToRemove.isEmpty() && domainsToAdd.isEmpty())
+        return;
+    
+    if (m_shouldPartitionCookiesForDomainsHandler)
+        m_shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, false);
 }
 
 void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
@@ -205,6 +217,17 @@ void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector
 
     if (m_shouldPartitionCookiesForDomainsHandler)
         m_shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, clearFirst);
+
+    if (clearFirst) {
+        for (auto& resourceStatistic : m_resourceStatisticsMap.values())
+            resourceStatistic.isMarkedForCookiePartitioning = false;
+    } else {
+        for (auto& domain : domainsToRemove)
+            ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = false;
+    }
+
+    for (auto& domain : domainsToAdd)
+        ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = true;
 }
 
 void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(double seconds)
@@ -213,6 +236,12 @@ void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(double seconds)
         timeToLiveUserInteraction = seconds;
 }
 
+void ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree(double seconds)
+{
+    if (seconds >= 0)
+        timeToLiveCookiePartitionFree = seconds;
+}
+
 void ResourceLoadStatisticsStore::processStatistics(std::function<void(ResourceLoadStatistics&)>&& processFunction)
 {
     for (auto& resourceStatistic : m_resourceStatisticsMap.values())
index 08eb5c9..ded1619 100644 (file)
@@ -63,7 +63,8 @@ public:
 
     void fireDataModificationHandler();
     void setTimeToLiveUserInteraction(double seconds);
-    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(bool clearFirst);
+    void setTimeToLiveCookiePartitionFree(double seconds);
+    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();
     void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 
     WEBCORE_EXPORT void processStatistics(std::function<void(ResourceLoadStatistics&)>&&);
index d760c41..930c160 100644 (file)
@@ -1,3 +1,29 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Introduce shorter time-to-live for cookie partition whitelisting
+        https://bugs.webkit.org/show_bug.cgi?id=171295
+        <rdar://problem/31823818>
+
+        Reviewed by Brent Fulgham.
+
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+        (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
+        (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
+        (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain):
+            Changes and additions to test infrastructure.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
+        (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
+        (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain):
+        (WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
+            Changes and additions to test infrastructure.
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+            No longer sends a boolean parameter to
+            WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
+
 2017-04-25  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r213719): WebGL content on cubeslam.com is 1/4 expected size
index 952cbfe..f898068 100644 (file)
@@ -76,14 +76,24 @@ void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
     WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(seconds);
 }
 
+void WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree(double seconds)
+{
+    WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(seconds);
+}
+
 void WKResourceLoadStatisticsManagerFireDataModificationHandler()
 {
     WebResourceLoadStatisticsManager::fireDataModificationHandler();
 }
 
-void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler(WKStringRef hostName, bool value)
+void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler()
+{
+    WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler();
+}
+
+void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain(WKStringRef hostName, bool value)
 {
-    WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler(toWTFString(hostName), value);
+    WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain(toWTFString(hostName), value);
 }
 
 void WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned(bool value)
index 42b52cf..647ec67 100644 (file)
@@ -41,8 +41,10 @@ extern "C" {
     WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree(double seconds);
     WK_EXPORT void WKResourceLoadStatisticsManagerFireDataModificationHandler();
-    WK_EXPORT void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler(WKStringRef hostName, bool value);
+    WK_EXPORT void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler();
+    WK_EXPORT void WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain(WKStringRef hostName, bool value);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned(bool value);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval(double seconds);
index 7e25926..53220a8 100644 (file)
@@ -81,12 +81,22 @@ void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double secon
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(seconds);
 }
 
+void WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(double seconds)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(seconds);
+}
+
 void WebResourceLoadStatisticsManager::fireDataModificationHandler()
 {
     WebCore::ResourceLoadObserver::sharedObserver().fireDataModificationHandler();
 }
 
-void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler(const String& hostName, bool value)
+void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler()
+{
+    WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler();
+}
+
+void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain(const String& hostName, bool value)
 {
     if (value)
         WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({ }, {hostName}, false);
@@ -117,6 +127,7 @@ void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore()
 void WebResourceLoadStatisticsManager::resetToConsistentState()
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(2592000);
+    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(86400);
     WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(false);
     WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(true);
     WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(60);
index 06aa448..dd48307 100644 (file)
@@ -46,9 +46,11 @@ public:
     static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
     static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
     static void setTimeToLiveUserInteraction(double seconds);
+    static void setTimeToLiveCookiePartitionFree(double seconds);
     static void setReducedTimestampResolution(double seconds);
     static void fireDataModificationHandler();
-    static void fireShouldPartitionCookiesHandler(const String& hostName, bool value);
+    static void fireShouldPartitionCookiesHandler();
+    static void fireShouldPartitionCookiesHandlerForOneDomain(const String& hostName, bool value);
     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
index a30e7b3..b9c7631 100644 (file)
@@ -152,7 +152,7 @@ void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(const Vector<
     coreStore().mergeStatistics(origins);
     // Fire before processing statistics to propagate user
     // interaction as fast as possible to the network process.
-    coreStore().fireShouldPartitionCookiesHandler(false);
+    coreStore().fireShouldPartitionCookiesHandler();
     processStatisticsAndDataRecords();
 }
 
index 365af45..0c27539 100644 (file)
@@ -1,3 +1,25 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Introduce shorter time-to-live for cookie partition whitelisting
+        https://bugs.webkit.org/show_bug.cgi?id=171295
+        <rdar://problem/31823818>
+
+        Reviewed by Brent Fulgham.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setStatisticsTimeToLiveCookiePartitionFree):
+        (WTR::TestRunner::statisticsFireShouldPartitionCookiesHandler):
+        (WTR::TestRunner::statisticsFireShouldPartitionCookiesHandlerForOneDomain):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree):
+        (WTR::TestController::statisticsFireShouldPartitionCookiesHandler):
+        (WTR::TestController::statisticsFireShouldPartitionCookiesHandlerForOneDomain):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2017-04-25  Tim Horton  <timothy_horton@apple.com>
 
         Try to fix the WKTR build after r215758
index 0e0bfeb..7b6200b 100644 (file)
@@ -258,8 +258,10 @@ interface TestRunner {
     void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
     void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
+    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
     void statisticsFireDataModificationHandler();
-    void statisticsFireShouldPartitionCookiesHandler(DOMString hostName, boolean value);
+    void statisticsFireShouldPartitionCookiesHandler();
+    void statisticsFireShouldPartitionCookiesHandlerForOneDomain(DOMString hostName, boolean value);
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(boolean value);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds);
index affc40f..c71f4cf 100644 (file)
@@ -1325,6 +1325,13 @@ void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::setStatisticsTimeToLiveCookiePartitionFree(double seconds)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTimeToLiveCookiePartitionFree"));
+    WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
 void TestRunner::installStatisticsDidModifyDataRecordsCallback(JSValueRef callback)
 {
     cacheTestRunnerCallback(StatisticsDidModifyDataRecordsCallbackID, callback);
@@ -1341,7 +1348,13 @@ void TestRunner::statisticsFireDataModificationHandler()
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
 }
 
-void TestRunner::statisticsFireShouldPartitionCookiesHandler(JSStringRef hostName, bool value)
+void TestRunner::statisticsFireShouldPartitionCookiesHandler()
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsFireShouldPartitionCookiesHandler"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+}
+
+void TestRunner::statisticsFireShouldPartitionCookiesHandlerForOneDomain(JSStringRef hostName, bool value)
 {
     Vector<WKRetainPtr<WKStringRef>> keys;
     Vector<WKRetainPtr<WKTypeRef>> values;
@@ -1360,7 +1373,7 @@ void TestRunner::statisticsFireShouldPartitionCookiesHandler(JSStringRef hostNam
         rawValues[i] = values[i].get();
     }
     
-    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsFireShouldPartitionCookiesHandler"));
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsFireShouldPartitionCookiesHandlerForOneDomain"));
     WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
index 8502cd2..d6392e9 100644 (file)
@@ -350,7 +350,8 @@ public:
     void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
     void statisticsDidModifyDataRecordsCallback();
     void statisticsFireDataModificationHandler();
-    void statisticsFireShouldPartitionCookiesHandler(JSStringRef hostName, bool value);
+    void statisticsFireShouldPartitionCookiesHandler();
+    void statisticsFireShouldPartitionCookiesHandlerForOneDomain(JSStringRef hostName, bool value);
     void setStatisticsPrevalentResource(JSStringRef hostName, bool value);
     bool isStatisticsPrevalentResource(JSStringRef hostName);
     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
@@ -359,6 +360,7 @@ public:
     void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
     void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
+    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
index a88b20a..8216da4 100644 (file)
@@ -2249,14 +2249,24 @@ void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
     WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(seconds);
 }
 
+void TestController::setStatisticsTimeToLiveCookiePartitionFree(double seconds)
+{
+    WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree(seconds);
+}
+
 void TestController::statisticsFireDataModificationHandler()
 {
     WKResourceLoadStatisticsManagerFireDataModificationHandler();
 }
     
-void TestController::statisticsFireShouldPartitionCookiesHandler(WKStringRef hostName, bool value)
+void TestController::statisticsFireShouldPartitionCookiesHandler()
+{
+    WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler();
+}
+
+void TestController::statisticsFireShouldPartitionCookiesHandlerForOneDomain(WKStringRef hostName, bool value)
 {
-    WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler(hostName, value);
+    WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain(hostName, value);
 }
 
 void TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
index 28846c2..aa66c02 100644 (file)
@@ -157,8 +157,10 @@ public:
     void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
+    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
     void statisticsFireDataModificationHandler();
-    void statisticsFireShouldPartitionCookiesHandler(WKStringRef hostName, bool value);
+    void statisticsFireShouldPartitionCookiesHandler();
+    void statisticsFireShouldPartitionCookiesHandlerForOneDomain(WKStringRef hostName, bool value);
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
index 5059500..b065823 100644 (file)
@@ -1002,12 +1002,24 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return nullptr;
     }
     
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveCookiePartitionFree")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
+        WKDoubleRef seconds = static_cast<WKDoubleRef>(messageBody);
+        TestController::singleton().setStatisticsTimeToLiveCookiePartitionFree(WKDoubleGetValue(seconds));
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "StatisticsFireDataModificationHandler")) {
         TestController::singleton().statisticsFireDataModificationHandler();
         return nullptr;
     }
     
     if (WKStringIsEqualToUTF8CString(messageName, "StatisticsFireShouldPartitionCookiesHandler")) {
+        TestController::singleton().statisticsFireShouldPartitionCookiesHandler();
+        return nullptr;
+    }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsFireShouldPartitionCookiesHandlerForOneDomain")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
@@ -1017,7 +1029,7 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
         WKBooleanRef value = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
         
-        TestController::singleton().statisticsFireShouldPartitionCookiesHandler(hostName, WKBooleanGetValue(value));
+        TestController::singleton().statisticsFireShouldPartitionCookiesHandlerForOneDomain(hostName, WKBooleanGetValue(value));
         return nullptr;
     }