<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body onload="runTest()">
<p>Test to NOT save state of a detached form control.</p>
<div id="console"></div>

<input id=emptyOnFirstVisit>
<form action="data:text/html,<script>history.back()&lt;/script>" id=form1>
<input name=user id=input2>
</form>

<script>
var i1;

function runTest()
{
    var form1 = document.getElementById('form1');
    var state = document.getElementById('emptyOnFirstVisit');
    if (!state.value) {
        // First visit.
        if (window.testRunner)
            testRunner.waitUntilDone();
        state.value = 'visited';

        form1.innerHTML = '<input name=user id=input1>';
        i1 = document.getElementById('input1');
        i1.value = 'value1';
        form1.removeChild(i1);
        // Submit form in a timeout to make sure that we create a new back/forward list item.
        setTimeout(function() {document.getElementById('form1').submit();}, 0);
    } else {
        // Second visit.
        shouldBe('document.getElementById("input2").value', '""'); // Not 'value1'.

        if (window.testRunner)
            testRunner.notifyDone();
    }
 }
</script>
</body>
</html>
