Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: LayoutTests/fast/forms/edit-autofilled-text.html

Issue 426593011: Set autofilled property to false when edit the autofilled text in textarea (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/edit-autofilled-text-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/forms/edit-autofilled-text-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698