Many resourceLoadStatistics tests and storageAccess tests using the ITP
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / do-not-capture-statistics-for-simple-top-navigations-database.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8">
5     <script src="/js-test-resources/js-test.js"></script>
6     <script src="resources/util.js"></script>
7 </head>
8 <body>
9 <script>
10     description("Test that a non-redirected top frame navigation doesn't get captured in statistics.");
11     jsTestIsAsync = true;
12     testRunner.setUseITPDatabase(true);
13     let timerHandle = 0;
14
15     function finishTest() {
16         if (timerHandle)
17           clearTimeout(timerHandle);
18
19         shouldBeFalse('testRunner.isStatisticsRegisteredAsSubFrameUnder("http://localhost", "http://127.0.0.1")');
20         shouldBeFalse('testRunner.isStatisticsRegisteredAsSubFrameUnder("http://127.0.0.1", "http://localhost")');
21         setEnableFeature(false, finishJSTest);
22     }
23
24     function runTest() {
25         switch (document.location.host) {
26             case "127.0.0.1:8000":
27                 setEnableFeature(true, function() {
28                     if (testRunner.isStatisticsPrevalentResource("http://localhost:8000"))
29                         testFailed("Localhost was classified as prevalent resource before the test starts.");
30                     document.location.href = "http://localhost:8000/resourceLoadStatistics/do-not-capture-statistics-for-simple-top-navigations-database.html";
31                 });
32                 break;
33             case "localhost:8000":
34                 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
35                 testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
36                 if (!testRunner.statisticsNotifyObserver())
37                     timerHandle = setTimeout(finishTest, 100);
38                 break;
39             default:
40                 testFailed("Unknown host: " + document.location.host);
41                 finishTest();
42         }
43     }
44
45     if (window.testRunner && window.internals)
46         runTest();
47 </script>
48 </body>
49 </html>