chromium/third_party/blink/web_tests/fast/history/same-document-iframes-changing-fragment.html

<!DOCTYPE html> 
<html> 
<head>
  <script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<pre id="console"></pre>

<iframe src="data:text/plain,iframe1" id="iframe1" name="iframe1"></iframe> 
<iframe src="data:text/plain,iframe2" id="iframe2" name="iframe2"></iframe> 

<script>
var wentBack = false;

description('Tests that we trigger same-document navigation when history entries are generated via fragment changes, even if the frames present in the document change between history entries.');

if (window.testRunner) {
    testRunner.dumpChildFrames();
    testRunner.clearBackForwardList();
    testRunner.dumpBackForwardList();
}

onload = function()
{
    // Run afer onload, to make sure that we can generate history entries.
    setTimeout(beginTest, 0);
}

onpopstate = function(event) {
    var loc = location.href;
    var filenameAndQuery = loc.substring(loc.lastIndexOf('/') + 1);
    debug('popstate to state: ' + event.state + ' filename: ' + filenameAndQuery);
    
    if (!location.hash) {
        if (wentBack) {
            debug('going forward');
            history.forward();
        }
    } else if (location.hash == '#newState') {
        if (!wentBack) {
            wentBack = true;
            debug('going back');
            history.back();
        } else {
            finishJSTest();
        }
    } else {
        testFailed('Unexpected state');
    }
};


function beginTest() 
{
    debug('removing iframe2');
    document.body.removeChild(document.getElementById('iframe2'));

    debug('navigating to #newState');
    window.location.href = '#newState';
}
var jsTestIsAsync = true;
</script>  
</body>
</html>