<!-- webkit-test-runner [ UsesBackForwardCache=true ] -->
<html>
<head>
<script>

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

function runTest()
{
    var input = document.getElementById("testinput");
    input.setAttribute("autocomplete", "on");
    input.parentNode.removeChild(input);

    // Location changes need to happen outside the onload handler to generate history entries.
    setTimeout(function() {window.location = "data:text/html,<script>history.back();</scrip" + "t>";}, 0);
}

function pageHidden()
{
    if (!sessionStorage.finishTest) {
        console.log('navigating away');
        sessionStorage.finishTest = true;
    } else {
        // Clean up after ourselves
        delete sessionStorage.finishTest;
    }
}

function pageShown()
{
    if (sessionStorage.finishTest) {
        console.log('navigated back');
        if (window.testRunner)
            testRunner.notifyDone();
    } else {
        runTest();
    }
}

</script>    
</head>

<body onpagehide="pageHidden();" onpageshow="pageShown();">
<pre>This test has an input element that starts out with autocomplete=off.
It then changes autocomplete to on.
It then removes the element so it is destroyed.
It then navigates to a new page, placing the current page in the page cache.
Finally it returns to the original page.</pre>
<form>
<input id="testinput" autocomplete="off">
</form>
</body>
