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> | 6 <body> |
7 <p>Test to NOT save state for non-edited controls</p> | 7 <p>Test to NOT save state for non-edited controls</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 </div> | 12 </div> |
13 | 13 |
14 <script> | 14 <script> |
15 | 15 |
16 function makeForm(parent, buttonValue, hiddenValue, imageValue, resetValue, subm
itValue, textValue0, textValue1, textValue2, textAreaValue) { | 16 function makeForm(parent, buttonValue, hiddenValue, imageValue, resetValue, subm
itValue, textValue0, textValue1, textValue2, textAreaValue) { |
17 document.write('<form action="data:text/html,<script>history.back()</scri
pt>" id=form1>' | 17 document.write('<form action="../../resources/back.html" id=form1>' |
18 + '<input name=button id=button type=button value="' + buttonValue + '">
' | 18 + '<input name=button id=button type=button value="' + buttonValue + '">
' |
19 + '<input name=hidden id=hidden type=hidden value="' + hiddenValue + '">
' | 19 + '<input name=hidden id=hidden type=hidden value="' + hiddenValue + '">
' |
20 + '<input name=image id=image type=image value="' + imageValue + '">' | 20 + '<input name=image id=image type=image value="' + imageValue + '">' |
21 + '<input name=reset id=reset type=reset value="' + resetValue + '">' | 21 + '<input name=reset id=reset type=reset value="' + resetValue + '">' |
22 + '<input name=submit1 id=submit1 type=submit value="' + submitValue + '
">' | 22 + '<input name=submit1 id=submit1 type=submit value="' + submitValue + '
">' |
23 + '<input name=text1 id=text0 type=text value="' + textValue0 + '">' | 23 + '<input name=text1 id=text0 type=text value="' + textValue0 + '">' |
24 + '<input name=text1 id=text1 type=text value="' + textValue1 + '">' | 24 + '<input name=text1 id=text1 type=text value="' + textValue1 + '">' |
25 + '<input name=text2 id=text2 type=text value="' + textValue2 + '">' | 25 + '<input name=text2 id=text2 type=text value="' + textValue2 + '">' |
26 + '<textarea name=textarea id=textarea>' + textAreaValue + '</textarea>' | 26 + '<textarea name=textarea id=textarea>' + textAreaValue + '</textarea>' |
27 + '</form>'); | 27 + '</form>'); |
28 } | 28 } |
29 | 29 |
30 function runTest() | 30 function runTest() |
31 { | 31 { |
32 var parent = document.getElementById('parent'); | 32 var parent = document.getElementById('parent'); |
33 var state = document.getElementById('emptyOnFirstVisit'); | 33 var state = document.getElementById('emptyOnFirstVisit'); |
34 if (!state.value) { | 34 if (!state.value) { |
35 // First visit. | 35 // First visit. |
36 if (window.testRunner) | 36 if (window.testRunner) |
37 testRunner.waitUntilDone(); | 37 testRunner.waitUntilDone(); |
38 state.value = 'visited'; | 38 state.value = 'visited'; |
39 makeForm(parent, '1', '1', '1', '1', '1', '1', '1', '1', '1'); | 39 makeForm(parent, '1', '1', '1', '1', '1', '1', '1', '1', '1'); |
40 | 40 |
41 document.getElementById('text1').value = 'edit'; | 41 document.getElementById('text1').value = 'edit'; |
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('form1').submit();}, 100)
; | 43 setTimeout(function() {document.getElementById('form1').submit();}, 100)
; |
44 } else { | 44 } else { |
45 // Second visit. | 45 // Second visit. |
46 makeForm(parent, '2', '2', '2', '2', '2', '2', '2', '2', '2'); | 46 makeForm(parent, '2', '2', '2', '2', '2', '2', '2', '2', '2'); |
47 | 47 |
48 shouldBe('document.getElementById("button").value', '"2"'); | 48 shouldBe('document.getElementById("button").value', '"2"'); |
49 shouldBe('document.getElementById("hidden").value', '"2"'); | 49 shouldBe('document.getElementById("hidden").value', '"2"'); |
50 shouldBe('document.getElementById("image").value', '"2"'); | 50 shouldBe('document.getElementById("image").value', '"2"'); |
51 shouldBe('document.getElementById("reset").value', '"2"'); | 51 shouldBe('document.getElementById("reset").value', '"2"'); |
52 shouldBe('document.getElementById("submit1").value', '"2"'); | 52 shouldBe('document.getElementById("submit1").value', '"2"'); |
53 shouldBe('document.getElementById("text0").value', '"2"'); | 53 shouldBe('document.getElementById("text0").value', '"2"'); |
54 shouldBe('document.getElementById("text1").value', '"edit"'); | 54 shouldBe('document.getElementById("text1").value', '"edit"'); |
55 shouldBe('document.getElementById("text2").value', '"2"'); | 55 shouldBe('document.getElementById("text2").value', '"2"'); |
56 shouldBe('document.getElementById("textarea").value', '"2"'); | 56 shouldBe('document.getElementById("textarea").value', '"2"'); |
57 | 57 |
58 parent.innerHTML = ''; | 58 parent.innerHTML = ''; |
59 if (window.testRunner) | 59 if (window.testRunner) |
60 testRunner.notifyDone(); | 60 testRunner.notifyDone(); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 runTest(); | 64 runTest(); |
65 </script> | 65 </script> |
66 </body> | 66 </body> |
OLD | NEW |