<html>
<head>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function getSubframeHistory()
{
    try {
      return window.frames[0].history;
    } catch (e) {
      console.log(e);
    }
}

window.onmessage = function(evt)
{
    if (evt.data != "done") {
        alert("Unexpected message: " + evt.data);
        testRunner.notifyDone();
        return;
    }

    alert("Child window's history object after attempt to clear: " + getSubframeHistory());
    testRunner.notifyDone();
}

function setHistoryLength()
{
    alert("Child window's history object before attempt to clear: " + getSubframeHistory());
    window.frames[0].postMessage("setHistoryLength", "*");
}

</script>
</head>
<body onload="setHistoryLength();">
<iframe id='testFrame' src="http://localhost:8000/history/resources/cross-origin-replaces-history-object-child-iframe.html"></iframe>
</body>
</html>
