Bug 1867190 - Initialise the PHC allocate delay later r=glandium
[gecko.git] / layout / xul / test / test_bug159346.xhtml
blobc33823f755f6643d8cac06fa8c4eb1a1ef60871a
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 -->
11 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
14 <scrollbar id="scrollbar" curpos="0" maxpos="500"/>
16 <script class="testbody" type="application/javascript">
17 <![CDATA[
19 var scrollbar = document.getElementById("scrollbar");
20 var downButton;
22 var domWinUtils = SpecialPowers.DOMWindowUtils;
23 domWinUtils.loadSheetUsingURIString('data:text/css,@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); scrollbarbutton[type="increment"][sbattr="scrollbar-down-bottom"] { display: -moz-box; min-width: 3px; min-height: 3px; }', domWinUtils.AGENT_SHEET);
25 function init()
27 downButton = SpecialPowers.unwrap(
28 SpecialPowers.InspectorUtils.getChildrenForNode(scrollbar, true, false)[4]);
29 if (!downButton) {
30 ok(navigator.userAgent.indexOf("Linux") !== -1 ||
31 navigator.userAgent.indexOf("Mac") !== -1, "Theme doesn't support scrollbar buttons");
32 SimpleTest.finish();
33 return;
35 SimpleTest.executeSoon(doTest1);
38 function getCurrentPos()
40 return Number(scrollbar.getAttribute("curpos"));
43 function doTest1()
45 var lastPos = 0;
47 synthesizeMouseAtCenter(downButton, { type: "mousedown" });
48 ok(getCurrentPos() > lastPos,
49 "scrollbar didn't change curpos by mousedown #1");
50 lastPos = getCurrentPos();
52 setTimeout(function () {
53 ok(getCurrentPos() > lastPos,
54 "scrollbar didn't change curpos by auto repeat #1");
55 synthesizeMouseAtCenter(downButton, { type: "mouseup" });
56 lastPos = getCurrentPos();
58 setTimeout(function () {
59 is(getCurrentPos(), lastPos,
60 "scrollbar changed curpos after mouseup #1");
61 SimpleTest.executeSoon(doTest2);
62 }, 1000);
63 }, 1000);
66 function doTest2()
68 SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0);
70 scrollbar.setAttribute("curpos", 0);
71 var lastPos = 0;
73 synthesizeMouseAtCenter(downButton, { type: "mousedown" });
74 ok(getCurrentPos() > lastPos,
75 "scrollbar didn't change curpos by mousedown #2");
76 lastPos = getCurrentPos();
78 synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
79 lastPos = getCurrentPos();
81 setTimeout(function () {
82 is(getCurrentPos(), lastPos,
83 "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2");
84 synthesizeMouseAtCenter(downButton, { type: "mousemove" });
85 lastPos = getCurrentPos();
87 setTimeout(function () {
88 ok(getCurrentPos() > lastPos,
89 "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2");
90 synthesizeMouseAtCenter(downButton, { type: "mouseup" });
91 SimpleTest.executeSoon(doTest3);
92 }, 1000);
93 }, 1000);
96 function doTest3()
98 SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1);
100 scrollbar.setAttribute("curpos", 0);
101 var lastPos = 0;
103 synthesizeMouseAtCenter(downButton, { type: "mousedown" });
104 ok(getCurrentPos() > lastPos,
105 "scrollbar didn't change curpos by mousedown #3");
106 synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
107 lastPos = getCurrentPos();
109 setTimeout(function () {
110 ok(getCurrentPos() > lastPos,
111 "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3");
112 synthesizeMouseAtCenter(downButton, { type: "mousemove" });
113 lastPos = getCurrentPos();
115 setTimeout(function () {
116 ok(getCurrentPos() > lastPos,
117 "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3");
118 synthesizeMouseAtCenter(downButton, { type: "mouseup" });
120 SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior");
121 SimpleTest.finish();
122 }, 1000);
123 }, 1000);
126 SimpleTest.waitForExplicitFinish();
129 </script>
131 <body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
132 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a>
133 <p id="display"></p>
135 <pre id="test">
136 </pre>
137 <script>
138 addLoadEvent(init);
139 </script>
140 </body>
143 </window>