| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script src="resources/util.js"></script> |
| <script> |
| description("Tests that redirects for sandboxed iframes get counted properly."); |
| jsTestIsAsync = true; |
| window.addEventListener("message", receiveMessage, false); |
| |
| function finishTest() { |
| setEnableFeature(false, finishJSTest); |
| } |
| |
| if (testRunner) { |
| setEnableFeature(true, function() { |
| testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); |
| testRunner.installStatisticsDidScanDataRecordsCallback(checkStats); |
| }); |
| } |
| |
| var lastPageInRedirectChainLoaded = false; |
| var statsChecked = false; |
| |
| function receiveMessage(event) { |
| if (event.origin === "null") { |
| if (event.data.indexOf("PASS") === -1) |
| testFailed(event.data.replace("FAIL ", "")); |
| } else |
| testFailed("Received a message from an unexpected origin: " + event.origin); |
| |
| lastPageInRedirectChainLoaded = true; |
| if (statsChecked) |
| finishTest(); |
| else |
| testRunner.statisticsNotifyObserver(); |
| } |
| |
| function checkStats() { |
| shouldBeTrue('testRunner.isStatisticsRegisteredAsSubFrameUnder("http://localhost", "http://127.0.0.1")'); |
| shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")'); |
| shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")'); |
| |
| statsChecked = true; |
| if (lastPageInRedirectChainLoaded) |
| finishTest(); |
| } |
| </script> |
| </head> |
| <body> |
| <iframe sandbox="allow-scripts" src="http://localhost:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/iframe-report-back-loaded.html"> |
| </iframe> |
| </body> |
| </html> |