Changeset 233888 in webkit
- Timestamp:
- Jul 17, 2018 10:45:41 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r233887 r233888 1 2018-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 1 58 2018-07-17 Ryan Haddad <ryanhaddad@apple.com> 2 59 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/add-blocking-to-redirect.html
r233688 r233888 59 59 // Set localhost as prevalent and with no user interaction to put it in the blocking category. 60 60 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 }); 66 67 }); 67 68 break; -
trunk/LayoutTests/http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html
r233688 r233888 59 59 // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category. 60 60 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 }); 67 69 }); 68 70 break; -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
r233688 r233888 28 28 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 29 29 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."); 33 33 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); 37 37 38 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);38 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 39 39 40 testRunner.statisticsProcessStatisticsAndDataRecords(); 40 testRunner.statisticsProcessStatisticsAndDataRecords(); 41 }); 41 42 } 42 43 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
r233688 r233888 28 28 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 29 29 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."); 33 33 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); 37 37 38 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);39 testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);38 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 39 testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest); 40 40 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 42 }); 42 43 } 43 44 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
r233688 r233888 27 27 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 28 28 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."); 32 32 33 testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);34 testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);33 testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1); 34 testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2); 35 35 36 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);36 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 37 37 38 testRunner.statisticsProcessStatisticsAndDataRecords(); 38 testRunner.statisticsProcessStatisticsAndDataRecords(); 39 }); 39 40 } 40 41 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
r233688 r233888 28 28 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 29 29 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."); 33 33 34 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);35 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);34 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1); 35 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2); 36 36 37 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);37 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 38 38 39 testRunner.statisticsProcessStatisticsAndDataRecords(); 39 testRunner.statisticsProcessStatisticsAndDataRecords(); 40 }); 40 41 } 41 42 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
r233688 r233888 32 32 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 33 33 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."); 37 37 38 testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);39 testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);38 testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1); 39 testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4); 40 40 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); 44 44 45 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);46 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);45 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3); 46 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1); 47 47 48 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);48 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 49 49 50 testRunner.statisticsProcessStatisticsAndDataRecords(); 50 testRunner.statisticsProcessStatisticsAndDataRecords(); 51 }); 51 52 } 52 53 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
r233688 r233888 32 32 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 33 33 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."); 37 37 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); 42 42 43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 44 44 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 46 }); 46 47 } 47 48 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html
r233688 r233888 34 34 testRunner.setStatisticsSubresourceUniqueRedirectFrom(subresourceOrigin3, subresourceOrigin4); 35 35 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."); 59 59 60 setEnableFeature(false, finishJSTest); 60 setEnableFeature(false, finishJSTest); 61 }); 61 62 } 62 63 63 64 if (document.location.host === hostUnderTest && window.testRunner && window.internals) { 64 65 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 }); 69 74 }); 70 75 } 71 76 </script> 72 <iframe onload="runTest()" src="http://localhost:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/onclick.html"></iframe>73 77 </body> 74 78 </html> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-to-prevalent.html
r233688 r233888 35 35 36 36 function runTest() { 37 testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true );38 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);37 testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() { 38 testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1); 39 39 40 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 40 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 42 }); 42 43 } 43 44 … … 46 47 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 47 48 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 }); 52 54 }); 53 55 } -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
r233688 r233888 32 32 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 33 33 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."); 37 37 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); 42 42 43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 44 44 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 46 }); 46 47 } 47 48 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
r233688 r233888 32 32 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 33 33 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."); 37 37 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); 42 42 43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);43 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 44 44 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 45 testRunner.statisticsProcessStatisticsAndDataRecords(); 46 }); 46 47 } 47 48 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html
r233688 r233888 33 33 testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin3, topFrameOrigin4); 34 34 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."); 58 58 59 setEnableFeature(false, finishJSTest); 59 setEnableFeature(false, finishJSTest); 60 }); 60 61 } 61 62 62 63 if (document.location.hash === "" && window.testRunner && window.internals) { 63 64 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."); 67 68 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 }); 69 71 }); 70 72 } else { -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-to-prevalent.html
r233688 r233888 35 35 36 36 function runTest() { 37 testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true );38 testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1);37 testRunner.setStatisticsPrevalentResource(topFrameOrigin1, true, function() { 38 testRunner.setStatisticsTopFrameUniqueRedirectTo(statisticsUrl, topFrameOrigin1); 39 39 40 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 40 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 41 testRunner.statisticsProcessStatisticsAndDataRecords(); 42 }); 42 43 } 43 44 … … 46 47 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 47 48 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 }); 52 54 }); 53 55 } -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html
r233688 r233888 52 52 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 53 53 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 }); 58 59 }); 59 60 } -
trunk/LayoutTests/http/tests/resourceLoadStatistics/classify-as-very-prevalent-based-on-mixed-statistics.html
r233688 r233888 41 41 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 42 42 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."); 46 46 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]); 52 52 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]); 56 56 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 } 62 62 63 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 64 testRunner.statisticsProcessStatisticsAndDataRecords(); 63 testRunner.installStatisticsDidScanDataRecordsCallback(completeTest); 64 testRunner.statisticsProcessStatisticsAndDataRecords(); 65 }); 65 66 } 66 67 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html
r233688 r233888 38 38 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 39 39 40 testRunner.setStatisticsPrevalentResource(statisticsUrl, false );40 testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {}); 41 41 if (testRunner.isStatisticsPrevalentResource(statisticsUrl)) 42 42 testFailed("Host did not get set as non-prevalent resource."); -
trunk/LayoutTests/http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
r233688 r233888 38 38 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 39 39 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."); 43 43 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); 51 51 52 testRunner.installStatisticsDidScanDataRecordsCallback(testStep2);52 testRunner.installStatisticsDidScanDataRecordsCallback(testStep2); 53 53 54 testRunner.statisticsProcessStatisticsAndDataRecords(); 54 testRunner.statisticsProcessStatisticsAndDataRecords(); 55 }); 55 56 } 56 57 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html
r231008 r233888 13 13 function doRedirect() 14 14 { 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 }); 22 23 } 23 24 </script> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/grandfathering.html
r233688 r233888 69 69 document.location.hash = "step5"; 70 70 // 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 }); 75 76 break; 76 77 case "#step5": … … 81 82 document.location.hash = "step7"; 82 83 // 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 }); 87 89 break; 88 90 case "#step7": -
trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html
r233688 r233888 29 29 testFailed("document.cookie did not get set."); 30 30 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."); 34 34 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."); 40 40 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."); 44 44 45 testRunner.installStatisticsDidScanDataRecordsCallback(function() {46 if (document.cookie === cookie)47 testPassed("Cookie not deleted.");48 else49 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); 50 50 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 }); 53 59 }); 54 60 }); 55 testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);56 testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);57 testRunner.statisticsProcessStatisticsAndDataRecords();58 61 } 59 62 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html
r233688 r233888 29 29 testFailed("document.cookie did not get set."); 30 30 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."); 34 34 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."); 40 40 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."); 44 44 45 testRunner.installStatisticsDidScanDataRecordsCallback(function() {46 if (document.cookie === cookie)47 testPassed("Cookie not deleted.");48 else49 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); 50 50 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 }); 53 59 }); 54 60 }); 55 testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);56 testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);57 testRunner.statisticsProcessStatisticsAndDataRecords();58 61 } 59 62 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html
r233688 r233888 45 45 46 46 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 }); 51 52 } 52 53 … … 78 79 break; 79 80 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. 81 82 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After user interaction, should still only receive one partitioned, third party cookie.", finishTest); 82 83 break; … … 85 86 86 87 if (document.location.host === partitionHost && document.location.hash == "" && window.testRunner && window.internals) { 88 testRunner.waitUntilDone(); 89 testRunner.dumpChildFramesAsText(); 87 90 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"; 93 94 94 testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest); 95 testRunner.statisticsSetShouldPartitionCookiesForHost(thirdPartyHostname, false, runTest); 96 }); 97 }); 95 98 }); 96 99 } else { -
trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
r233688 r233888 52 52 53 53 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 }); 58 59 } 59 60 … … 97 98 document.location.hash = "step1"; 98 99 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."); 102 103 103 testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest); 104 testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true, runTest); 105 }); 104 106 }); 105 107 } 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.13 1 PASS successfullyParsed is true 14 2 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
r233688 r233888 44 44 45 45 function fireShouldPartitionCookiesHandlerAndContinue() { 46 console.log("fireShouldPartitionCookiesHandlerAndContinue().");47 46 testRunner.statisticsUpdateCookiePartitioning(runTest); 48 47 } 49 48 50 49 function setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue() { 51 console.log("setShortCookiePartitioningTimeOutPlusFireShouldPartitionCookiesHandlerAndContinue().");52 50 testRunner.setStatisticsTimeToLiveCookiePartitionFree(1); 53 51 setTimeout(fireShouldPartitionCookiesHandlerAndContinue, 2000); … … 55 53 56 54 function setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue() { 57 console.log("setNormalCookiePartitioningTimeOutPlusUserInteractionAndContinue().");58 55 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 }); 63 61 } 64 62 … … 66 64 switch (document.location.hash) { 67 65 case "#step1": 68 console.log("Step 1.");69 66 // Set first-party cookie for http://localhost:8000 70 67 document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + fragmentWithReturnUrl + "#step2"; 71 68 break; 72 69 case "#step2": 73 console.log("Step 2.");74 70 // Check that the first-party cookie is not sent in partition 127.0.0.1:8000 75 71 document.location.hash = "step3"; … … 78 74 break; 79 75 case "#step3": 80 console.log("Step 3.");81 76 // Set third-party cookie for http://localhost:8000 in partition 127.0.0.1:8000 82 77 document.location.hash = "step4"; … … 85 80 break; 86 81 case "#step4": 87 console.log("Step 4.");88 82 // Check that only partitioned cookie get sent in partition 127.0.0.1:8000 89 83 document.location.hash = "step5"; … … 92 86 break; 93 87 case "#step5": 94 console.log("Step 5.");95 88 // http://localhost:8000 now has user interaction, check that un-partitioned cookie is sent for third-party 96 89 document.location.hash = "step6"; … … 99 92 break; 100 93 case "#step6": 101 console.log("Step 6.");102 94 // Cookie partitioning should be applied again 103 95 document.location.hash = "step7"; … … 106 98 break; 107 99 case "#step7": 108 console.log("Step 7.");109 100 // http://localhost:8000 now has fresh user interaction, check that un-partitioned cookie is sent for third-party 110 101 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After second user interaction, should still only receive a partitioned, third-party cookie.", … … 115 106 116 107 if (document.location.hash === "" && window.testRunner && window.internals) { 117 console.log("Bootstrapping test."); 108 testRunner.waitUntilDone(); 109 testRunner.dumpChildFramesAsText(); 118 110 setEnableFeature(true, function() { 119 111 // 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"); 124 116 125 testRunner.statisticsUpdateCookiePartitioning();117 testRunner.statisticsUpdateCookiePartitioning(); 126 118 127 testRunner.waitUntilDone(); 128 testRunner.dumpChildFramesAsText(); 129 document.location.hash = "step1"; 119 document.location.hash = "step1"; 130 120 131 runTest(); 121 runTest(); 122 }); 132 123 }); 133 124 } else -
trunk/LayoutTests/http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html
r233688 r233888 44 44 45 45 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 }); 50 51 } 51 52 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-handled-keydown.html
r233688 r233888 17 17 } 18 18 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."); 22 22 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."); 26 26 27 testInput = document.getElementById("testInput");27 testInput = document.getElementById("testInput"); 28 28 29 testRunner.installStatisticsDidModifyDataRecordsCallback(function() {30 shouldBeEqualToString("testInput.value", "a");29 testRunner.installStatisticsDidModifyDataRecordsCallback(function() { 30 shouldBeEqualToString("testInput.value", "a"); 31 31 32 if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))33 testFailed("Origin did not get user interaction credit.");34 else35 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."); 36 36 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 }); 45 55 }); 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 56 } 55 57 </script> 56 58 <iframe id="testFrame" src="resources/onclick.html"></iframe> 57 <input id="testInput" type="text"> </input>59 <input id="testInput" type="text"> 58 60 </body> 59 61 </html> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-unhandled-keydown.html
r233688 r233888 17 17 } 18 18 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."); 22 22 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."); 26 26 27 testRunner.installStatisticsDidModifyDataRecordsCallback(function() {27 testRunner.installStatisticsDidModifyDataRecordsCallback(function() { 28 28 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."); 31 31 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 }); 40 49 }); 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 50 } 49 51 </script> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
r233688 r233888 18 18 testFailed("document.cookie did not get set."); 19 19 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."); 23 23 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."); 27 27 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); 36 44 }); 37 45 }); 38 testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);39 testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);40 testRunner.setStatisticsTimeToLiveUserInteraction(0);41 setTimeout("testRunner.statisticsProcessStatisticsAndDataRecords()", 1000);42 46 } 43 47 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
r233688 r233888 19 19 testFailed("document.cookie did not get set."); 20 20 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."); 24 24 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."); 30 30 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."); 34 34 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 }); 43 49 }); 44 50 }); 45 testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);46 testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);47 testRunner.statisticsProcessStatisticsAndDataRecords();48 51 } 49 52 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-without-user-interaction.html
r233688 r233888 30 30 testFailed("document.cookie did not get set."); 31 31 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."); 35 35 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."); 39 39 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 }); 42 47 }); 43 testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);44 testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);45 testRunner.statisticsProcessStatisticsAndDataRecords();46 48 } 47 49 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prune-statistics.html
r233688 r233888 56 56 } 57 57 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 } 86 117 } 87 118 … … 95 126 if (currentTest < urlsToBePruned.length) { 96 127 ++currentTest; 97 runTest(); 128 testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning); 129 initializeStatisticsAndRunTests(1); 98 130 } else { 99 131 testRunner.statisticsResetToConsistentState(function() { … … 103 135 } 104 136 137 let fillerUrl; 105 138 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 }); 113 147 } 114 148 … … 121 155 122 156 currentTest = 1; 123 runTest(); 157 testRunner.installStatisticsDidScanDataRecordsCallback(checkStatisticsAfterPruning); 158 initializeStatisticsAndRunTests(1); 124 159 } 125 160 </script> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html
r233688 r233888 60 60 // Set localhost as prevalent and with non-recent user interaction to put it in the blocking category. 61 61 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 }); 67 68 }); 68 69 break; -
trunk/LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html
r233688 r233888 60 60 // Set localhost as prevalent and with non-recent user interaction to put it in the partitioning category. 61 61 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 }); 68 68 }); 69 69 break; -
trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html
r233688 r233888 39 39 shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html"); 40 40 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."); 44 44 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 }); 48 49 }); 49 50 }); 50 51 51 }).catch(function(error) { 52 52 console.log(error.message); -
trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html
r233688 r233888 39 39 shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html"); 40 40 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."); 44 44 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/"); 51 51 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); 53 58 setEnableFeature(false, finishJSTest); 54 59 }); 55 56 }).catch(function(error) {57 console.log(error.message);58 setEnableFeature(false, finishJSTest);59 60 }); 60 61 }); 61 62 62 }).catch(function(error) { 63 63 console.log(error.message); -
trunk/LayoutTests/http/tests/resourceLoadStatistics/telemetry-generation.html
r233688 r233888 91 91 makeUrlPrevalent(prevalentResourceUrl4); 92 92 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 }); 98 98 } 99 99 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html
r233688 r233888 46 46 47 47 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 }); 52 53 } 53 54 … … 95 96 96 97 // 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 }); 100 103 }); 101 104 } else { -
trunk/LayoutTests/http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html
r233688 r233888 45 45 shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)"); 46 46 47 if (testRunner) 48 testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false); 47 if (testRunner) { 48 testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false, function() { 49 shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)"); 49 50 50 shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");51 52 activateElement("testElement", finishTest);51 activateElement("testElement", finishTest); 52 }); 53 } 53 54 } 54 55 -
trunk/Source/WebKit/ChangeLog
r233877 r233888 1 2018-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 1 34 2018-07-16 Simon Fraser <simon.fraser@apple.com> 2 35 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r233688 r233888 70 70 } 71 71 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; 72 void 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 85 void 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 } 86 92 87 93 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 }); 89 97 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 103 void 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 99 111 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 }); 101 115 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 }); 103 119 } 104 120 … … 155 171 } 156 172 157 void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value) 158 { 159 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 160 if (!store) 161 return; 173 void 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 } 162 180 163 181 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 }); 165 185 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 191 void 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 }); 176 202 } 177 203 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r233688 r233888 41 41 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable); 42 42 WK_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); 43 typedef void (*WKWebsiteDataStoreStatisticsLastSeenFunction)(void* functionContext); 44 WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler); 45 typedef void (*WKWebsiteDataStoreStatisticsPrevalentResourceFunction)(void* functionContext); 46 WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler); 47 typedef void (*WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction)(void* functionContext); 48 WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler); 46 49 typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext); 47 50 WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback); … … 51 54 typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction)(bool isRegisteredAsRedirectingTo, void* functionContext); 52 55 WK_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); 56 typedef void (*WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction)(void* functionContext); 57 WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler); 58 typedef void (*WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction)(void* functionContext); 59 WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadNonRecentUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasHadNonRecentUserInteractionFunction completionHandler); 55 60 typedef void (*WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction)(bool hasHadUserInteraction, void* functionContext); 56 61 WK_EXPORT void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback); -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
r233688 r233888 404 404 } 405 405 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)] { 406 void 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 { 414 416 if (m_memoryStore) 415 417 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 424 void 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 { 427 434 if (m_memoryStore) 428 435 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 442 void 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 { 440 452 if (m_memoryStore) 441 453 m_memoryStore->clearUserInteraction(primaryDomain); 454 postTaskReply([completionHandler = WTFMove(completionHandler)] { 455 completionHandler(); 456 }); 442 457 }); 443 458 } … … 460 475 } 461 476 462 void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds) 463 { 464 ASSERT(RunLoop::isMain()); 465 466 if (url.isBlankURL() || url.isEmpty()) 467 return; 477 void 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 } 468 494 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)] { 495 void 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 { 483 505 if (m_memoryStore) 484 506 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 513 void 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 { 496 523 if (m_memoryStore) 497 524 m_memoryStore->setVeryPrevalentResource(primaryDomain); 525 postTaskReply([completionHandler = WTFMove(completionHandler)] { 526 completionHandler(); 527 }); 498 528 }); 499 529 } … … 557 587 } 558 588 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)] { 589 void 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 { 567 599 if (m_memoryStore) 568 600 m_memoryStore->clearPrevalentResource(primaryDomain); 601 postTaskReply([completionHandler = WTFMove(completionHandler)] { 602 completionHandler(); 603 }); 569 604 }); 570 605 } -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
r233688 r233888 88 88 89 89 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()>&&); 93 93 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()>&&); 97 97 void isPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&); 98 98 void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&); 99 99 void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&); 100 100 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()>&&); 102 102 void setGrandfathered(const WebCore::URL&, bool); 103 103 void isGrandfathered(const WebCore::URL&, CompletionHandler<void(bool)>&&); -
trunk/Tools/ChangeLog
r233878 r233888 1 2018-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 1 37 2018-07-16 Jeremy Jones <jeremyj@apple.com> 2 38 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r233782 r233888 273 273 void installStatisticsDidScanDataRecordsCallback(object callback); 274 274 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); 278 278 boolean isStatisticsPrevalentResource(DOMString hostName); 279 279 boolean isStatisticsVeryPrevalentResource(DOMString hostName); 280 280 boolean isStatisticsRegisteredAsSubFrameUnder(DOMString subFrameHost, DOMString topFrameHost); 281 281 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); 284 284 boolean isStatisticsHasHadUserInteraction(DOMString hostName); 285 285 void setStatisticsGrandfathered(DOMString hostName, boolean value); -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r233688 r233888 316 316 } 317 317 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 318 343 if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAllStorageAccessEntries")) { 319 344 ASSERT(messageBody); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r233782 r233888 737 737 DidEndSwipeCallbackID, 738 738 DidRemoveSwipeSnapshotCallbackID, 739 SetStatisticsLastSeenCallbackID, 740 SetStatisticsPrevalentResourceCallbackID, 741 SetStatisticsVeryPrevalentResourceCallbackID, 742 SetStatisticsHasHadUserInteractionCallbackID, 739 743 StatisticsDidModifyDataRecordsCallbackID, 740 744 StatisticsDidScanDataRecordsCallbackID, … … 1328 1332 } 1329 1333 1330 void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds) 1331 { 1334 void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler) 1335 { 1336 cacheTestRunnerCallback(SetStatisticsLastSeenCallbackID, completionHandler); 1337 1332 1338 Vector<WKRetainPtr<WKStringRef>> keys; 1333 1339 Vector<WKRetainPtr<WKTypeRef>> values; … … 1352 1358 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1353 1359 } 1354 1355 void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value) 1356 { 1360 1361 void TestRunner::statisticsCallDidSetLastSeenCallback() 1362 { 1363 callTestRunnerCallback(SetStatisticsLastSeenCallbackID); 1364 } 1365 1366 1367 void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler) 1368 { 1369 cacheTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID, completionHandler); 1370 1357 1371 Vector<WKRetainPtr<WKStringRef>> keys; 1358 1372 Vector<WKRetainPtr<WKTypeRef>> values; … … 1380 1394 } 1381 1395 1382 void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value) 1383 { 1396 void TestRunner::statisticsCallDidSetPrevalentResourceCallback() 1397 { 1398 callTestRunnerCallback(SetStatisticsPrevalentResourceCallbackID); 1399 } 1400 1401 void TestRunner::setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler) 1402 { 1403 cacheTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID, completionHandler); 1404 1384 1405 Vector<WKRetainPtr<WKStringRef>> keys; 1385 1406 Vector<WKRetainPtr<WKTypeRef>> values; … … 1405 1426 1406 1427 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1428 } 1429 1430 void TestRunner::statisticsCallDidSetVeryPrevalentResourceCallback() 1431 { 1432 callTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID); 1407 1433 } 1408 1434 … … 1477 1503 } 1478 1504 1479 void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value) 1480 { 1505 void TestRunner::setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler) 1506 { 1507 cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler); 1508 1481 1509 Vector<WKRetainPtr<WKStringRef>> keys; 1482 1510 Vector<WKRetainPtr<WKTypeRef>> values; … … 1504 1532 } 1505 1533 1506 void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName) 1507 { 1534 void TestRunner::setStatisticsHasHadNonRecentUserInteraction(JSStringRef hostName, JSValueRef completionHandler) 1535 { 1536 cacheTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID, completionHandler); 1537 1508 1538 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsHasHadNonRecentUserInteraction")); 1509 1539 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName)); 1510 1540 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1541 } 1542 1543 void TestRunner::statisticsCallDidSetHasHadUserInteractionCallback() 1544 { 1545 callTestRunnerCallback(SetStatisticsHasHadUserInteractionCallbackID); 1511 1546 } 1512 1547 -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r233782 r233888 383 383 void statisticsCallDidSetPartitionOrBlockCookiesForHostCallback(); 384 384 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(); 388 391 bool isStatisticsPrevalentResource(JSStringRef hostName); 389 392 bool isStatisticsVeryPrevalentResource(JSStringRef hostName); 390 393 bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost); 391 394 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(); 394 398 bool isStatisticsHasHadUserInteraction(JSStringRef hostName); 395 399 void setStatisticsGrandfathered(JSStringRef hostName, bool value); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r233869 r233888 2621 2621 } 2622 2622 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 2641 2623 struct ResourceStatisticsCallbackContext { 2642 2624 explicit ResourceStatisticsCallbackContext(TestController& controller) … … 2664 2646 context->testController.notifyDone(); 2665 2647 } 2648 2649 void 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 2658 void 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 2667 void 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 } 2666 2675 2667 2676 bool TestController::isStatisticsPrevalentResource(WKStringRef host) … … 2704 2713 { 2705 2714 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(); 2707 2719 } 2708 2720 … … 2710 2722 { 2711 2723 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(); 2713 2728 } 2714 2729 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r233799 r233888 1528 1528 } 1529 1529 1530 void TestInvocation::didSetLastSeen() 1531 { 1532 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetLastSeen")); 1533 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1534 } 1535 1536 void TestInvocation::didSetPrevalentResource() 1537 { 1538 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetPrevalentResource")); 1539 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1540 } 1541 1542 void TestInvocation::didSetVeryPrevalentResource() 1543 { 1544 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetVeryPrevalentResource")); 1545 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1546 } 1547 1548 void TestInvocation::didSetHasHadUserInteraction() 1549 { 1550 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadUserInteraction")); 1551 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1552 } 1553 1554 void TestInvocation::didSetHasHadNonRecentUserInteraction() 1555 { 1556 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetHasHadNonRecentUserInteraction")); 1557 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1558 } 1559 1530 1560 void TestInvocation::didReceiveAllStorageAccessEntries(Vector<String>& domains) 1531 1561 { -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r233688 r233888 75 75 void didResetStatisticsToConsistentState(); 76 76 void didSetPartitionOrBlockCookiesForHost(); 77 void didSetLastSeen(); 78 void didSetPrevalentResource(); 79 void didSetVeryPrevalentResource(); 80 void didSetHasHadUserInteraction(); 81 void didSetHasHadNonRecentUserInteraction(); 77 82 void didReceiveAllStorageAccessEntries(Vector<String>& domains); 78 83
Note: See TracChangeset
for help on using the changeset viewer.