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