67 lines
2.6 KiB
HTML
67 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<p>Test to NOT save state for non-edited controls</p>
|
|
<div id="console"></div>
|
|
|
|
<input id=emptyOnFirstVisit>
|
|
<div id=parent>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
function makeForm(parent, buttonValue, hiddenValue, imageValue, resetValue, submitValue, textValue0, textValue1, textValue2, textAreaValue) {
|
|
document.write('<form action="data:text/html,<script>history.back()</script>" id=form1>'
|
|
+ '<input name=button id=button type=button value="' + buttonValue + '">'
|
|
+ '<input name=hidden id=hidden type=hidden value="' + hiddenValue + '">'
|
|
+ '<input name=image id=image type=image value="' + imageValue + '">'
|
|
+ '<input name=reset id=reset type=reset value="' + resetValue + '">'
|
|
+ '<input name=submit1 id=submit1 type=submit value="' + submitValue + '">'
|
|
+ '<input name=text1 id=text0 type=text value="' + textValue0 + '">'
|
|
+ '<input name=text1 id=text1 type=text value="' + textValue1 + '">'
|
|
+ '<input name=text2 id=text2 type=text value="' + textValue2 + '">'
|
|
+ '<textarea name=textarea id=textarea>' + textAreaValue + '</textarea>'
|
|
+ '</form>');
|
|
}
|
|
|
|
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';
|
|
makeForm(parent, '1', '1', '1', '1', '1', '1', '1', '1', '1');
|
|
|
|
document.getElementById('text1').value = 'edit';
|
|
// 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.
|
|
makeForm(parent, '2', '2', '2', '2', '2', '2', '2', '2', '2');
|
|
|
|
shouldBe('document.getElementById("button").value', '"2"');
|
|
shouldBe('document.getElementById("hidden").value', '"2"');
|
|
shouldBe('document.getElementById("image").value', '"2"');
|
|
shouldBe('document.getElementById("reset").value', '"2"');
|
|
shouldBe('document.getElementById("submit1").value', '"2"');
|
|
shouldBe('document.getElementById("text0").value', '"2"');
|
|
shouldBe('document.getElementById("text1").value', '"edit"');
|
|
shouldBe('document.getElementById("text2").value', '"2"');
|
|
shouldBe('document.getElementById("textarea").value', '"2"');
|
|
|
|
parent.innerHTML = '';
|
|
if (window.testRunner)
|
|
testRunner.notifyDone();
|
|
}
|
|
}
|
|
|
|
runTest();
|
|
</script>
|
|
</body>
|