<!DOCTYPE html>
<html>
<head>
    <script src="resources/util.js"></script>
</head>
<body onload="setTimeout('runTest()', 100)">
<div id="description">Non-user initiated, delayed cross-site navigations done client-side should be detected as top frame redirects by ITP.</div>
<div id="output"></div>
<script>
    if (window.testRunner) {
        testRunner.waitUntilDone();
        testRunner.dumpAsText();
    }

    const navigationEndOrigin = "http://localhost:8000";
    const navigationStartOrigin = "http://127.0.0.1:8000";

    function navigateCrossSite() {
        document.location.href = navigationEndOrigin + "/resourceLoadStatistics/log-delayed-client-side-redirects.html?dummyParam=" + Math.random();
    }

    function runTest() {
        if (document.location.origin === navigationStartOrigin) {
            setEnableFeature(true, navigateCrossSite);
        } else {
            testRunner.dumpResourceLoadStatistics();
            setEnableFeature(false, function () {
                testRunner.notifyDone();
            });
        }
    }
</script>
</body>
</html>
