| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <style type="text/css"> | |
| 4 #draggable { | |
| 5 padding: 5pt; | |
| 6 border: 3px solid #00cc00; | |
| 7 background: #00cccc; | |
| 8 width: 80px; | |
| 9 cursor: hand; | |
| 10 } | |
| 11 | |
| 12 #scrollable { | |
| 13 height: 200px; | |
| 14 overflow: auto; | |
| 15 border: solid 3px #cc0000; | |
| 16 font-size: 80px; | |
| 17 } | |
| 18 </style> | |
| 19 <script> | |
| 20 function $(id) { return document.getElementById(id); } | |
| 21 var MIDDLE_BUTTON = 1; | |
| 22 var PAN_SCROLL_RADIUS = 15; // from WebCore/platform/ScrollView.h | |
| 23 | |
| 24 function finishTest() { | |
| 25 $('container').innerHTML = ''; | |
| 26 window.testRunner.notifyDone(); | |
| 27 } | |
| 28 | |
| 29 function testIt() { | |
| 30 var scrollable = $('scrollable'); | |
| 31 | |
| 32 if (!window.eventSender) | |
| 33 return; | |
| 34 | |
| 35 // Start pan scroll by drag | |
| 36 eventSender.mouseMoveTo(scrollable.offsetLeft + 5, scrollable.offsetTop + 5)
; | |
| 37 eventSender.mouseDown(MIDDLE_BUTTON); | |
| 38 eventSender.mouseMoveTo(scrollable.offsetLeft + 5, scrollable.offsetTop + PA
N_SCROLL_RADIUS + 6); | |
| 39 | |
| 40 var retryCount = 0; | |
| 41 var lastScrollTop = 0; | |
| 42 | |
| 43 function checkScrolled() | |
| 44 { | |
| 45 if (scrollable.scrollTop > 0) { | |
| 46 testPassed('scrollable.scrollTop > 0'); | |
| 47 // Stop spring loaded pan scroll | |
| 48 eventSender.mouseUp(MIDDLE_BUTTON); | |
| 49 retryCount = 0; | |
| 50 window.setTimeout(checkStopped, 50); | |
| 51 return; | |
| 52 } | |
| 53 | |
| 54 ++retryCount; | |
| 55 if (retryCount > 10) { | |
| 56 testFailed('No autoscroll'); | |
| 57 finishTest(); | |
| 58 return; | |
| 59 } | |
| 60 | |
| 61 // Autoscroll is occurred evey 0.05 sec. | |
| 62 window.setTimeout(checkScrolled, 50); | |
| 63 } | |
| 64 | |
| 65 function checkStopped() | |
| 66 { | |
| 67 if (lastScrollTop == scrollable.scrollTop) { | |
| 68 testPassed('autoscroll stopped'); | |
| 69 finishTest(); | |
| 70 return; | |
| 71 } | |
| 72 | |
| 73 ++retryCount; | |
| 74 if (retryCount > 10) { | |
| 75 testFailed('still autoscroll'); | |
| 76 finishTest(); | |
| 77 return; | |
| 78 } | |
| 79 | |
| 80 lastScrollTop = scrollable.scrollTop; | |
| 81 window.setTimeout(checkStopped, 50); | |
| 82 } | |
| 83 | |
| 84 checkScrolled(); | |
| 85 } | |
| 86 | |
| 87 function setUpTest() | |
| 88 { | |
| 89 var scrollable = $('scrollable'); | |
| 90 for (var i = 0; i < 100; ++i) { | |
| 91 var line = document.createElement('div'); | |
| 92 line.innerHTML = "line " + i; | |
| 93 scrollable.appendChild(line); | |
| 94 } | |
| 95 | |
| 96 if (!window.eventSender) { | |
| 97 console.log('Please run within DumpRenderTree'); | |
| 98 return; | |
| 99 } | |
| 100 | |
| 101 window.jsTestIsAsync = true; | |
| 102 window.setTimeout(testIt, 0); | |
| 103 } | |
| 104 </script> | |
| 105 </head> | |
| 106 <body> | |
| 107 For manual testing, hold middle button in scrollable and move aroudn mouse point
er for scrolling, then release middle button to stop scrolling. | |
| 108 <div id="container"> | |
| 109 Scrollable | |
| 110 <div id="scrollable"> | |
| 111 </div> | |
| 112 </div> | |
| 113 <div id="console"></div> | |
| 114 <script src="../../../../fast/js/resources/js-test-pre.js"></script> | |
| 115 <script> | |
| 116 description('Check pan scroll by drag mouse'); | |
| 117 setUpTest(); | |
| 118 </script> | |
| 119 <script src="../../../../fast/js/resources/js-test-post.js"></script> | |
| 120 </body> | |
| 121 </html> | |
| OLD | NEW |