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