9738ea3b59a0a70743d345df052ea629d2f6b93d
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip-database.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="/js-test-resources/js-test.js"></script>
5     <script src="resources/util.js"></script>
6     <script>
7         description("Tests that redirects for a sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
8         jsTestIsAsync = true;
9         window.addEventListener("message", receiveMessage, false);
10
11         function finishTest() {
12             setEnableFeature(false, finishJSTest);
13         }
14
15         var lastPageInRedirectChainLoaded = false;
16         var statsChecked = false;
17
18         function receiveMessage(event) {
19             if (event.origin === "null") {
20                 if (event.data.indexOf("PASS") === -1)
21                     testFailed(event.data.replace("FAIL ", ""));
22             } else
23                 testFailed("Received a message from an unexpected origin: " + event.origin);
24
25             lastPageInRedirectChainLoaded = true;
26             if (statsChecked)
27                 finishTest();
28             else
29                 testRunner.statisticsNotifyObserver();
30         }
31
32         function checkStats() {
33             shouldBeTrue('testRunner.isStatisticsRegisteredAsSubFrameUnder("http://localhost", "http://127.0.0.1")');
34             shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
35             shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
36
37             statsChecked = true;
38             if (lastPageInRedirectChainLoaded)
39                 finishTest();
40         }
41
42         if (testRunner) {
43             testRunner.setUseITPDatabase(true);
44             setEnableFeature(true, function() {
45                 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
46                 testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
47             });
48         }
49     </script>
50 </head>
51 <body>
52 <iframe src="http://127.0.0.1:8000/resourceLoadStatistics/resources/page-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html">
53 </iframe>
54 </body>
55 </html>