| OLD | NEW |
| (Empty) | |
| 1 <script src="../../../resources/js-test.js"></script> |
| 2 <div id="target">Target</div> |
| 3 <div id="description">Test user gesture behavior during touch events.</div> |
| 4 <div id="console"></div> |
| 5 |
| 6 <script> |
| 7 |
| 8 var openedPopup = undefined; |
| 9 function handler(e) { |
| 10 if (openedPopup !== undefined) |
| 11 testFailed("Handler invoked multiple times"); |
| 12 |
| 13 var w = window.open("about:blank", "_blank"); |
| 14 if (w) { |
| 15 w.close(); |
| 16 openedPopup = true; |
| 17 } else { |
| 18 openedPopup = false; |
| 19 } |
| 20 } |
| 21 |
| 22 var target = document.getElementById('target'); |
| 23 |
| 24 function testPopupOnEventDuring(eventType, expectPopup, operation) { |
| 25 openedPopup = undefined; |
| 26 target.addEventListener(eventType, handler); |
| 27 |
| 28 operation(); |
| 29 |
| 30 if (openedPopup===undefined) |
| 31 testFailed(eventType + ' handler was not invoked'); |
| 32 else if (expectPopup) |
| 33 shouldBeTrue("openedPopup"); |
| 34 else |
| 35 shouldBeFalse("openedPopup"); |
| 36 |
| 37 target.removeEventListener(eventType, handler); |
| 38 } |
| 39 |
| 40 if (window.testRunner) { |
| 41 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 42 testRunner.setCanOpenWindows(); |
| 43 testRunner.setPopupBlockingEnabled(true); |
| 44 } |
| 45 |
| 46 |
| 47 var rect = target.getBoundingClientRect(); |
| 48 var targetX = rect.left + rect.width / 2; |
| 49 var targetY = rect.top + rect.height / 2; |
| 50 |
| 51 debug('touchstart should be a user gesture'); |
| 52 eventSender.addTouchPoint(targetX, targetY); |
| 53 testPopupOnEventDuring('touchstart', true, function() { eventSender.touchStart()
; }); |
| 54 |
| 55 debug('touchend for the same gesture should not get a new gesture'); |
| 56 eventSender.releaseTouchPoint(0); |
| 57 testPopupOnEventDuring('touchend', false, function() { eventSender.touchStart();
}); |
| 58 |
| 59 debug('touchmove should be a user gesture'); |
| 60 eventSender.addTouchPoint(targetX, targetY); |
| 61 eventSender.touchStart(); |
| 62 eventSender.updateTouchPoint(0, targetX + 1, targetY); |
| 63 testPopupOnEventDuring('touchmove', true, function() { eventSender.touchMove("mo
vedBeyondSlopRegion"); }); |
| 64 |
| 65 debug('second touchmove for the same gesture should not get a new gesture'); |
| 66 eventSender.updateTouchPoint(0, targetX + 2, targetY); |
| 67 testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove("m
ovedBeyondSlopRegion"); }); |
| 68 eventSender.releaseTouchPoint(0); |
| 69 eventSender.touchEnd(); |
| 70 |
| 71 debug('touchend should be a user gesture'); |
| 72 eventSender.addTouchPoint(targetX, targetY); |
| 73 eventSender.touchStart(); |
| 74 eventSender.releaseTouchPoint(0); |
| 75 testPopupOnEventDuring('touchend', true, function() { eventSender.touchEnd(); })
; |
| 76 |
| 77 </script> |
| OLD | NEW |