Resource Load Statistics: Add alternate classification method
[WebKit-https.git] / LayoutTests / http / tests / loading / resourceLoadStatistics / classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.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="../../resources/js-test-pre.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     function runTestRunnerTest() {
16         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
17         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
18             testFailed("Host did not get set as non-prevalent resource.");
19
20         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
21         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
22         testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
23
24         testRunner.statisticsFireDataModificationHandler();
25
26         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
27             testFailed("Host classified as prevalent resource.");
28         else
29             testPassed("Host did not get classified as prevalent resource.");
30
31         testRunner.statisticsResetToConsistentState();
32         testRunner.notifyDone();
33     }
34
35     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
36         testRunner.waitUntilDone();
37         internals.setResourceLoadStatisticsEnabled(true);
38         runTestRunnerTest();
39     }
40 </script>
41 </body>
42 </html>