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 = SpecialPowers.Services.prefs;
81 const kPrefSmoothScroll =
"general.smoothScroll";
82 const kPrefNameTimeout =
"mousewheel.transaction.timeout";
83 const kDefaultTimeout = gPrefSvc.getIntPref(kPrefNameTimeout);
85 gPrefSvc.setBoolPref(kPrefSmoothScroll, false);
87 var gTimeout = kDefaultTimeout;
89 gBody.addEventListener(
"MozMouseScrollFailed", onMouseScrollFailed);
90 gBody.addEventListener(
"MozMouseScrollTransactionTimeout",
91 onTransactionTimeout);
93 function setTimeoutPrefs(aTimeout)
95 gPrefSvc.setIntPref(kPrefNameTimeout, aTimeout);
99 function resetTimeoutPrefs()
101 if (gTimeout == kDefaultTimeout)
103 setTimeoutPrefs(kDefaultTimeout);
106 function growUpTimeoutPrefs()
108 if (gTimeout != kDefaultTimeout)
110 setTimeoutPrefs(
5000);
115 disableNonTestMouseEvents(true);
116 setTimeout(runNextTest,
0);
122 disableNonTestMouseEvents(false);
123 gPrefSvc.clearUserPref(kPrefSmoothScroll);
124 SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
125 window.arguments[
0].SimpleTest.finish();
136 function clearTimer()
138 clearTimeout(gTimer);
142 function runNextTest()
145 if (++gCurrentTestIndex
>= gTests.length) {
146 ok(true,
"didn't crash, succeeded");
150 fireWheelScrollEvent(gTests[gCurrentTestIndex].scrollToForward);
154 function retryAllTests()
157 if (--gRetryCount
>=
0) {
159 gView.scrollLeft =
0;
160 gCurrentTestIndex = -
1;
161 growUpTimeoutPrefs();
162 ok(true,
"WARNING: retry current test-list...");
163 gTimer = setTimeout(runNextTest,
0);
165 ok(false,
"Failed by unexpected timeout");
170 function fireWheelScrollEvent(aForward)
172 gIgnoreScrollEvent = false;
173 var event = { deltaY: aForward ?
4.0 : -
4.0,
174 deltaMode: WheelEvent.DOM_DELTA_LINE };
175 sendWheelAndPaint(gView,
5,
5, event, function() {
176 // No callback - we're just forcing the refresh driver to tick.
180 function onScrollView(aEvent)
182 if (gIgnoreScrollEvent)
184 gIgnoreScrollEvent = true;
186 ok(gTests[gCurrentTestIndex].shouldScroll,
"The view is scrolled");
187 gTimer = setTimeout(runNextTest,
0);
190 function onMouseScrollFailed(aEvent)
193 gIgnoreScrollEvent = true;
194 ok(!gTests[gCurrentTestIndex].shouldScroll,
"The view is not scrolled");
195 if (!gTests[gCurrentTestIndex].shouldScroll)
196 gBody.removeChild(gView);
200 function onTransactionTimeout(aEvent)
204 gIgnoreScrollEvent = true;