Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <head> | |
|
tkent
2014/08/04 01:44:55
Please move this test to fast/forms/textarea/.
(Or
| |
| 2 <script src="../../resources/js-test.js"></script> | |
|
tkent
2014/08/04 01:44:55
This indentation helps nothing. Please remove it.
| |
| 3 <script> | |
| 4 function test() { | |
| 5 if (window.testRunner) { | |
| 6 testRunner.dumpAsText(); | |
|
tkent
2014/08/04 01:44:55
This is unnecessary. js-test.js does it.
| |
| 7 } | |
| 8 | |
| 9 if (!window.internals) { | |
| 10 testFailed('This test requires the test harness to run.'); | |
| 11 return; | |
| 12 } | |
| 13 | |
| 14 var textarea = document.getElementById('textarea'); | |
| 15 textarea.value = 'autofilled is true'; | |
| 16 | |
| 17 var computedStyleTextarea = document.defaultView.getComputedStyle(textar ea); | |
|
tkent
2014/08/04 01:44:55
Can we just check querySelector('textarea:-webkit-
ziran.sun
2014/08/04 15:23:46
I'm not sure that I fully understand your suggesti
tkent
2014/08/04 23:47:02
Right. It should make the test code simpler.
| |
| 18 var originalForeground = computedStyleTextarea.color; | |
| 19 var originalBackground = computedStyleTextarea.backgroundColor; | |
| 20 | |
| 21 if (originalForeground != computedStyleTextarea.color) { | |
| 22 testFailed('Unexpected initial foreground color for <textarea> field .'); | |
| 23 return; | |
| 24 } | |
| 25 if (originalBackground != computedStyleTextarea.backgroundColor) { | |
| 26 testFailed('Unexpected initial background color for <textarea> field .'); | |
| 27 return; | |
| 28 } | |
| 29 | |
| 30 if (window.internals) | |
| 31 window.internals.setAutofilled(textarea, true); | |
| 32 | |
| 33 // Both the foreground and background colors should change. | |
| 34 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); | |
| 35 if (computedStyleTextarea.color == originalForeground) { | |
| 36 testFailed('Foreground color for <textarea> element did not change w hen autofilled.'); | |
| 37 return; | |
| 38 } | |
| 39 if (computedStyleTextarea.backgroundColor == originalBackground) { | |
| 40 testFailed('Background color for <textarea> element did not change w hen autofilled.'); | |
| 41 return; | |
| 42 } | |
| 43 | |
| 44 // Edit the autofilled text. | |
| 45 textarea.focus(); | |
| 46 document.execCommand('Delete', false, null); | |
| 47 document.execCommand('Delete', false, null); | |
| 48 document.execCommand('Delete', false, null); | |
| 49 document.execCommand('Delete', false, null); | |
| 50 document.execCommand('InsertText', false, 'false'); | |
| 51 | |
| 52 // Colors should be restored. | |
| 53 computedStyleTextarea = document.defaultView.getComputedStyle(textarea); | |
| 54 if (computedStyleTextarea.color != originalForeground) { | |
| 55 testFailed('Foreground color for <textarea> element did not revert w hen un-autofilled.'); | |
| 56 return; | |
| 57 } | |
| 58 if (computedStyleTextarea.backgroundColor != originalBackground) { | |
| 59 testFailed('Background color for <textarea> element did not revert w hen un-autofilled.'); | |
| 60 return; | |
| 61 } | |
| 62 | |
| 63 testPassed(''); | |
| 64 } | |
| 65 </script> | |
| 66 | |
| 67 <style> | |
| 68 textarea { | |
|
tkent
2014/08/04 01:44:55
Please do not indent the content of <style>.
| |
| 69 color: #FFFFFF; | |
| 70 background: transparent; | |
| 71 } | |
| 72 </style> | |
| 73 </head> | |
| 74 <body onload="test()"> | |
| 75 This tests that background and foreground colors for autofilled textarea sho uld be restored to original colors when editing the text.<br> | |
| 76 <form name="fm"> | |
| 77 <textarea id="textarea"></textarea> | |
| 78 </form> | |
| 79 <div id="console"></div> | |
| 80 </body> | |
| OLD | NEW |