OLD | NEW |
1 <head> | 1 <head> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <script src="resources/common.js"></script> | 3 <script src="resources/common.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 function backgroundOf(element) { | 6 function backgroundOf(element) { |
7 return document.defaultView.getComputedStyle(element, null).getPropertyValue
('background-color'); | 7 return document.defaultView.getComputedStyle(element, null).getPropertyValue
('background-color'); |
8 } | 8 } |
9 | 9 |
10 function foregroundOf(element) { | 10 function foregroundOf(element) { |
(...skipping 12 matching lines...) Expand all Loading... |
23 return; | 23 return; |
24 } | 24 } |
25 | 25 |
26 var field = document.getElementById('field'); | 26 var field = document.getElementById('field'); |
27 var search = document.getElementById('search'); | 27 var search = document.getElementById('search'); |
28 var textarea1 = document.getElementById('textarea1'); | 28 var textarea1 = document.getElementById('textarea1'); |
29 var textarea2 = document.getElementById('textarea2'); | 29 var textarea2 = document.getElementById('textarea2'); |
30 textarea2.value = 'autofilled is true'; | 30 textarea2.value = 'autofilled is true'; |
31 var select1 = document.getElementById('select1'); | 31 var select1 = document.getElementById('select1'); |
32 select2 = document.getElementById('select2'); | 32 select2 = document.getElementById('select2'); |
33 var select3 = document.getElementById('select3'); | |
34 | 33 |
35 shouldBe('foregroundOf(textarea1)', 'originalForeground'); | 34 shouldBe('foregroundOf(textarea1)', 'originalForeground'); |
36 shouldBe('backgroundOf(textarea1)', 'originalBackground'); | 35 shouldBe('backgroundOf(textarea1)', 'originalBackground'); |
37 | 36 |
38 window.internals.setAutofilled(field, true); | 37 window.internals.setAutofilled(field, true); |
39 window.internals.setAutofilled(search, true); | 38 window.internals.setAutofilled(search, true); |
40 window.internals.setAutofilled(textarea1, true); | 39 window.internals.setAutofilled(textarea1, true); |
41 window.internals.setAutofilled(textarea2, true); | 40 window.internals.setAutofilled(textarea2, true); |
42 window.internals.setAutofilled(select1, true); | 41 window.internals.setAutofilled(select1, true); |
43 window.internals.setAutofilled(select2, true); | 42 window.internals.setAutofilled(select2, true); |
44 window.internals.setAutofilled(select3, true); | |
45 | 43 |
46 shouldBeEqualToString('search.value', 'Search value'); | 44 shouldBeEqualToString('search.value', 'Search value'); |
47 | 45 |
48 // Both the foreground and background colors should change. | 46 // Both the foreground and background colors should change. |
49 shouldNotBe('foregroundOf(field)', 'originalForeground'); | 47 shouldNotBe('foregroundOf(field)', 'originalForeground'); |
50 shouldNotBe('backgroundOf(field)', 'originalBackground'); | 48 shouldNotBe('backgroundOf(field)', 'originalBackground'); |
51 shouldNotBe('foregroundOf(search)', 'originalForeground'); | 49 shouldNotBe('foregroundOf(search)', 'originalForeground'); |
52 shouldNotBe('backgroundOf(search)', 'originalBackground'); | 50 shouldNotBe('backgroundOf(search)', 'originalBackground'); |
53 shouldNotBe('foregroundOf(textarea1)', 'originalForeground'); | 51 shouldNotBe('foregroundOf(textarea1)', 'originalForeground'); |
54 shouldNotBe('backgroundOf(textarea1)', 'originalBackground'); | 52 shouldNotBe('backgroundOf(textarea1)', 'originalBackground'); |
55 shouldNotBe('foregroundOf(textarea2)', 'originalForeground'); | 53 shouldNotBe('foregroundOf(textarea2)', 'originalForeground'); |
56 shouldNotBe('backgroundOf(textarea2)', 'originalBackground'); | 54 shouldNotBe('backgroundOf(textarea2)', 'originalBackground'); |
57 shouldNotBe('foregroundOf(select1)', 'originalForeground'); | 55 shouldNotBe('foregroundOf(select1)', 'originalForeground'); |
58 shouldNotBe('backgroundOf(select1)', 'originalBackground'); | 56 shouldNotBe('backgroundOf(select1)', 'originalBackground'); |
59 shouldNotBe('foregroundOf(select2)', 'originalForeground'); | 57 shouldNotBe('foregroundOf(select2)', 'originalForeground'); |
60 shouldNotBe('backgroundOf(select2)', 'originalBackground'); | 58 shouldNotBe('backgroundOf(select2)', 'originalBackground'); |
61 shouldNotBe('foregroundOf(select3)', 'originalForeground'); | |
62 shouldNotBe('backgroundOf(select3)', 'originalBackground'); | |
63 | 59 |
64 // Remove an unselected option from <select> element. This should not affect
the background color for the autofilled <select> element. | 60 // Remove an unselected option from <select> element. This should not affect
the background color for the autofilled <select> element. |
65 shouldBe('select2.options.length', '3'); | 61 shouldBe('select2.options.length', '3'); |
66 select2.removeChild(select2.childNodes[1]); | 62 select2.removeChild(select2.childNodes[1]); |
67 shouldBe('select2.options.length', '2'); | 63 shouldBe('select2.options.length', '2'); |
68 autofilledSelectForeground = foregroundOf(select2); | 64 autofilledSelectForeground = foregroundOf(select2); |
69 autofilledSelectBackground = backgroundOf(select2); | 65 autofilledSelectBackground = backgroundOf(select2); |
70 shouldBe('foregroundOf(select2)', 'autofilledSelectForeground'); | 66 shouldBe('foregroundOf(select2)', 'autofilledSelectForeground'); |
71 shouldBe('backgroundOf(select2)', 'autofilledSelectBackground'); | 67 shouldBe('backgroundOf(select2)', 'autofilledSelectBackground'); |
72 | 68 |
(...skipping 12 matching lines...) Expand all Loading... |
85 textarea2.focus(); | 81 textarea2.focus(); |
86 document.execCommand('Delete', false, null); | 82 document.execCommand('Delete', false, null); |
87 document.execCommand('Delete', false, null); | 83 document.execCommand('Delete', false, null); |
88 document.execCommand('Delete', false, null); | 84 document.execCommand('Delete', false, null); |
89 document.execCommand('Delete', false, null); | 85 document.execCommand('Delete', false, null); |
90 document.execCommand('InsertText', false, 'false'); | 86 document.execCommand('InsertText', false, 'false'); |
91 | 87 |
92 // Remove selected option for select2 element | 88 // Remove selected option for select2 element |
93 select2.removeChild(select2[select2.selectedIndex]); | 89 select2.removeChild(select2[select2.selectedIndex]); |
94 | 90 |
95 // Change selected option for select3 element | |
96 select3.selectedIndex = 2; | |
97 | |
98 // Colors should be restored. | 91 // Colors should be restored. |
99 shouldBe('foregroundOf(field)', 'originalForeground'); | 92 shouldBe('foregroundOf(field)', 'originalForeground'); |
100 shouldBe('backgroundOf(field)', 'originalBackground'); | 93 shouldBe('backgroundOf(field)', 'originalBackground'); |
101 shouldBe('foregroundOf(search)', 'originalForeground'); | 94 shouldBe('foregroundOf(search)', 'originalForeground'); |
102 shouldBe('backgroundOf(search)', 'originalBackground'); | 95 shouldBe('backgroundOf(search)', 'originalBackground'); |
103 shouldBe('foregroundOf(textarea1)', 'originalForeground'); | 96 shouldBe('foregroundOf(textarea1)', 'originalForeground'); |
104 shouldBe('backgroundOf(textarea1)', 'originalBackground'); | 97 shouldBe('backgroundOf(textarea1)', 'originalBackground'); |
105 shouldBe('foregroundOf(textarea2)', 'originalForeground'); | 98 shouldBe('foregroundOf(textarea2)', 'originalForeground'); |
106 shouldBe('backgroundOf(textarea2)', 'originalBackground'); | 99 shouldBe('backgroundOf(textarea2)', 'originalBackground'); |
107 shouldBe('foregroundOf(select1)', 'originalForeground'); | 100 shouldBe('foregroundOf(select1)', 'originalForeground'); |
108 shouldBe('backgroundOf(select1)', 'originalBackground'); | 101 shouldBe('backgroundOf(select1)', 'originalBackground'); |
109 shouldBe('foregroundOf(select2)', 'originalForeground'); | 102 shouldBe('foregroundOf(select2)', 'originalForeground'); |
110 shouldBe('backgroundOf(select2)', 'originalBackground'); | 103 shouldBe('backgroundOf(select2)', 'originalBackground'); |
111 shouldBe('foregroundOf(select3)', 'originalForeground'); | |
112 shouldBe('backgroundOf(select3)', 'originalBackground'); | |
113 } | 104 } |
114 </script> | 105 </script> |
115 | 106 |
116 <style> | 107 <style> |
117 #field, #search, #textarea1, #textarea2, #select1, #select2, #select3 { | 108 #field, #search, #textarea1, #textarea2, #select1, #select2 { |
118 color: #FFFFFF; | 109 color: #FFFFFF; |
119 background-color: #FFFFFF; | 110 background-color: #FFFFFF; |
120 } | 111 } |
121 </style> | 112 </style> |
122 </head> | 113 </head> |
123 <body onload="test()"> | 114 <body onload="test()"> |
124 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> |
125 <form name="fm"> | 116 <form name="fm"> |
126 <input type="text" id="field" value="Field value"> | 117 <input type="text" id="field" value="Field value"> |
127 <input type="search" id="search" value="Search value"> | 118 <input type="search" id="search" value="Search value"> |
128 <textarea id="textarea1"></textarea> | 119 <textarea id="textarea1"></textarea> |
129 <textarea id="textarea2"></textarea> | 120 <textarea id="textarea2"></textarea> |
130 <select id="select1"></select> | 121 <select id="select1"></select> |
131 <select id="select2"> | 122 <select id="select2"> |
132 <option selected>1</option> | 123 <option selected>1</option> |
133 <option >2</option> | 124 <option >2</option> |
134 <option>3</option> | 125 <option>3</option> |
135 </select> | 126 </select> |
136 <select id="select3"> | |
137 <option selected>1</option> | |
138 <option >2</option> | |
139 <option>3</option> | |
140 </select> | |
141 </form> | 127 </form> |
142 <div id="console"></div> | 128 <div id="console"></div> |
143 </body> | 129 </body> |
OLD | NEW |