| OLD | NEW |
| 1 <head> | 1 <head> |
| 2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> | 3 <script> |
| 4 function test() { | 4 function test() { |
| 5 if (window.testRunner) { | 5 if (window.testRunner) { |
| 6 testRunner.dumpAsText(); | 6 testRunner.dumpAsText(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 if (!window.internals) { | 9 if (!window.internals) { |
| 10 testFailed('This test requires the test harness to run.'); | 10 testFailed('This test requires the test harness to run.'); |
| 11 return; | 11 return; |
| 12 } | 12 } |
| 13 | 13 |
| 14 var field = document.getElementById('field'); | 14 var field = document.getElementById('field'); |
| 15 var textarea = document.getElementById('textarea'); | 15 var textarea = document.getElementById('textarea'); |
| 16 var select = document.getElementById('select'); |
| 16 | 17 |
| 17 var computedStyleField = document.defaultView.getComputedStyle(field); | 18 var computedStyleField = document.defaultView.getComputedStyle(field); |
| 18 var computedStyleTextarea = document.defaultView.getComputedStyle(textar
ea); | 19 var computedStyleTextarea = document.defaultView.getComputedStyle(textar
ea); |
| 20 var computedStyleSelect = document.defaultView.getComputedStyle(select); |
| 19 var originalForeground = computedStyleField.color; | 21 var originalForeground = computedStyleField.color; |
| 20 var originalBackground = computedStyleField.backgroundColor; | 22 var originalBackground = computedStyleField.backgroundColor; |
| 21 | 23 |
| 22 if (originalForeground != computedStyleTextarea.color) { | 24 if (originalForeground != computedStyleTextarea.color) { |
| 23 testFailed('Unexpected initial foreground color for <textarea> field
.'); | 25 testFailed('Unexpected initial foreground color for <textarea> field
.'); |
| 24 return; | 26 return; |
| 25 } | 27 } |
| 26 if (originalForeground != computedStyleTextarea.backgroundColor) { | 28 if (originalForeground != computedStyleTextarea.backgroundColor) { |
| 27 testFailed('Unexpected initial background color for <textarea> field
.'); | 29 testFailed('Unexpected initial background color for <textarea> field
.'); |
| 28 return; | 30 return; |
| 29 } | 31 } |
| 30 | 32 |
| 31 if (window.internals) { | 33 if (window.internals) { |
| 32 window.internals.setAutofilled(field, true); | 34 window.internals.setAutofilled(field, true); |
| 33 window.internals.setAutofilled(textarea, true); | 35 window.internals.setAutofilled(textarea, true); |
| 36 window.internals.setAutofilled(select, true); |
| 34 } | 37 } |
| 35 | 38 |
| 36 // Both the foreground and background colors should change. | 39 // Both the foreground and background colors should change. |
| 37 computedStyleField = document.defaultView.getComputedStyle(field); | 40 computedStyleField = document.defaultView.getComputedStyle(field); |
| 38 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); | 41 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| 42 computedStyleSelect = document.defaultView.getComputedStyle(select); |
| 39 if (computedStyleField.color == originalForeground) { | 43 if (computedStyleField.color == originalForeground) { |
| 40 testFailed('Foreground color for <input> element did not change when
autofilled.'); | 44 testFailed('Foreground color for <input> element did not change when
autofilled.'); |
| 41 return; | 45 return; |
| 42 } | 46 } |
| 43 if (computedStyleField.backgroundColor == originalBackground) { | 47 if (computedStyleField.backgroundColor == originalBackground) { |
| 44 testFailed('Background color for <input> element did not change when
autofilled.'); | 48 testFailed('Background color for <input> element did not change when
autofilled.'); |
| 45 return; | 49 return; |
| 46 } | 50 } |
| 47 if (computedStyleTextarea.color == originalForeground) { | 51 if (computedStyleTextarea.color == originalForeground) { |
| 48 testFailed('Foreground color for <textarea> element did not change w
hen autofilled.'); | 52 testFailed('Foreground color for <textarea> element did not change w
hen autofilled.'); |
| 49 return; | 53 return; |
| 50 } | 54 } |
| 51 if (computedStyleTextarea.backgroundColor == originalBackground) { | 55 if (computedStyleTextarea.backgroundColor == originalBackground) { |
| 52 testFailed('Background color for <textarea> element did not change w
hen autofilled.'); | 56 testFailed('Background color for <textarea> element did not change w
hen autofilled.'); |
| 53 return; | 57 return; |
| 54 } | 58 } |
| 59 if (computedStyleSelect.color == originalForeground) { |
| 60 testFailed('Foreground color for <select> element did not change whe
n autofilled.'); |
| 61 return; |
| 62 } |
| 63 if (computedStyleSelect.backgroundColor == originalBackground) { |
| 64 testFailed('Background color for <select> element did not change whe
n autofilled.'); |
| 65 return; |
| 66 } |
| 55 | 67 |
| 56 if (window.internals) { | 68 if (window.internals) { |
| 57 window.internals.setAutofilled(field, false); | 69 window.internals.setAutofilled(field, false); |
| 58 window.internals.setAutofilled(textarea, false); | 70 window.internals.setAutofilled(textarea, false); |
| 71 window.internals.setAutofilled(select, false); |
| 59 } | 72 } |
| 60 | 73 |
| 61 // Colors should be restored. | 74 // Colors should be restored. |
| 62 computedStyleField = document.defaultView.getComputedStyle(field); | 75 computedStyleField = document.defaultView.getComputedStyle(field); |
| 63 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); | 76 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| 77 computedStyleSelect = document.defaultView.getComputedStyle(select); |
| 64 if (computedStyleField.color != originalForeground) { | 78 if (computedStyleField.color != originalForeground) { |
| 65 testFailed('Foreground color for <input> element did not revert when
un-autofilled.'); | 79 testFailed('Foreground color for <input> element did not revert when
un-autofilled.'); |
| 66 return; | 80 return; |
| 67 } | 81 } |
| 68 if (computedStyleField.backgroundColor != originalBackground) { | 82 if (computedStyleField.backgroundColor != originalBackground) { |
| 69 testFailed('Background color for <input> element did not revert when
un-autofilled.'); | 83 testFailed('Background color for <input> element did not revert when
un-autofilled.'); |
| 70 return; | 84 return; |
| 71 } | 85 } |
| 72 if (computedStyleTextarea.color != originalForeground) { | 86 if (computedStyleTextarea.color != originalForeground) { |
| 73 testFailed('Foreground color for <textarea> element did not revert w
hen un-autofilled.'); | 87 testFailed('Foreground color for <textarea> element did not revert w
hen un-autofilled.'); |
| 74 return; | 88 return; |
| 75 } | 89 } |
| 76 if (computedStyleTextarea.backgroundColor != originalBackground) { | 90 if (computedStyleTextarea.backgroundColor != originalBackground) { |
| 77 testFailed('Background color for <textarea> element did not revert w
hen un-autofilled.'); | 91 testFailed('Background color for <textarea> element did not revert w
hen un-autofilled.'); |
| 78 return; | 92 return; |
| 79 } | 93 } |
| 94 if (computedStyleSelect.color != originalForeground) { |
| 95 testFailed('Foreground color for <select> element did not revert whe
n un-autofilled.'); |
| 96 return; |
| 97 } |
| 98 if (computedStyleSelect.backgroundColor != originalBackground) { |
| 99 testFailed('Background color for <select> element did not revert whe
n un-autofilled.'); |
| 100 return; |
| 101 } |
| 80 | 102 |
| 81 testPassed(''); | 103 testPassed(''); |
| 82 } | 104 } |
| 83 </script> | 105 </script> |
| 84 | 106 |
| 85 <style> | 107 <style> |
| 86 #field, #textarea { | 108 #field, #textarea, #select { |
| 87 color: #FFFFFF; | 109 color: #FFFFFF; |
| 88 background-color: #FFFFFF; | 110 background-color: #FFFFFF; |
| 89 } | 111 } |
| 90 </style> | 112 </style> |
| 91 </head> | 113 </head> |
| 92 <body onload="test()"> | 114 <body onload="test()"> |
| 93 This tests that foreground and background colors properly change for autofil
led inputs. It can only be run using the test harness.<br> | 115 This tests that foreground and background colors properly change for autofil
led inputs or select options. It can only be run using the test harness.<br> |
| 94 <form name="fm"> | 116 <form name="fm"> |
| 95 <input type="text" id="field" value="Field value"> | 117 <input type="text" id="field" value="Field value"> |
| 96 <textarea id="textarea"></textarea> | 118 <textarea id="textarea"></textarea> |
| 119 <select id="select"></select> |
| 97 </form> | 120 </form> |
| 98 <div id="console"></div> | 121 <div id="console"></div> |
| 99 </body> | 122 </body> |
| OLD | NEW |