chromium/third_party/blink/web_tests/fast/loader/hashchange-event-properties.html

<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<div id="description"></div>
<pre id="console"></pre>
<script>
description('Tests that hashchange events have the expected newURL and oldURL properties.');

function hashOf(url)
{
    var hashIndex = url.lastIndexOf('#');
    return hashIndex != -1 ? url.substring(hashIndex) : '[none]';
}

var goingForward = true;

onload = function()
{
    setTimeout(function() {location.href = '#state1';}, 0);
};

onhashchange = function(event)
{
    debug('hashchange fired with oldURL hash "' + hashOf(event.oldURL) + '" and newURL hash "' + hashOf(event.newURL) + '"');
    
    switch (hashOf(event.newURL)) {
        case '#state1':
            if (goingForward)
                location.href = '#state2';
            else
                history.back();
            break;
        case '#state2':
            if (goingForward) {
                goingForward = false;
                history.back();
            } else {
                testFailed('should always be going forward at #state2');
            }
            break;
        case '[none]':
            finishJSTest();
            break;
    }
};
var jsTestIsAsync = true;
</script>
</html>