blob: dad54c0bbf7e4f5034d88ce9443d4e2d592c3aa7 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body onload="runTest()">
<p>Test to NOT restore form state to a form with autocomplete=off.</p>
<div id="console"></div>
<input id=emptyOnFirstVisit>
<div id=parent>
<form action="../../resources/back.html" id=form1 autocomplete=off>
<input name=user id=input1>
<textarea name=comment id=textarea1></textarea>
<select name=os id=select1><option>Mac<option>Windows<option>BSD</select>
</form>
<form action="../../resources/back.html" id=form2>
<input name=user id=input2>
<textarea name=comment id=textarea2></textarea>
<select name=os id=select2><option>Mac<option>Windows<option>BSD</select>
</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').value = 'value1';
document.getElementById('textarea1').value = 'nice';
document.getElementById('select1').value = 'Windows';
document.getElementById('input2').value = 'value2';
document.getElementById('textarea2').value = 'good';
document.getElementById('select2').value = 'BSD';
// Submit form in a timeout to make sure that we create a new back/forward list item.
setTimeout(function() {document.getElementById('form2').submit();}, 0);
} else {
// Second visit.
debug('Controls in the first form should have their default values:');
shouldBe('document.getElementById("input1").value', '""');
shouldBe('document.getElementById("textarea1").value', '""');
shouldBe('document.getElementById("select1").value', '"Mac"');
debug('Controls in the second form should have edited values:');
shouldBe('document.getElementById("input2").value', '"value2"');
shouldBe('document.getElementById("textarea2").value', '"good"');
shouldBe('document.getElementById("select2").value', '"BSD"');
if (window.testRunner)
testRunner.notifyDone();
}
}
</script>
</body>