Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / gesture-tap-frame-scrollbar.html
blobc37ed31e8c6010debce27158549eca2e719b6b3f
1 <!DOCTYPE HTML>
2 <script src="../../../../resources/js-test.js"></script>
3 <style>
4 #target {
5 width: 50px;
6 height: 50px;
8 </style>
9 <iframe id="target" src="resources/event-delegator.html"></iframe>
10 <div id=console></div>
11 <script>
12 var scrollbarEventType;
14 function onEventInFrame(e) {
15 debug("Received " + e.type + " in child frame");
16 if (e.type == scrollbarEventType) {
17 debug('Adding scrollbars to iframe');
18 target.contentDocument.body.style.height = "500px";
22 function eventLogger(e) {
23 debug("Received " + e.type + " in main frame");
26 document.addEventListener('mousemove', eventLogger);
27 document.addEventListener('mousedown', eventLogger);
28 document.addEventListener('mouseup', eventLogger);
29 document.addEventListener('click', eventLogger);
31 description("Taps at a point that becomes a scrollbar (i.e. hit test with innerNode=null) during the tap and verifies we don't crash.");
33 // Tap at the right edge of the frame, where its scrollbar would live.
34 var rect = target.getBoundingClientRect();
35 var point = {
36 x: rect.right - 4,
37 y: rect.top + rect.height / 2
40 function doTap(type)
42 return new Promise(function(resolve, reject) {
43 if (type) {
44 debug('Test case: Add scrollbars during ' + type);
45 scrollbarEventType = type;
46 target.contentDocument.body.style.height = "0";
47 } else {
48 debug('Test case: Tap on consistent scrollbar');
51 eventSender.gestureTapDown(point.x, point.y);
52 eventSender.gestureShowPress(point.x, point.y);
53 debug("Sending GestureTap");
54 eventSender.gestureTap(point.x, point.y);
56 setTimeout(function() {
57 debug('');
58 resolve();
59 }, 0);
60 });
63 if (window.eventSender) {
64 jsTestIsAsync = true;
66 // Some versions of MacOS native scrollbars intercept events differently, so
67 // use mock scrollbars for consistency.
68 internals.settings.setMockScrollbarsEnabled(true);
70 target.onload = function() {
71 doTap()
72 .then(function() { return doTap('mousemove'); })
73 .then(function() { return doTap('mousedown'); })
74 .then(function() { return doTap('mouseup'); })
75 .catch(function(err) {
76 testFailed("Promise rejected: " + err.message);
77 }).then(finishJSTest);
79 } else {
80 debug("This test requires eventSender");
82 </script>