1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/test/test_bug159346.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,135 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.8 + xmlns:html="http://www.w3.org/1999/xhtml" 1.9 + title="Test for Bug 159346"> 1.10 +<!-- 1.11 +https://bugzilla.mozilla.org/show_bug.cgi?id=159346 1.12 +--> 1.13 + 1.14 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.15 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.16 + 1.17 +<scrollbar id="scrollbar" curpos="0" maxpos="500"/> 1.18 + 1.19 +<script class="testbody" type="application/javascript"> 1.20 +<![CDATA[ 1.21 + 1.22 +var scrollbar = document.getElementById("scrollbar"); 1.23 +var downButton = 1.24 + document.getAnonymousElementByAttribute(scrollbar, "sbattr", 1.25 + "scrollbar-down-bottom"); 1.26 + 1.27 +function init() 1.28 +{ 1.29 + downButton.style.display = "-moz-box"; 1.30 + SimpleTest.executeSoon(doTest1); 1.31 +} 1.32 + 1.33 +function getCurrentPos() 1.34 +{ 1.35 + return Number(scrollbar.getAttribute("curpos")); 1.36 +} 1.37 + 1.38 +function doTest1() 1.39 +{ 1.40 + var lastPos = 0; 1.41 + 1.42 + synthesizeMouseAtCenter(downButton, { type: "mousedown" }); 1.43 + ok(getCurrentPos() > lastPos, 1.44 + "scrollbar didn't change curpos by mousedown #1"); 1.45 + lastPos = getCurrentPos(); 1.46 + 1.47 + setTimeout(function () { 1.48 + ok(getCurrentPos() > lastPos, 1.49 + "scrollbar didn't change curpos by auto repeat #1"); 1.50 + synthesizeMouseAtCenter(downButton, { type: "mouseup" }); 1.51 + lastPos = getCurrentPos(); 1.52 + 1.53 + setTimeout(function () { 1.54 + is(getCurrentPos(), lastPos, 1.55 + "scrollbar changed curpos after mouseup #1"); 1.56 + SimpleTest.executeSoon(doTest2); 1.57 + }, 1000); 1.58 + }, 1000); 1.59 +} 1.60 + 1.61 +function doTest2() 1.62 +{ 1.63 + SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0); 1.64 + 1.65 + scrollbar.setAttribute("curpos", 0); 1.66 + var lastPos = 0; 1.67 + 1.68 + synthesizeMouseAtCenter(downButton, { type: "mousedown" }); 1.69 + ok(getCurrentPos() > lastPos, 1.70 + "scrollbar didn't change curpos by mousedown #2"); 1.71 + lastPos = getCurrentPos(); 1.72 + 1.73 + synthesizeMouse(downButton, -10, -10, { type: "mousemove" }); 1.74 + lastPos = getCurrentPos(); 1.75 + 1.76 + setTimeout(function () { 1.77 + is(getCurrentPos(), lastPos, 1.78 + "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2"); 1.79 + synthesizeMouseAtCenter(downButton, { type: "mousemove" }); 1.80 + lastPos = getCurrentPos(); 1.81 + 1.82 + setTimeout(function () { 1.83 + ok(getCurrentPos() > lastPos, 1.84 + "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2"); 1.85 + synthesizeMouseAtCenter(downButton, { type: "mouseup" }); 1.86 + SimpleTest.executeSoon(doTest3); 1.87 + }, 1000); 1.88 + }, 1000); 1.89 +} 1.90 + 1.91 +function doTest3() 1.92 +{ 1.93 + SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1); 1.94 + 1.95 + scrollbar.setAttribute("curpos", 0); 1.96 + var lastPos = 0; 1.97 + 1.98 + synthesizeMouseAtCenter(downButton, { type: "mousedown" }); 1.99 + ok(getCurrentPos() > lastPos, 1.100 + "scrollbar didn't change curpos by mousedown #3"); 1.101 + synthesizeMouse(downButton, -10, -10, { type: "mousemove" }); 1.102 + lastPos = getCurrentPos(); 1.103 + 1.104 + setTimeout(function () { 1.105 + ok(getCurrentPos() > lastPos, 1.106 + "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3"); 1.107 + synthesizeMouseAtCenter(downButton, { type: "mousemove" }); 1.108 + lastPos = getCurrentPos(); 1.109 + 1.110 + setTimeout(function () { 1.111 + ok(getCurrentPos() > lastPos, 1.112 + "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3"); 1.113 + synthesizeMouseAtCenter(downButton, { type: "mouseup" }); 1.114 + 1.115 + SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior"); 1.116 + SimpleTest.finish(); 1.117 + }, 1000); 1.118 + }, 1000); 1.119 +} 1.120 + 1.121 +SimpleTest.waitForExplicitFinish(); 1.122 + 1.123 +]]> 1.124 +</script> 1.125 + 1.126 +<body id="html_body" xmlns="http://www.w3.org/1999/xhtml"> 1.127 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a> 1.128 +<p id="display"></p> 1.129 + 1.130 +<pre id="test"> 1.131 +</pre> 1.132 +<script> 1.133 +addLoadEvent(init); 1.134 +</script> 1.135 +</body> 1.136 + 1.137 + 1.138 +</window>