OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body onload="runTest()"> | 6 <body onload="runTest()"> |
7 <p>Test to NOT restore form state to a form with autocomplete=off.</p> | 7 <p>Test to NOT restore form state to a form with autocomplete=off.</p> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 | 9 |
10 <input id=emptyOnFirstVisit> | 10 <input id=emptyOnFirstVisit> |
11 <div id=parent> | 11 <div id=parent> |
12 <form action="data:text/html,<script>history.back()</script>" id=form1 autoco
mplete=off> | 12 <form action="../../resources/back.html" id=form1 autocomplete=off> |
13 <input name=user id=input1> | 13 <input name=user id=input1> |
14 <textarea name=comment id=textarea1></textarea> | 14 <textarea name=comment id=textarea1></textarea> |
15 <select name=os id=select1><option>Mac<option>Windows<option>BSD</select> | 15 <select name=os id=select1><option>Mac<option>Windows<option>BSD</select> |
16 </form> | 16 </form> |
17 <form action="data:text/html,<script>history.back()</script>" id=form2> | 17 <form action="../../resources/back.html" id=form2> |
18 <input name=user id=input2> | 18 <input name=user id=input2> |
19 <textarea name=comment id=textarea2></textarea> | 19 <textarea name=comment id=textarea2></textarea> |
20 <select name=os id=select2><option>Mac<option>Windows<option>BSD</select> | 20 <select name=os id=select2><option>Mac<option>Windows<option>BSD</select> |
21 </form> | 21 </form> |
22 </div> | 22 </div> |
23 | 23 |
24 <script> | 24 <script> |
25 | 25 |
26 function runTest() | 26 function runTest() |
27 { | 27 { |
28 var parent = document.getElementById('parent'); | 28 var parent = document.getElementById('parent'); |
29 var state = document.getElementById('emptyOnFirstVisit'); | 29 var state = document.getElementById('emptyOnFirstVisit'); |
30 if (!state.value) { | 30 if (!state.value) { |
31 // First visit. | 31 // First visit. |
32 if (window.testRunner) | 32 if (window.testRunner) |
33 testRunner.waitUntilDone(); | 33 testRunner.waitUntilDone(); |
34 state.value = 'visited'; | 34 state.value = 'visited'; |
35 | 35 |
36 document.getElementById('input1').value = 'value1'; | 36 document.getElementById('input1').value = 'value1'; |
37 document.getElementById('textarea1').value = 'nice'; | 37 document.getElementById('textarea1').value = 'nice'; |
38 document.getElementById('select1').value = 'Windows'; | 38 document.getElementById('select1').value = 'Windows'; |
39 document.getElementById('input2').value = 'value2'; | 39 document.getElementById('input2').value = 'value2'; |
40 document.getElementById('textarea2').value = 'good'; | 40 document.getElementById('textarea2').value = 'good'; |
41 document.getElementById('select2').value = 'BSD'; | 41 document.getElementById('select2').value = 'BSD'; |
42 // Submit form in a timeout to make sure that we create a new back/forwa
rd list item. | 42 // Submit form in a timeout to make sure that we create a new back/forwa
rd list item. |
43 setTimeout(function() {document.getElementById('form2').submit();}, 0); | 43 setTimeout(function() {document.getElementById('form2').submit();}, 0); |
44 } else { | 44 } else { |
45 // Second visit. | 45 // Second visit. |
46 debug('Controls in the first form should have their default values:'); | 46 debug('Controls in the first form should have their default values:'); |
47 shouldBe('document.getElementById("input1").value', '""'); | 47 shouldBe('document.getElementById("input1").value', '""'); |
48 shouldBe('document.getElementById("textarea1").value', '""'); | 48 shouldBe('document.getElementById("textarea1").value', '""'); |
49 shouldBe('document.getElementById("select1").value', '"Mac"'); | 49 shouldBe('document.getElementById("select1").value', '"Mac"'); |
50 debug('Controls in the second form should have edited values:'); | 50 debug('Controls in the second form should have edited values:'); |
51 shouldBe('document.getElementById("input2").value', '"value2"'); | 51 shouldBe('document.getElementById("input2").value', '"value2"'); |
52 shouldBe('document.getElementById("textarea2").value', '"good"'); | 52 shouldBe('document.getElementById("textarea2").value', '"good"'); |
53 shouldBe('document.getElementById("select2").value', '"BSD"'); | 53 shouldBe('document.getElementById("select2").value', '"BSD"'); |
54 if (window.testRunner) | 54 if (window.testRunner) |
55 testRunner.notifyDone(); | 55 testRunner.notifyDone(); |
56 } | 56 } |
57 } | 57 } |
58 </script> | 58 </script> |
59 </body> | 59 </body> |
OLD | NEW |