Chromium Code Reviews| Index: LayoutTests/fast/forms/edit-autofilled-text.html |
| diff --git a/LayoutTests/fast/forms/edit-autofilled-text.html b/LayoutTests/fast/forms/edit-autofilled-text.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f0ae9945b6139f9b133d37be0557f0dc5e25cfcc |
| --- /dev/null |
| +++ b/LayoutTests/fast/forms/edit-autofilled-text.html |
| @@ -0,0 +1,80 @@ |
| +<head> |
|
tkent
2014/08/04 01:44:55
Please move this test to fast/forms/textarea/.
(Or
|
| + <script src="../../resources/js-test.js"></script> |
|
tkent
2014/08/04 01:44:55
This indentation helps nothing. Please remove it.
|
| + <script> |
| + function test() { |
| + if (window.testRunner) { |
| + testRunner.dumpAsText(); |
|
tkent
2014/08/04 01:44:55
This is unnecessary. js-test.js does it.
|
| + } |
| + |
| + if (!window.internals) { |
| + testFailed('This test requires the test harness to run.'); |
| + return; |
| + } |
| + |
| + var textarea = document.getElementById('textarea'); |
| + textarea.value = 'autofilled is true'; |
| + |
| + var computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
|
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.
|
| + var originalForeground = computedStyleTextarea.color; |
| + var originalBackground = computedStyleTextarea.backgroundColor; |
| + |
| + if (originalForeground != computedStyleTextarea.color) { |
| + testFailed('Unexpected initial foreground color for <textarea> field.'); |
| + return; |
| + } |
| + if (originalBackground != computedStyleTextarea.backgroundColor) { |
| + testFailed('Unexpected initial background color for <textarea> field.'); |
| + return; |
| + } |
| + |
| + if (window.internals) |
| + window.internals.setAutofilled(textarea, true); |
| + |
| + // Both the foreground and background colors should change. |
| + computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| + if (computedStyleTextarea.color == originalForeground) { |
| + testFailed('Foreground color for <textarea> element did not change when autofilled.'); |
| + return; |
| + } |
| + if (computedStyleTextarea.backgroundColor == originalBackground) { |
| + testFailed('Background color for <textarea> element did not change when autofilled.'); |
| + return; |
| + } |
| + |
| + // Edit the autofilled text. |
| + textarea.focus(); |
| + document.execCommand('Delete', false, null); |
| + document.execCommand('Delete', false, null); |
| + document.execCommand('Delete', false, null); |
| + document.execCommand('Delete', false, null); |
| + document.execCommand('InsertText', false, 'false'); |
| + |
| + // Colors should be restored. |
| + computedStyleTextarea = document.defaultView.getComputedStyle(textarea); |
| + if (computedStyleTextarea.color != originalForeground) { |
| + testFailed('Foreground color for <textarea> element did not revert when un-autofilled.'); |
| + return; |
| + } |
| + if (computedStyleTextarea.backgroundColor != originalBackground) { |
| + testFailed('Background color for <textarea> element did not revert when un-autofilled.'); |
| + return; |
| + } |
| + |
| + testPassed(''); |
| + } |
| + </script> |
| + |
| + <style> |
| + textarea { |
|
tkent
2014/08/04 01:44:55
Please do not indent the content of <style>.
|
| + color: #FFFFFF; |
| + background: transparent; |
| + } |
| + </style> |
| +</head> |
| +<body onload="test()"> |
| + This tests that background and foreground colors for autofilled textarea should be restored to original colors when editing the text.<br> |
| + <form name="fm"> |
| + <textarea id="textarea"></textarea> |
| + </form> |
| + <div id="console"></div> |
| +</body> |