OLD | NEW |
(Empty) | |
| 1 <head> |
| 2 <script src="../../../resources/js-test.js"></script> |
| 3 <script> |
| 4 function test() { |
| 5 if (!window.internals) { |
| 6 testFailed('This test requires the test harness to run.'); |
| 7 return; |
| 8 } |
| 9 |
| 10 var textarea = document.querySelector('textarea'); |
| 11 textarea.value = 'autofilled is true'; |
| 12 |
| 13 var computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| 14 var originalForeground = computedStyleTextarea.color; |
| 15 var originalBackground = computedStyleTextarea.backgroundColor; |
| 16 |
| 17 if (window.internals) |
| 18 window.internals.setAutofilled(textarea, true); |
| 19 |
| 20 // Both the foreground and background colors should change. |
| 21 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| 22 if (computedStyleTextarea.color == originalForeground) { |
| 23 testFailed('Foreground color for <textarea> element did not change when
autofilled.'); |
| 24 return; |
| 25 } |
| 26 if (computedStyleTextarea.backgroundColor == originalBackground) { |
| 27 testFailed('Background color for <textarea> element did not change when
autofilled.'); |
| 28 return; |
| 29 } |
| 30 |
| 31 // Edit the autofilled text. |
| 32 textarea.focus(); |
| 33 document.execCommand('Delete', false, null); |
| 34 document.execCommand('Delete', false, null); |
| 35 document.execCommand('Delete', false, null); |
| 36 document.execCommand('Delete', false, null); |
| 37 document.execCommand('InsertText', false, 'false'); |
| 38 |
| 39 // Colors should be restored. |
| 40 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| 41 if (computedStyleTextarea.color != originalForeground) { |
| 42 testFailed('Foreground color for <textarea> element did not revert when
un-autofilled.'); |
| 43 return; |
| 44 } |
| 45 if (computedStyleTextarea.backgroundColor != originalBackground) { |
| 46 testFailed('Background color for <textarea> element did not revert when
un-autofilled.'); |
| 47 return; |
| 48 } |
| 49 |
| 50 testPassed(''); |
| 51 } |
| 52 </script> |
| 53 |
| 54 <style> |
| 55 textarea { |
| 56 color: #FFFFFF; |
| 57 background: transparent; |
| 58 } |
| 59 </style> |
| 60 </head> |
| 61 <body onload="test()"> |
| 62 This tests that background and foreground colors for autofilled textarea sho
uld be restored to original colors when editing the text.<br> |
| 63 <form name="fm"> |
| 64 <textarea id="textarea"></textarea> |
| 65 </form> |
| 66 <div id="console"></div> |
| 67 </body> |
OLD | NEW |