layout/xul/test/test_bug159346.xul

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

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

mercurial