Changeset 233888 in webkit


Ignore:
Timestamp:
Jul 17, 2018 10:45:41 AM (6 years ago)
Author:
wilander@apple.com
Message:

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.

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:
Location:
trunk
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r233887 r233888  
     12018-07-17  John Wilander  <wilander@apple.com>
     2
     3        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
     4        https://bugs.webkit.org/show_bug.cgi?id=187710
     5        <rdar://problem/42252757>
     6
     7        Reviewed by Chris Dumez.
     8
     9        These changes are to update all test cases that make use of
     10        TestRunner functions:
     11        - setStatisticsLastSeen(),
     12        - setStatisticsPrevalentResource(),
     13        - setStatisticsVeryPrevalentResource(),
     14        - setStatisticsHasHadUserInteraction(), and
     15        - setStatisticsHasHadNonRecentUserInteraction().
     16
     17        * http/tests/resourceLoadStatistics/add-blocking-to-redirect.html:
     18        * http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html:
     19        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html:
     20        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html:
     21        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html:
     22        * http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html:
     23        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html:
     24        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html:
     25        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html:
     26        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html:
     27        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html:
     28        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html:
     29        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html:
     30        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html:
     31        * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html:
     32        * http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html:
     33        * http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html:
     34        * http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html:
     35        * http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html:
     36        * http/tests/resourceLoadStatistics/grandfathering.html:
     37        * http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html:
     38        * http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html:
     39        * http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html:
     40        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html:
     41        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt:
     42        * http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
     43        * http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html:
     44        * http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html:
     45        * http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html:
     46        * http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html:
     47        * http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
     48        * http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html:
     49        * http/tests/resourceLoadStatistics/prune-statistics.html:
     50        * http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html:
     51        * http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html:
     52        * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html:
     53        * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html:
     54        * http/tests/resourceLoadStatistics/telemetry-generation.html:
     55        * http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html:
     56        * http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html:
     57
    1582018-07-17  Ryan Haddad  <ryanhaddad@apple.com>
    259
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/add-blocking-to-redirect.html

    r233688 r233888  
    5959                // Set localhost as prevalent and with no user interaction to put it in the blocking category.
    6060                document.location.hash = "step5";
    61                 testRunner.setStatisticsPrevalentResource("http://localhost", true);
    62                 if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    63                     testFailed("Host did not get set as prevalent resource.");
    64                 testRunner.statisticsUpdateCookiePartitioning(function() {
    65                     runTest();
     61                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     62                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     63                        testFailed("Host did not get set as prevalent resource.");
     64                    testRunner.statisticsUpdateCookiePartitioning(function() {
     65                        runTest();
     66                    });
    6667                });
    6768                break;
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html

    r233688 r233888  
    5959                // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
    6060                document.location.hash = "step5";
    61                 testRunner.setStatisticsPrevalentResource("http://localhost", true);
    62                 if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    63                     testFailed("Host did not get set as prevalent resource.");
    64                 testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
    65                 testRunner.statisticsUpdateCookiePartitioning(function() {
    66                     runTest();
     61                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     62                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     63                        testFailed("Host did not get set as prevalent resource.");
     64                    testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost", function() {
     65                        testRunner.statisticsUpdateCookiePartitioning(function() {
     66                            runTest();
     67                        });
     68                    });
    6769                });
    6870                break;
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html

    r233688 r233888  
    2828        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    2929
    30         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    31         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    32             testFailed("Host did not get set as non-prevalent resource.");
     30        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     31            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     32                testFailed("Host did not get set as non-prevalent resource.");
    3333
    34         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    35         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    36         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
     34            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     35            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     36            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
    3737
    38         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     38            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    3939
    40         testRunner.statisticsProcessStatisticsAndDataRecords();
     40            testRunner.statisticsProcessStatisticsAndDataRecords();
     41        });
    4142    }
    4243
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html

    r233688 r233888  
    2828        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    2929
    30         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    31         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    32             testFailed("Host did not get set as non-prevalent resource.");
     30        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     31            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     32                testFailed("Host did not get set as non-prevalent resource.");
    3333
    34         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    35         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    36         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
     34            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     35            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     36            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
    3737
    38         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    39         testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
     38            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     39            testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
    4040
    41         testRunner.statisticsProcessStatisticsAndDataRecords();
     41            testRunner.statisticsProcessStatisticsAndDataRecords();
     42        });
    4243    }
    4344
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html

    r233688 r233888  
    2727        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    2828 
    29         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    30         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    31             testFailed("Host did not get set as non-prevalent resource.");
     29        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     30            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     31                testFailed("Host did not get set as non-prevalent resource.");
    3232
    33         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    34         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     33            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     34            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    3535
    36         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     36            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    3737
    38         testRunner.statisticsProcessStatisticsAndDataRecords();
     38            testRunner.statisticsProcessStatisticsAndDataRecords();
     39        });
    3940    }
    4041
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html

    r233688 r233888  
    2828        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    2929 
    30         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    31         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    32             testFailed("Host did not get set as non-prevalent resource.");
     30        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     31            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     32                testFailed("Host did not get set as non-prevalent resource.");
    3333
    34         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    35         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
     34            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     35            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
    3636
    37         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     37            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    3838
    39         testRunner.statisticsProcessStatisticsAndDataRecords();
     39            testRunner.statisticsProcessStatisticsAndDataRecords();
     40        });
    4041    }
    4142
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html

    r233688 r233888  
    3232        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3333 
    34         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    35         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    36             testFailed("Host did not get set as non-prevalent resource.");
     34        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     35            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     36                testFailed("Host did not get set as non-prevalent resource.");
    3737
    38         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    39         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
     38            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     39            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
    4040
    41         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    42         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
    43         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
     41            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     42            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
     43            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
    4444
    45         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
    46         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     45            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
     46            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    4747
    48         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     48            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    4949
    50         testRunner.statisticsProcessStatisticsAndDataRecords();
     50            testRunner.statisticsProcessStatisticsAndDataRecords();
     51        });
    5152    }
    5253
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html

    r233688 r233888  
    3232        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3333
    34         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    35         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    36             testFailed("Host did not get set as non-prevalent resource.");
     34        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     35            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     36                testFailed("Host did not get set as non-prevalent resource.");
    3737
    38         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    39         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    40         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
    41         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
     38            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     39            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     40            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
     41            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
    4242
    43         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     43            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    4444
    45         testRunner.statisticsProcessStatisticsAndDataRecords();
     45            testRunner.statisticsProcessStatisticsAndDataRecords();
     46        });
    4647    }
    4748
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html

    r233688 r233888  
    3434        testRunner.setStatisticsSubresourceUniqueRedirectFrom(subresourceOrigin3, subresourceOrigin4);
    3535
    36         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    37         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    38             testFailed("Host explicity set did not get set as prevalent resource.");
    39         if (testRunner.isStatisticsPrevalentResource(subresourceOrigin1))
    40             testPassed("Colluding host 1 got set as prevalent resource.");
    41         if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin1))
    42             testFailed("Colluding host 1 got classified as very prevalent resource.");
    43         if (testRunner.isStatisticsPrevalentResource(subresourceOrigin2))
    44             testPassed("Colluding host 2 got set as prevalent resource.");
    45         if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin2))
    46             testFailed("Colluding host 2 got classified as very prevalent resource.");
    47         if (testRunner.isStatisticsPrevalentResource(subresourceOrigin3))
    48             testPassed("Colluding host 3 got set as prevalent resource.");
    49         if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin3))
    50             testFailed("Colluding host 3 got classified as very prevalent resource.");
    51         if (testRunner.isStatisticsPrevalentResource(subresourceOrigin4))
    52             testPassed("Colluding host 4 got set as prevalent resource.");
    53         if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin4))
    54             testFailed("Colluding host 4 got classified as very prevalent resource.");
    55         if (testRunner.isStatisticsPrevalentResource("http://localhost:8000"))
    56             testPassed("Colluding localhost got set as prevalent resource after actual sub frame redirect.");
    57         if (testRunner.isStatisticsVeryPrevalentResource("http://localhost:8000"))
    58             testFailed("Colluding localhost got classified as very prevalent resource.");
     36        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     37            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     38                testFailed("Host explicity set did not get set as prevalent resource.");
     39            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin1))
     40                testPassed("Colluding host 1 got set as prevalent resource.");
     41            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin1))
     42                testFailed("Colluding host 1 got classified as very prevalent resource.");
     43            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin2))
     44                testPassed("Colluding host 2 got set as prevalent resource.");
     45            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin2))
     46                testFailed("Colluding host 2 got classified as very prevalent resource.");
     47            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin3))
     48                testPassed("Colluding host 3 got set as prevalent resource.");
     49            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin3))
     50                testFailed("Colluding host 3 got classified as very prevalent resource.");
     51            if (testRunner.isStatisticsPrevalentResource(subresourceOrigin4))
     52                testPassed("Colluding host 4 got set as prevalent resource.");
     53            if (testRunner.isStatisticsVeryPrevalentResource(subresourceOrigin4))
     54                testFailed("Colluding host 4 got classified as very prevalent resource.");
     55            if (testRunner.isStatisticsPrevalentResource("http://localhost:8000"))
     56                testPassed("Colluding localhost got set as prevalent resource after actual sub frame redirect.");
     57            if (testRunner.isStatisticsVeryPrevalentResource("http://localhost:8000"))
     58                testFailed("Colluding localhost got classified as very prevalent resource.");
    5959
    60         setEnableFeature(false, finishJSTest);
     60            setEnableFeature(false, finishJSTest);
     61        });
    6162    }
    6263
    6364    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
    6465        setEnableFeature(true, function () {
    65             testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    66             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    67                 testFailed("Host did not get set as non-prevalent resource.");
    68 
     66            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     67                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     68                    testFailed("Host did not get set as non-prevalent resource.");
     69                let iframeElement = document.createElement("iframe");
     70                iframeElement.onload = runTest;
     71                iframeElement.src = "http://localhost:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/onclick.html";
     72                document.body.appendChild(iframeElement);
     73            });
    6974        });
    7075    }
    7176</script>
    72 <iframe onload="runTest()" src="http://localhost:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/onclick.html"></iframe>
    7377</body>
    7478</html>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html

    r233688 r233888  
    3535
    3636    function runTest() {
    37         testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true);
    38         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     37        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() {
     38            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    3939
    40         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    41         testRunner.statisticsProcessStatisticsAndDataRecords();
     40            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     41            testRunner.statisticsProcessStatisticsAndDataRecords();
     42        });
    4243    }
    4344
     
    4647            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    4748
    48             testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    49             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    50                 testFailed("Host did not get set as non-prevalent resource.");
    51             runTest();
     49            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     50                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     51                    testFailed("Host did not get set as non-prevalent resource.");
     52                runTest();
     53            });
    5254        });
    5355    }
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html

    r233688 r233888  
    3232        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3333 
    34         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    35         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    36             testFailed("Host did not get set as non-prevalent resource.");
     34        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     35            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     36                testFailed("Host did not get set as non-prevalent resource.");
    3737
    38         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    39         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    40         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
    41         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
     38            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     39            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     40            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
     41            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
    4242
    43         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     43            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    4444
    45         testRunner.statisticsProcessStatisticsAndDataRecords();
     45            testRunner.statisticsProcessStatisticsAndDataRecords();
     46        });
    4647    }
    4748
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html

    r233688 r233888  
    3232        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3333 
    34         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    35         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    36             testFailed("Host did not get set as non-prevalent resource.");
     34        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     35            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     36                testFailed("Host did not get set as non-prevalent resource.");
    3737
    38         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    39         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
    40         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
    41         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
     38            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     39            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
     40            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
     41            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
    4242
    43         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     43            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    4444
    45         testRunner.statisticsProcessStatisticsAndDataRecords();
     45            testRunner.statisticsProcessStatisticsAndDataRecords();
     46        });
    4647    }
    4748
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html

    r233688 r233888  
    3333        testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin3, topFrameOrigin4);
    3434
    35         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    36         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    37             testFailed("Host explicity set did not get set as prevalent resource.");
    38         if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
    39             testPassed("Colluding host 1 got set as prevalent resource.");
    40         if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
    41             testFailed("Colluding host 1 got classified as very prevalent resource.");
    42         if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
    43             testPassed("Colluding host 2 got set as prevalent resource.");
    44         if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
    45             testFailed("Colluding host 2 got classified as very prevalent resource.");
    46         if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
    47             testPassed("Colluding host 3 got set as prevalent resource.");
    48         if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
    49             testFailed("Colluding host 3 got classified as very prevalent resource.");
    50         if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
    51             testPassed("Colluding host 4 got set as prevalent resource.");
    52         if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
    53             testFailed("Colluding host 4 got classified as very prevalent resource.");
    54         if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
    55             testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
    56         if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
    57             testFailed("Colluding localhost got classified as very prevalent resource.");
     35        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     36            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     37                testFailed("Host explicity set did not get set as prevalent resource.");
     38            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
     39                testPassed("Colluding host 1 got set as prevalent resource.");
     40            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
     41                testFailed("Colluding host 1 got classified as very prevalent resource.");
     42            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
     43                testPassed("Colluding host 2 got set as prevalent resource.");
     44            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
     45                testFailed("Colluding host 2 got classified as very prevalent resource.");
     46            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
     47                testPassed("Colluding host 3 got set as prevalent resource.");
     48            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
     49                testFailed("Colluding host 3 got classified as very prevalent resource.");
     50            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
     51                testPassed("Colluding host 4 got set as prevalent resource.");
     52            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
     53                testFailed("Colluding host 4 got classified as very prevalent resource.");
     54            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
     55                testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
     56            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
     57                testFailed("Colluding localhost got classified as very prevalent resource.");
    5858
    59         setEnableFeature(false, finishJSTest);
     59            setEnableFeature(false, finishJSTest);
     60        });
    6061    }
    6162
    6263    if (document.location.hash === "" && window.testRunner && window.internals) {
    6364        setEnableFeature(true, function() {
    64             testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    65             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    66                 testFailed("Host did not get set as non-prevalent resource.");
     65            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     66                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     67                    testFailed("Host did not get set as non-prevalent resource.");
    6768
    68             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";
     69                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";
     70            });
    6971        });
    7072    } else {
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html

    r233688 r233888  
    3535
    3636    function runTest() {
    37         testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true);
    38         testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     37        testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() {
     38            testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    3939
    40         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    41         testRunner.statisticsProcessStatisticsAndDataRecords();
     40            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     41            testRunner.statisticsProcessStatisticsAndDataRecords();
     42        });
    4243    }
    4344
     
    4647            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    4748
    48             testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    49             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    50                 testFailed("Host did not get set as non-prevalent resource.");
    51             runTest();
     49            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     50                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     51                    testFailed("Host did not get set as non-prevalent resource.");
     52                runTest();
     53            });
    5254        });
    5355    }
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html

    r233688 r233888  
    5252            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    5353
    54             testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    55             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    56                 testFailed("Host did not get set as non-prevalent resource.");
    57             runTest();
     54            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     55                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     56                    testFailed("Host did not get set as non-prevalent resource.");
     57                runTest();
     58            });
    5859        });
    5960    }
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html

    r233688 r233888  
    4141        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    4242 
    43         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    44         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    45             testFailed("Host started out as prevalent resource.");
     43        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     44            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     45                testFailed("Host started out as prevalent resource.");
    4646
    47         var i = 0;
    48         while (i < numberOfSubresourceDomains) {
    49             testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
    50             testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
    51             testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i]);
     47            var i = 0;
     48            while (i < numberOfSubresourceDomains) {
     49                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
     50                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
     51                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i]);
    5252
    53             testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
    54             testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
    55             testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+1]);
     53                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
     54                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
     55                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+1]);
    5656
    57             testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
    58             testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
    59             testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+2]);
    60             i += 3;
    61         }
     57                testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
     58                testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
     59                testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+2]);
     60                i += 3;
     61            }
    6262
    63         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
    64         testRunner.statisticsProcessStatisticsAndDataRecords();
     63            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
     64            testRunner.statisticsProcessStatisticsAndDataRecords();
     65        });
    6566    }
    6667
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html

    r233688 r233888  
    3838        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3939
    40         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
     40        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {});
    4141        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    4242            testFailed("Host did not get set as non-prevalent resource.");
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html

    r233688 r233888  
    3838        testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    3939
    40         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    41         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    42             testFailed("Host did not get set as non-prevalent resource.");
     40        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     41            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     42                testFailed("Host did not get set as non-prevalent resource.");
    4343
    44         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    45         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
    46         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
    47         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    48         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
    49         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
    50         testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
     44            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     45            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
     46            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
     47            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     48            testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
     49            testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
     50            testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
    5151
    52         testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);
     52            testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);
    5353
    54         testRunner.statisticsProcessStatisticsAndDataRecords();
     54            testRunner.statisticsProcessStatisticsAndDataRecords();
     55        });
    5556    }
    5657
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html

    r231008 r233888  
    1313    function doRedirect()
    1414    {
    15         testRunner.setStatisticsPrevalentResource("http://localhost", true);
    16         if (!testRunner.isStatisticsPrevalentResource("http://localhost")) {
    17             testFailed("Host did not get set as prevalent resource.");
    18             finishJSTest();
    19         }
    20         else
    21             window.location = "http://localhost:8000/cookies/resources/set-cookie-on-redirect.php?step=1";
     15        testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     16            if (!testRunner.isStatisticsPrevalentResource("http://localhost")) {
     17                testFailed("Host did not get set as prevalent resource.");
     18                finishJSTest();
     19            }
     20            else
     21                window.location = "http://localhost:8000/cookies/resources/set-cookie-on-redirect.php?step=1";
     22        });
    2223    }
    2324</script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/grandfathering.html

    r233688 r233888  
    6969                document.location.hash = "step5";
    7070                // Set localhost as prevalent resource.
    71                 testRunner.setStatisticsPrevalentResource("http://localhost", true);
    72                 if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    73                     testFailed("Localhost did not get set as prevalent resource.");
    74                 runTest();
     71                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     72                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     73                        testFailed("Localhost did not get set as prevalent resource.");
     74                    runTest();
     75                });
    7576                break;
    7677            case "#step5":
     
    8182                document.location.hash = "step7";
    8283                // Set 127.0.0.1 as prevalent resource
    83                 testRunner.setStatisticsPrevalentResource("http://127.0.0.1", true);
    84                 if (!testRunner.isStatisticsPrevalentResource("http://127.0.0.1"))
    85                     testFailed("127.0.0.1 did not get set as prevalent resource.");
    86                 runTest();
     84                testRunner.setStatisticsPrevalentResource("http://127.0.0.1", true, function() {
     85                    if (!testRunner.isStatisticsPrevalentResource("http://127.0.0.1"))
     86                        testFailed("127.0.0.1 did not get set as prevalent resource.");
     87                    runTest();
     88                });
    8789                break;
    8890            case "#step7":
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html

    r233688 r233888  
    2929            testFailed("document.cookie did not get set.");
    3030
    31         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    32         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    33             testFailed("Host did not get set as non-prevalent resource.");
     31        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     32            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     33                testFailed("Host did not get set as non-prevalent resource.");
    3434
    35         // This is done to not have an empty set of prevalent resources.
    36         // Otherwise data records are never scanned.
    37         testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
    38         if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
    39             testFailed("Other host did not get set as prevalent resource.");
     35            // This is done to not have an empty set of prevalent resources.
     36            // Otherwise data records are never scanned.
     37            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
     38                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
     39                    testFailed("Other host did not get set as prevalent resource.");
    4040
    41         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
    42         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    43             testFailed("Host did not get logged for user interaction.");
     41                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
     42                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     43                        testFailed("Host did not get logged for user interaction.");
    4444
    45         testRunner.installStatisticsDidScanDataRecordsCallback(function() {
    46             if (document.cookie === cookie)
    47                 testPassed("Cookie not deleted.");
    48             else
    49                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
     45                    testRunner.installStatisticsDidScanDataRecordsCallback(function() {
     46                        if (document.cookie === cookie)
     47                            testPassed("Cookie not deleted.");
     48                        else
     49                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
    5050
    51             setEnableFeature(false, function() {
    52                 testRunner.notifyDone();
     51                        setEnableFeature(false, function() {
     52                            testRunner.notifyDone();
     53                        });
     54                    });
     55                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     56                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     57                    testRunner.statisticsProcessStatisticsAndDataRecords();
     58                });
    5359            });
    5460        });
    55         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    56         testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    57         testRunner.statisticsProcessStatisticsAndDataRecords();
    5861    }
    5962
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html

    r233688 r233888  
    2929            testFailed("document.cookie did not get set.");
    3030
    31         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
    32         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
    33             testFailed("Host did not get set as non-prevalent resource.");
     31        testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
     32            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
     33                testFailed("Host did not get set as non-prevalent resource.");
    3434
    35         // This is done to not have an empty set of prevalent resources.
    36         // Otherwise data records are never scanned.
    37         testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
    38         if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
    39             testFailed("Other host did not get set as prevalent resource.");
     35            // This is done to not have an empty set of prevalent resources.
     36            // Otherwise data records are never scanned.
     37            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
     38                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
     39                    testFailed("Other host did not get set as prevalent resource.");
    4040
    41         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
    42         if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    43             testFailed("Host did not get cleared of user interaction.");
     41                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
     42                    if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     43                        testFailed("Host did not get cleared of user interaction.");
    4444
    45         testRunner.installStatisticsDidScanDataRecordsCallback(function() {
    46             if (document.cookie === cookie)
    47                 testPassed("Cookie not deleted.");
    48             else
    49                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
     45                    testRunner.installStatisticsDidScanDataRecordsCallback(function() {
     46                        if (document.cookie === cookie)
     47                            testPassed("Cookie not deleted.");
     48                        else
     49                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
    5050
    51             setEnableFeature(false, function() {
    52                 testRunner.notifyDone();
     51                        setEnableFeature(false, function() {
     52                            testRunner.notifyDone();
     53                        });
     54                    });
     55                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     56                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     57                    testRunner.statisticsProcessStatisticsAndDataRecords();
     58                });
    5359            });
    5460        });
    55         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    56         testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    57         testRunner.statisticsProcessStatisticsAndDataRecords();
    5861    }
    5962
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html

    r233688 r233888  
    4545
    4646    function setUserInteractionAndContinue() {
    47         testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
    48         if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
    49             testFailed("Third party did not get logged for user interaction.");
    50         runTest();
     47        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
     48            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
     49                testFailed("Third party did not get logged for user interaction.");
     50            runTest();
     51        });
    5152    }
    5253
     
    7879                break;
    7980            case "#step6":
    80                 // Load localhost under 127.0.0.1 and check that it gets its non-partitioned cookie after user interaction.
     81                // Load localhost under 127.0.0.1 and check that it still gets partitioned cookie after user interaction.
    8182                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After user interaction, should still only receive one partitioned, third party cookie.", finishTest);
    8283                break;
     
    8586
    8687    if (document.location.host === partitionHost && document.location.hash == "" && window.testRunner && window.internals) {
     88        testRunner.waitUntilDone();
     89        testRunner.dumpChildFramesAsText();
    8790        setEnableFeature(true, function() {
    88             testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false);
    89             testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false);
    90             testRunner.waitUntilDone();
    91             testRunner.dumpChildFramesAsText();
    92             document.location.hash = "step1";
     91            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false, function() {
     92                testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false, function() {
     93                    document.location.hash = "step1";
    9394
    94             testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
     95                    testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
     96                });
     97            });
    9598        });
    9699    } else {
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html

    r233688 r233888  
    5252
    5353    function setUserInteractionAndContinue() {
    54         testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
    55         if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
    56             testFailed("Third party did not get logged for user interaction.");
    57         runTest();
     54        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
     55            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
     56                testFailed("Third party did not get logged for user interaction.");
     57            runTest();
     58        });
    5859    }
    5960
     
    9798            document.location.hash = "step1";
    9899
    99             testRunner.setStatisticsPrevalentResource("http://localhost", true);
    100             if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    101                 testFailed("Host did not get set as prevalent resource.");
     100            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     101                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     102                    testFailed("Host did not get set as prevalent resource.");
    102103
    103             testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest);
     104                testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest);
     105            });
    104106        });
    105107    } else {
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout-expected.txt

    r233688 r233888  
    1 CONSOLE MESSAGE: line 117: Bootstrapping test.
    2 CONSOLE MESSAGE: line 68: Step 1.
    3 CONSOLE MESSAGE: line 73: Step 2.
    4 CONSOLE MESSAGE: line 80: Step 3.
    5 CONSOLE MESSAGE: line 87: Step 4.
    6 CONSOLE MESSAGE: line 57: setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().
    7 CONSOLE MESSAGE: line 94: Step 5.
    8 CONSOLE MESSAGE: line 51: setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue().
    9 CONSOLE MESSAGE: line 46: fireShouldPartitionCookiesHandlerAndContinue().
    10 CONSOLE MESSAGE: line 101: Step 6.
    11 CONSOLE MESSAGE: line 57: setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().
    12 CONSOLE MESSAGE: line 108: Step 7.
    131PASS successfullyParsed is true
    142
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html

    r233688 r233888  
    4444
    4545    function fireShouldPartitionCookiesHandlerAndContinue() {
    46         console.log("fireShouldPartitionCookiesHandlerAndContinue().");
    4746        testRunner.statisticsUpdateCookiePartitioning(runTest);
    4847    }
    4948
    5049    function setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue() {
    51         console.log("setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue().");
    5250        testRunner.setStatisticsTimeToLiveCookiePartitionFree(1);
    5351        setTimeout(fireShouldPartitionCookiesHandlerAndContinue, 2000);
     
    5553
    5654    function setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue() {
    57         console.log("setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().");
    5855        testRunner.setStatisticsTimeToLiveCookiePartitionFree(86400);
    59         testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
    60         if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
    61             testFailed("Third party did not get logged for user interaction.");
    62         runTest();
     56        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
     57            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
     58                testFailed("Third party did not get logged for user interaction.");
     59            runTest();
     60        });
    6361    }
    6462
     
    6664        switch (document.location.hash) {
    6765            case "#step1":
    68                 console.log("Step 1.");
    6966                // Set first-party cookie for http://localhost:8000
    7067                document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + fragmentWithReturnUrl + "#step2";
    7168                break;
    7269            case "#step2":
    73                 console.log("Step 2.");
    7470                // Check that the first-party cookie is not sent in partition 127.0.0.1:8000
    7571                document.location.hash = "step3";
     
    7874                break;
    7975            case "#step3":
    80                 console.log("Step 3.");
    8176                // Set third-party cookie for http://localhost:8000 in partition 127.0.0.1:8000
    8277                document.location.hash = "step4";
     
    8580                break;
    8681            case "#step4":
    87                 console.log("Step 4.");
    8882                // Check that only partitioned cookie get sent in partition 127.0.0.1:8000
    8983                document.location.hash = "step5";
     
    9286                break;
    9387            case "#step5":
    94                 console.log("Step 5.");
    9588                // http://localhost:8000 now has user interaction, check that un-partitioned cookie is sent for third-party
    9689                document.location.hash = "step6";
     
    9992                break;
    10093            case "#step6":
    101                 console.log("Step 6.");
    10294                // Cookie partitioning should be applied again
    10395                document.location.hash = "step7";
     
    10698                break;
    10799            case "#step7":
    108                 console.log("Step 7.");
    109100                // http://localhost:8000 now has fresh user interaction, check that un-partitioned cookie is sent for third-party
    110101                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After second user interaction, should still only receive a partitioned, third-party cookie.",
     
    115106
    116107    if (document.location.hash === "" && window.testRunner && window.internals) {
    117         console.log("Bootstrapping test.");
     108        testRunner.waitUntilDone();
     109        testRunner.dumpChildFramesAsText();
    118110        setEnableFeature(true, function() {
    119111            // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
    120             testRunner.setStatisticsPrevalentResource("http://localhost", true);
    121             if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    122                 testFailed("Host did not get set as prevalent resource.");
    123             testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
     112            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     113                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     114                    testFailed("Host did not get set as prevalent resource.");
     115                testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
    124116
    125             testRunner.statisticsUpdateCookiePartitioning();
     117                testRunner.statisticsUpdateCookiePartitioning();
    126118
    127             testRunner.waitUntilDone();
    128             testRunner.dumpChildFramesAsText();
    129             document.location.hash = "step1";
     119                document.location.hash = "step1";
    130120
    131             runTest();
     121                runTest();
     122            });
    132123        });
    133124    } else
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html

    r233688 r233888  
    4444
    4545    function setUserInteractionAndContinue() {
    46         testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
    47         if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
    48             testFailed("Third party did not get logged for user interaction.");
    49         runTest();
     46        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
     47            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
     48                testFailed("Third party did not get logged for user interaction.");
     49            runTest();
     50        });
    5051    }
    5152
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html

    r233688 r233888  
    1717    }
    1818
    19     testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    20     if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    21         testFailed("Host did not get set as prevalent resource.");
     19    testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     20        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     21            testFailed("Host did not get set as prevalent resource.");
    2222
    23     testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
    24     if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    25         testFailed("Host did not get cleared of user interaction.");
     23        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
     24            if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     25                testFailed("Host did not get cleared of user interaction.");
    2626
    27     testInput = document.getElementById("testInput");
     27            testInput = document.getElementById("testInput");
    2828
    29     testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
    30         shouldBeEqualToString("testInput.value", "a");
     29            testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
     30                shouldBeEqualToString("testInput.value", "a");
    3131
    32         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    33             testFailed("Origin did not get user interaction credit.");
    34         else
    35             testPassed("Origin was granted user interaction.");
     32                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     33                    testFailed("Origin did not get user interaction credit.");
     34                else
     35                    testPassed("Origin was granted user interaction.");
    3636
    37         setTimeout(function() {
    38             testFrame.src = "about:blank";
    39             setTimeout(function() {
    40                 testRunner.statisticsResetToConsistentState(function() {
    41                     finishJSTest();
    42                 });
    43             }, 0);
    44         }, 0);
     37                setTimeout(function() {
     38                    testFrame.src = "about:blank";
     39                    setTimeout(function() {
     40                        testRunner.statisticsResetToConsistentState(function() {
     41                            finishJSTest();
     42                        });
     43                    }, 0);
     44                }, 0);
     45            });
     46            testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     47            testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     48            testRunner.statisticsProcessStatisticsAndDataRecords();
     49
     50            debug("Simulate user typing letter 'a' into the field.");
     51            testInput.focus();
     52            if (window.eventSender)
     53                eventSender.keyDown("a");
     54        });
    4555    });
    46     testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    47     testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    48     testRunner.statisticsProcessStatisticsAndDataRecords();
    49 
    50     debug("Simulate user typing letter 'a' into the field.");
    51     testInput.focus();
    52     if (window.eventSender)
    53         eventSender.keyDown("a");   
    5456}
    5557</script>
    5658<iframe id="testFrame" src="resources/onclick.html"></iframe>
    57 <input id="testInput" type="text"></input>
     59<input id="testInput" type="text">
    5860</body>
    5961</html>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html

    r233688 r233888  
    1717    }
    1818
    19     testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    20     if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    21         testFailed("Host did not get set as prevalent resource.");
     19    testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     20        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     21            testFailed("Host did not get set as prevalent resource.");
    2222
    23     testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
    24     if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    25         testFailed("Host did not get cleared of user interaction.");
     23        testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
     24            if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     25                testFailed("Host did not get cleared of user interaction.");
    2626
    27     testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
     27            testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
    2828
    29         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    30             testPassed("Origin did not get user interaction credit.");
     29                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     30                    testPassed("Origin did not get user interaction credit.");
    3131
    32         setTimeout(function() {
    33             testFrame.src = "about:blank";
    34             setTimeout(function() {
    35                 testRunner.statisticsResetToConsistentState(function() {
    36                     finishJSTest();
    37                 });
    38             }, 0);
    39         }, 0);
     32                setTimeout(function() {
     33                    testFrame.src = "about:blank";
     34                    setTimeout(function() {
     35                        testRunner.statisticsResetToConsistentState(function() {
     36                            finishJSTest();
     37                        });
     38                    }, 0);
     39                }, 0);
     40            });
     41            testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     42            testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     43            testRunner.statisticsProcessStatisticsAndDataRecords();
     44
     45            debug("Simulate an unhandled user key press.");
     46            if (window.eventSender)
     47                eventSender.keyDown("a", ["metaKey"]);
     48        });
    4049    });
    41     testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    42     testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    43     testRunner.statisticsProcessStatisticsAndDataRecords();
    44 
    45     debug("Simulate an unhandled user key press.");
    46     if (window.eventSender)
    47         eventSender.keyDown("a", ["metaKey"]);   
    4850}
    4951</script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html

    r233688 r233888  
    1818            testFailed("document.cookie did not get set.");
    1919
    20         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    21         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    22             testFailed("Host did not get set as prevalent resource.");
     20        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     21            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     22                testFailed("Host did not get set as prevalent resource.");
    2323
    24         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
    25         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    26             testFailed("Host did not get logged for user interaction.");
     24            testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
     25                if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     26                    testFailed("Host did not get logged for user interaction.");
    2727
    28         testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
    29             if (document.cookie !== "")
    30                 testFailed("Cookie not deleted: " + document.cookie);
    31             else
    32                 testPassed("Cookie deleted.");
    33             internals.setResourceLoadStatisticsEnabled(false);
    34             testRunner.statisticsResetToConsistentState(function() {
    35                 testRunner.notifyDone();
     28                testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
     29                    if (document.cookie !== "")
     30                        testFailed("Cookie not deleted: " + document.cookie);
     31                    else
     32                        testPassed("Cookie deleted.");
     33                    internals.setResourceLoadStatisticsEnabled(false);
     34                    testRunner.statisticsResetToConsistentState(function() {
     35                        testRunner.notifyDone();
     36                    });
     37                });
     38                testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     39                testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     40                testRunner.setStatisticsTimeToLiveUserInteraction(0);
     41
     42                // This is to ensure the timeout we're testing.
     43                setTimeout("testRunner.statisticsProcessStatisticsAndDataRecords()", 1000);
    3644            });
    3745        });
    38         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    39         testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    40         testRunner.setStatisticsTimeToLiveUserInteraction(0);
    41         setTimeout("testRunner.statisticsProcessStatisticsAndDataRecords()", 1000);
    4246    }
    4347
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html

    r233688 r233888  
    1919            testFailed("document.cookie did not get set.");
    2020
    21         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    22         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    23             testFailed("Host did not get set as prevalent resource.");
     21        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     22            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     23                testFailed("Host did not get set as prevalent resource.");
    2424
    25         // This is done to not have an empty set of prevalent resources.
    26         // Otherwise data records are never scanned.
    27         testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true);
    28         if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
    29             testFailed("Other host did not get set as prevalent resource.");
     25            // This is done to not have an empty set of prevalent resources.
     26            // Otherwise data records are never scanned.
     27            testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
     28                if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
     29                    testFailed("Other host did not get set as prevalent resource.");
    3030
    31         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
    32         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    33             testFailed("Host did not get logged for user interaction.");
     31                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
     32                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     33                        testFailed("Host did not get logged for user interaction.");
    3434
    35         testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
    36             if (document.cookie === cookie)
    37                 testPassed("Cookie not deleted.");
    38             else
    39                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
    40             internals.setResourceLoadStatisticsEnabled(false);
    41             testRunner.statisticsResetToConsistentState(function() {
    42                 testRunner.notifyDone();
     35                    testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
     36                        if (document.cookie === cookie)
     37                            testPassed("Cookie not deleted.");
     38                        else
     39                            testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
     40                        internals.setResourceLoadStatisticsEnabled(false);
     41                        testRunner.statisticsResetToConsistentState(function() {
     42                            testRunner.notifyDone();
     43                        });
     44                    });
     45                    testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     46                    testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     47                    testRunner.statisticsProcessStatisticsAndDataRecords();
     48                });
    4349            });
    4450        });
    45         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    46         testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    47         testRunner.statisticsProcessStatisticsAndDataRecords();
    4851    }
    4952
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html

    r233688 r233888  
    3030            testFailed("document.cookie did not get set.");
    3131
    32         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
    33         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
    34             testFailed("Host did not get set as prevalent resource.");
     32        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
     33            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
     34                testFailed("Host did not get set as prevalent resource.");
    3535
    36         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
    37         if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
    38             testFailed("Host did not get cleared of user interaction.");
     36            testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() {
     37                if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
     38                    testFailed("Host did not get cleared of user interaction.");
    3939
    40         testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
    41             setTimeout("finishTest()", 1000);
     40                testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
     41                    setTimeout("finishTest()", 1000);
     42                });
     43                testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
     44                testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
     45                testRunner.statisticsProcessStatisticsAndDataRecords();
     46            });
    4247        });
    43         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
    44         testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
    45         testRunner.statisticsProcessStatisticsAndDataRecords();
    4648    }
    4749
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/prune-statistics.html

    r233688 r233888  
    5656    }
    5757
    58     function initializeStatistics() {
    59         testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
    60 
    61         // Non-prevalent without user interaction to be pruned first.
    62         testRunner.setStatisticsLastSeen(urlsToBePruned[0].url, olderTimestamp);
    63         testRunner.setStatisticsLastSeen(urlsToBePruned[1].url, newerTimestamp);
    64 
    65         // Prevalent without user interaction to be pruned second.
    66         testRunner.setStatisticsPrevalentResource(urlsToBePruned[2].url, true);
    67         testRunner.setStatisticsLastSeen(urlsToBePruned[2].url, olderTimestamp);
    68         testRunner.setStatisticsPrevalentResource(urlsToBePruned[3].url, true);
    69         testRunner.setStatisticsLastSeen(urlsToBePruned[3].url, newerTimestamp);
    70 
    71         // Non-prevalent with user interaction to be pruned third.
    72         testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[4].url, true);
    73         testRunner.setStatisticsLastSeen(urlsToBePruned[4].url, olderTimestamp);
    74         testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[5].url, true);
    75         testRunner.setStatisticsLastSeen(urlsToBePruned[5].url, newerTimestamp);
    76 
    77         // Prevalent with user interaction to be pruned last.
    78         testRunner.setStatisticsPrevalentResource(urlsToBePruned[6].url, true);
    79         testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[6].url, true);
    80         testRunner.setStatisticsLastSeen(urlsToBePruned[6].url, olderTimestamp);
    81         testRunner.setStatisticsPrevalentResource(urlsToBePruned[7].url, true);
    82         testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[7].url, true);
    83         testRunner.setStatisticsLastSeen(urlsToBePruned[7].url, newerTimestamp);
    84 
    85         checkIfPrevalentAccordingToInitialExpectation(0, urlsToBePruned.length);
     58    function initializeStatisticsAndRunTests(step) {
     59        switch (step) {
     60            // Non-prevalent without user interaction to be pruned first.
     61            case 1:
     62                testRunner.setStatisticsLastSeen(urlsToBePruned[0].url, olderTimestamp, function() { initializeStatisticsAndRunTests(2); });
     63                break;
     64            case 2:
     65                testRunner.setStatisticsLastSeen(urlsToBePruned[1].url, newerTimestamp, function() { initializeStatisticsAndRunTests(3); });
     66                break;
     67            // Prevalent without user interaction to be pruned second.
     68            case 3:
     69                testRunner.setStatisticsPrevalentResource(urlsToBePruned[2].url, true, function() { initializeStatisticsAndRunTests(4); });
     70                break;
     71            case 4:
     72                testRunner.setStatisticsLastSeen(urlsToBePruned[2].url, olderTimestamp, function() { initializeStatisticsAndRunTests(5); });
     73                break;
     74            case 5:
     75                testRunner.setStatisticsPrevalentResource(urlsToBePruned[3].url, true, function() { initializeStatisticsAndRunTests(6); });
     76                break;
     77            case 6:
     78                testRunner.setStatisticsLastSeen(urlsToBePruned[3].url, newerTimestamp, function() { initializeStatisticsAndRunTests(7); });
     79                break;
     80            // Non-prevalent with user interaction to be pruned third.
     81            case 7:
     82                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[4].url, true, function() { initializeStatisticsAndRunTests(8); });
     83                break;
     84            case 8:
     85                testRunner.setStatisticsLastSeen(urlsToBePruned[4].url, olderTimestamp, function() { initializeStatisticsAndRunTests(9); });
     86                break;
     87            case 9:
     88                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[5].url, true, function() { initializeStatisticsAndRunTests(10); });
     89                break;
     90            case 10:
     91                testRunner.setStatisticsLastSeen(urlsToBePruned[5].url, newerTimestamp, function() { initializeStatisticsAndRunTests(11); });
     92                break;
     93            // Prevalent with user interaction to be pruned last.
     94            case 11:
     95                testRunner.setStatisticsPrevalentResource(urlsToBePruned[6].url, true, function() { initializeStatisticsAndRunTests(12); });
     96                break;
     97            case 12:
     98                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[6].url, true, function() { initializeStatisticsAndRunTests(13); });
     99                break;
     100            case 13:
     101                testRunner.setStatisticsLastSeen(urlsToBePruned[6].url, olderTimestamp, function() { initializeStatisticsAndRunTests(14); });
     102                break;
     103            case 14:
     104                testRunner.setStatisticsPrevalentResource(urlsToBePruned[7].url, true, function() { initializeStatisticsAndRunTests(15); });
     105                break;
     106            case 15:
     107                testRunner.setStatisticsHasHadUserInteraction(urlsToBePruned[7].url, true, function() { initializeStatisticsAndRunTests(16); });
     108                break;
     109            case 16:
     110                testRunner.setStatisticsLastSeen(urlsToBePruned[7].url, newerTimestamp, function() { initializeStatisticsAndRunTests(17); });
     111                break;
     112            case 17:
     113                checkIfPrevalentAccordingToInitialExpectation(0, urlsToBePruned.length);
     114                runTest();
     115                break;
     116        }
    86117    }
    87118
     
    95126        if (currentTest < urlsToBePruned.length) {
    96127            ++currentTest;
    97             runTest();
     128            testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
     129            initializeStatisticsAndRunTests(1);
    98130        } else {
    99131            testRunner.statisticsResetToConsistentState(function() {
     
    103135    }
    104136
     137    let fillerUrl;
    105138    function runTest() {
    106         initializeStatistics();
    107 
    108         var fillerUrl = "http://127.0." + currentTest + ".1:8000/temp";
    109         testRunner.setStatisticsPrevalentResource(fillerUrl, true);
    110         testRunner.setStatisticsHasHadUserInteraction(fillerUrl, true);
    111         testRunner.setStatisticsLastSeen(fillerUrl, newestTimestamp);
    112         testRunner.statisticsProcessStatisticsAndDataRecords();
     139        fillerUrl = "http://127.0." + currentTest + ".1:8000/temp";
     140        testRunner.setStatisticsPrevalentResource(fillerUrl, true, function() {
     141            testRunner.setStatisticsHasHadUserInteraction(fillerUrl, true, function() {
     142                testRunner.setStatisticsLastSeen(fillerUrl, newestTimestamp, function() {
     143                    testRunner.statisticsProcessStatisticsAndDataRecords();
     144                });
     145            });
     146        });
    113147    }
    114148
     
    121155
    122156        currentTest = 1;
    123         runTest();
     157        testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning);
     158        initializeStatisticsAndRunTests(1);
    124159    }
    125160</script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html

    r233688 r233888  
    6060                // Set localhost as prevalent and with non-recent user interaction to put it in the blocking category.
    6161                document.location.hash = "step5";
    62                 testRunner.setStatisticsPrevalentResource("http://localhost", true);
    63                 if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    64                     testFailed("Host did not get set as prevalent resource.");
    65                 testRunner.statisticsUpdateCookiePartitioning(function() {
    66                     runTest();
     62                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     63                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     64                        testFailed("Host did not get set as prevalent resource.");
     65                    testRunner.statisticsUpdateCookiePartitioning(function() {
     66                        runTest();
     67                    });
    6768                });
    6869                break;
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html

    r233688 r233888  
    6060                // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category.
    6161                document.location.hash = "step5";
    62                 testRunner.setStatisticsPrevalentResource("http://localhost", true);
    63                 if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    64                     testFailed("Host did not get set as prevalent resource.");
    65                 testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost");
    66                 testRunner.statisticsUpdateCookiePartitioning(function() {
    67                     runTest();
     62                testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     63                    if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     64                        testFailed("Host did not get set as prevalent resource.");
     65                    testRunner.setStatisticsHasHadNonRecentUserInteraction("http://localhost", function() {
     66                        testRunner.statisticsUpdateCookiePartitioning(runTest);
     67                    });
    6868                });
    6969                break;
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html

    r233688 r233888  
    3939            shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html");
    4040
    41             testRunner.setStatisticsPrevalentResource("http://localhost", true);
    42             if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    43                 testFailed("Host did not get set as prevalent resource.");
     41            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     42                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     43                    testFailed("Host did not get set as prevalent resource.");
    4444
    45             testRunner.statisticsUpdateCookiePartitioning(function() {
    46                 openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
    47                     setEnableFeature(false, finishJSTest);
     45                testRunner.statisticsUpdateCookiePartitioning(function() {
     46                    openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
     47                        setEnableFeature(false, finishJSTest);
     48                    });
    4849                });
    4950            });
    50 
    5151        }).catch(function(error) {
    5252            console.log(error.message);
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html

    r233688 r233888  
    3939            shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html");
    4040
    41             testRunner.setStatisticsPrevalentResource("http://localhost", true);
    42             if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
    43                 testFailed("Host did not get set as prevalent resource.");
     41            testRunner.setStatisticsPrevalentResource("http://localhost", true, function() {
     42                if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
     43                    testFailed("Host did not get set as prevalent resource.");
    4444
    45             testRunner.statisticsUpdateCookiePartitioning(function() {
    46                 fetch("http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php").then(function(response) {
    47                     return response.text();
    48                 }).then(function(data) {
    49                     referrer = data;
    50                     shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
     45                testRunner.statisticsUpdateCookiePartitioning(function() {
     46                    fetch("http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php").then(function(response) {
     47                        return response.text();
     48                    }).then(function(data) {
     49                        referrer = data;
     50                        shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
    5151
    52                     openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
     52                        openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", function() {
     53                            setEnableFeature(false, finishJSTest);
     54                        });
     55
     56                    }).catch(function(error) {
     57                        console.log(error.message);
    5358                        setEnableFeature(false, finishJSTest);
    5459                    });
    55 
    56                 }).catch(function(error) {
    57                     console.log(error.message);
    58                     setEnableFeature(false, finishJSTest);
    5960                });
    6061            });
    61 
    6262        }).catch(function(error) {
    6363            console.log(error.message);
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/telemetry-generation.html

    r233688 r233888  
    9191        makeUrlPrevalent(prevalentResourceUrl4);
    9292
    93         testRunner.setStatisticsHasHadUserInteraction(prevalentResourceUrl4, true);
    94 
    95         testRunner.installStatisticsDidScanDataRecordsCallback(checkSufficientClassificationAndContinue);
    96         testRunner.installStatisticsDidRunTelemetryCallback(checkSufficientTelemetry);
    97         testRunner.statisticsProcessStatisticsAndDataRecords();
     93        testRunner.setStatisticsHasHadUserInteraction(prevalentResourceUrl4, true, function() {
     94            testRunner.installStatisticsDidScanDataRecordsCallback(checkSufficientClassificationAndContinue);
     95            testRunner.installStatisticsDidRunTelemetryCallback(checkSufficientTelemetry);
     96            testRunner.statisticsProcessStatisticsAndDataRecords();
     97        });
    9898    }
    9999
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html

    r233688 r233888  
    4646
    4747    function setUserInteractionAndContinue() {
    48         testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true);
    49         if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
    50             testFailed("Third party did not get logged for user interaction.");
    51         runTest();
     48        testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, true, function() {
     49            if (!testRunner.isStatisticsHasHadUserInteraction(thirdPartyOrigin))
     50                testFailed("Third party did not get logged for user interaction.");
     51            runTest();
     52        });
    5253    }
    5354
     
    9596
    9697            // Start test with third party as non-prevalent
    97             testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false);
    98             testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false);
    99             testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
     98            testRunner.setStatisticsPrevalentResource(thirdPartyHostname, false, function() {
     99                testRunner.setStatisticsHasHadUserInteraction(thirdPartyOrigin, false, function() {
     100                    testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest);
     101                });
     102            });
    100103        });
    101104    } else {
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html

    r233688 r233888  
    4545        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
    4646
    47         if (testRunner)
    48             testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false);
     47        if (testRunner) {
     48            testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false, function() {
     49                shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
    4950
    50         shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
    51 
    52         activateElement("testElement", finishTest);
     51                activateElement("testElement", finishTest);
     52            });
     53        }
    5354    }
    5455
  • trunk/Source/WebKit/ChangeLog

    r233877 r233888  
     12018-07-17  John Wilander  <wilander@apple.com>
     2
     3        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
     4        https://bugs.webkit.org/show_bug.cgi?id=187710
     5        <rdar://problem/42252757>
     6
     7        Reviewed by Chris Dumez.
     8
     9        These changes are to back the completion handler functionality of
     10        TestRunner functions:
     11        - setStatisticsLastSeen(),
     12        - setStatisticsPrevalentResource(),
     13        - setStatisticsVeryPrevalentResource(),
     14        - setStatisticsHasHadUserInteraction(), and
     15        - setStatisticsHasHadNonRecentUserInteraction().
     16
     17        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     18        (WKWebsiteDataStoreSetStatisticsLastSeen):
     19        (WKWebsiteDataStoreSetStatisticsPrevalentResource):
     20        (WKWebsiteDataStoreSetStatisticsVeryPrevalentResource):
     21        (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
     22        (WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction):
     23        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     24        * UIProcess/WebResourceLoadStatisticsStore.cpp:
     25        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
     26        (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction):
     27        (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
     28        (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
     29        (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
     30        (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
     31        (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
     32        * UIProcess/WebResourceLoadStatisticsStore.h:
     33
    1342018-07-16  Simon Fraser  <simon.fraser@apple.com>
    235
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r233688 r233888  
    7070}
    7171
    72 void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds)
    73 {
    74     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    75     if (!store)
    76         return;
    77 
    78     store->setLastSeen(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), Seconds { seconds });
    79 }
    80 
    81 void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
    82 {
    83     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    84     if (!store)
    85         return;
     72void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler)
     73{
     74    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     75    if (!store) {
     76        completionHandler(context);
     77        return;
     78    }
     79
     80    store->setLastSeen(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] {
     81        completionHandler(context);
     82    });
     83}
     84
     85void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler)
     86{
     87    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     88    if (!store) {
     89        completionHandler(context);
     90        return;
     91    }
    8692
    8793    if (value)
    88         store->setPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
     94        store->setPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     95            completionHandler(context);
     96        });
    8997    else
    90         store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
    91 }
    92 
    93 void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
    94 {
    95     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    96     if (!store)
    97         return;
    98    
     98        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     99            completionHandler(context);
     100        });
     101}
     102
     103void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler)
     104{
     105    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     106    if (!store) {
     107        completionHandler(context);
     108        return;
     109    }
     110
    99111    if (value)
    100         store->setVeryPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
     112        store->setVeryPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     113            completionHandler(context);
     114        });
    101115    else
    102         store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
     116        store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     117            completionHandler(context);
     118        });
    103119}
    104120
     
    155171}
    156172
    157 void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
    158 {
    159     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    160     if (!store)
    161         return;
     173void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler)
     174{
     175    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     176    if (!store) {
     177        completionHandler(context);
     178        return;
     179    }
    162180
    163181    if (value)
    164         store->logUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
     182        store->logUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     183            completionHandler(context);
     184        });
    165185    else
    166         store->clearUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
    167 }
    168 
    169 void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host)
    170 {
    171     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    172     if (!store)
    173         return;
    174    
    175     store->logNonRecentUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
     186        store->clearUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     187            completionHandler(context);
     188        });
     189}
     190
     191void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction completionHandler)
     192{
     193    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     194    if (!store) {
     195        completionHandler(context);
     196        return;
     197    }
     198
     199    store->logNonRecentUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     200        completionHandler(context);
     201    });
    176202}
    177203
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r233688 r233888  
    4141WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable);
    4242WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef dataStoreRef, bool enable);
    43 WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds);
    44 WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
    45 WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
     43typedef void (*WKWebsiteDataStoreStatisticsLastSeenFunction)(void* functionContext);
     44WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler);
     45typedef void (*WKWebsiteDataStoreStatisticsPrevalentResourceFunction)(void* functionContext);
     46WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler);
     47typedef void (*WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction)(void* functionContext);
     48WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler);
    4649typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext);
    4750WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
     
    5154typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction)(bool isRegisteredAsRedirectingTo, void* functionContext);
    5255WK_EXPORT void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction callback);
    53 WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
    54 WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host);
     56typedef void (*WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction)(void* functionContext);
     57WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler);
     58typedef void (*WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction)(void* functionContext);
     59WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction completionHandler);
    5560typedef void (*WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction)(bool hasHadUserInteraction, void* functionContext);
    5661WK_EXPORT void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback);
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp

    r233688 r233888  
    404404}
    405405
    406 void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url)
    407 {
    408     ASSERT(RunLoop::isMain());
    409 
    410     if (url.isBlankURL() || url.isEmpty())
    411         return;
    412 
    413     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     406void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
     407{
     408    ASSERT(RunLoop::isMain());
     409
     410    if (url.isBlankURL() || url.isEmpty()) {
     411        completionHandler();
     412        return;
     413    }
     414
     415    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    414416        if (m_memoryStore)
    415417            m_memoryStore->logUserInteraction(primaryDomain);
    416     });
    417 }
    418 
    419 void WebResourceLoadStatisticsStore::logNonRecentUserInteraction(const URL& url)
    420 {
    421     ASSERT(RunLoop::isMain());
    422 
    423     if (url.isBlankURL() || url.isEmpty())
    424         return;
    425    
    426     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     418        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     419            completionHandler();
     420        });
     421    });
     422}
     423
     424void WebResourceLoadStatisticsStore::logNonRecentUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
     425{
     426    ASSERT(RunLoop::isMain());
     427
     428    if (url.isBlankURL() || url.isEmpty()) {
     429        completionHandler();
     430        return;
     431    }
     432
     433    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    427434        if (m_memoryStore)
    428435            m_memoryStore->logNonRecentUserInteraction(primaryDomain);
    429     });
    430 }
    431 
    432 void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url)
    433 {
    434     ASSERT(RunLoop::isMain());
    435 
    436     if (url.isBlankURL() || url.isEmpty())
    437         return;
    438 
    439     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     436        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     437            completionHandler();
     438        });
     439    });
     440}
     441
     442void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
     443{
     444    ASSERT(RunLoop::isMain());
     445
     446    if (url.isBlankURL() || url.isEmpty()) {
     447        completionHandler();
     448        return;
     449    }
     450
     451    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    440452        if (m_memoryStore)
    441453            m_memoryStore->clearUserInteraction(primaryDomain);
     454        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     455            completionHandler();
     456        });
    442457    });
    443458}
     
    460475}
    461476
    462 void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds)
    463 {
    464     ASSERT(RunLoop::isMain());
    465 
    466     if (url.isBlankURL() || url.isEmpty())
    467         return;
     477void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     478{
     479    ASSERT(RunLoop::isMain());
     480
     481    if (url.isBlankURL() || url.isEmpty()) {
     482        completionHandler();
     483        return;
     484    }
     485
     486    postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds, completionHandler = WTFMove(completionHandler)]() mutable {
     487        if (m_memoryStore)
     488            m_memoryStore->setLastSeen(primaryDomain, seconds);
     489        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     490            completionHandler();
     491        });
     492    });
     493}
    468494   
    469     postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds] {
    470         if (m_memoryStore)
    471             m_memoryStore->setLastSeen(primaryDomain, seconds);
    472     });
    473 }
    474    
    475 void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url)
    476 {
    477     ASSERT(RunLoop::isMain());
    478 
    479     if (url.isBlankURL() || url.isEmpty())
    480         return;
    481 
    482     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     495void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     496{
     497    ASSERT(RunLoop::isMain());
     498
     499    if (url.isBlankURL() || url.isEmpty()) {
     500        completionHandler();
     501        return;
     502    }
     503
     504    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    483505        if (m_memoryStore)
    484506            m_memoryStore->setPrevalentResource(primaryDomain);
    485     });
    486 }
    487 
    488 void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url)
    489 {
    490     ASSERT(RunLoop::isMain());
    491 
    492     if (url.isBlankURL() || url.isEmpty())
    493         return;
    494    
    495     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     507        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     508            completionHandler();
     509        });
     510    });
     511}
     512
     513void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     514{
     515    ASSERT(RunLoop::isMain());
     516
     517    if (url.isBlankURL() || url.isEmpty()) {
     518        completionHandler();
     519        return;
     520    }
     521
     522    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    496523        if (m_memoryStore)
    497524            m_memoryStore->setVeryPrevalentResource(primaryDomain);
     525        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     526            completionHandler();
     527        });
    498528    });
    499529}
     
    557587}
    558588
    559 void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url)
    560 {
    561     ASSERT(RunLoop::isMain());
    562 
    563     if (url.isBlankURL() || url.isEmpty())
    564         return;
    565 
    566     postTask([this, primaryDomain = isolatedPrimaryDomain(url)] {
     589void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     590{
     591    ASSERT(RunLoop::isMain());
     592
     593    if (url.isBlankURL() || url.isEmpty()) {
     594        completionHandler();
     595        return;
     596    }
     597
     598    postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    567599        if (m_memoryStore)
    568600            m_memoryStore->clearPrevalentResource(primaryDomain);
     601        postTaskReply([completionHandler = WTFMove(completionHandler)] {
     602            completionHandler();
     603        });
    569604    });
    570605}
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h

    r233688 r233888  
    8888
    8989    void logFrameNavigation(const WebFrameProxy&, const WebCore::URL& pageURL, const WebCore::ResourceRequest&, const WebCore::URL& redirectURL);
    90     void logUserInteraction(const WebCore::URL&);
    91     void logNonRecentUserInteraction(const WebCore::URL&);
    92     void clearUserInteraction(const WebCore::URL&);
     90    void logUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
     91    void logNonRecentUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
     92    void clearUserInteraction(const WebCore::URL&, CompletionHandler<void()>&&);
    9393    void hasHadUserInteraction(const WebCore::URL&, CompletionHandler<void(bool)>&&);
    94     void setLastSeen(const WebCore::URL&, Seconds);
    95     void setPrevalentResource(const WebCore::URL&);
    96     void setVeryPrevalentResource(const WebCore::URL&);
     94    void setLastSeen(const WebCore::URL&, Seconds, CompletionHandler<void()>&&);
     95    void setPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
     96    void setVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
    9797    void isPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
    9898    void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
    9999    void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&);
    100100    void isRegisteredAsRedirectingTo(const WebCore::URL& hostRedirectedFrom, const WebCore::URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
    101     void clearPrevalentResource(const WebCore::URL&);
     101    void clearPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
    102102    void setGrandfathered(const WebCore::URL&, bool);
    103103    void isGrandfathered(const WebCore::URL&, CompletionHandler<void(bool)>&&);
  • trunk/Tools/ChangeLog

    r233878 r233888  
     12018-07-17  John Wilander  <wilander@apple.com>
     2
     3        Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatisticsPrevalentResource(), setStatisticsVeryPrevalentResource(), setStatisticsHasHadUserInteraction(), and setStatisticsHasHadNonRecentUserInteraction()
     4        https://bugs.webkit.org/show_bug.cgi?id=187710
     5        <rdar://problem/42252757>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     10        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     11        (WTR::InjectedBundle::didReceiveMessageToPage):
     12        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     13        (WTR::TestRunner::setStatisticsLastSeen):
     14        (WTR::TestRunner::statisticsCallDidSetLastSeenCallback):
     15        (WTR::TestRunner::setStatisticsPrevalentResource):
     16        (WTR::TestRunner::statisticsCallDidSetPrevalentResourceCallback):
     17        (WTR::TestRunner::setStatisticsVeryPrevalentResource):
     18        (WTR::TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback):
     19        (WTR::TestRunner::setStatisticsHasHadUserInteraction):
     20        (WTR::TestRunner::setStatisticsHasHadNonRecentUserInteraction):
     21        (WTR::TestRunner::statisticsCallDidSetHasHadUserInteractionCallback):
     22        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     23        * WebKitTestRunner/TestController.cpp:
     24        (WTR::TestController::setStatisticsLastSeen):
     25        (WTR::TestController::setStatisticsPrevalentResource):
     26        (WTR::TestController::setStatisticsVeryPrevalentResource):
     27        (WTR::TestController::setStatisticsHasHadUserInteraction):
     28        (WTR::TestController::setStatisticsHasHadNonRecentUserInteraction):
     29        * WebKitTestRunner/TestInvocation.cpp:
     30        (WTR::TestInvocation::didSetLastSeen):
     31        (WTR::TestInvocation::didSetPrevalentResource):
     32        (WTR::TestInvocation::didSetVeryPrevalentResource):
     33        (WTR::TestInvocation::didSetHasHadUserInteraction):
     34        (WTR::TestInvocation::didSetHasHadNonRecentUserInteraction):
     35        * WebKitTestRunner/TestInvocation.h:
     36
    1372018-07-16  Jeremy Jones  <jeremyj@apple.com>
    238
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r233782 r233888  
    273273    void installStatisticsDidScanDataRecordsCallback(object callback);
    274274    void installStatisticsDidRunTelemetryCallback(object callback);
    275     void setStatisticsLastSeen(DOMString hostName, double seconds);
    276     void setStatisticsPrevalentResource(DOMString hostName, boolean value);
    277     void setStatisticsVeryPrevalentResource(DOMString hostName, boolean value);
     275    void setStatisticsLastSeen(DOMString hostName, double seconds, object completionHandler);
     276    void setStatisticsPrevalentResource(DOMString hostName, boolean value, object completionHandler);
     277    void setStatisticsVeryPrevalentResource(DOMString hostName, boolean value, object completionHandler);
    278278    boolean isStatisticsPrevalentResource(DOMString hostName);
    279279    boolean isStatisticsVeryPrevalentResource(DOMString hostName);
    280280    boolean isStatisticsRegisteredAsSubFrameUnder(DOMString subFrameHost, DOMString topFrameHost);
    281281    boolean isStatisticsRegisteredAsRedirectingTo(DOMString hostRedirectedFrom, DOMString hostRedirectedTo);
    282     void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value);
    283     void setStatisticsHasHadNonRecentUserInteraction(DOMString hostName);
     282    void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value, object completionHandler);
     283    void setStatisticsHasHadNonRecentUserInteraction(DOMString hostName, object completionHandler);
    284284    boolean isStatisticsHasHadUserInteraction(DOMString hostName);
    285285    void setStatisticsGrandfathered(DOMString hostName, boolean value);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r233688 r233888  
    316316    }
    317317
     318    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetLastSeen")) {
     319        m_testRunner->statisticsCallDidSetLastSeenCallback();
     320        return;
     321    }
     322
     323    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetPrevalentResource")) {
     324        m_testRunner->statisticsCallDidSetPrevalentResourceCallback();
     325        return;
     326    }
     327
     328    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetVeryPrevalentResource")) {
     329        m_testRunner->statisticsCallDidSetVeryPrevalentResourceCallback();
     330        return;
     331    }
     332
     333    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetHasHadUserInteraction")) {
     334        m_testRunner->statisticsCallDidSetHasHadUserInteractionCallback();
     335        return;
     336    }
     337   
     338    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetHasHadNonRecentUserInteraction")) {
     339        m_testRunner->statisticsCallDidSetHasHadUserInteractionCallback();
     340        return;
     341    }
     342   
    318343    if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAllStorageAccessEntries")) {
    319344        ASSERT(messageBody);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r233782 r233888  
    737737    DidEndSwipeCallbackID,
    738738    DidRemoveSwipeSnapshotCallbackID,
     739    SetStatisticsLastSeenCallbackID,
     740    SetStatisticsPrevalentResourceCallbackID,
     741    SetStatisticsVeryPrevalentResourceCallbackID,
     742    SetStatisticsHasHadUserInteractionCallbackID,
    739743    StatisticsDidModifyDataRecordsCallbackID,
    740744    StatisticsDidScanDataRecordsCallbackID,
     
    13281332}
    13291333
    1330 void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds)
    1331 {
     1334void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler)
     1335{
     1336    cacheTestRunnerCallback(SetStatisticsLastSeenCallbackID, completionHandler);
     1337
    13321338    Vector<WKRetainPtr<WKStringRef>> keys;
    13331339    Vector<WKRetainPtr<WKTypeRef>> values;
     
    13521358    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    13531359}
    1354    
    1355 void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value)
    1356 {
     1360
     1361void TestRunner::statisticsCallDidSetLastSeenCallback()
     1362{
     1363    callTestRunnerCallback(SetStatisticsLastSeenCallbackID);
     1364}
     1365
     1366
     1367void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler)
     1368{
     1369    cacheTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID, completionHandler);
     1370
    13571371    Vector<WKRetainPtr<WKStringRef>> keys;
    13581372    Vector<WKRetainPtr<WKTypeRef>> values;
     
    13801394}
    13811395
    1382 void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value)
    1383 {
     1396void TestRunner::statisticsCallDidSetPrevalentResourceCallback()
     1397{
     1398    callTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID);
     1399}
     1400
     1401void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler)
     1402{
     1403    cacheTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID, completionHandler);
     1404
    13841405    Vector<WKRetainPtr<WKStringRef>> keys;
    13851406    Vector<WKRetainPtr<WKTypeRef>> values;
     
    14051426   
    14061427    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1428}
     1429
     1430void TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback()
     1431{
     1432    callTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID);
    14071433}
    14081434
     
    14771503}
    14781504
    1479 void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value)
    1480 {
     1505void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler)
     1506{
     1507    cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler);
     1508
    14811509    Vector<WKRetainPtr<WKStringRef>> keys;
    14821510    Vector<WKRetainPtr<WKTypeRef>> values;
     
    15041532}
    15051533
    1506 void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName)
    1507 {
     1534void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName, JSValueRef completionHandler)
     1535{
     1536    cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler);
     1537
    15081538    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsHasHadNonRecentUserInteraction"));
    15091539    WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName));
    15101540    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1541}
     1542
     1543void TestRunner::statisticsCallDidSetHasHadUserInteractionCallback()
     1544{
     1545    callTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID);
    15111546}
    15121547
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r233782 r233888  
    383383    void statisticsCallDidSetPartitionOrBlockCookiesForHostCallback();
    384384    void statisticsSubmitTelemetry();
    385     void setStatisticsLastSeen(JSStringRef hostName, double seconds);
    386     void setStatisticsPrevalentResource(JSStringRef hostName, bool value);
    387     void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value);
     385    void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler);
     386    void statisticsCallDidSetLastSeenCallback();
     387    void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
     388    void statisticsCallDidSetPrevalentResourceCallback();
     389    void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
     390    void statisticsCallDidSetVeryPrevalentResourceCallback();
    388391    bool isStatisticsPrevalentResource(JSStringRef hostName);
    389392    bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
    390393    bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
    391394    bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
    392     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
    393     void setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName);
     395    void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
     396    void setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName, JSValueRef completionHandler);
     397    void statisticsCallDidSetHasHadUserInteractionCallback();
    394398    bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
    395399    void setStatisticsGrandfathered(JSStringRef hostName, bool value);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r233869 r233888  
    26212621}
    26222622
    2623 void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
    2624 {
    2625     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2626     WKWebsiteDataStoreSetStatisticsLastSeen(dataStore, host, seconds);
    2627 }
    2628 
    2629 void TestController::setStatisticsPrevalentResource(WKStringRef host, bool value)
    2630 {
    2631     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2632     WKWebsiteDataStoreSetStatisticsPrevalentResource(dataStore, host, value);
    2633 }
    2634 
    2635 void TestController::setStatisticsVeryPrevalentResource(WKStringRef host, bool value)
    2636 {
    2637     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2638     WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(dataStore, host, value);
    2639 }
    2640 
    26412623struct ResourceStatisticsCallbackContext {
    26422624    explicit ResourceStatisticsCallbackContext(TestController& controller)
     
    26642646    context->testController.notifyDone();
    26652647}
     2648   
     2649void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
     2650{
     2651    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2652    ResourceStatisticsCallbackContext context(*this);
     2653    WKWebsiteDataStoreSetStatisticsLastSeen(dataStore, host, seconds, &context, resourceStatisticsVoidResultCallback);
     2654    runUntil(context.done, noTimeout);
     2655    m_currentInvocation->didSetLastSeen();
     2656}
     2657
     2658void TestController::setStatisticsPrevalentResource(WKStringRef host, bool value)
     2659{
     2660    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2661    ResourceStatisticsCallbackContext context(*this);
     2662    WKWebsiteDataStoreSetStatisticsPrevalentResource(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
     2663    runUntil(context.done, noTimeout);
     2664    m_currentInvocation->didSetPrevalentResource();
     2665}
     2666
     2667void TestController::setStatisticsVeryPrevalentResource(WKStringRef host, bool value)
     2668{
     2669    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2670    ResourceStatisticsCallbackContext context(*this);
     2671    WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
     2672    runUntil(context.done, noTimeout);
     2673    m_currentInvocation->didSetVeryPrevalentResource();
     2674}
    26662675
    26672676bool TestController::isStatisticsPrevalentResource(WKStringRef host)
     
    27042713{
    27052714    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2706     WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(dataStore, host, value);
     2715    ResourceStatisticsCallbackContext context(*this);
     2716    WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
     2717    runUntil(context.done, noTimeout);
     2718    m_currentInvocation->didSetHasHadUserInteraction();
    27072719}
    27082720
     
    27102722{
    27112723    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2712     WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(dataStore, host);
     2724    ResourceStatisticsCallbackContext context(*this);
     2725    WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(dataStore, host, &context, resourceStatisticsVoidResultCallback);
     2726    runUntil(context.done, noTimeout);
     2727    m_currentInvocation->didSetHasHadNonRecentUserInteraction();
    27132728}
    27142729
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r233799 r233888  
    15281528}
    15291529
     1530void TestInvocation::didSetLastSeen()
     1531{
     1532    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetLastSeen"));
     1533    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
     1534}
     1535
     1536void TestInvocation::didSetPrevalentResource()
     1537{
     1538    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetPrevalentResource"));
     1539    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
     1540}
     1541
     1542void TestInvocation::didSetVeryPrevalentResource()
     1543{
     1544    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetVeryPrevalentResource"));
     1545    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
     1546}
     1547
     1548void TestInvocation::didSetHasHadUserInteraction()
     1549{
     1550    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadUserInteraction"));
     1551    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
     1552}
     1553
     1554void TestInvocation::didSetHasHadNonRecentUserInteraction()
     1555{
     1556    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadNonRecentUserInteraction"));
     1557    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
     1558}
     1559
    15301560void TestInvocation::didReceiveAllStorageAccessEntries(Vector<String>& domains)
    15311561{
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r233688 r233888  
    7575    void didResetStatisticsToConsistentState();
    7676    void didSetPartitionOrBlockCookiesForHost();
     77    void didSetLastSeen();
     78    void didSetPrevalentResource();
     79    void didSetVeryPrevalentResource();
     80    void didSetHasHadUserInteraction();
     81    void didSetHasHadNonRecentUserInteraction();
    7782    void didReceiveAllStorageAccessEntries(Vector<String>& domains);
    7883
Note: See TracChangeset for help on using the changeset viewer.