4c2e860631634cc6b2bc602b8c8485807ba82c40
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="/js-test-resources/js-test.js"></script>
5     <script src="/js-test-resources/ui-helper.js"></script>
6     <script>
7         description("Tests that redirects for a non-sandboxed iframe get counted properly.");
8         jsTestIsAsync = true;
9         window.addEventListener("message", receiveMessage, false);
10         if (testRunner) {
11             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
12             testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
13         }
14
15         var testPhasesDone = 0;
16
17         function receiveMessage(event) {
18             if (event.origin === "http://127.0.0.1:8000") {
19                 if (event.data.indexOf("PASS") === -1)
20                     testFailed(event.data.replace("FAIL ", ""));
21             } else
22                 testFailed("Received a message from an unexpected origin: " + event.origin);
23             ++testPhasesDone;
24             if (testPhasesDone === 2)
25                 finishJSTest();
26         }
27
28         function checkStats() {
29             shouldBeTrue('testRunner.isStatisticsRegisteredAsSubFrameUnder("http://localhost", "http://127.0.0.1")');
30             shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
31             shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
32             ++testPhasesDone;
33             if (testPhasesDone === 2)
34                 finishJSTest();
35         }
36     </script>
37 </head>
38 <body>
39 <iframe src="http://127.0.0.1:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/resources/iframe-report-back-loaded.html">
40 </iframe>
41 </body>
42 </html>