OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../../../resources/js-test.js"></script> | |
5 <style> | |
6 #box { | |
7 width: 300px; | |
8 height: 50px; | |
9 } | |
10 | |
11 #overflowBox { | |
12 width: 300px; | |
13 height: 600px; | |
14 } | |
15 | |
16 #container { | |
17 width: 300px; | |
18 height: 50px; | |
19 overflow-y: scroll; | |
20 overflow-x: hidden; | |
21 margin: 10px 0 10px 0; | |
22 } | |
23 | |
24 #frame { | |
25 width: 200px; | |
26 height: 50px; | |
27 } | |
28 | |
29 .interactive { background-color: blue; } | |
30 | |
31 .interactive:hover { background-color: red; } | |
32 | |
33 .interactive:active { background-color: green; } | |
34 | |
35 .interactive:hover:active { background-color: yellow; } | |
36 | |
37 </style> | |
38 </head> | |
39 <body onload="runTests()"> | |
40 | |
41 <select id="combobox" class="interactive"> | |
42 <option value="1"> One </option> | |
43 <option value="2"> Two </option> | |
44 <option value="3"> Three </option> | |
45 <option value="4"> Four </option> | |
46 <option value="5"> Five </option> | |
47 <option value="6"> Six </option> | |
48 <option value="7"> Sever </option> | |
49 <option value="8"> Eight </option> | |
50 <option value="9"> Nine </option> | |
51 <option value="10"> Ten </option> | |
52 <option value="11"> Eleven </option> | |
53 <option value="12"> Twelve </option> | |
54 <option value="13"> Thirteen </option> | |
55 <option value="14"> Fourteen </option> | |
56 <option value="15"> Fifteen </option> | |
57 <option value="16"> Sixteen </option> | |
58 <option value="17"> Seventeen </option> | |
59 <option value="18"> Eighteen </option> | |
60 <option value="19"> Nineteen </option> | |
61 <option value="20"> Twenty </option> | |
62 </select> | |
63 | |
64 <select id="listbox" class="interactive" multiple="5"> | |
65 <option value="1"> One </option> | |
66 <option value="2"> Two </option> | |
67 <option value="3"> Three </option> | |
68 <option value="4"> Four </option> | |
69 <option value="5"> Five </option> | |
70 <option value="6"> Six </option> | |
71 <option value="7"> Sever </option> | |
72 <option value="8"> Eight </option> | |
73 <option value="9"> Nine </option> | |
74 <option value="10"> Ten </option> | |
75 </select> | |
76 | |
77 <input type="text" id="textbox" class="interactive" value="The input element rep resents a typed data field, usually with a form control to allow the user to edi t the data."/> | |
78 | |
79 <textarea id="textarea" class="interactive" rows="3"> | |
80 The textarea element represents a multiline plain text edit control for the elem ent's raw value. The contents of the control represent the control's default val ue. | |
81 | |
82 The raw value of a textarea control must be initially the empty string. | |
83 </textarea> | |
84 | |
85 <iframe id="frame" src="resources/gesture-tap-down-iframe.html"></iframe> | |
86 | |
87 <p id="description"></p> | |
88 <p>See http://crbug.com/316974 for details</p> | |
89 | |
90 <div id="console" style="clear:both; float: left"></div> | |
91 | |
92 <script> | |
93 var console = document.getElementById('console'); | |
94 document.onmousemove = function(e) { | |
95 console.innerHTML = e.pageX + ', ' + e.pageY; | |
96 } | |
97 | |
98 if (window.internals) { | |
99 internals.settings.setViewportEnabled(true); | |
100 internals.settings.setViewportMetaEnabled(true); | |
101 } | |
102 | |
103 var color; | |
104 | |
105 function isBoxOfColor(e, givenColor) | |
106 { | |
107 color = window.getComputedStyle(e).backgroundColor; | |
108 if (color == givenColor) | |
109 return true; | |
110 | |
111 testFailed('Box had backgroundColor: ' + color); | |
112 return false; | |
113 } | |
114 | |
115 function isBoxHoverActive(id) | |
116 { | |
117 var e = document.getElementById(id); | |
118 return isBoxOfColor(e, "rgb(255, 255, 0)"); | |
119 } | |
120 | |
121 function isBoxDefault(id) | |
122 { | |
123 var e = document.getElementById(id); | |
124 return isBoxOfColor(e, "rgb(0, 0, 255)"); | |
125 } | |
126 | |
127 function isFrameDefault() | |
128 { | |
129 var e = document.getElementById('frame').contentDocument.body; | |
130 return isBoxOfColor(e, "rgb(0, 0, 255)"); | |
131 } | |
132 | |
133 description("Tests gesture tapdown behaviour on different form elements."); | |
134 | |
135 function runTests() | |
136 { | |
137 if (!window.eventSender) { | |
138 debug('This test requires DRT.'); | |
139 return; | |
140 } | |
141 | |
142 if (!eventSender.gestureTapDown | |
143 || !eventSender.gestureShowPress) { | |
144 debug('Gesture events are not supported by this platform'); | |
145 return; | |
146 } | |
147 | |
148 // Insert meta tag after viewport has been enabled via internals | |
149 var meta = document.createElement('meta'); | |
150 meta.name = 'viewport'; | |
151 meta.content = 'width=device-width, initial-scale=1, user-scalable=no'; | |
152 document.head.appendChild(meta); | |
153 | |
154 debug("Scroll and Pinch are disabled on the page"); | |
155 debug("Verify hover, active aren't initially set"); | |
156 shouldBeTrue("isBoxDefault('combobox')"); | |
157 eventSender.gestureTapDown(50, 65); | |
bokan
2014/03/03 13:01:19
Get the coordinates of the element you're trying t
| |
158 debug("combobox should always be activated on tapdown"); | |
159 shouldBeTrue("isBoxHoverActive('combobox')"); | |
160 eventSender.gestureShowPress(50, 65); | |
161 eventSender.gestureTapCancel(50, 65); | |
162 | |
163 debug("Verify hover, active aren't initially set"); | |
164 shouldBeTrue("isBoxDefault('listbox')"); | |
165 eventSender.gestureTapDown(125, 50); | |
166 debug("Overflow listbox should remain unchanged"); | |
167 shouldBeTrue("isBoxDefault('listbox')"); | |
168 eventSender.gestureShowPress(125, 50); | |
169 eventSender.gestureTapCancel(125, 50); | |
170 | |
171 debug("Verify hover, active aren't initially set"); | |
172 shouldBeTrue("isBoxDefault('textbox')"); | |
173 eventSender.gestureTapDown(240, 65); | |
174 debug("Overflow textbox should remain unchanged"); | |
175 shouldBeTrue("isBoxDefault('textbox')"); | |
176 eventSender.gestureShowPress(240, 65); | |
177 eventSender.gestureTapCancel(240, 65); | |
178 | |
179 debug("Verify hover, active aren't initially set"); | |
180 shouldBeTrue("isBoxDefault('textarea')"); | |
181 eventSender.gestureTapDown(400, 45); | |
182 debug("Overflow textarea should remain unchanged"); | |
183 shouldBeTrue("isBoxDefault('textarea')"); | |
184 eventSender.gestureShowPress(400, 45); | |
185 eventSender.gestureTapCancel(400, 45); | |
186 | |
187 debug("Verify hover, active aren't initially set"); | |
188 shouldBeTrue("isFrameDefault()"); | |
189 eventSender.gestureTapDown(600, 45); | |
190 debug("Overflow iframe should remain unchanged"); | |
191 shouldBeTrue("isFrameDefault()"); | |
192 eventSender.gestureShowPress(600, 45); | |
193 eventSender.gestureTapCancel(600, 45); | |
194 } | |
195 </script> | |
196 </body> | |
197 </html> | |
198 | |
OLD | NEW |