| Index: third_party/WebKit/LayoutTests/fast/events/touch/resources/touch-user-gesture-frame.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/resources/touch-user-gesture-frame.html b/third_party/WebKit/LayoutTests/fast/events/touch/resources/touch-user-gesture-frame.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ef5e9e86e4ddff1875b615fef41cbf75c5a20cd6
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/fast/events/touch/resources/touch-user-gesture-frame.html
|
| @@ -0,0 +1,94 @@
|
| +<style>
|
| + #target {
|
| + width: 100%;
|
| + height: 200px;
|
| + background: lightblue;
|
| + }
|
| +</style>
|
| +<script src='../../../../resources/js-test.js'></script>
|
| +<div id='target'>Target</div>
|
| +<div id='description'>Test user gesture behavior during touch events.</div>
|
| +<div id='console'></div>
|
| +
|
| +<script>
|
| +window.jsTestIsAsync = true;
|
| +var openedPopup = undefined;
|
| +var cancelEvent = false;
|
| +
|
| +function handler(e) {
|
| + if (cancelEvent)
|
| + e.preventDefault();
|
| +
|
| + if (openedPopup !== undefined)
|
| + testFailed('Handler invoked multiple times');
|
| +
|
| + var w = window.open('about:blank', '_blank');
|
| + if (w) {
|
| + w.close();
|
| + openedPopup = true;
|
| + } else {
|
| + openedPopup = false;
|
| + }
|
| +}
|
| +
|
| +var target = document.getElementById('target');
|
| +
|
| +function testPopupOnEventDuring(eventType, expectPopup, operation) {
|
| + openedPopup = undefined;
|
| + target.addEventListener(eventType, handler);
|
| +
|
| + operation();
|
| +
|
| + if (openedPopup===undefined)
|
| + testFailed(eventType + ' handler was not invoked');
|
| + else if (expectPopup)
|
| + shouldBeTrue('openedPopup');
|
| + else
|
| + shouldBeFalse('openedPopup');
|
| +
|
| + target.removeEventListener(eventType, handler);
|
| +}
|
| +
|
| +if (window.testRunner) {
|
| + testRunner.setCloseRemainingWindowsWhenComplete(true);
|
| + testRunner.setCanOpenWindows();
|
| + testRunner.setPopupBlockingEnabled(true);
|
| +}
|
| +
|
| +window.addEventListener('load', function() {
|
| + var rect = target.getBoundingClientRect();
|
| + var targetX = rect.left + rect.width / 2;
|
| + var targetY = rect.top + rect.height / 2;
|
| +
|
| + debug('touchstart should not be a user gesture');
|
| + eventSender.addTouchPoint(targetX, targetY);
|
| + testPopupOnEventDuring('touchstart', false, function() { eventSender.touchStart(); });
|
| +
|
| + debug('touchmove should not be a user gesture');
|
| + eventSender.updateTouchPoint(0, targetX + 1, targetY);
|
| + testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove(); });
|
| +
|
| + debug("touchend should not be a user gesture if it's moved beyond the slop region");
|
| + eventSender.releaseTouchPoint(0);
|
| + testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd('movedBeyondSlopRegion'); });
|
| +
|
| + debug('touchend should be a user gesture when it occurs as part of a tap');
|
| + eventSender.addTouchPoint(targetX, targetY);
|
| + eventSender.touchStart();
|
| + eventSender.updateTouchPoint(0, targetX + 1, targetY);
|
| + eventSender.touchMove();
|
| + eventSender.releaseTouchPoint(0);
|
| + testPopupOnEventDuring('touchend', true, function() { eventSender.touchEnd(); });
|
| +
|
| + debug('touchmove and touchend should not be a user gesture when it occurs as part of a drag without scrolling');
|
| + cancelEvent = true;
|
| + eventSender.addTouchPoint(targetX, targetY);
|
| + eventSender.touchStart();
|
| + eventSender.updateTouchPoint(0, targetX + 1, targetY);
|
| + testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove('movedBeyondSlopRegion'); });
|
| + eventSender.releaseTouchPoint(0);
|
| + testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd('movedBeyondSlopRegion'); });
|
| +
|
| + finishJSTest();
|
| + });
|
| +</script>
|
|
|