b8540908ed80d134e7380496a27505ad005c97ba
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-database.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8">
5     <title>Tests for Classification Based on Sub Frame Under Top Frame Origins</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.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
36             testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
37
38             testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
39             testRunner.installStatisticsDidModifyDataRecordsCallback(completeTest);
40
41             testRunner.statisticsProcessStatisticsAndDataRecords();
42         });
43     }
44
45     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
46         testRunner.setUseITPDatabase(true);
47         testRunner.waitUntilDone();
48         internals.setResourceLoadStatisticsEnabled(true);
49         runTestRunnerTest();
50     }
51 </script>
52 </body>
53 </html>