| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../js/resources/js-test-pre.js"></script> |
| <style type="text/css"> |
| #touchtarget { |
| width: 100px; |
| height: 100px; |
| position: relative; |
| background: white; |
| } |
| |
| #movingbox { |
| width: 100%; |
| height: 100%; |
| position: absolute; |
| word-wrap: break-word; |
| overflow-y: scroll; |
| overflow-x: scroll; |
| display: block; |
| } |
| |
| #greenbox { |
| width: 100px; |
| height: 100px; |
| background: green; |
| padding: 0px; |
| margin: 0px; |
| } |
| |
| #redbox { |
| width: 100px; |
| height: 100px; |
| background: red; |
| padding: 0px; |
| margin: 0px; |
| } |
| |
| td { |
| padding: 0px; |
| } |
| </style> |
| </head> |
| <body style="margin:0" onload="runTest();"> |
| <div id="touchtarget"> |
| <div id="movingbox"> |
| <table border="0" cellspacing="0px"> |
| <tr> |
| <td><div id="redbox"></div></td> |
| <td><div id="greenbox"></div></td> |
| </tr> |
| <tr> |
| <td><div id="greenbox"></div></td> |
| <td><div id="greenbox"></div></td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| |
| <p id="description"></p> |
| <div id="console"></div> |
| <script type="text/javascript"> |
| |
| var movingdiv; |
| var expectedScrollsTotal = 2; |
| var scrollsOccurred = 0; |
| var scrollAmountX = ['90', '90']; |
| var scrollAmountY = ['0', '95']; |
| |
| function checkScrollOffset() |
| { |
| movingdiv = document.getElementById('movingbox'); |
| if (window.eventSender) { |
| shouldBe('movingdiv.scrollTop', scrollAmountY[scrollsOccurred]); |
| shouldBe('movingdiv.scrollLeft', scrollAmountX[scrollsOccurred]); |
| scrollsOccurred++; |
| } |
| |
| if (scrollsOccurred == expectedScrollsTotal) { |
| // If we've got here, we've passed. |
| isSuccessfullyParsed(); |
| if (window.layoutTestController) |
| layoutTestController.notifyDone(); |
| } else { |
| secondTouchDragSequence(); |
| } |
| } |
| |
| function fingerUp(event) |
| { |
| if (!window.layoutTestController) |
| debug('moved: ' + event.currentTarget.scrollTop + ', ' + event.currentTarget.scrollLeft); |
| return true; // Want the default behaviour. |
| } |
| |
| function firstTouchDragSequence() |
| { |
| debug("first gesture"); |
| eventSender.clearTouchPoints(); |
| eventSender.addTouchPoint(95, 12); |
| eventSender.touchStart(); |
| |
| // Scroll the div to the left. |
| eventSender.updateTouchPoint(0, 5, 12); |
| eventSender.touchMove(); |
| |
| eventSender.releaseTouchPoint(0); |
| eventSender.touchEnd(); |
| |
| // Wait for layout. |
| checkScrollOffset(); |
| } |
| |
| function secondTouchDragSequence() |
| { |
| debug("second gesture"); |
| eventSender.clearTouchPoints(); |
| eventSender.addTouchPoint(12, 97); |
| eventSender.touchStart(); |
| |
| // Scroll the rectangle down. |
| eventSender.updateTouchPoint(0, 12, 2); |
| eventSender.touchMove(); |
| |
| eventSender.releaseTouchPoint(0); |
| eventSender.touchEnd(); |
| |
| // Wait for layout. |
| checkScrollOffset(); |
| } |
| |
| function exitIfNecessary() |
| { |
| debug('Gesture manager not implemented on this platform or broken'); |
| isSuccessfullyParsed(); |
| if (window.layoutTestController) |
| layoutTestController.notifyDone(); |
| } |
| |
| if (window.layoutTestController) |
| layoutTestController.waitUntilDone(); |
| |
| function runTest() |
| { |
| var movingdiv = document.getElementById('movingbox'); |
| |
| if (window.eventSender) { |
| description('This tests scroll gesture generation from touch events. ' + |
| 'Square is (mostly) green on pass'); |
| |
| if (eventSender.clearTouchPoints) |
| firstTouchDragSequence(); |
| else |
| exitIfNecessary(); |
| } else { |
| debug("This test requires DumpRenderTree. Touch scroll the red rect to log."); |
| movingdiv.addEventListener('touchend', fingerUp, false); |
| } |
| } |
| </script> |
| |
| |
| |
| </body> |
| </html> |