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

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

Issue 471803003: Adjust autofilled property for <search> input and <select> elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and add NeedsRebaseLine for window test. 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 | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/forms/input-autofilled-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
1 <head> 1 <head>
2 <script src="../../resources/js-test.js"></script> 2 <script src="../../resources/js-test.js"></script>
3 <script> 3 <script src="resources/common.js"></script>
4 function test() { 4 <script>
5 if (window.testRunner) {
6 testRunner.dumpAsText();
7 }
8 5
9 if (!window.internals) { 6 function backgroundOf(element) {
10 testFailed('This test requires the test harness to run.'); 7 return document.defaultView.getComputedStyle(element, null).getPropertyValue ('background-color');
11 return; 8 }
12 }
13 9
14 var field = document.getElementById('field'); 10 function foregroundOf(element) {
15 var textarea = document.getElementById('textarea'); 11 return document.defaultView.getComputedStyle(element, null).getPropertyValue ('color');
16 var select = document.getElementById('select'); 12 }
17 13
18 var computedStyleField = document.defaultView.getComputedStyle(field); 14 var select2;
19 var computedStyleTextarea = document.defaultView.getComputedStyle(textar ea); 15 var autofilledSelectForeground;
20 var computedStyleSelect = document.defaultView.getComputedStyle(select); 16 var autofilledSelectBackground;
21 var originalForeground = computedStyleField.color; 17 var originalForeground = 'rgb(255, 255, 255)';
22 var originalBackground = computedStyleField.backgroundColor; 18 var originalBackground = 'rgb(255, 255, 255)';
23 19
24 if (originalForeground != computedStyleTextarea.color) { 20 function test() {
25 testFailed('Unexpected initial foreground color for <textarea> field .'); 21 if (!window.internals) {
26 return; 22 testFailed('This test requires the test harness to run.');
27 } 23 return;
28 if (originalForeground != computedStyleTextarea.backgroundColor) { 24 }
29 testFailed('Unexpected initial background color for <textarea> field .');
30 return;
31 }
32 25
33 if (window.internals) { 26 var field = document.getElementById('field');
34 window.internals.setAutofilled(field, true); 27 var search = document.getElementById('search');
35 window.internals.setAutofilled(textarea, true); 28 var textarea1 = document.getElementById('textarea1');
36 window.internals.setAutofilled(select, true); 29 var textarea2 = document.getElementById('textarea2');
37 } 30 textarea2.value = 'autofilled is true';
31 var select1 = document.getElementById('select1');
32 select2 = document.getElementById('select2');
38 33
39 // Both the foreground and background colors should change. 34 shouldBe('foregroundOf(textarea1)', 'originalForeground');
40 computedStyleField = document.defaultView.getComputedStyle(field); 35 shouldBe('backgroundOf(textarea1)', 'originalBackground');
41 computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
42 computedStyleSelect = document.defaultView.getComputedStyle(select);
43 if (computedStyleField.color == originalForeground) {
44 testFailed('Foreground color for <input> element did not change when autofilled.');
45 return;
46 }
47 if (computedStyleField.backgroundColor == originalBackground) {
48 testFailed('Background color for <input> element did not change when autofilled.');
49 return;
50 }
51 if (computedStyleTextarea.color == originalForeground) {
52 testFailed('Foreground color for <textarea> element did not change w hen autofilled.');
53 return;
54 }
55 if (computedStyleTextarea.backgroundColor == originalBackground) {
56 testFailed('Background color for <textarea> element did not change w hen autofilled.');
57 return;
58 }
59 if (computedStyleSelect.color == originalForeground) {
60 testFailed('Foreground color for <select> element did not change whe n autofilled.');
61 return;
62 }
63 if (computedStyleSelect.backgroundColor == originalBackground) {
64 testFailed('Background color for <select> element did not change whe n autofilled.');
65 return;
66 }
67 36
68 if (window.internals) { 37 window.internals.setAutofilled(field, true);
69 window.internals.setAutofilled(field, false); 38 window.internals.setAutofilled(search, true);
70 window.internals.setAutofilled(textarea, false); 39 window.internals.setAutofilled(textarea1, true);
71 window.internals.setAutofilled(select, false); 40 window.internals.setAutofilled(textarea2, true);
72 } 41 window.internals.setAutofilled(select1, true);
42 window.internals.setAutofilled(select2, true);
73 43
74 // Colors should be restored. 44 shouldBeEqualToString('search.value', 'Search value');
75 computedStyleField = document.defaultView.getComputedStyle(field);
76 computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
77 computedStyleSelect = document.defaultView.getComputedStyle(select);
78 if (computedStyleField.color != originalForeground) {
79 testFailed('Foreground color for <input> element did not revert when un-autofilled.');
80 return;
81 }
82 if (computedStyleField.backgroundColor != originalBackground) {
83 testFailed('Background color for <input> element did not revert when un-autofilled.');
84 return;
85 }
86 if (computedStyleTextarea.color != originalForeground) {
87 testFailed('Foreground color for <textarea> element did not revert w hen un-autofilled.');
88 return;
89 }
90 if (computedStyleTextarea.backgroundColor != originalBackground) {
91 testFailed('Background color for <textarea> element did not revert w hen un-autofilled.');
92 return;
93 }
94 if (computedStyleSelect.color != originalForeground) {
95 testFailed('Foreground color for <select> element did not revert whe n un-autofilled.');
96 return;
97 }
98 if (computedStyleSelect.backgroundColor != originalBackground) {
99 testFailed('Background color for <select> element did not revert whe n un-autofilled.');
100 return;
101 }
102 45
103 testPassed(''); 46 // Both the foreground and background colors should change.
104 } 47 shouldNotBe('foregroundOf(field)', 'originalForeground');
105 </script> 48 shouldNotBe('backgroundOf(field)', 'originalBackground');
49 shouldNotBe('foregroundOf(search)', 'originalForeground');
50 shouldNotBe('backgroundOf(search)', 'originalBackground');
51 shouldNotBe('foregroundOf(textarea1)', 'originalForeground');
52 shouldNotBe('backgroundOf(textarea1)', 'originalBackground');
53 shouldNotBe('foregroundOf(textarea2)', 'originalForeground');
54 shouldNotBe('backgroundOf(textarea2)', 'originalBackground');
55 shouldNotBe('foregroundOf(select1)', 'originalForeground');
56 shouldNotBe('backgroundOf(select1)', 'originalBackground');
57 shouldNotBe('foregroundOf(select2)', 'originalForeground');
58 shouldNotBe('backgroundOf(select2)', 'originalBackground');
106 59
107 <style> 60 // Remove an unselected option from <select> element. This should not affect the background color for the autofilled <select> element.
108 #field, #textarea, #select { 61 shouldBe('select2.options.length', '3');
109 color: #FFFFFF; 62 select2.removeChild(select2.childNodes[1]);
110 background-color: #FFFFFF; 63 shouldBe('select2.options.length', '2');
111 } 64 autofilledSelectForeground = foregroundOf(select2);
112 </style> 65 autofilledSelectBackground = backgroundOf(select2);
66 shouldBe('foregroundOf(select2)', 'autofilledSelectForeground');
67 shouldBe('backgroundOf(select2)', 'autofilledSelectBackground');
68
69 window.internals.setAutofilled(field, false);
70 window.internals.setAutofilled(textarea1, false);
71 window.internals.setAutofilled(select1, false);
72
73 // Cancel search by pressing cancel button
74 var cancelPos = searchCancelButtonPosition(search);
75 eventSender.mouseMoveTo(cancelPos.x, cancelPos.y);
76 eventSender.mouseDown();
77 eventSender.mouseUp();
78 shouldBeEmptyString('search.value');
79
80 // Edit text in the autofilled textarea.
81 textarea2.focus();
82 document.execCommand('Delete', false, null);
83 document.execCommand('Delete', false, null);
84 document.execCommand('Delete', false, null);
85 document.execCommand('Delete', false, null);
86 document.execCommand('InsertText', false, 'false');
87
88 // Remove selected option for select2 element
89 select2.removeChild(select2[select2.selectedIndex]);
90
91 // Colors should be restored.
92 shouldBe('foregroundOf(field)', 'originalForeground');
93 shouldBe('backgroundOf(field)', 'originalBackground');
94 shouldBe('foregroundOf(search)', 'originalForeground');
95 shouldBe('backgroundOf(search)', 'originalBackground');
96 shouldBe('foregroundOf(textarea1)', 'originalForeground');
97 shouldBe('backgroundOf(textarea1)', 'originalBackground');
98 shouldBe('foregroundOf(textarea2)', 'originalForeground');
99 shouldBe('backgroundOf(textarea2)', 'originalBackground');
100 shouldBe('foregroundOf(select1)', 'originalForeground');
101 shouldBe('backgroundOf(select1)', 'originalBackground');
102 shouldBe('foregroundOf(select2)', 'originalForeground');
103 shouldBe('backgroundOf(select2)', 'originalBackground');
104 }
105 </script>
106
107 <style>
108 #field, #search, #textarea1, #textarea2, #select1, #select2 {
109 color: #FFFFFF;
110 background-color: #FFFFFF;
111 }
112 </style>
113 </head> 113 </head>
114 <body onload="test()"> 114 <body onload="test()">
115 This tests that foreground and background colors properly change for autofil led inputs or select options. It can only be run using the test harness.<br> 115 This tests that foreground and background colors properly change for autofil led inputs or select options. It can only be run using the test harness.<br>
116 <form name="fm"> 116 <form name="fm">
117 <input type="text" id="field" value="Field value"> 117 <input type="text" id="field" value="Field value">
118 <textarea id="textarea"></textarea> 118 <input type="search" id="search" value="Search value">
119 <select id="select"></select> 119 <textarea id="textarea1"></textarea>
120 <textarea id="textarea2"></textarea>
121 <select id="select1"></select>
122 <select id="select2">
123 <option selected>1</option>
124 <option >2</option>
125 <option>3</option>
126 </select>
120 </form> 127 </form>
121 <div id="console"></div> 128 <div id="console"></div>
122 </body> 129 </body>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/forms/input-autofilled-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698