Mouseup event does not fire on Scroll Bar
[WebKit-https.git] / LayoutTests / fast / scrolling / scrollbar-mousedown-move-mouseup.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="../js/resources/js-test-pre.js"></script>
5     <script>
6         window.jsTestIsAsync = true;
7
8         function initEventHandlers(element) {
9             element.addEventListener('mousedown', handleEvent);
10             element.addEventListener('mouseup', handleEvent);
11         }
12
13         window.events = {
14             'scrollme': [],
15             'notscrollme': []
16         };
17         function handleEvent(e) {
18             window.events[e.target.id].push(e);
19         }
20
21         function finish() {
22             shouldBe("events['scrollme'].length", "4");
23             shouldBe("events['notscrollme'].length", "0");
24             shouldBeEqualToString("events['scrollme'][0].type", "mousedown");
25             shouldBe("events['scrollme'][0].which", "1");
26             shouldBeEqualToString("events['scrollme'][1].type", "mouseup");
27             shouldBe("events['scrollme'][1].which", "1");
28             shouldBeEqualToString("events['scrollme'][2].type", "mousedown");
29             shouldBe("events['scrollme'][2].which", "2");
30             shouldBeEqualToString("events['scrollme'][3].type", "mouseup");
31             shouldBe("events['scrollme'][3].which", "2");
32             finishJSTest();
33         }
34
35         window.onload = function () {
36             var d1 = document.querySelector('#scrollme');
37             var d2 = document.querySelector('#notscrollme');
38             initEventHandlers(d1);
39             initEventHandlers(d2);
40
41             if (window.eventSender) {
42                 eventSender.mouseMoveTo(d1.offsetLeft + d1.offsetWidth - 4, d1.offsetTop + 4);
43                 eventSender.mouseDown();
44                 eventSender.mouseMoveTo(d2.offsetLeft + d2.offsetWidth - 4, d2.offsetTop + 4);
45                 eventSender.mouseUp();
46                 eventSender.mouseMoveTo(d1.offsetLeft + d1.offsetWidth - 4, d1.offsetTop + 4);
47                 eventSender.mouseDown(1);
48                 eventSender.mouseMoveTo(d2.offsetLeft + d2.offsetWidth - 4, d2.offsetTop + 4);
49                 eventSender.mouseUp(1);
50                 finish();
51             } else
52                 debug('This test requires eventSender. Click the scrollbar to play manually.');
53         };
54     </script>
55     <script src="../js/resources/js-test-post.js"></script>
56     <style>
57         #scrollme, #notscrollme {
58             width: 100px;
59             height: 100px;
60             overflow: auto;
61         }
62         #scrollme p {
63             height: 1000px;
64         }
65     </style>
66 </head>
67 <body>
68     <div id="scrollme"><p>This is a scrollable div.</p></div>
69     <div id="notscrollme"></div>
70     <pre id="console"></pre>
71 </body>
72 </html>