2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <window title=
"Mozilla Bug 478536"
4 width=
"600" height=
"600"
7 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
10 <script src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
11 <script src=
"chrome://mochikit/content/tests/SimpleTest/paint_listener.js" />
13 <body xmlns=
"http://www.w3.org/1999/xhtml" id=
"body">
14 <style type=
"text/css">
23 <pre id=
"view" onscroll=
"onScrollView(event);">
24 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
25 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
26 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
27 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
28 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
29 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
30 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
31 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
32 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
33 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
37 <script class=
"testbody" type=
"application/javascript">
40 function ok(aCondition, aMessage)
42 window.arguments[
0].SimpleTest.ok(aCondition, aMessage);
45 function is(aLeft, aRight, aMessage)
47 window.arguments[
0].SimpleTest.is(aLeft, aRight, aMessage);
50 function isnot(aLeft, aRight, aMessage)
52 window.arguments[
0].SimpleTest.isnot(aLeft, aRight, aMessage);
55 var gBody = document.getElementById(
"body");
56 var gView = document.getElementById(
"view");
61 * First, lock the wheel scrolling target to
"view" at first step.
62 * Next, scroll back to top most of the
"view" at second step.
63 * Finally, scroll back again at third step. This fails to scroll the
"view",
64 * then, |onMouseScrollFailed| event should be fired. And at that time, we
65 * can remove the
"view". So, in post processing of the event firere, the
66 *
"view" should not be referred.
68 * For suppressing random test failure, all tests will be retried if we handle
69 * unexpected timeout event.
73 { scrollToForward: true, shouldScroll: true },
74 { scrollToForward: false, shouldScroll: true },
75 { scrollToForward: false, shouldScroll: false }
77 var gCurrentTestIndex = -
1;
78 var gIgnoreScrollEvent = true;
80 var gPrefSvc = Cc[
"@mozilla.org/preferences-service;1"].
81 getService(Ci.nsIPrefBranch);
82 const kPrefSmoothScroll =
"general.smoothScroll";
83 const kPrefNameTimeout =
"mousewheel.transaction.timeout";
84 const kDefaultTimeout = gPrefSvc.getIntPref(kPrefNameTimeout);
86 gPrefSvc.setBoolPref(kPrefSmoothScroll, false);
88 var gTimeout = kDefaultTimeout;
90 gBody.addEventListener(
"MozMouseScrollFailed", onMouseScrollFailed, false);
91 gBody.addEventListener(
"MozMouseScrollTransactionTimeout",
92 onTransactionTimeout, false);
94 function setTimeoutPrefs(aTimeout)
96 gPrefSvc.setIntPref(kPrefNameTimeout, aTimeout);
100 function resetTimeoutPrefs()
102 if (gTimeout == kDefaultTimeout)
104 setTimeoutPrefs(kDefaultTimeout);
107 function growUpTimeoutPrefs()
109 if (gTimeout != kDefaultTimeout)
111 setTimeoutPrefs(
5000);
116 disableNonTestMouseEvents(true);
117 setTimeout(runNextTest,
0);
123 disableNonTestMouseEvents(false);
124 gPrefSvc.clearUserPref(kPrefSmoothScroll);
125 SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
126 window.arguments[
0].SimpleTest.finish();
137 function clearTimer()
139 clearTimeout(gTimer);
143 function runNextTest()
146 if (++gCurrentTestIndex
>= gTests.length) {
147 ok(true,
"didn't crash, succeeded");
151 fireWheelScrollEvent(gTests[gCurrentTestIndex].scrollToForward);
155 function retryAllTests()
158 if (--gRetryCount
>=
0) {
160 gView.scrollLeft =
0;
161 gCurrentTestIndex = -
1;
162 growUpTimeoutPrefs();
163 ok(true,
"WARNING: retry current test-list...");
164 gTimer = setTimeout(runNextTest,
0);
166 ok(false,
"Failed by unexpected timeout");
171 function fireWheelScrollEvent(aForward)
173 gIgnoreScrollEvent = false;
174 var event = { deltaY: aForward ?
4.0 : -
4.0,
175 deltaMode: WheelEvent.DOM_DELTA_LINE };
176 sendWheelAndPaint(gView,
5,
5, event, function() {
177 // No callback - we're just forcing the refresh driver to tick.
181 function onScrollView(aEvent)
183 if (gIgnoreScrollEvent)
185 gIgnoreScrollEvent = true;
187 ok(gTests[gCurrentTestIndex].shouldScroll,
"The view is scrolled");
188 gTimer = setTimeout(runNextTest,
0);
191 function onMouseScrollFailed(aEvent)
194 gIgnoreScrollEvent = true;
195 ok(!gTests[gCurrentTestIndex].shouldScroll,
"The view is not scrolled");
196 if (!gTests[gCurrentTestIndex].shouldScroll)
197 gBody.removeChild(gView);
201 function onTransactionTimeout(aEvent)
205 gIgnoreScrollEvent = true;