4 <script src=
"../../resources/js-test.js"></script>
6 window
.jsTestIsAsync
= true;
8 function initEventHandlers(element
) {
9 element
.addEventListener('mousedown', handleEvent
);
10 element
.addEventListener('mouseup', handleEvent
);
17 function handleEvent(e
) {
18 window
.events
[e
.target
.id
].push(e
);
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");
35 window
.onload = function () {
36 var d1
= document
.querySelector('#scrollme');
37 var d2
= document
.querySelector('#notscrollme');
38 initEventHandlers(d1
);
39 initEventHandlers(d2
);
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);
52 debug('This test requires eventSender. Click the scrollbar to play manually.');
56 #scrollme, #notscrollme {
67 <div id=
"scrollme"><p>This is a scrollable div.
</p></div>
68 <div id=
"notscrollme"></div>
69 <pre id=
"console"></pre>