Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test gets skipped with pattern: os == 'android'
- This test failed 2 times in the preceding 30 days. quicksearch this test
- Manifest: layout/xul/test/chrome.toml
<?xml version="1.0"?>
<!--
-->
<scrollbar id="scrollbar" curpos="0" maxpos="500"/>
<script class="testbody" type="application/javascript">
<![CDATA[
var scrollbar = document.getElementById("scrollbar");
var downButton;
var domWinUtils = SpecialPowers.DOMWindowUtils;
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);
function init()
{
downButton = SpecialPowers.unwrap(
SpecialPowers.InspectorUtils.getChildrenForNode(scrollbar, true, false)[4]);
if (!downButton) {
ok(navigator.userAgent.indexOf("Linux") !== -1 ||
navigator.userAgent.indexOf("Mac") !== -1, "Theme doesn't support scrollbar buttons");
SimpleTest.finish();
return;
}
SimpleTest.executeSoon(doTest1);
}
function getCurrentPos()
{
return Number(scrollbar.getAttribute("curpos"));
}
function doTest1()
{
var lastPos = 0;
synthesizeMouseAtCenter(downButton, { type: "mousedown" });
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by mousedown #1");
lastPos = getCurrentPos();
setTimeout(function () {
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by auto repeat #1");
synthesizeMouseAtCenter(downButton, { type: "mouseup" });
lastPos = getCurrentPos();
setTimeout(function () {
is(getCurrentPos(), lastPos,
"scrollbar changed curpos after mouseup #1");
SimpleTest.executeSoon(doTest2);
}, 1000);
}, 1000);
}
function doTest2()
{
SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0);
scrollbar.setAttribute("curpos", 0);
var lastPos = 0;
synthesizeMouseAtCenter(downButton, { type: "mousedown" });
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by mousedown #2");
lastPos = getCurrentPos();
synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
lastPos = getCurrentPos();
setTimeout(function () {
is(getCurrentPos(), lastPos,
"scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2");
synthesizeMouseAtCenter(downButton, { type: "mousemove" });
lastPos = getCurrentPos();
setTimeout(function () {
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2");
synthesizeMouseAtCenter(downButton, { type: "mouseup" });
SimpleTest.executeSoon(doTest3);
}, 1000);
}, 1000);
}
function doTest3()
{
SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1);
scrollbar.setAttribute("curpos", 0);
var lastPos = 0;
synthesizeMouseAtCenter(downButton, { type: "mousedown" });
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by mousedown #3");
synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
lastPos = getCurrentPos();
setTimeout(function () {
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3");
synthesizeMouseAtCenter(downButton, { type: "mousemove" });
lastPos = getCurrentPos();
setTimeout(function () {
ok(getCurrentPos() > lastPos,
"scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3");
synthesizeMouseAtCenter(downButton, { type: "mouseup" });
SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior");
SimpleTest.finish();
}, 1000);
}, 1000);
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a>
<p id="display"></p>
<pre id="test">
</pre>
<script>
addLoadEvent(init);
</script>
</body>
</window>