|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
5 xmlns:html="http://www.w3.org/1999/xhtml" |
|
6 title="Test for Bug 159346"> |
|
7 <!-- |
|
8 https://bugzilla.mozilla.org/show_bug.cgi?id=159346 |
|
9 --> |
|
10 |
|
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
12 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
13 |
|
14 <scrollbar id="scrollbar" curpos="0" maxpos="500"/> |
|
15 |
|
16 <script class="testbody" type="application/javascript"> |
|
17 <![CDATA[ |
|
18 |
|
19 var scrollbar = document.getElementById("scrollbar"); |
|
20 var downButton = |
|
21 document.getAnonymousElementByAttribute(scrollbar, "sbattr", |
|
22 "scrollbar-down-bottom"); |
|
23 |
|
24 function init() |
|
25 { |
|
26 downButton.style.display = "-moz-box"; |
|
27 SimpleTest.executeSoon(doTest1); |
|
28 } |
|
29 |
|
30 function getCurrentPos() |
|
31 { |
|
32 return Number(scrollbar.getAttribute("curpos")); |
|
33 } |
|
34 |
|
35 function doTest1() |
|
36 { |
|
37 var lastPos = 0; |
|
38 |
|
39 synthesizeMouseAtCenter(downButton, { type: "mousedown" }); |
|
40 ok(getCurrentPos() > lastPos, |
|
41 "scrollbar didn't change curpos by mousedown #1"); |
|
42 lastPos = getCurrentPos(); |
|
43 |
|
44 setTimeout(function () { |
|
45 ok(getCurrentPos() > lastPos, |
|
46 "scrollbar didn't change curpos by auto repeat #1"); |
|
47 synthesizeMouseAtCenter(downButton, { type: "mouseup" }); |
|
48 lastPos = getCurrentPos(); |
|
49 |
|
50 setTimeout(function () { |
|
51 is(getCurrentPos(), lastPos, |
|
52 "scrollbar changed curpos after mouseup #1"); |
|
53 SimpleTest.executeSoon(doTest2); |
|
54 }, 1000); |
|
55 }, 1000); |
|
56 } |
|
57 |
|
58 function doTest2() |
|
59 { |
|
60 SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0); |
|
61 |
|
62 scrollbar.setAttribute("curpos", 0); |
|
63 var lastPos = 0; |
|
64 |
|
65 synthesizeMouseAtCenter(downButton, { type: "mousedown" }); |
|
66 ok(getCurrentPos() > lastPos, |
|
67 "scrollbar didn't change curpos by mousedown #2"); |
|
68 lastPos = getCurrentPos(); |
|
69 |
|
70 synthesizeMouse(downButton, -10, -10, { type: "mousemove" }); |
|
71 lastPos = getCurrentPos(); |
|
72 |
|
73 setTimeout(function () { |
|
74 is(getCurrentPos(), lastPos, |
|
75 "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2"); |
|
76 synthesizeMouseAtCenter(downButton, { type: "mousemove" }); |
|
77 lastPos = getCurrentPos(); |
|
78 |
|
79 setTimeout(function () { |
|
80 ok(getCurrentPos() > lastPos, |
|
81 "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2"); |
|
82 synthesizeMouseAtCenter(downButton, { type: "mouseup" }); |
|
83 SimpleTest.executeSoon(doTest3); |
|
84 }, 1000); |
|
85 }, 1000); |
|
86 } |
|
87 |
|
88 function doTest3() |
|
89 { |
|
90 SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1); |
|
91 |
|
92 scrollbar.setAttribute("curpos", 0); |
|
93 var lastPos = 0; |
|
94 |
|
95 synthesizeMouseAtCenter(downButton, { type: "mousedown" }); |
|
96 ok(getCurrentPos() > lastPos, |
|
97 "scrollbar didn't change curpos by mousedown #3"); |
|
98 synthesizeMouse(downButton, -10, -10, { type: "mousemove" }); |
|
99 lastPos = getCurrentPos(); |
|
100 |
|
101 setTimeout(function () { |
|
102 ok(getCurrentPos() > lastPos, |
|
103 "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3"); |
|
104 synthesizeMouseAtCenter(downButton, { type: "mousemove" }); |
|
105 lastPos = getCurrentPos(); |
|
106 |
|
107 setTimeout(function () { |
|
108 ok(getCurrentPos() > lastPos, |
|
109 "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3"); |
|
110 synthesizeMouseAtCenter(downButton, { type: "mouseup" }); |
|
111 |
|
112 SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior"); |
|
113 SimpleTest.finish(); |
|
114 }, 1000); |
|
115 }, 1000); |
|
116 } |
|
117 |
|
118 SimpleTest.waitForExplicitFinish(); |
|
119 |
|
120 ]]> |
|
121 </script> |
|
122 |
|
123 <body id="html_body" xmlns="http://www.w3.org/1999/xhtml"> |
|
124 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a> |
|
125 <p id="display"></p> |
|
126 |
|
127 <pre id="test"> |
|
128 </pre> |
|
129 <script> |
|
130 addLoadEvent(init); |
|
131 </script> |
|
132 </body> |
|
133 |
|
134 |
|
135 </window> |