<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body onload="runTest()">
<p>Test to restore form value states for a radio group.</p>
<div id="console"></div>

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

<script>

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

        document.getElementById('input1').checked = true;
        // 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.
        shouldBeTrue('document.getElementById("input1").checked');
        shouldBeFalse('document.getElementById("input2").checked');
        if (window.testRunner)
            testRunner.notifyDone();
    }
}
</script>
</body>
