Resource Load Statistics: Add alternate classification method
[WebKit-https.git] / LayoutTests / http / tests / loading / resourceLoadStatistics / classify-as-prevalent-based-on-subresource-unique-redirects-to.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8">
5     <title>Tests for Classification Based on Subresource Unique Redirects To</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     const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
16     function runTestRunnerTest() {
17         testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
18         if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
19             testFailed("Host did not get set as non-prevalent resource.");
20
21         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
22         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
23         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
24         testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
25
26         testRunner.statisticsFireDataModificationHandler();
27
28         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
29             testFailed("Host did not get classified as prevalent resource.");
30         else
31             testPassed("Host classified as prevalent resource.");
32
33         testRunner.statisticsResetToConsistentState();
34         testRunner.notifyDone();
35     }
36
37     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
38         testRunner.waitUntilDone();
39         internals.setResourceLoadStatisticsEnabled(true);
40         runTestRunnerTest();
41     }
42 </script>
43 </body>
44 </html>