/
state-restore-to-non-autocomplete-form.html
57 lines (53 loc) · 2.22 KB
/
state-restore-to-non-autocomplete-form.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<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="data:text/html,<script>history.back()</script>" 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="data:text/html,<script>history.back()</script>" 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>
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>