Source/WebCore:
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / classify-as-non-prevalent-based-on-mixed-statistics-database.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8">
5     <title>Tests for Classification Based on Mixed Statistics</title>
6     <script src="/js-test-resources/js-test.js"></script>
7 </head>
8 <body>
9 <script>
10     const hostUnderTest = "127.0.0.1:8000";
11     const statisticsUrl = "http://" + hostUnderTest + "/temp";
12     const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
13     const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
14     const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
15
16     function completeTest() {
17         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
18             testFailed("Host classified as prevalent resource.");
19         else
20             testPassed("Host did not get classified as prevalent resource.");
21
22         testRunner.statisticsResetToConsistentState(function() {
23             testRunner.notifyDone();
24         });
25     }
26
27     function runTestRunnerTest() {
28         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
29
30         testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
31             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
32                 testFailed("Host did not get set as non-prevalent resource.");
33
34             testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
35             testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
36             testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
37
38             testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
39
40             testRunner.statisticsProcessStatisticsAndDataRecords();
41         });
42     }
43
44     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
45         testRunner.setUseITPDatabase(true);
46         testRunner.waitUntilDone();
47         internals.setResourceLoadStatisticsEnabled(true);
48         runTestRunnerTest();
49     }
50 </script>
51 </body>
52 </html>