chromium/third_party/blink/web_tests/http/tests/navigation/cross-origin-fragment-navigation-is-async.html

<!DOCTYPE html>
<html>
<body>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

window.onload = function() {
    window.postMessage("postmessage", "*");
    document.querySelector('iframe').src = "http://localhost:8000/navigation/resources/postmessage-on-hashchange.html#anchor1";
    if (window.internals) {
        if (internals.doesWindowHaveUrlFragment(document.querySelector('iframe').contentWindow))
            alert("FAIL: url fragment should change asynchronously");
        else
            alert("PASS: url fragment is changing asynchronously");
    }
}

var receivedScheduledPostMessage = false;
var receivedHashchangeMessage = false;
window.addEventListener('message', function (e) {
    if (e.data === 'postmessage') {
        receivedScheduledPostMessage = true;
        if (receivedHashchangeMessage)
            alert('FAIL: hashchange already triggered!');
        else
            alert('PASS: scheduled postMessage() before hashchange triggered.');
    } else {
        receivedHashchangeMessage = true;
        if (receivedScheduledPostMessage)
            alert('PASS: hashchange triggered after postMessage().');
        else
            alert('FAIL: hashchange triggered before postMessage().');
        testRunner.notifyDone();
    }
});

function onloadFired() {
    alert("iframe onload fired");
}
</script>
<p>This tests that cross-origin-initiated fragment navigations are asynchronous
and always fire the load event at their embedding iframe element if it's cross-origin. It does
so by scheduling a postMessage before scheduling the navigation. If the
navigation is synchronous, the internals API will be able to report the presence
of an url fragment immediately.</p>
<iframe src="http://localhost:8000/navigation/resources/postmessage-on-hashchange.html" onload="onloadFired()"></iframe>
</body>
</html>