| OLD | NEW |
| (Empty) | |
| 1 <style> |
| 2 #target { |
| 3 width: 100%; |
| 4 height: 200px; |
| 5 background: lightblue; |
| 6 } |
| 7 </style> |
| 8 <script src='../../../../resources/js-test.js'></script> |
| 9 <div id='target'>Target</div> |
| 10 <div id='description'>Test user gesture behavior during touch events.</div> |
| 11 <div id='console'></div> |
| 12 |
| 13 <script> |
| 14 window.jsTestIsAsync = true; |
| 15 var openedPopup = undefined; |
| 16 var cancelEvent = false; |
| 17 |
| 18 function handler(e) { |
| 19 if (cancelEvent) |
| 20 e.preventDefault(); |
| 21 |
| 22 if (openedPopup !== undefined) |
| 23 testFailed('Handler invoked multiple times'); |
| 24 |
| 25 var w = window.open('about:blank', '_blank'); |
| 26 if (w) { |
| 27 w.close(); |
| 28 openedPopup = true; |
| 29 } else { |
| 30 openedPopup = false; |
| 31 } |
| 32 } |
| 33 |
| 34 var target = document.getElementById('target'); |
| 35 |
| 36 function testPopupOnEventDuring(eventType, expectPopup, operation) { |
| 37 openedPopup = undefined; |
| 38 target.addEventListener(eventType, handler); |
| 39 |
| 40 operation(); |
| 41 |
| 42 if (openedPopup===undefined) |
| 43 testFailed(eventType + ' handler was not invoked'); |
| 44 else if (expectPopup) |
| 45 shouldBeTrue('openedPopup'); |
| 46 else |
| 47 shouldBeFalse('openedPopup'); |
| 48 |
| 49 target.removeEventListener(eventType, handler); |
| 50 } |
| 51 |
| 52 if (window.testRunner) { |
| 53 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 54 testRunner.setCanOpenWindows(); |
| 55 testRunner.setPopupBlockingEnabled(true); |
| 56 } |
| 57 |
| 58 window.addEventListener('load', function() { |
| 59 var rect = target.getBoundingClientRect(); |
| 60 var targetX = rect.left + rect.width / 2; |
| 61 var targetY = rect.top + rect.height / 2; |
| 62 |
| 63 debug('touchstart should not be a user gesture'); |
| 64 eventSender.addTouchPoint(targetX, targetY); |
| 65 testPopupOnEventDuring('touchstart', false, function() { eventSender.touchSt
art(); }); |
| 66 |
| 67 debug('touchmove should not be a user gesture'); |
| 68 eventSender.updateTouchPoint(0, targetX + 1, targetY); |
| 69 testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMov
e(); }); |
| 70 |
| 71 debug("touchend should not be a user gesture if it's moved beyond the slop r
egion"); |
| 72 eventSender.releaseTouchPoint(0); |
| 73 testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd(
'movedBeyondSlopRegion'); }); |
| 74 |
| 75 debug('touchend should be a user gesture when it occurs as part of a tap'); |
| 76 eventSender.addTouchPoint(targetX, targetY); |
| 77 eventSender.touchStart(); |
| 78 eventSender.updateTouchPoint(0, targetX + 1, targetY); |
| 79 eventSender.touchMove(); |
| 80 eventSender.releaseTouchPoint(0); |
| 81 testPopupOnEventDuring('touchend', true, function() { eventSender.touchEnd()
; }); |
| 82 |
| 83 debug('touchmove and touchend should not be a user gesture when it occurs as
part of a drag without scrolling'); |
| 84 cancelEvent = true; |
| 85 eventSender.addTouchPoint(targetX, targetY); |
| 86 eventSender.touchStart(); |
| 87 eventSender.updateTouchPoint(0, targetX + 1, targetY); |
| 88 testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMov
e('movedBeyondSlopRegion'); }); |
| 89 eventSender.releaseTouchPoint(0); |
| 90 testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd(
'movedBeyondSlopRegion'); }); |
| 91 |
| 92 finishJSTest(); |
| 93 }); |
| 94 </script> |
| OLD | NEW |