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