| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <script src="../../../../resources/js-test.js"></script> | 3 <script src="../../../../resources/js-test.js"></script> |
| 4 <style type="text/css"> | 4 <style type="text/css"> |
| 5 #box { | 5 #box { |
| 6 background-color: blue; | 6 background-color: blue; |
| 7 width: 300px; | 7 width: 300px; |
| 8 height: 100px; | 8 height: 100px; |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (!window.eventSender) { | 45 if (!window.eventSender) { |
| 46 debug('This test requires DRT.'); | 46 debug('This test requires DRT.'); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (!eventSender.gestureShowPress) { | 50 if (!eventSender.gestureShowPress) { |
| 51 debug('GestureShowPress is not supported by this platform'); | 51 debug('GestureShowPress is not supported by this platform'); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (window.testRunner) { | 55 if (!internals.fireActiveIntervalTimer) { |
| 56 window.jsTestIsAsync = true; | 56 debug('Mocked timers are not supported by this platform'); |
| 57 testRunner.waitUntilDone(); | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 internals.setActiveIntervalTimerInManualMode(document, true); |
| 61 |
| 60 debug("Verify active isn't initially set"); | 62 debug("Verify active isn't initially set"); |
| 61 shouldBeFalse("isBoxActive()"); | 63 shouldBeFalse("isBoxActive()"); |
| 62 | 64 |
| 63 debug("Verify tapdown,tap sets and clears active"); | 65 debug("Verify tapdown,tap sets and clears active"); |
| 64 eventSender.gestureShowPress(50, 50); | 66 eventSender.gestureShowPress(50, 50); |
| 65 shouldBeTrue("isBoxActive()"); | 67 shouldBeTrue("isBoxActive()"); |
| 66 eventSender.gestureTap(50, 50); | 68 eventSender.gestureTap(50, 50); |
| 67 // FIXME: Enable after implementing mocked timers (http://crbug.com/319529) | 69 shouldBeTrue("isBoxActive()"); |
| 68 // shouldBeTrue("isBoxActive()"); | 70 internals.fireActiveIntervalTimer(document); |
| 69 waitUntilActiveCleared(); | |
| 70 } | |
| 71 | |
| 72 function waitUntilActiveCleared() | |
| 73 { | |
| 74 if (isBoxActive()) { | |
| 75 return setTimeout(waitUntilActiveCleared, 10); | |
| 76 } | |
| 77 | |
| 78 shouldBeFalse("isBoxActive()"); | 71 shouldBeFalse("isBoxActive()"); |
| 79 | 72 |
| 80 debug("Verify tapdown,tapcancel on the element sets and clears active"); | 73 debug("Verify tapdown,tapcancel on the element sets and clears active"); |
| 81 eventSender.gestureShowPress(50, 50); | 74 eventSender.gestureShowPress(50, 50); |
| 82 shouldBeTrue("isBoxActive()"); | 75 shouldBeTrue("isBoxActive()"); |
| 83 eventSender.gestureTapCancel(50, 50); | 76 eventSender.gestureTapCancel(50, 50); |
| 84 shouldBeFalse("isBoxActive()"); | 77 shouldBeFalse("isBoxActive()"); |
| 85 | 78 |
| 86 debug("Verify tap elsewhere still clears active"); | 79 debug("Verify tap elsewhere still clears active"); |
| 87 eventSender.gestureShowPress(50, 50); | 80 eventSender.gestureShowPress(50, 50); |
| 88 shouldBeTrue("isBoxActive()"); | 81 shouldBeTrue("isBoxActive()"); |
| 89 eventSender.gestureTap(400, 250); | 82 eventSender.gestureTap(400, 250); |
| 90 // FIXME: Remove after mocked timers added (http://crbug.com/319529) | 83 internals.fireActiveIntervalTimer(document); |
| 91 waitUntilAnotherActiveCleared(); | |
| 92 } | |
| 93 | |
| 94 function waitUntilAnotherActiveCleared() | |
| 95 { | |
| 96 if (isBoxActive()) { | |
| 97 return setTimeout(waitUntilAnotherActiveCleared, 10); | |
| 98 } | |
| 99 | |
| 100 shouldBeFalse("isBoxActive()"); | 84 shouldBeFalse("isBoxActive()"); |
| 101 | 85 |
| 102 debug("Verify tapCancel elsewhere still clears active"); | 86 debug("Verify tapCancel elsewhere still clears active"); |
| 103 eventSender.gestureShowPress(50, 50); | 87 eventSender.gestureShowPress(50, 50); |
| 104 shouldBeTrue("isBoxActive()"); | 88 shouldBeTrue("isBoxActive()"); |
| 105 eventSender.gestureTapCancel(400, 250); | 89 eventSender.gestureTapCancel(400, 250); |
| 106 shouldBeFalse("isBoxActive()"); | 90 shouldBeFalse("isBoxActive()"); |
| 107 | 91 |
| 108 debug("Verify that touchstart doesn't trigger active state"); | 92 debug("Verify that touchstart doesn't trigger active state"); |
| 109 eventSender.addTouchPoint(50, 50); | 93 eventSender.addTouchPoint(50, 50); |
| 110 eventSender.touchStart(); | 94 eventSender.touchStart(); |
| 111 shouldBeFalse("isBoxActive()"); | 95 shouldBeFalse("isBoxActive()"); |
| 112 eventSender.releaseTouchPoint(0); | 96 eventSender.releaseTouchPoint(0); |
| 113 eventSender.touchEnd(); | 97 eventSender.touchEnd(); |
| 114 | 98 |
| 115 debug("Verify that touchstart/touchend doesn't cancel active"); | 99 debug("Verify that touchstart/touchend doesn't cancel active"); |
| 116 eventSender.gestureShowPress(50, 50); | 100 eventSender.gestureShowPress(50, 50); |
| 117 shouldBeTrue("isBoxActive()"); | 101 shouldBeTrue("isBoxActive()"); |
| 118 eventSender.addTouchPoint(50, 50); | 102 eventSender.addTouchPoint(50, 50); |
| 119 eventSender.touchStart(); | 103 eventSender.touchStart(); |
| 120 shouldBeTrue("isBoxActive()"); | 104 shouldBeTrue("isBoxActive()"); |
| 121 eventSender.releaseTouchPoint(0); | 105 eventSender.releaseTouchPoint(0); |
| 122 eventSender.touchEnd(); | 106 eventSender.touchEnd(); |
| 123 shouldBeTrue("isBoxActive()"); | 107 shouldBeTrue("isBoxActive()"); |
| 124 | |
| 125 finishJSTest(); | |
| 126 } | 108 } |
| 127 | 109 |
| 128 runTests(); | 110 runTests(); |
| 129 </script> | 111 </script> |
| 130 </body> | 112 </body> |
| 131 </html> | 113 </html> |
| OLD | NEW |