Chromium Code Reviews| Index: LayoutTests/fast/events/touch/gesture/gesture-tap-down-scroll-pinch.html |
| diff --git a/LayoutTests/fast/events/touch/gesture/gesture-tap-down-scroll-pinch.html b/LayoutTests/fast/events/touch/gesture/gesture-tap-down-scroll-pinch.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3a19fad9720f486a4d4036a22985d81e9f96e30f |
| --- /dev/null |
| +++ b/LayoutTests/fast/events/touch/gesture/gesture-tap-down-scroll-pinch.html |
| @@ -0,0 +1,178 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="../../../../resources/js-test.js"></script> |
| +<style type="text/css"> |
| +#box { |
| + width: 300px; |
| + height: 50px; |
| +} |
| + |
| +#overflowBox { |
| + width: 300px; |
| + height: 600px; |
| +} |
| + |
| +#container { |
| + width: 300px; |
| + height: 50px; |
| + overflow-y: scroll; |
| + overflow-x: hidden; |
| + margin: 10px 0 10px 0; |
| +} |
| + |
| +.interactive { background-color: blue; } |
| + |
| +.interactive:hover { background-color: red; } |
| + |
| +.interactive:active { background-color: green; } |
| + |
| +.interactive:hover:active { background-color: yellow; } |
| + |
| +#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.
|
| + display: none; |
| + width: 100px; |
| + height: 600px; |
| +} |
| +</style> |
| +</head> |
| +<body> |
| +<div id="box" class="interactive">Gestures go here</div> |
| +<div id="container"> |
| + <div id="overflowBox" class="interactive">Gestures go here</div> |
| +</div> |
| + |
| +<p id="description"></p> |
| +<p>See http://crbug.com/316974 for details</p> |
| + |
| +<div id="console"></div> |
| + |
| +<div id="scroller"></div> |
| + |
| +<script> |
| +if (window.internals) { |
| + internals.settings.setViewportEnabled(true); |
| + internals.settings.setViewportMetaEnabled(true); |
| +} |
| + |
| +var color; |
| + |
| +function isBoxOfColor(id, givenColor) |
| +{ |
| + var b = document.getElementById(id); |
| + color = window.getComputedStyle(b).backgroundColor; |
| + if (color == givenColor) |
| + return true; |
| + |
| + testFailed('Box had backgroundColor: ' + color); |
| + return false; |
| +} |
| + |
| +function isBoxHoverActive(id) |
| +{ |
| + return isBoxOfColor(id, "rgb(255, 255, 0)"); |
| +} |
| + |
| +function isBoxDefault(id) |
| +{ |
| + return isBoxOfColor(id, "rgb(0, 0, 255)"); |
| +} |
| + |
| +function elementCenter(id) { |
| + var e = document.getElementById(id); |
| + return { |
| + x: e.offsetLeft + e.offsetWidth / 2, |
| + y: e.offsetTop + e.offsetHeight / 2 |
| + } |
| +} |
| + |
| +description("Tests gesture tapdown behaviour on different scroll / pinch settings."); |
| + |
| +function runTests() |
| +{ |
| + if (!window.eventSender) { |
| + debug('This test requires DRT.'); |
| + return; |
| + } |
| + |
| + if (!eventSender.gestureTapDown |
| + || !eventSender.gestureShowPress) { |
| + debug('Gesture events are not supported by this platform'); |
| + return; |
| + } |
| + |
| + // Insert meta tag after viewport has been enabled via internals |
| + var meta = document.createElement('meta'); |
| + meta.name = 'viewport'; |
| + meta.content = 'initial-scale=1, maximum-scale=2'; |
| + document.head.appendChild(meta); |
| + |
| + // Verify behaviour when page is pinchable |
| + debug("Verify hover, active aren't initially set (scroll disabled, pinch enabled)."); |
| + shouldBeTrue("isBoxDefault('box')"); |
| + |
| + var box = elementCenter("box"); |
| + debug("tapdown on element should not activate."); |
| + eventSender.gestureTapDown(box.x, box.y); |
| + shouldBeTrue("isBoxDefault('box')"); |
| + |
| + debug("showpress on element should activate."); |
| + eventSender.gestureShowPress(box.x, box.y); |
| + shouldBeTrue("isBoxHoverActive('box')"); |
| + 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
|
| + |
| + // Send a sequence to another element to clear current one without relying on 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
|
| + var container = elementCenter("container"); |
| + eventSender.gestureTapDown(container.x, container.y); |
| + eventSender.gestureShowPress(container.x, container.y); |
| + eventSender.gestureTapCancel(container.x, container.y); |
| + |
| + // Update viewport to make page non-pinchable |
| + meta.content = 'width=device-width, initial-scale=1, user-scalable=no'; |
| + |
| + // Verify behaviour when page isn't scrollable or pinchable |
| + debug("Verify hover, active aren't initially set (scroll disabled, pinch disabled)."); |
| + shouldBeTrue("isBoxDefault('box')"); |
| + |
| + debug("tapdown on element should activate."); |
| + eventSender.gestureTapDown(box.x, box.y); |
| + shouldBeTrue("isBoxHoverActive('box')"); |
| + |
| + debug("showpress on element should keep hover and active."); |
| + eventSender.gestureShowPress(box.x, box.y); |
| + shouldBeTrue("isBoxHoverActive('box')"); |
| + eventSender.gestureTapCancel(box.x, box.y); |
| + |
| + // Verify behaviour when ancestor is scrollable |
| + debug("Verify hover, active aren't initially set (overflowBox with scrollable ancestor)."); |
| + shouldBeTrue("isBoxDefault('overflowBox')"); |
| + |
| + debug("tapdown on element should not activate."); |
| + eventSender.gestureTapDown(container.x, container.y); |
| + shouldBeTrue("isBoxDefault('overflowBox')"); |
| + |
| + debug("showpress on element should activate."); |
| + eventSender.gestureShowPress(container.x, container.y); |
| + shouldBeTrue("isBoxHoverActive('overflowBox')"); |
| + eventSender.gestureTapCancel(container.x, container.y); |
| + |
| + // Now check when page becomes scrollable |
| + document.getElementById('scroller').style.display = 'block'; |
| + debug("Verify hover, active aren't initially set (scroll enabled, pinch disabled)."); |
| + shouldBeTrue("isBoxDefault('box')"); |
| + |
| + 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
|
| + eventSender.gestureTapDown(box.x, box.y); |
| + shouldBeTrue("isBoxDefault('box')"); |
| + |
| + debug("showpress on element should activate."); |
| + eventSender.gestureShowPress(box.x, box.y); |
| + shouldBeTrue("isBoxHoverActive('box')"); |
| + eventSender.gestureTapCancel(box.x, box.y); |
| +} |
| + |
| +runTests(); |
| +</script> |
| +</body> |
| +</html> |
| + |