2010-08-13 Mihai Parparita <mihaip@chromium.org>

        Reviewed by Dimitri Glazkov.

        Form state restore tests fail on GTK build with r65340
        https://bugs.webkit.org/show_bug.cgi?id=43998

        Move form submits (and rest of test) to run during onload, to make sure
        that the submit generates a history entry.

        * fast/forms/state-restore-to-non-autocomplete-form.html:
        * fast/forms/state-restore-to-non-edited-controls.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 44a8e522
2010-08-13 Mihai Parparita <mihaip@chromium.org>
Reviewed by Dimitri Glazkov.
Form state restore tests fail on GTK build with r65340
https://bugs.webkit.org/show_bug.cgi?id=43998
Move form submits (and rest of test) to run during onload, to make sure
that the submit generates a history entry.
* fast/forms/state-restore-to-non-autocomplete-form.html:
* fast/forms/state-restore-to-non-edited-controls.html:
2010-08-13 Mihai Parparita <mihaip@chromium.org>
Reviewed by Dimitri Glazkov.
......@@ -4,7 +4,7 @@
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<body onload="runTest()">
<p>Test to NOT restore form state to a form with autocomplete=off.</p>
<div id="console"></div>
......@@ -24,34 +24,37 @@
<script>
var parent = document.getElementById('parent');
var state = document.getElementById('emptyOnFirstVisit');
if (!state.value) {
// First visit.
if (window.layoutTestController)
layoutTestController.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.layoutTestController)
layoutTestController.notifyDone();
}
function runTest()
{
var parent = document.getElementById('parent');
var state = document.getElementById('emptyOnFirstVisit');
if (!state.value) {
// First visit.
if (window.layoutTestController)
layoutTestController.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.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
</body>
......@@ -4,7 +4,7 @@
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<body onload="runTest()">
<p>Test to NOT save state for non-edited controls</p>
<div id="console"></div>
......@@ -27,34 +27,37 @@ function makeForm(parent, buttonValue, hiddenValue, imageValue, resetValue, subm
+ '</form>';
}
var parent = document.getElementById('parent');
var state = document.getElementById('emptyOnFirstVisit');
if (!state.value) {
// First visit.
if (window.layoutTestController)
layoutTestController.waitUntilDone();
state.value = 'visited';
makeForm(parent, '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');
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("text1").value', '"edit"');
shouldBe('document.getElementById("text2").value', '"2"');
shouldBe('document.getElementById("textarea").value', '"2"');
parent.innerHTML = '';
if (window.layoutTestController)
layoutTestController.notifyDone();
function runTest()
{
var parent = document.getElementById('parent');
var state = document.getElementById('emptyOnFirstVisit');
if (!state.value) {
// First visit.
if (window.layoutTestController)
layoutTestController.waitUntilDone();
state.value = 'visited';
makeForm(parent, '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');
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("text1").value', '"edit"');
shouldBe('document.getElementById("text2").value', '"2"');
shouldBe('document.getElementById("textarea").value', '"2"');
parent.innerHTML = '';
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
</body>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment