Title: [217606] trunk
Revision
217606
Author
[email protected]
Date
2017-05-31 09:58:53 -0700 (Wed, 31 May 2017)

Log Message

Make ResourceLoadStatistics testing more reliable
https://bugs.webkit.org/show_bug.cgi?id=172730
<rdar://problem/32028373>

Reviewed by Andy Estes.

Source/WebKit2:

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed): Add a convenience method to notify the
WebProcess when the UIProcess has finished processing the load statistics data.
* UIProcess/WebProcessProxy.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): Notify clients (if they requested) when
statistics have been processed.

Tools:

When we tell the UIProcess (WebKitTestRunner) to notify the system about statistics update notifications,
we also need to tell the WebProcess to do so, too, or else the test system doesn't get messages.

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsNotifyPagesWhenDataRecordsWereScanned):

LayoutTests:

Revise some of the tests to wait to check state until after the background process has finished processing the
load information.

* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html:
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html:
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html:
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html:
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html:
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html:
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html:
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html:
* http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html:
* http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html:
* http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
* http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217605 => 217606)


--- trunk/LayoutTests/ChangeLog	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/ChangeLog	2017-05-31 16:58:53 UTC (rev 217606)
@@ -1,3 +1,27 @@
+2017-05-31  Brent Fulgham  <[email protected]>
+
+        Make ResourceLoadStatistics testing more reliable
+        https://bugs.webkit.org/show_bug.cgi?id=172730
+        <rdar://problem/32028373>
+
+        Reviewed by Andy Estes.
+
+        Revise some of the tests to wait to check state until after the background process has finished processing the
+        load information.
+
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html:
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html:
+        * http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html:
+        * http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html:
+        * http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
+        * http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
+
 2017-05-31  Claudio Saavedra  <[email protected]>
 
         [WPE] More CSS test expectations cleanup

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -12,7 +12,20 @@
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+
+    function completeTest() {
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -21,15 +34,9 @@
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host classified as prevalent resource.");
-        else
-            testPassed("Host did not get classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -12,7 +12,20 @@
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+
+    function completeTest() {
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -21,15 +34,10 @@
         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+        testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host classified as prevalent resource.");
-        else
-            testPassed("Host did not get classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -11,7 +11,20 @@
     const statisticsUrl = "http://" + hostUnderTest + "/temp";
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+
+    function completeTest() {
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ 
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -19,15 +32,9 @@
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host classified as prevalent resource.");
-        else
-            testPassed("Host did not get classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -11,16 +11,8 @@
     const statisticsUrl = "http://" + hostUnderTest + "/temp";
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
-    function runTestRunnerTest() {
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get set as non-prevalent resource.");
 
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
-        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
-
-        testRunner.statisticsFireDataModificationHandler();
-
+    function completeTest() {
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host classified as prevalent resource.");
         else
@@ -31,6 +23,21 @@
         testRunner.notifyDone();
     }
 
+    function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ 
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
+        testRunner.statisticsFireDataModificationHandler();
+    }
+
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
         testRunner.waitUntilDone();
         internals.setResourceLoadStatisticsEnabled(true);

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -13,7 +13,21 @@
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
     const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+
+    function completeTest() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();        
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ 
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -28,16 +42,9 @@
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get classified as prevalent resource.");
-        else
-            testPassed("Host classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -13,7 +13,21 @@
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
     const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+
+    function completeTest() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -23,16 +37,9 @@
         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get classified as prevalent resource.");
-        else
-            testPassed("Host classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -13,7 +13,21 @@
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
     const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+
+    function completeTest() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ 
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -23,16 +37,9 @@
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get classified as prevalent resource.");
-        else
-            testPassed("Host classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -13,7 +13,21 @@
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
     const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+
+    function completeTest() {
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ 
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -23,16 +37,9 @@
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host did not get classified as prevalent resource.");
-        else
-            testPassed("Host classified as prevalent resource.");
-
-        testRunner.statisticsResetToConsistentState();
-        internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -12,7 +12,34 @@
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+
+    function completeTest() {
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host is still a prevalent resource after the store was cleared.");
+        else
+            testPassed("Host is no longer a prevalent resource after the store was cleared.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    function testStep2() {
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testPassed("Host classified as prevalent resource.");
+        else
+            testFailed("Host did not get classified as prevalent resource.");
+
+        testRunner.clearTestRunnerCallbacks();
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+        testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
+
+        testRunner.statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(1);
+    }
+
     function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+
         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host did not get set as non-prevalent resource.");
@@ -25,23 +52,10 @@
         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
 
+        testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);
+        testRunner.installStatisticsDidModifyDataRecordsCallback(testStep2);
+
         testRunner.statisticsFireDataModificationHandler();
-
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testPassed("Host classified as prevalent resource.");
-        else
-            testFailed("Host did not get classified as prevalent resource.");
-
-        testRunner.statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(1);
-
-        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host is still a prevalent resource after the store was cleared.");
-        else
-            testPassed("Host is no longer a prevalent resource after the store was cleared.");
-
-        testRunner.statisticsResetToConsistentState();
-        internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
     }
 
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -12,28 +12,21 @@
     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
-    function runTestRunnerTest() {
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-        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.statisticsFireDataModificationHandler();
-
+    function testStep2() {
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testPassed("Host classified as prevalent resource.");
         else
             testFailed("Host did not get classified as prevalent resource.");
 
+        testRunner.clearTestRunnerCallbacks();
+        testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
+        testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
+
         testRunner.statisticsClearInMemoryAndPersistentStore();
+    }
 
+    function completeTest() {
         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
             testFailed("Host is still a prevalent resource after the store was cleared.");
         else
@@ -41,9 +34,30 @@
 
         testRunner.statisticsResetToConsistentState();
         internals.setResourceLoadStatisticsEnabled(false);
-        testRunner.notifyDone();
+        testRunner.notifyDone();        
     }
 
+    function runTestRunnerTest() {
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        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.installStatisticsDidScanDataRecordsCallback(testStep2);
+        testRunner.installStatisticsDidModifyDataRecordsCallback(testStep2);
+
+        testRunner.statisticsFireDataModificationHandler();
+    }
+
     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
         testRunner.waitUntilDone();
         internals.setResourceLoadStatisticsEnabled(true);

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -18,9 +18,9 @@
     const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName + "&name2=" + thirdPartyCookieName;
 
     function setEnableFeature(enable) {
-        if (!enable) {
+        if (!enable)
             testRunner.statisticsResetToConsistentState();
-        }
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(enable);
         internals.setResourceLoadStatisticsEnabled(enable);
         testRunner.setCookieStoragePartitioningEnabled(enable);
     }

Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html (217605 => 217606)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html	2017-05-31 16:58:53 UTC (rev 217606)
@@ -21,6 +21,7 @@
         if (!enable) {
             testRunner.statisticsResetToConsistentState();
         }
+        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(enable);
         internals.setResourceLoadStatisticsEnabled(enable);
         testRunner.setCookieStoragePartitioningEnabled(enable);
     }

Modified: trunk/Source/WebKit2/ChangeLog (217605 => 217606)


--- trunk/Source/WebKit2/ChangeLog	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-31 16:58:53 UTC (rev 217606)
@@ -1,3 +1,19 @@
+2017-05-31  Brent Fulgham  <[email protected]>
+
+        Make ResourceLoadStatistics testing more reliable
+        https://bugs.webkit.org/show_bug.cgi?id=172730
+        <rdar://problem/32028373>
+
+        Reviewed by Andy Estes.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed): Add a convenience method to notify the
+        WebProcess when the UIProcess has finished processing the load statistics data.
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): Notify clients (if they requested) when
+        statistics have been processed.
+
 2017-05-31  Simon Fraser  <[email protected]>
 
         Get <chrono> out of StdLibExtras.h

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (217605 => 217606)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-05-31 16:58:53 UTC (rev 217606)
@@ -322,7 +322,13 @@
         });
     }
 }
-
+    
+void WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
+{
+    for (auto& page : globalPageMap())
+        page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
+}
+    
 Ref<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
 {
     uint64_t pageID = generatePageID();

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (217605 => 217606)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-05-31 16:58:53 UTC (rev 217606)
@@ -143,6 +143,7 @@
     void deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, Function<void()> completionHandler);
     static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, std::function<void(Vector<String>)> completionHandler);
     static void topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, std::function<void(HashSet<String>&&)> completionHandler);
+    static void notifyPageStatisticsAndDataRecordsProcessed();
 
     void enableSuddenTermination();
     void disableSuddenTermination();

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (217605 => 217606)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-05-31 16:58:53 UTC (rev 217606)
@@ -139,7 +139,13 @@
             });
         }
         removeDataRecords();
-
+        
+        if (notifyPages) {
+            RunLoop::main().dispatch([] () mutable {
+                WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
+            });
+        }
+            
         writeStoreToDisk();
     });
 }

Modified: trunk/Tools/ChangeLog (217605 => 217606)


--- trunk/Tools/ChangeLog	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Tools/ChangeLog	2017-05-31 16:58:53 UTC (rev 217606)
@@ -1,3 +1,17 @@
+2017-05-31  Brent Fulgham  <[email protected]>
+
+        Make ResourceLoadStatistics testing more reliable
+        https://bugs.webkit.org/show_bug.cgi?id=172730
+        <rdar://problem/32028373>
+
+        Reviewed by Andy Estes.
+
+        When we tell the UIProcess (WebKitTestRunner) to notify the system about statistics update notifications,
+        we also need to tell the WebProcess to do so, too, or else the test system doesn't get messages.
+
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setStatisticsNotifyPagesWhenDataRecordsWereScanned):
+
 2017-05-31  Carlos Alberto Lopez Perez  <[email protected]>
 
         [GTK][WPE] run-_javascript_core-tests should use the jhbuild

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (217605 => 217606)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-05-31 16:13:59 UTC (rev 217605)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-05-31 16:58:53 UTC (rev 217606)
@@ -46,6 +46,7 @@
 #include <WebKit/WKBundleScriptWorld.h>
 #include <WebKit/WKData.h>
 #include <WebKit/WKPagePrivate.h>
+#include <WebKit/WKResourceLoadStatisticsManager.h>
 #include <WebKit/WKRetainPtr.h>
 #include <WebKit/WKSerializedScriptValue.h>
 #include <WebKit/WebKit2_C.h>
@@ -1430,6 +1431,7 @@
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsNotifyPagesWhenDataRecordsWereScanned"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+    WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned(value);
 }
 
 void TestRunner::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to