Chromium Code Reviews| 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 if (window.internals) { | |
| 94 internals.settings.setViewportEnabled(true); | |
| 95 internals.settings.setViewportMetaEnabled(true); | |
| 96 } | |
| 97 | |
| 98 var color; | |
| 99 | |
| 100 function isBoxOfColor(e, givenColor) | |
| 101 { | |
| 102 color = window.getComputedStyle(e).backgroundColor; | |
| 103 if (color == givenColor) | |
| 104 return true; | |
| 105 | |
| 106 testFailed('Box had backgroundColor: ' + color); | |
| 107 return false; | |
| 108 } | |
| 109 | |
| 110 function isBoxHoverActive(id) | |
|
Rick Byers
2014/03/13 01:40:06
there's a bunch of copy-paste here from the other
Zeeshan Qureshi
2014/03/24 21:37:43
Done in separate CL: http://crrev.com/197923006
| |
| 111 { | |
| 112 var e = document.getElementById(id); | |
| 113 return isBoxOfColor(e, "rgb(255, 255, 0)"); | |
| 114 } | |
| 115 | |
| 116 function isBoxDefault(id) | |
| 117 { | |
| 118 var e = document.getElementById(id); | |
| 119 return isBoxOfColor(e, "rgb(0, 0, 255)"); | |
| 120 } | |
| 121 | |
| 122 function isFrameDefault() | |
| 123 { | |
| 124 var e = document.getElementById('frame').contentDocument.body; | |
| 125 return isBoxOfColor(e, "rgb(0, 0, 255)"); | |
| 126 } | |
| 127 | |
| 128 function elementCenter(id) { | |
| 129 var e = document.getElementById(id); | |
| 130 return { | |
| 131 x: e.offsetLeft + e.offsetWidth / 2, | |
| 132 y: e.offsetTop + e.offsetHeight / 2 | |
| 133 } | |
| 134 } | |
| 135 | |
| 136 description("Tests gesture tapdown behaviour on different form elements."); | |
| 137 | |
| 138 function runTests() | |
| 139 { | |
| 140 if (!window.eventSender) { | |
| 141 debug('This test requires DRT.'); | |
| 142 return; | |
| 143 } | |
| 144 | |
| 145 if (!eventSender.gestureTapDown | |
| 146 || !eventSender.gestureShowPress) { | |
| 147 debug('Gesture events are not supported by this platform'); | |
| 148 return; | |
| 149 } | |
| 150 | |
| 151 // Insert meta tag after viewport has been enabled via internals | |
| 152 var meta = document.createElement('meta'); | |
| 153 meta.name = 'viewport'; | |
| 154 meta.content = 'width=device-width, initial-scale=1, user-scalable=no'; | |
| 155 document.head.appendChild(meta); | |
| 156 | |
| 157 var combobox = elementCenter("combobox"); | |
| 158 debug("Scroll and Pinch are disabled on the page"); | |
| 159 debug("Verify hover, active aren't initially set"); | |
| 160 shouldBeTrue("isBoxDefault('combobox')"); | |
| 161 eventSender.gestureTapDown(combobox.x, combobox.y); | |
| 162 debug("combobox should always be activated on tapdown"); | |
|
Rick Byers
2014/03/13 01:40:06
why? Is this something your CL changed, or has it
Zeeshan Qureshi
2014/03/24 21:37:43
A <select> tag with just 1 selectable item will ne
Rick Byers
2014/03/25 19:46:47
Why do you say "1 selectable item"? This combobox
| |
| 163 shouldBeTrue("isBoxHoverActive('combobox')"); | |
| 164 eventSender.gestureShowPress(combobox.x, combobox.y); | |
|
Rick Byers
2014/03/13 01:40:06
should you check it's state after showPress too?
Zeeshan Qureshi
2014/03/24 21:37:43
Yes, just to make sure it's maintained.
| |
| 165 eventSender.gestureTapCancel(combobox.x, combobox.y); | |
| 166 | |
| 167 var listbox = elementCenter("listbox"); | |
| 168 debug("Verify hover, active aren't initially set"); | |
| 169 shouldBeTrue("isBoxDefault('listbox')"); | |
| 170 eventSender.gestureTapDown(listbox.x, listbox.y); | |
| 171 debug("Overflow listbox should remain unchanged"); | |
|
Rick Byers
2014/03/13 01:40:06
why? Does it change after showPress?
Zeeshan Qureshi
2014/03/24 21:37:43
See below.
| |
| 172 shouldBeTrue("isBoxDefault('listbox')"); | |
| 173 eventSender.gestureShowPress(listbox.x, listbox.y); | |
| 174 eventSender.gestureTapCancel(listbox.x, listbox.y); | |
| 175 | |
| 176 var textbox = elementCenter("textbox") | |
| 177 debug("Verify hover, active aren't initially set"); | |
| 178 shouldBeTrue("isBoxDefault('textbox')"); | |
| 179 eventSender.gestureTapDown(textbox.x, textbox.y); | |
| 180 debug("Overflow textbox should remain unchanged"); | |
|
Rick Byers
2014/03/13 01:40:06
because it supports scrolling? Does it go active
Zeeshan Qureshi
2014/03/24 21:37:43
Yes, see comment below.
| |
| 181 shouldBeTrue("isBoxDefault('textbox')"); | |
| 182 eventSender.gestureShowPress(textbox.x, textbox.y); | |
| 183 eventSender.gestureTapCancel(textbox.x, textbox.y); | |
| 184 | |
| 185 var textarea = elementCenter("textarea"); | |
| 186 debug("Verify hover, active aren't initially set"); | |
| 187 shouldBeTrue("isBoxDefault('textarea')"); | |
| 188 eventSender.gestureTapDown(textarea.x, textarea.y); | |
| 189 debug("Overflow textarea should remain unchanged"); | |
| 190 shouldBeTrue("isBoxDefault('textarea')"); | |
| 191 eventSender.gestureShowPress(textarea.x, textarea.y); | |
| 192 eventSender.gestureTapCancel(textarea.x, textarea.y); | |
| 193 | |
| 194 var frame = elementCenter("frame"); | |
| 195 debug("Verify hover, active aren't initially set"); | |
| 196 shouldBeTrue("isFrameDefault()"); | |
| 197 eventSender.gestureTapDown(frame.x, frame.y); | |
| 198 debug("Overflow iframe should remain unchanged"); | |
| 199 shouldBeTrue("isFrameDefault()"); | |
| 200 eventSender.gestureShowPress(frame.x, frame.y); | |
|
Rick Byers
2014/03/13 01:40:06
We should have at least one test where doing a ges
Rick Byers
2014/03/13 01:40:06
It'll be active after the showPress, right?
Zeeshan Qureshi
2014/03/24 21:37:43
That functionality is tested in gesture-tap-active
Rick Byers
2014/03/25 19:46:47
Makes sense, thanks!
| |
| 201 eventSender.gestureTapCancel(frame.x, frame.y); | |
| 202 } | |
| 203 </script> | |
| 204 </body> | |
| 205 </html> | |
| 206 | |
| OLD | NEW |