Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../../resources/js-test.js"></script> | |
| 5 <style type="text/css"> | |
| 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 .interactive { background-color: blue; } | |
| 25 | |
| 26 .interactive:hover { background-color: red; } | |
| 27 | |
| 28 .interactive:active { background-color: green; } | |
| 29 | |
| 30 .interactive:hover:active { background-color: yellow; } | |
| 31 | |
| 32 #scroller { | |
|
Rick Byers
2014/03/13 01:40:05
nit: "scroller" suggests overflow:scroll to me. M
Zeeshan Qureshi
2014/03/24 21:37:43
Done.
| |
| 33 display: none; | |
| 34 width: 100px; | |
| 35 height: 600px; | |
| 36 } | |
| 37 </style> | |
| 38 </head> | |
| 39 <body> | |
| 40 <div id="box" class="interactive">Gestures go here</div> | |
| 41 <div id="container"> | |
| 42 <div id="overflowBox" class="interactive">Gestures go here</div> | |
| 43 </div> | |
| 44 | |
| 45 <p id="description"></p> | |
| 46 <p>See http://crbug.com/316974 for details</p> | |
| 47 | |
| 48 <div id="console"></div> | |
| 49 | |
| 50 <div id="scroller"></div> | |
| 51 | |
| 52 <script> | |
| 53 if (window.internals) { | |
| 54 internals.settings.setViewportEnabled(true); | |
| 55 internals.settings.setViewportMetaEnabled(true); | |
| 56 } | |
| 57 | |
| 58 var color; | |
| 59 | |
| 60 function isBoxOfColor(id, givenColor) | |
| 61 { | |
| 62 var b = document.getElementById(id); | |
| 63 color = window.getComputedStyle(b).backgroundColor; | |
| 64 if (color == givenColor) | |
| 65 return true; | |
| 66 | |
| 67 testFailed('Box had backgroundColor: ' + color); | |
| 68 return false; | |
| 69 } | |
| 70 | |
| 71 function isBoxHoverActive(id) | |
| 72 { | |
| 73 return isBoxOfColor(id, "rgb(255, 255, 0)"); | |
| 74 } | |
| 75 | |
| 76 function isBoxDefault(id) | |
| 77 { | |
| 78 return isBoxOfColor(id, "rgb(0, 0, 255)"); | |
| 79 } | |
| 80 | |
| 81 function elementCenter(id) { | |
| 82 var e = document.getElementById(id); | |
| 83 return { | |
| 84 x: e.offsetLeft + e.offsetWidth / 2, | |
| 85 y: e.offsetTop + e.offsetHeight / 2 | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 description("Tests gesture tapdown behaviour on different scroll / pinch setting s."); | |
| 90 | |
| 91 function runTests() | |
| 92 { | |
| 93 if (!window.eventSender) { | |
| 94 debug('This test requires DRT.'); | |
| 95 return; | |
| 96 } | |
| 97 | |
| 98 if (!eventSender.gestureTapDown | |
| 99 || !eventSender.gestureShowPress) { | |
| 100 debug('Gesture events are not supported by this platform'); | |
| 101 return; | |
| 102 } | |
| 103 | |
| 104 // Insert meta tag after viewport has been enabled via internals | |
| 105 var meta = document.createElement('meta'); | |
| 106 meta.name = 'viewport'; | |
| 107 meta.content = 'initial-scale=1, maximum-scale=2'; | |
| 108 document.head.appendChild(meta); | |
| 109 | |
| 110 // Verify behaviour when page is pinchable | |
| 111 debug("Verify hover, active aren't initially set (scroll disabled, pinch ena bled)."); | |
| 112 shouldBeTrue("isBoxDefault('box')"); | |
| 113 | |
| 114 var box = elementCenter("box"); | |
| 115 debug("tapdown on element should not activate."); | |
| 116 eventSender.gestureTapDown(box.x, box.y); | |
| 117 shouldBeTrue("isBoxDefault('box')"); | |
| 118 | |
| 119 debug("showpress on element should activate."); | |
| 120 eventSender.gestureShowPress(box.x, box.y); | |
| 121 shouldBeTrue("isBoxHoverActive('box')"); | |
| 122 eventSender.gestureTapCancel(box.x, box.y); | |
|
Rick Byers
2014/03/13 01:40:05
can you test after this that it's no longer active
Zeeshan Qureshi
2014/03/24 21:37:43
Yes, it goes inactive but stays hovered. Already t
| |
| 123 | |
| 124 // Send a sequence to another element to clear current one without relying o n tap | |
|
Rick Byers
2014/03/13 01:40:05
This is just to clear hover (active is already cle
Zeeshan Qureshi
2014/03/24 21:37:43
Yep
| |
| 125 var container = elementCenter("container"); | |
| 126 eventSender.gestureTapDown(container.x, container.y); | |
| 127 eventSender.gestureShowPress(container.x, container.y); | |
| 128 eventSender.gestureTapCancel(container.x, container.y); | |
| 129 | |
| 130 // Update viewport to make page non-pinchable | |
| 131 meta.content = 'width=device-width, initial-scale=1, user-scalable=no'; | |
| 132 | |
| 133 // Verify behaviour when page isn't scrollable or pinchable | |
| 134 debug("Verify hover, active aren't initially set (scroll disabled, pinch dis abled)."); | |
| 135 shouldBeTrue("isBoxDefault('box')"); | |
| 136 | |
| 137 debug("tapdown on element should activate."); | |
| 138 eventSender.gestureTapDown(box.x, box.y); | |
| 139 shouldBeTrue("isBoxHoverActive('box')"); | |
| 140 | |
| 141 debug("showpress on element should keep hover and active."); | |
| 142 eventSender.gestureShowPress(box.x, box.y); | |
| 143 shouldBeTrue("isBoxHoverActive('box')"); | |
| 144 eventSender.gestureTapCancel(box.x, box.y); | |
| 145 | |
| 146 // Verify behaviour when ancestor is scrollable | |
| 147 debug("Verify hover, active aren't initially set (overflowBox with scrollabl e ancestor)."); | |
| 148 shouldBeTrue("isBoxDefault('overflowBox')"); | |
| 149 | |
| 150 debug("tapdown on element should not activate."); | |
| 151 eventSender.gestureTapDown(container.x, container.y); | |
| 152 shouldBeTrue("isBoxDefault('overflowBox')"); | |
| 153 | |
| 154 debug("showpress on element should activate."); | |
| 155 eventSender.gestureShowPress(container.x, container.y); | |
| 156 shouldBeTrue("isBoxHoverActive('overflowBox')"); | |
| 157 eventSender.gestureTapCancel(container.x, container.y); | |
| 158 | |
| 159 // Now check when page becomes scrollable | |
| 160 document.getElementById('scroller').style.display = 'block'; | |
| 161 debug("Verify hover, active aren't initially set (scroll enabled, pinch disa bled)."); | |
| 162 shouldBeTrue("isBoxDefault('box')"); | |
| 163 | |
| 164 debug("tapdown on element should not activate."); | |
|
Rick Byers
2014/03/13 01:40:05
you repeat this basic set of checks often enough t
| |
| 165 eventSender.gestureTapDown(box.x, box.y); | |
| 166 shouldBeTrue("isBoxDefault('box')"); | |
| 167 | |
| 168 debug("showpress on element should activate."); | |
| 169 eventSender.gestureShowPress(box.x, box.y); | |
| 170 shouldBeTrue("isBoxHoverActive('box')"); | |
| 171 eventSender.gestureTapCancel(box.x, box.y); | |
| 172 } | |
| 173 | |
| 174 runTests(); | |
| 175 </script> | |
| 176 </body> | |
| 177 </html> | |
| 178 | |
| OLD | NEW |