Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatistic...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2018 17:45:41 +0000 (17:45 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2018 17:45:41 +0000 (17:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187710
<rdar://problem/42252757>

Reviewed by Chris Dumez.

Source/WebKit:

These changes are to back the completion handler functionality of
TestRunner functions:
- setStatisticsLastSeen(),
- setStatisticsPrevalentResource(),
- setStatisticsVeryPrevalentResource(),
- setStatisticsHasHadUserInteraction(), and
- setStatisticsHasHadNonRecentUserInteraction().

* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreSetStatisticsLastSeen):
(WKWebsiteDataStoreSetStatisticsPrevalentResource):
(WKWebsiteDataStoreSetStatisticsVeryPrevalentResource):
(WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
(WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
(WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction):
(WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
(WebKit::WebResourceLoadStatisticsStore::setLastSeen):
(WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
(WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
(WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
* UIProcess/WebResourceLoadStatisticsStore.h:

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsLastSeen):
(WTR::TestRunner::statisticsCallDidSetLastSeenCallback):
(WTR::TestRunner::setStatisticsPrevalentResource):
(WTR::TestRunner::statisticsCallDidSetPrevalentResourceCallback):
(WTR::TestRunner::setStatisticsVeryPrevalentResource):
(WTR::TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback):
(WTR::TestRunner::setStatisticsHasHadUserInteraction):
(WTR::TestRunner::setStatisticsHasHadNonRecentUserInteraction):
(WTR::TestRunner::statisticsCallDidSetHasHadUserInteractionCallback):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsLastSeen):
(WTR::TestController::setStatisticsPrevalentResource):
(WTR::TestController::setStatisticsVeryPrevalentResource):
(WTR::TestController::setStatisticsHasHadUserInteraction):
(WTR::TestController::setStatisticsHasHadNonRecentUserInteraction):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didSetLastSeen):
(WTR::TestInvocation::didSetPrevalentResource):
(WTR::TestInvocation::didSetVeryPrevalentResource):
(WTR::TestInvocation::didSetHasHadUserInteraction):
(WTR::TestInvocation::didSetHasHadNonRecentUserInteraction):
* WebKitTestRunner/TestInvocation.h:

LayoutTests:

These changes are to update all test cases that make use of
TestRunner functions:
- setStatisticsLastSeen(),
- setStatisticsPrevalentResource(),
- setStatisticsVeryPrevalentResource(),
- setStatisticsHasHadUserInteraction(), and
- setStatisticsHasHadNonRecentUserInteraction().

* http/tests/resourceLoadStatistics/add-blocking-to-redirect.html:
* http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html:
* http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html:
* http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html:
* http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html:
* http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html:
* http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html:
* http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html:
* http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html:
* http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html:
* http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html:
* http/tests/resourceLoadStatistics/grandfathering.html:
* http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html:
* http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html:
* http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html:
* http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html:
* http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt:
* http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
* http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
* http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html:
* http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html:
* http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html:
* http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
* http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html:
* http/tests/resourceLoadStatistics/prune-statistics.html:
* http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html:
* http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html:
* http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html:
* http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html:
* http/tests/resourceLoadStatistics/telemetry-generation.html:
* http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html:
* http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html:

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

54 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/resourceLoadStatistics/add-blocking-to-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html
LayoutTests/http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html
LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html
LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/grandfathering.html
LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html
LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt
LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
LayoutTests/http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/prune-statistics.html
LayoutTests/http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html
LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html
LayoutTests/http/tests/resourceLoadStatistics/telemetry-generation.html
LayoutTests/http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
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/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h

index ab65736..d12e5ac 100644 (file)
@@ -1,3 +1,60 @@
+2018-07-17  John Wilander  <wilander@apple.com>
+
+        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
+        https://bugs.webkit.org/show_bug.cgi?id=187710
+        <rdar://problem/42252757>
+
+        Reviewed by Chris Dumez.
+
+        These changes are to update all test cases that make use of
+        TestRunner functions:
+        - setStatisticsLastSeen(),
+        - setStatisticsPrevalentResource(),
+        - setStatisticsVeryPrevalentResource(),
+        - setStatisticsHasHadUserInteraction(), and
+        - setStatisticsHasHadNonRecentUserInteraction().
+
+        * http/tests/resourceLoadStatistics/add-blocking-to-redirect.html:
+        * http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html:
+        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html:
+        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html:
+        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html:
+        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html:
+        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html:
+        * http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html:
+        * http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html:
+        * http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html:
+        * http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html:
+        * http/tests/resourceLoadStatistics/grandfathering.html:
+        * http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html:
+        * http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html:
+        * http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html:
+        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html:
+        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt:
+        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
+        * http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
+        * http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html:
+        * http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html:
+        * http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html:
+        * http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
+        * http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html:
+        * http/tests/resourceLoadStatistics/prune-statistics.html:
+        * http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html:
+        * http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html:
+        * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html:
+        * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html:
+        * http/tests/resourceLoadStatistics/telemetry-generation.html:
+        * http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html:
+        * http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html:
+
 2018-07-17  Ryan Haddad  <ryanhaddad@apple.com>
 
         Rebaseline displaylists/extent-includes-* tests for mac-wk1 after r233869.
index 1f689ee..bbb3145 100644 (file)
             case "#step4":
                 // Set localhost as prevalent and with no user interaction to put it in the blocking category.
                 document.location.hash = "step5";
-                testRunner.setStatisticsPrevalentResource("http://localhost", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                    testFailed("Host did not get set as prevalent resource.");
-                testRunner.statisticsUpdateCookiePartitioning(function() {
-                    runTest();
+                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                        testFailed("Host did not get set as prevalent resource.");
+                    testRunner.statisticsUpdateCookiePartitioning(function() {
+                        runTest();
+                    });
                 });
                 break;
             case "#step5":
index e6f48df..01f020b 100644 (file)
             case "#step4":
                 // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
                 document.location.hash = "step5";
-                testRunner.setStatisticsPrevalentResource("http://localhost", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                    testFailed("Host did not get set as prevalent resource.");
-                testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
-                testRunner.statisticsUpdateCookiePartitioning(function() {
-                    runTest();
+                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                        testFailed("Host did not get set as prevalent resource.");
+                    testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost", function() {
+                        testRunner.statisticsUpdateCookiePartitioning(function() {
+                            runTest();
+                        });
+                    });
                 });
                 break;
             case "#step5":
index 9a5d275..94607ef 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 02d6dad..9ce13df 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
-        testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 4bf30a8..237caf1 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 6523e27..85ddae7 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 8ce5461..9d636d7 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index d307ff4..cf9c0e7 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index bcace88..c3bcd6d 100644 (file)
         testRunner.setStatisticsSubresourceUniqueRedirectFrom(subresourceOrigin2, subresourceOrigin3);
         testRunner.setStatisticsSubresourceUniqueRedirectFrom(subresourceOrigin3, subresourceOrigin4);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host explicity set did not get set as prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(subresourceOrigin1))
-            testPassed("Colluding host 1 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin1))
-            testFailed("Colluding host 1 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(subresourceOrigin2))
-            testPassed("Colluding host 2 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin2))
-            testFailed("Colluding host 2 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(subresourceOrigin3))
-            testPassed("Colluding host 3 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin3))
-            testFailed("Colluding host 3 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(subresourceOrigin4))
-            testPassed("Colluding host 4 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin4))
-            testFailed("Colluding host 4 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource("http://localhost:8000"))
-            testPassed("Colluding localhost got set as prevalent resource after actual sub frame redirect.");
-        if (testRunner.isStatisticsVeryPrevalentResource("http://localhost:8000"))
-            testFailed("Colluding localhost got classified as very prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host explicity set did not get set as prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin1))
+                testPassed("Colluding host 1 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin1))
+                testFailed("Colluding host 1 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin2))
+                testPassed("Colluding host 2 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin2))
+                testFailed("Colluding host 2 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin3))
+                testPassed("Colluding host 3 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin3))
+                testFailed("Colluding host 3 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin4))
+                testPassed("Colluding host 4 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin4))
+                testFailed("Colluding host 4 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource("http://localhost:8000"))
+                testPassed("Colluding localhost got set as prevalent resource after actual sub frame redirect.");
+            if (testRunner.isStatisticsVeryPrevalentResource("http://localhost:8000"))
+                testFailed("Colluding localhost got classified as very prevalent resource.");
 
-        setEnableFeature(false, finishJSTest);
+            setEnableFeature(false, finishJSTest);
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
         setEnableFeature(true, function () {
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
-
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
+                let iframeElement = document.createElement("iframe");
+                iframeElement.onload = runTest;
+                iframeElement.src = "http://localhost:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/onclick.html";
+                document.body.appendChild(iframeElement);
+            });
         });
     }
 </script>
-<iframe onload="runTest()" src="http://localhost:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/onclick.html"></iframe>
 </body>
 </html>
index 46b889b..6980ab4 100644 (file)
     }
 
     function runTest() {
-        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() {
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
         setEnableFeature(true, function() {
             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
-            runTest();
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
+                runTest();
+            });
         });
     }
 </script>
index 25f7898..b33d524 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index f04fdc4..b8b12a5 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index ab2a372..459bb17 100644 (file)
         testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin2, topFrameOrigin3);
         testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin3, topFrameOrigin4);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host explicity set did not get set as prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
-            testPassed("Colluding host 1 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
-            testFailed("Colluding host 1 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
-            testPassed("Colluding host 2 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
-            testFailed("Colluding host 2 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
-            testPassed("Colluding host 3 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
-            testFailed("Colluding host 3 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
-            testPassed("Colluding host 4 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
-            testFailed("Colluding host 4 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
-            testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
-            testFailed("Colluding localhost got classified as very prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host explicity set did not get set as prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
+                testPassed("Colluding host 1 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
+                testFailed("Colluding host 1 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
+                testPassed("Colluding host 2 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
+                testFailed("Colluding host 2 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
+                testPassed("Colluding host 3 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
+                testFailed("Colluding host 3 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
+                testPassed("Colluding host 4 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
+                testFailed("Colluding host 4 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
+                testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
+                testFailed("Colluding localhost got classified as very prevalent resource.");
 
-        setEnableFeature(false, finishJSTest);
+            setEnableFeature(false, finishJSTest);
+        });
     }
 
     if (document.location.hash === "" && window.testRunner && window.internals) {
         setEnableFeature(true, function() {
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
 
-            document.location.href = topFrameOrigin5 + "resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html#continue";
+                document.location.href = topFrameOrigin5 + "resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html#continue";
+            });
         });
     } else {
         testRunner.statisticsNotifyObserver();
index f2eb3a3..9cb8870 100644 (file)
     }
 
     function runTest() {
-        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true);
-        testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() {
+            testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
         setEnableFeature(true, function() {
             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
-            runTest();
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
+                runTest();
+            });
         });
     }
 </script>
index c3e9213..95977f9 100644 (file)
         setEnableFeature(true, function() {
             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
-            runTest();
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
+                runTest();
+            });
         });
     }
 </script>
index 922e3cc..040ca6a 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
  
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host started out as prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host started out as prevalent resource.");
 
-        var i = 0;
-        while (i < numberOfSubresourceDomains) {
-            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
-            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
-            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i]);
+            var i = 0;
+            while (i < numberOfSubresourceDomains) {
+                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
+                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
+                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i]);
 
-            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
-            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
-            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+1]);
+                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
+                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
+                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+1]);
 
-            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
-            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
-            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+2]);
-            i += 3;
-        }
+                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
+                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
+                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+2]);
+                i += 3;
+            }
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 0e99ab9..4d123c0 100644 (file)
@@ -37,7 +37,7 @@
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {});
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
 
index 457eb0e..452f6e5 100644 (file)
     function runTestRunnerTest() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
-        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);
+            testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);
 
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 81a85c7..01a3781 100644 (file)
 
     function doRedirect()
     {
-        testRunner.setStatisticsPrevalentResource("http://localhost", true);
-        if (!testRunner.isStatisticsPrevalentResource("http://localhost")) {
-            testFailed("Host did not get set as prevalent resource.");
-            finishJSTest();
-        }
-        else
-            window.location = "http://localhost:8000/cookies/resources/set-cookie-on-redirect.php?step=1";
+        testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+            if (!testRunner.isStatisticsPrevalentResource("http://localhost")) {
+                testFailed("Host did not get set as prevalent resource.");
+                finishJSTest();
+            }
+            else
+                window.location = "http://localhost:8000/cookies/resources/set-cookie-on-redirect.php?step=1";
+        });
     }
 </script>
 </head>
index f49fd8b..6cbd872 100644 (file)
             case "#step4":
                 document.location.hash = "step5";
                 // Set localhost as prevalent resource.
-                testRunner.setStatisticsPrevalentResource("http://localhost", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                    testFailed("Localhost did not get set as prevalent resource.");
-                runTest();
+                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                        testFailed("Localhost did not get set as prevalent resource.");
+                    runTest();
+                });
                 break;
             case "#step5":
                 // Set a first-party cookie for 127.0.0.1.
             case "#step6":
                 document.location.hash = "step7";
                 // Set 127.0.0.1 as prevalent resource
-                testRunner.setStatisticsPrevalentResource("http://127.0.0.1", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://127.0.0.1"))
-                    testFailed("127.0.0.1 did not get set as prevalent resource.");
-                runTest();
+                testRunner.setStatisticsPrevalentResource("http://127.0.0.1", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://127.0.0.1"))
+                        testFailed("127.0.0.1 did not get set as prevalent resource.");
+                    runTest();
+                });
                 break;
             case "#step7":
                 document.location.hash = "step8";
index 6722208..e4adbde 100644 (file)
         if (document.cookie !== cookie)
             testFailed("document.cookie did not get set.");
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        // This is done to not have an empty set of prevalent resources.
-        // Otherwise data records are never scanned.
-        testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
-            testFailed("Other host did not get set as prevalent resource.");
+            // This is done to not have an empty set of prevalent resources.
+            // Otherwise data records are never scanned.
+            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
+                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
+                    testFailed("Other host did not get set as prevalent resource.");
 
-        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Host did not get logged for user interaction.");
+                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
+                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                        testFailed("Host did not get logged for user interaction.");
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(function() {
-            if (document.cookie === cookie)
-                testPassed("Cookie not deleted.");
-            else
-                testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
+                    testRunner.installStatisticsDidScanDataRecordsCallback(function() {
+                        if (document.cookie === cookie)
+                            testPassed("Cookie not deleted.");
+                        else
+                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
 
-            setEnableFeature(false, function() {
-                testRunner.notifyDone();
+                        setEnableFeature(false, function() {
+                            testRunner.notifyDone();
+                        });
+                    });
+                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+                    testRunner.statisticsProcessStatisticsAndDataRecords();
+                });
             });
         });
-        testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-        testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 1befc13..3b9aff4 100644 (file)
         if (document.cookie !== cookie)
             testFailed("document.cookie did not get set.");
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as non-prevalent resource.");
 
-        // This is done to not have an empty set of prevalent resources.
-        // Otherwise data records are never scanned.
-        testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
-            testFailed("Other host did not get set as prevalent resource.");
+            // This is done to not have an empty set of prevalent resources.
+            // Otherwise data records are never scanned.
+            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
+                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
+                    testFailed("Other host did not get set as prevalent resource.");
 
-        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
-        if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Host did not get cleared of user interaction.");
+                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
+                    if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                        testFailed("Host did not get cleared of user interaction.");
 
-        testRunner.installStatisticsDidScanDataRecordsCallback(function() {
-            if (document.cookie === cookie)
-                testPassed("Cookie not deleted.");
-            else
-                testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
+                    testRunner.installStatisticsDidScanDataRecordsCallback(function() {
+                        if (document.cookie === cookie)
+                            testPassed("Cookie not deleted.");
+                        else
+                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
 
-            setEnableFeature(false, function() {
-                testRunner.notifyDone();
+                        setEnableFeature(false, function() {
+                            testRunner.notifyDone();
+                        });
+                    });
+                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+                    testRunner.statisticsProcessStatisticsAndDataRecords();
+                });
             });
         });
-        testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-        testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index f24f489..4669c57 100644 (file)
     }
 
     function setUserInteractionAndContinue() {
-        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
-            testFailed("Third party did not get logged for user interaction.");
-        runTest();
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
+            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
+                testFailed("Third party did not get logged for user interaction.");
+            runTest();
+        });
     }
 
     function runTest() {
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive one partitioned, third party cookie.", setUserInteractionAndContinue);
                 break;
             case "#step6":
-                // Load localhost under 127.0.0.1 and check that it gets its non-partitioned cookie after user interaction.
+                // Load localhost under 127.0.0.1 and check that it still gets partitioned cookie after user interaction.
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After user interaction, should still only receive one partitioned, third party cookie.", finishTest);
                 break;
         }
     }
 
     if (document.location.host === partitionHost && document.location.hash == "" && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        testRunner.dumpChildFramesAsText();
         setEnableFeature(true, function() {
-            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false);
-            testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false);
-            testRunner.waitUntilDone();
-            testRunner.dumpChildFramesAsText();
-            document.location.hash = "step1";
+            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false, function() {
+                testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false, function() {
+                    document.location.hash = "step1";
 
-            testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
+                    testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
+                });
+            });
         });
     } else {
         runTest();
index 37e2c7c..28fa0b5 100644 (file)
     }
 
     function setUserInteractionAndContinue() {
-        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
-            testFailed("Third party did not get logged for user interaction.");
-        runTest();
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
+            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
+                testFailed("Third party did not get logged for user interaction.");
+            runTest();
+        });
     }
 
     function runTest() {
             testRunner.dumpChildFramesAsText();
             document.location.hash = "step1";
 
-            testRunner.setStatisticsPrevalentResource("http://localhost", true);
-            if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                    testFailed("Host did not get set as prevalent resource.");
 
-            testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest);
+                testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest);
+            });
         });
     } else {
         runTest();
index a40d7f5..50e82c8 100644 (file)
@@ -1,15 +1,3 @@
-CONSOLE MESSAGE: line 117: Bootstrapping test.
-CONSOLE MESSAGE: line 68: Step 1.
-CONSOLE MESSAGE: line 73: Step 2.
-CONSOLE MESSAGE: line 80: Step 3.
-CONSOLE MESSAGE: line 87: Step 4.
-CONSOLE MESSAGE: line 57: setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().
-CONSOLE MESSAGE: line 94: Step 5.
-CONSOLE MESSAGE: line 51: setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue().
-CONSOLE MESSAGE: line 46: fireShouldPartitionCookiesHandlerAndContinue().
-CONSOLE MESSAGE: line 101: Step 6.
-CONSOLE MESSAGE: line 57: setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().
-CONSOLE MESSAGE: line 108: Step 7.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index aa57099..beff3a3 100644 (file)
     }
 
     function fireShouldPartitionCookiesHandlerAndContinue() {
-        console.log("fireShouldPartitionCookiesHandlerAndContinue().");
         testRunner.statisticsUpdateCookiePartitioning(runTest);
     }
 
     function setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue() {
-        console.log("setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue().");
         testRunner.setStatisticsTimeToLiveCookiePartitionFree(1);
         setTimeout(fireShouldPartitionCookiesHandlerAndContinue, 2000);
     }
 
     function setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue() {
-        console.log("setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().");
         testRunner.setStatisticsTimeToLiveCookiePartitionFree(86400);
-        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
-            testFailed("Third party did not get logged for user interaction.");
-        runTest();
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
+            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 still only receive a partitioned, third-party 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 still only receive a partitioned, third-party cookie.",
                     finishTest);
     }
 
     if (document.location.hash === "" && window.testRunner && window.internals) {
-        console.log("Bootstrapping test.");
+        testRunner.waitUntilDone();
+        testRunner.dumpChildFramesAsText();
         setEnableFeature(true, function() {
             // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
-            testRunner.setStatisticsPrevalentResource("http://localhost", true);
-            if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                testFailed("Host did not get set as prevalent resource.");
-            testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
+            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                    testFailed("Host did not get set as prevalent resource.");
+                testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
 
-            testRunner.statisticsUpdateCookiePartitioning();
+                testRunner.statisticsUpdateCookiePartitioning();
 
-            testRunner.waitUntilDone();
-            testRunner.dumpChildFramesAsText();
-            document.location.hash = "step1";
+                document.location.hash = "step1";
 
-            runTest();
+                runTest();
+            });
         });
     } else
         runTest();
index ebfd9d7..8a43c93 100644 (file)
     }
 
     function setUserInteractionAndContinue() {
-        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
-            testFailed("Third party did not get logged for user interaction.");
-        runTest();
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
+            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
+                testFailed("Third party did not get logged for user interaction.");
+            runTest();
+        });
     }
 
     function runTest() {
index ee9091d..7992f49 100644 (file)
@@ -16,44 +16,46 @@ onload = function() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
     }
 
-    testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-    if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-        testFailed("Host did not get set as prevalent resource.");
-
-    testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
-    if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-        testFailed("Host did not get cleared of user interaction.");
-
-    testInput = document.getElementById("testInput");
-
-    testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
-        shouldBeEqualToString("testInput.value", "a");
-
-        if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Origin did not get user interaction credit.");
-        else
-            testPassed("Origin was granted user interaction.");
-
-        setTimeout(function() {
-            testFrame.src = "about:blank";
-            setTimeout(function() {
-                testRunner.statisticsResetToConsistentState(function() {
-                    finishJSTest();
-                });
-            }, 0);
-        }, 0);
+    testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as prevalent resource.");
+
+        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get cleared of user interaction.");
+
+            testInput = document.getElementById("testInput");
+
+            testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
+                shouldBeEqualToString("testInput.value", "a");
+
+                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                    testFailed("Origin did not get user interaction credit.");
+                else
+                    testPassed("Origin was granted user interaction.");
+
+                setTimeout(function() {
+                    testFrame.src = "about:blank";
+                    setTimeout(function() {
+                        testRunner.statisticsResetToConsistentState(function() {
+                            finishJSTest();
+                        });
+                    }, 0);
+                }, 0);
+            });
+            testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+            testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+
+            debug("Simulate user typing letter 'a' into the field.");
+            testInput.focus();
+            if (window.eventSender)
+                eventSender.keyDown("a");
+        });
     });
-    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-    testRunner.statisticsProcessStatisticsAndDataRecords();
-
-    debug("Simulate user typing letter 'a' into the field.");
-    testInput.focus();
-    if (window.eventSender)
-        eventSender.keyDown("a");    
 }
 </script>
 <iframe id="testFrame" src="resources/onclick.html"></iframe>
-<input id="testInput" type="text"></input>
+<input id="testInput" type="text">
 </body>
 </html>
index d5cfd7f..b235b65 100644 (file)
@@ -16,35 +16,37 @@ onload = function() {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
     }
 
-    testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-    if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-        testFailed("Host did not get set as prevalent resource.");
-
-    testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
-    if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-        testFailed("Host did not get cleared of user interaction.");
-
-    testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
-
-        if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testPassed("Origin did not get user interaction credit.");
-
-        setTimeout(function() {
-            testFrame.src = "about:blank";
-            setTimeout(function() {
-                testRunner.statisticsResetToConsistentState(function() {
-                    finishJSTest();
-                });
-            }, 0);
-        }, 0);
+    testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as prevalent resource.");
+
+        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
+            if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get cleared of user interaction.");
+
+            testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
+
+                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                    testPassed("Origin did not get user interaction credit.");
+
+                setTimeout(function() {
+                    testFrame.src = "about:blank";
+                    setTimeout(function() {
+                        testRunner.statisticsResetToConsistentState(function() {
+                            finishJSTest();
+                        });
+                    }, 0);
+                }, 0);
+            });
+            testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+            testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+
+            debug("Simulate an unhandled user key press.");
+            if (window.eventSender)
+                eventSender.keyDown("a", ["metaKey"]);
+        });
     });
-    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-    testRunner.statisticsProcessStatisticsAndDataRecords();
-
-    debug("Simulate an unhandled user key press.");
-    if (window.eventSender)
-        eventSender.keyDown("a", ["metaKey"]);    
 }
 </script>
 <iframe id="testFrame" src="resources/onclick.html"></iframe>
index b8bf51e..352499d 100644 (file)
         if (document.cookie !== cookie)
             testFailed("document.cookie did not get set.");
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
 
-        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Host did not get logged for user interaction.");
+            testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
+                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                    testFailed("Host did not get logged for user interaction.");
 
-        testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
-            if (document.cookie !== "")
-                testFailed("Cookie not deleted: " + document.cookie);
-            else
-                testPassed("Cookie deleted.");
-            internals.setResourceLoadStatisticsEnabled(false);
-            testRunner.statisticsResetToConsistentState(function() {
-                testRunner.notifyDone();
+                testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
+                    if (document.cookie !== "")
+                        testFailed("Cookie not deleted: " + document.cookie);
+                    else
+                        testPassed("Cookie deleted.");
+                    internals.setResourceLoadStatisticsEnabled(false);
+                    testRunner.statisticsResetToConsistentState(function() {
+                        testRunner.notifyDone();
+                    });
+                });
+                testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+                testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+                testRunner.setStatisticsTimeToLiveUserInteraction(0);
+
+                // This is to ensure the timeout we're testing.
+                setTimeout("testRunner.statisticsProcessStatisticsAndDataRecords()", 1000);
             });
         });
-        testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-        testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-        testRunner.setStatisticsTimeToLiveUserInteraction(0);
-        setTimeout("testRunner.statisticsProcessStatisticsAndDataRecords()", 1000);
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 0bbad25..8d56978 100644 (file)
         if (document.cookie !== cookie)
             testFailed("document.cookie did not get set.");
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
 
-        // This is done to not have an empty set of prevalent resources.
-        // Otherwise data records are never scanned.
-        testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
-            testFailed("Other host did not get set as prevalent resource.");
+            // This is done to not have an empty set of prevalent resources.
+            // Otherwise data records are never scanned.
+            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
+                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
+                    testFailed("Other host did not get set as prevalent resource.");
 
-        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Host did not get logged for user interaction.");
+                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
+                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                        testFailed("Host did not get logged for user interaction.");
 
-        testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
-            if (document.cookie === cookie)
-                testPassed("Cookie not deleted.");
-            else
-                testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
-            internals.setResourceLoadStatisticsEnabled(false);
-            testRunner.statisticsResetToConsistentState(function() {
-                testRunner.notifyDone();
+                    testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
+                        if (document.cookie === cookie)
+                            testPassed("Cookie not deleted.");
+                        else
+                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
+                        internals.setResourceLoadStatisticsEnabled(false);
+                        testRunner.statisticsResetToConsistentState(function() {
+                            testRunner.notifyDone();
+                        });
+                    });
+                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+                    testRunner.statisticsProcessStatisticsAndDataRecords();
+                });
             });
         });
-        testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-        testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index 52509c9..f200312 100644 (file)
         if (document.cookie !== cookie)
             testFailed("document.cookie did not get set.");
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
 
-        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
-        if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-            testFailed("Host did not get cleared of user interaction.");
+            testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                    testFailed("Host did not get cleared of user interaction.");
 
-        testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
-            setTimeout("finishTest()", 1000);
+                testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
+                    setTimeout("finishTest()", 1000);
+                });
+                testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
+                testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
+                testRunner.statisticsProcessStatisticsAndDataRecords();
+            });
         });
-        testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
-        testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
index bbc5c16..b51522f 100644 (file)
         }
     }
 
-    function initializeStatistics() {
-        testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
-
-        // Non-prevalent without user interaction to be pruned first.
-        testRunner.setStatisticsLastSeen(urlsToBePruned[0].url, olderTimestamp);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[1].url, newerTimestamp);
-
-        // Prevalent without user interaction to be pruned second.
-        testRunner.setStatisticsPrevalentResource(urlsToBePruned[2].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[2].url, olderTimestamp);
-        testRunner.setStatisticsPrevalentResource(urlsToBePruned[3].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[3].url, newerTimestamp);
-
-        // Non-prevalent with user interaction to be pruned third.
-        testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[4].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[4].url, olderTimestamp);
-        testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[5].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[5].url, newerTimestamp);
-
-        // Prevalent with user interaction to be pruned last.
-        testRunner.setStatisticsPrevalentResource(urlsToBePruned[6].url, true);
-        testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[6].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[6].url, olderTimestamp);
-        testRunner.setStatisticsPrevalentResource(urlsToBePruned[7].url, true);
-        testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[7].url, true);
-        testRunner.setStatisticsLastSeen(urlsToBePruned[7].url, newerTimestamp);
-
-        checkIfPrevalentAccordingToInitialExpectation(0, urlsToBePruned.length);
+    function initializeStatisticsAndRunTests(step) {
+        switch (step) {
+            // Non-prevalent without user interaction to be pruned first.
+            case 1:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[0].url, olderTimestamp, function() { initializeStatisticsAndRunTests(2); });
+                break;
+            case 2:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[1].url, newerTimestamp, function() { initializeStatisticsAndRunTests(3); });
+                break;
+            // Prevalent without user interaction to be pruned second.
+            case 3:
+                testRunner.setStatisticsPrevalentResource(urlsToBePruned[2].url, true, function() { initializeStatisticsAndRunTests(4); });
+                break;
+            case 4:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[2].url, olderTimestamp, function() { initializeStatisticsAndRunTests(5); });
+                break;
+            case 5:
+                testRunner.setStatisticsPrevalentResource(urlsToBePruned[3].url, true, function() { initializeStatisticsAndRunTests(6); });
+                break;
+            case 6:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[3].url, newerTimestamp, function() { initializeStatisticsAndRunTests(7); });
+                break;
+            // Non-prevalent with user interaction to be pruned third.
+            case 7:
+                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[4].url, true, function() { initializeStatisticsAndRunTests(8); });
+                break;
+            case 8:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[4].url, olderTimestamp, function() { initializeStatisticsAndRunTests(9); });
+                break;
+            case 9:
+                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[5].url, true, function() { initializeStatisticsAndRunTests(10); });
+                break;
+            case 10:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[5].url, newerTimestamp, function() { initializeStatisticsAndRunTests(11); });
+                break;
+            // Prevalent with user interaction to be pruned last.
+            case 11:
+                testRunner.setStatisticsPrevalentResource(urlsToBePruned[6].url, true, function() { initializeStatisticsAndRunTests(12); });
+                break;
+            case 12:
+                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[6].url, true, function() { initializeStatisticsAndRunTests(13); });
+                break;
+            case 13:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[6].url, olderTimestamp, function() { initializeStatisticsAndRunTests(14); });
+                break;
+            case 14:
+                testRunner.setStatisticsPrevalentResource(urlsToBePruned[7].url, true, function() { initializeStatisticsAndRunTests(15); });
+                break;
+            case 15:
+                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[7].url, true, function() { initializeStatisticsAndRunTests(16); });
+                break;
+            case 16:
+                testRunner.setStatisticsLastSeen(urlsToBePruned[7].url, newerTimestamp, function() { initializeStatisticsAndRunTests(17); });
+                break;
+            case 17:
+                checkIfPrevalentAccordingToInitialExpectation(0, urlsToBePruned.length);
+                runTest();
+                break;
+        }
     }
 
     var currentTest;
         testPassed("Test iteration " + currentTest + " passed.");
         if (currentTest < urlsToBePruned.length) {
             ++currentTest;
-            runTest();
+            testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
+            initializeStatisticsAndRunTests(1);
         } else {
             testRunner.statisticsResetToConsistentState(function() {
                 finishJSTest();
         }
     }
 
+    let fillerUrl;
     function runTest() {
-        initializeStatistics();
-
-        var fillerUrl = "http://127.0." + currentTest + ".1:8000/temp";
-        testRunner.setStatisticsPrevalentResource(fillerUrl, true);
-        testRunner.setStatisticsHasHadUserInteraction(fillerUrl, true);
-        testRunner.setStatisticsLastSeen(fillerUrl, newestTimestamp);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+        fillerUrl = "http://127.0." + currentTest + ".1:8000/temp";
+        testRunner.setStatisticsPrevalentResource(fillerUrl, true, function() {
+            testRunner.setStatisticsHasHadUserInteraction(fillerUrl, true, function() {
+                testRunner.setStatisticsLastSeen(fillerUrl, newestTimestamp, function() {
+                    testRunner.statisticsProcessStatisticsAndDataRecords();
+                });
+            });
+        });
     }
 
     if (window.testRunner) {
         testRunner.setStatisticsPruneEntriesDownTo(urlsToBePruned.length);
 
         currentTest = 1;
-        runTest();
+        testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
+        initializeStatisticsAndRunTests(1);
     }
 </script>
 </body>
index 0e74a03..558e8f2 100644 (file)
             case "#step4":
                 // Set localhost as prevalent and with non-recent user interaction to put it in the blocking category.
                 document.location.hash = "step5";
-                testRunner.setStatisticsPrevalentResource("http://localhost", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                    testFailed("Host did not get set as prevalent resource.");
-                testRunner.statisticsUpdateCookiePartitioning(function() {
-                    runTest();
+                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                        testFailed("Host did not get set as prevalent resource.");
+                    testRunner.statisticsUpdateCookiePartitioning(function() {
+                        runTest();
+                    });
                 });
                 break;
             case "#step5":
index 9c110c0..a5e3d91 100644 (file)
             case "#step4":
                 // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
                 document.location.hash = "step5";
-                testRunner.setStatisticsPrevalentResource("http://localhost", true);
-                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                    testFailed("Host did not get set as prevalent resource.");
-                testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
-                testRunner.statisticsUpdateCookiePartitioning(function() {
-                    runTest();
+                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                        testFailed("Host did not get set as prevalent resource.");
+                    testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost", function() {
+                        testRunner.statisticsUpdateCookiePartitioning(runTest);
+                    });
                 });
                 break;
             case "#step5":
index 391fbb5..e8b7f09 100644 (file)
             referrer = data;
             shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html");
 
-            testRunner.setStatisticsPrevalentResource("http://localhost", true);
-            if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                    testFailed("Host did not get set as prevalent resource.");
 
-            testRunner.statisticsUpdateCookiePartitioning(function() {
-                openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
-                    setEnableFeature(false, finishJSTest);
+                testRunner.statisticsUpdateCookiePartitioning(function() {
+                    openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
+                        setEnableFeature(false, finishJSTest);
+                    });
                 });
             });
-
         }).catch(function(error) {
             console.log(error.message);
             setEnableFeature(false, finishJSTest);
index 6d3b676..2040288 100644 (file)
             referrer = data;
             shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html");
 
-            testRunner.setStatisticsPrevalentResource("http://localhost", true);
-            if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
-                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
+                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+                    testFailed("Host did not get set as prevalent resource.");
 
-            testRunner.statisticsUpdateCookiePartitioning(function() {
-                fetch("http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php").then(function(response) {
-                    return response.text();
-                }).then(function(data) {
-                    referrer = data;
-                    shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
+                testRunner.statisticsUpdateCookiePartitioning(function() {
+                    fetch("http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php").then(function(response) {
+                        return response.text();
+                    }).then(function(data) {
+                        referrer = data;
+                        shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
 
-                    openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
+                        openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
+                            setEnableFeature(false, finishJSTest);
+                        });
+
+                    }).catch(function(error) {
+                        console.log(error.message);
                         setEnableFeature(false, finishJSTest);
                     });
-
-                }).catch(function(error) {
-                    console.log(error.message);
-                    setEnableFeature(false, finishJSTest);
                 });
             });
-
         }).catch(function(error) {
             console.log(error.message);
             setEnableFeature(false, finishJSTest);
index 1055973..4db3127 100644 (file)
         makeUrlPrevalent(prevalentResourceUrl3);
         makeUrlPrevalent(prevalentResourceUrl4);
 
-        testRunner.setStatisticsHasHadUserInteraction(prevalentResourceUrl4, true);
-
-        testRunner.installStatisticsDidScanDataRecordsCallback(checkSufficientClassificationAndContinue);
-        testRunner.installStatisticsDidRunTelemetryCallback(checkSufficientTelemetry);
-        testRunner.statisticsProcessStatisticsAndDataRecords();
+        testRunner.setStatisticsHasHadUserInteraction(prevalentResourceUrl4, true, function() {
+            testRunner.installStatisticsDidScanDataRecordsCallback(checkSufficientClassificationAndContinue);
+            testRunner.installStatisticsDidRunTelemetryCallback(checkSufficientTelemetry);
+            testRunner.statisticsProcessStatisticsAndDataRecords();
+        });
     }
 
     function runTelemetryAndContinue() {
index e217a03..b72163e 100644 (file)
     }
 
     function setUserInteractionAndContinue() {
-        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
-        if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
-            testFailed("Third party did not get logged for user interaction.");
-        runTest();
+        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
+            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
+                testFailed("Third party did not get logged for user interaction.");
+            runTest();
+        });
     }
 
     function runTest() {
             document.location.hash = "step1";
 
             // Start test with third party as non-prevalent
-            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false);
-            testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false);
-            testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
+            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false, function() {
+                testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false, function() {
+                    testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
+                });
+            });
         });
     } else {
         runTest();
index 09806f4..a30b228 100644 (file)
         shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
         shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
 
-        if (testRunner)
-            testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false);
+        if (testRunner) {
+            testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false, function() {
+                shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
 
-        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
-
-        activateElement("testElement", finishTest);
+                activateElement("testElement", finishTest);
+            });
+        }
     }
 
     function finishTest() {
index b647dcb..33aa873 100644 (file)
@@ -1,3 +1,36 @@
+2018-07-17  John Wilander  <wilander@apple.com>
+
+        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
+        https://bugs.webkit.org/show_bug.cgi?id=187710
+        <rdar://problem/42252757>
+
+        Reviewed by Chris Dumez.
+
+        These changes are to back the completion handler functionality of
+        TestRunner functions:
+        - setStatisticsLastSeen(),
+        - setStatisticsPrevalentResource(),
+        - setStatisticsVeryPrevalentResource(),
+        - setStatisticsHasHadUserInteraction(), and
+        - setStatisticsHasHadNonRecentUserInteraction().
+
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreSetStatisticsLastSeen):
+        (WKWebsiteDataStoreSetStatisticsPrevalentResource):
+        (WKWebsiteDataStoreSetStatisticsVeryPrevalentResource):
+        (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
+        (WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
+        (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction):
+        (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
+        (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
+        (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
+        (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
+        (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+
 2018-07-16  Simon Fraser  <simon.fraser@apple.com>
 
         Add color filter for transforming colors in Dark Mode
index 66c0303..a54ecbc 100644 (file)
@@ -69,37 +69,53 @@ void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef
     WebKit::toImpl(dataStoreRef)->setResourceLoadStatisticsDebugMode(enable);
 }
 
-void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds)
+void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler)
 {
     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
-    if (!store)
+    if (!store) {
+        completionHandler(context);
         return;
+    }
 
-    store->setLastSeen(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), Seconds { seconds });
+    store->setLastSeen(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] {
+        completionHandler(context);
+    });
 }
 
-void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler)
 {
     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
-    if (!store)
+    if (!store) {
+        completionHandler(context);
         return;
+    }
 
     if (value)
-        store->setPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->setPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
     else
-        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
 }
 
-void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler)
 {
     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
-    if (!store)
+    if (!store) {
+        completionHandler(context);
         return;
-    
+    }
+
     if (value)
-        store->setVeryPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->setVeryPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
     else
-        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
 }
 
 void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback)
@@ -154,25 +170,35 @@ void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreR
     });
 }
 
-void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler)
 {
     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
-    if (!store)
+    if (!store) {
+        completionHandler(context);
         return;
+    }
 
     if (value)
-        store->logUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->logUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
     else
-        store->clearUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+        store->clearUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+            completionHandler(context);
+        });
 }
 
-void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host)
+void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction completionHandler)
 {
     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
-    if (!store)
+    if (!store) {
+        completionHandler(context);
         return;
-    
-    store->logNonRecentUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+    }
+
+    store->logNonRecentUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
+        completionHandler(context);
+    });
 }
 
 void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback)
index e6b88b3..5b74620 100644 (file)
@@ -40,9 +40,12 @@ WK_EXPORT WKWebsiteDataStoreRef WKWebsiteDataStoreCreateNonPersistentDataStore()
 WK_EXPORT bool WKWebsiteDataStoreGetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef);
 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable);
 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef dataStoreRef, bool enable);
-WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds);
-WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
-WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
+typedef void (*WKWebsiteDataStoreStatisticsLastSeenFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler);
+typedef void (*WKWebsiteDataStoreStatisticsPrevalentResourceFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler);
+typedef void (*WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler);
 typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
 WK_EXPORT void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
@@ -50,8 +53,10 @@ typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction)(
 WK_EXPORT void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback);
 typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction)(bool isRegisteredAsRedirectingTo, void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction callback);
-WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
-WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host);
+typedef void (*WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler);
+typedef void (*WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction completionHandler);
 typedef void (*WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction)(bool hasHadUserInteraction, void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback);
 WK_EXPORT void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
index 0cba7c3..b09ae4a 100644 (file)
@@ -403,42 +403,57 @@ void WebResourceLoadStatisticsStore::logFrameNavigation(const WebFrameProxy& fra
     });
 }
 
-void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url)
+void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
+    }
 
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->logUserInteraction(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
-void WebResourceLoadStatisticsStore::logNonRecentUserInteraction(const URL& url)
+void WebResourceLoadStatisticsStore::logNonRecentUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
-    
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    }
+
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->logNonRecentUserInteraction(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
-void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url)
+void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
+    }
 
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->clearUserInteraction(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
@@ -459,42 +474,57 @@ void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, Compl
     });
 }
 
-void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds)
+void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
-    
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds] {
+    }
+
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds, completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->setLastSeen(primaryDomain, seconds);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
     
-void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url)
+void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
+    }
 
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->setPrevalentResource(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
-void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url)
+void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
-    
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    }
+
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->setVeryPrevalentResource(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
@@ -556,16 +586,21 @@ void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const URL& host
     });
 }
 
-void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url)
+void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    if (url.isBlankURL() || url.isEmpty())
+    if (url.isBlankURL() || url.isEmpty()) {
+        completionHandler();
         return;
+    }
 
-    postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
+    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
         if (m_memoryStore)
             m_memoryStore->clearPrevalentResource(primaryDomain);
+        postTaskReply([completionHandler = WTFMove(completionHandler)] {
+            completionHandler();
+        });
     });
 }
 
index b518746..5dc8d9d 100644 (file)
@@ -87,18 +87,18 @@ public:
     void applicationWillTerminate();
 
     void logFrameNavigation(const WebFrameProxy&, const WebCore::URL& pageURL, const WebCore::ResourceRequest&, const WebCore::URL& redirectURL);
-    void logUserInteraction(const WebCore::URL&);
-    void logNonRecentUserInteraction(const WebCore::URL&);
-    void clearUserInteraction(const WebCore::URL&);
+    void logUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
+    void logNonRecentUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
+    void clearUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
     void hasHadUserInteraction(const WebCore::URL&, CompletionHandler<void(bool)>&&);
-    void setLastSeen(const WebCore::URL&, Seconds);
-    void setPrevalentResource(const WebCore::URL&);
-    void setVeryPrevalentResource(const WebCore::URL&);
+    void setLastSeen(const WebCore::URL&, Seconds, CompletionHandler<void()>&&);
+    void setPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
+    void setVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
     void isPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
     void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
     void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&);
     void isRegisteredAsRedirectingTo(const WebCore::URL& hostRedirectedFrom, const WebCore::URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
-    void clearPrevalentResource(const WebCore::URL&);
+    void clearPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
     void setGrandfathered(const WebCore::URL&, bool);
     void isGrandfathered(const WebCore::URL&, CompletionHandler<void(bool)>&&);
     void setSubframeUnderTopFrameOrigin(const WebCore::URL& subframe, const WebCore::URL& topFrame);
index 5d5b60f..78b1de4 100644 (file)
@@ -1,3 +1,39 @@
+2018-07-17  John Wilander  <wilander@apple.com>
+
+        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
+        https://bugs.webkit.org/show_bug.cgi?id=187710
+        <rdar://problem/42252757>
+
+        Reviewed by Chris Dumez.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setStatisticsLastSeen):
+        (WTR::TestRunner::statisticsCallDidSetLastSeenCallback):
+        (WTR::TestRunner::setStatisticsPrevalentResource):
+        (WTR::TestRunner::statisticsCallDidSetPrevalentResourceCallback):
+        (WTR::TestRunner::setStatisticsVeryPrevalentResource):
+        (WTR::TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback):
+        (WTR::TestRunner::setStatisticsHasHadUserInteraction):
+        (WTR::TestRunner::setStatisticsHasHadNonRecentUserInteraction):
+        (WTR::TestRunner::statisticsCallDidSetHasHadUserInteractionCallback):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setStatisticsLastSeen):
+        (WTR::TestController::setStatisticsPrevalentResource):
+        (WTR::TestController::setStatisticsVeryPrevalentResource):
+        (WTR::TestController::setStatisticsHasHadUserInteraction):
+        (WTR::TestController::setStatisticsHasHadNonRecentUserInteraction):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didSetLastSeen):
+        (WTR::TestInvocation::didSetPrevalentResource):
+        (WTR::TestInvocation::didSetVeryPrevalentResource):
+        (WTR::TestInvocation::didSetHasHadUserInteraction):
+        (WTR::TestInvocation::didSetHasHadNonRecentUserInteraction):
+        * WebKitTestRunner/TestInvocation.h:
+
 2018-07-16  Jeremy Jones  <jeremyj@apple.com>
 
         Fix API Test failures introduced by r233865
index 6c4b989..c09cbae 100644 (file)
@@ -272,15 +272,15 @@ interface TestRunner {
     void installStatisticsDidModifyDataRecordsCallback(object callback);
     void installStatisticsDidScanDataRecordsCallback(object callback);
     void installStatisticsDidRunTelemetryCallback(object callback);
-    void setStatisticsLastSeen(DOMString hostName, double seconds);
-    void setStatisticsPrevalentResource(DOMString hostName, boolean value);
-    void setStatisticsVeryPrevalentResource(DOMString hostName, boolean value);
+    void setStatisticsLastSeen(DOMString hostName, double seconds, object completionHandler);
+    void setStatisticsPrevalentResource(DOMString hostName, boolean value, object completionHandler);
+    void setStatisticsVeryPrevalentResource(DOMString hostName, boolean value, object completionHandler);
     boolean isStatisticsPrevalentResource(DOMString hostName);
     boolean isStatisticsVeryPrevalentResource(DOMString hostName);
     boolean isStatisticsRegisteredAsSubFrameUnder(DOMString subFrameHost, DOMString topFrameHost);
     boolean isStatisticsRegisteredAsRedirectingTo(DOMString hostRedirectedFrom, DOMString hostRedirectedTo);
-    void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value);
-    void setStatisticsHasHadNonRecentUserInteraction(DOMString hostName);
+    void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value, object completionHandler);
+    void setStatisticsHasHadNonRecentUserInteraction(DOMString hostName, object completionHandler);
     boolean isStatisticsHasHadUserInteraction(DOMString hostName);
     void setStatisticsGrandfathered(DOMString hostName, boolean value);
     boolean isStatisticsGrandfathered(DOMString hostName);
index 84f4409..59f1a6b 100644 (file)
@@ -315,6 +315,31 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetLastSeen")) {
+        m_testRunner->statisticsCallDidSetLastSeenCallback();
+        return;
+    }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetPrevalentResource")) {
+        m_testRunner->statisticsCallDidSetPrevalentResourceCallback();
+        return;
+    }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetVeryPrevalentResource")) {
+        m_testRunner->statisticsCallDidSetVeryPrevalentResourceCallback();
+        return;
+    }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetHasHadUserInteraction")) {
+        m_testRunner->statisticsCallDidSetHasHadUserInteractionCallback();
+        return;
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetHasHadNonRecentUserInteraction")) {
+        m_testRunner->statisticsCallDidSetHasHadUserInteractionCallback();
+        return;
+    }
+    
     if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAllStorageAccessEntries")) {
         ASSERT(messageBody);
         ASSERT(WKGetTypeID(messageBody) == WKArrayGetTypeID());
index b3af72a..374ec79 100644 (file)
@@ -736,6 +736,10 @@ enum {
     WillEndSwipeCallbackID,
     DidEndSwipeCallbackID,
     DidRemoveSwipeSnapshotCallbackID,
+    SetStatisticsLastSeenCallbackID,
+    SetStatisticsPrevalentResourceCallbackID,
+    SetStatisticsVeryPrevalentResourceCallbackID,
+    SetStatisticsHasHadUserInteractionCallbackID,
     StatisticsDidModifyDataRecordsCallbackID,
     StatisticsDidScanDataRecordsCallbackID,
     StatisticsDidRunTelemetryCallbackID,
@@ -1327,8 +1331,10 @@ void TestRunner::callDidRemoveSwipeSnapshotCallback()
     callTestRunnerCallback(DidRemoveSwipeSnapshotCallbackID);
 }
 
-void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds)
+void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler)
 {
+    cacheTestRunnerCallback(SetStatisticsLastSeenCallbackID, completionHandler);
+
     Vector<WKRetainPtr<WKStringRef>> keys;
     Vector<WKRetainPtr<WKTypeRef>> values;
     
@@ -1351,9 +1357,17 @@ void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds)
     
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
-    
-void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value)
+
+void TestRunner::statisticsCallDidSetLastSeenCallback()
+{
+    callTestRunnerCallback(SetStatisticsLastSeenCallbackID);
+}
+
+
+void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler)
 {
+    cacheTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID, completionHandler);
+
     Vector<WKRetainPtr<WKStringRef>> keys;
     Vector<WKRetainPtr<WKTypeRef>> values;
 
@@ -1379,8 +1393,15 @@ void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
-void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value)
+void TestRunner::statisticsCallDidSetPrevalentResourceCallback()
+{
+    callTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID);
+}
+
+void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler)
 {
+    cacheTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID, completionHandler);
+
     Vector<WKRetainPtr<WKStringRef>> keys;
     Vector<WKRetainPtr<WKTypeRef>> values;
     
@@ -1406,6 +1427,11 @@ void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool v
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback()
+{
+    callTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID);
+}
+
 bool TestRunner::isStatisticsPrevalentResource(JSStringRef hostName)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsPrevalentResource"));
@@ -1476,8 +1502,10 @@ bool TestRunner::isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirecte
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
-void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value)
+void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler)
 {
+    cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler);
+
     Vector<WKRetainPtr<WKStringRef>> keys;
     Vector<WKRetainPtr<WKTypeRef>> values;
     
@@ -1503,13 +1531,20 @@ void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool v
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
-void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName)
+void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName, JSValueRef completionHandler)
 {
+    cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler);
+
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsHasHadNonRecentUserInteraction"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::statisticsCallDidSetHasHadUserInteractionCallback()
+{
+    callTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID);
+}
+
 bool TestRunner::isStatisticsHasHadUserInteraction(JSStringRef hostName)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsHasHadUserInteraction"));
index 2639b4e..4dad0f0 100644 (file)
@@ -382,15 +382,19 @@ public:
     void statisticsSetShouldPartitionCookiesForHost(JSStringRef hostName, bool value, JSValueRef callback);
     void statisticsCallDidSetPartitionOrBlockCookiesForHostCallback();
     void statisticsSubmitTelemetry();
-    void setStatisticsLastSeen(JSStringRef hostName, double seconds);
-    void setStatisticsPrevalentResource(JSStringRef hostName, bool value);
-    void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value);
+    void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler);
+    void statisticsCallDidSetLastSeenCallback();
+    void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
+    void statisticsCallDidSetPrevalentResourceCallback();
+    void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
+    void statisticsCallDidSetVeryPrevalentResourceCallback();
     bool isStatisticsPrevalentResource(JSStringRef hostName);
     bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
     bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
     bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
-    void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
-    void setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName);
+    void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
+    void setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName, JSValueRef completionHandler);
+    void statisticsCallDidSetHasHadUserInteractionCallback();
     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
     void setStatisticsGrandfathered(JSStringRef hostName, bool value);
     bool isStatisticsGrandfathered(JSStringRef hostName);
index 6085170..e0a8534 100644 (file)
@@ -2620,24 +2620,6 @@ uint64_t TestController::domCacheSize(WKStringRef origin)
     return context.result;
 }
 
-void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
-{
-    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
-    WKWebsiteDataStoreSetStatisticsLastSeen(dataStore, host, seconds);
-}
-
-void TestController::setStatisticsPrevalentResource(WKStringRef host, bool value)
-{
-    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
-    WKWebsiteDataStoreSetStatisticsPrevalentResource(dataStore, host, value);
-}
-
-void TestController::setStatisticsVeryPrevalentResource(WKStringRef host, bool value)
-{
-    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
-    WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(dataStore, host, value);
-}
-
 struct ResourceStatisticsCallbackContext {
     explicit ResourceStatisticsCallbackContext(TestController& controller)
         : testController(controller)
@@ -2663,6 +2645,33 @@ static void resourceStatisticsBooleanResultCallback(bool result, void* userData)
     context->done = true;
     context->testController.notifyDone();
 }
+    
+void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
+{
+    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+    ResourceStatisticsCallbackContext context(*this);
+    WKWebsiteDataStoreSetStatisticsLastSeen(dataStore, host, seconds, &context, resourceStatisticsVoidResultCallback);
+    runUntil(context.done, noTimeout);
+    m_currentInvocation->didSetLastSeen();
+}
+
+void TestController::setStatisticsPrevalentResource(WKStringRef host, bool value)
+{
+    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+    ResourceStatisticsCallbackContext context(*this);
+    WKWebsiteDataStoreSetStatisticsPrevalentResource(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
+    runUntil(context.done, noTimeout);
+    m_currentInvocation->didSetPrevalentResource();
+}
+
+void TestController::setStatisticsVeryPrevalentResource(WKStringRef host, bool value)
+{
+    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+    ResourceStatisticsCallbackContext context(*this);
+    WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
+    runUntil(context.done, noTimeout);
+    m_currentInvocation->didSetVeryPrevalentResource();
+}
 
 bool TestController::isStatisticsPrevalentResource(WKStringRef host)
 {
@@ -2703,13 +2712,19 @@ bool TestController::isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedir
 void TestController::setStatisticsHasHadUserInteraction(WKStringRef host, bool value)
 {
     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
-    WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(dataStore, host, value);
+    ResourceStatisticsCallbackContext context(*this);
+    WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
+    runUntil(context.done, noTimeout);
+    m_currentInvocation->didSetHasHadUserInteraction();
 }
 
 void TestController::setStatisticsHasHadNonRecentUserInteraction(WKStringRef host)
 {
     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
-    WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(dataStore, host);
+    ResourceStatisticsCallbackContext context(*this);
+    WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(dataStore, host, &context, resourceStatisticsVoidResultCallback);
+    runUntil(context.done, noTimeout);
+    m_currentInvocation->didSetHasHadNonRecentUserInteraction();
 }
 
 bool TestController::isStatisticsHasHadUserInteraction(WKStringRef host)
index a27b67e..68bb07e 100644 (file)
@@ -1527,6 +1527,36 @@ void TestInvocation::didSetPartitionOrBlockCookiesForHost()
     WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
 }
 
+void TestInvocation::didSetLastSeen()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetLastSeen"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didSetPrevalentResource()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetPrevalentResource"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didSetVeryPrevalentResource()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetVeryPrevalentResource"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didSetHasHadUserInteraction()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadUserInteraction"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didSetHasHadNonRecentUserInteraction()
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadNonRecentUserInteraction"));
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
 void TestInvocation::didReceiveAllStorageAccessEntries(Vector<String>& domains)
 {
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidReceiveAllStorageAccessEntries"));
index 356bac5..005f37d 100644 (file)
@@ -74,6 +74,11 @@ public:
     void didClearStatisticsThroughWebsiteDataRemoval();
     void didResetStatisticsToConsistentState();
     void didSetPartitionOrBlockCookiesForHost();
+    void didSetLastSeen();
+    void didSetPrevalentResource();
+    void didSetVeryPrevalentResource();
+    void didSetHasHadUserInteraction();
+    void didSetHasHadNonRecentUserInteraction();
     void didReceiveAllStorageAccessEntries(Vector<String>& domains);
 
     void didRemoveAllSessionCredentials();