widget/tests/window_wheeltransaction.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <window title="Wheel scroll tests"
michael@0 4 width="600" height="600"
michael@0 5 onload="onload();"
michael@0 6 onunload="onunload();"
michael@0 7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
michael@0 11
michael@0 12 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 13 <style type="text/css">
michael@0 14 #rootview {
michael@0 15 overflow: auto;
michael@0 16 width: 400px;
michael@0 17 height: 400px;
michael@0 18 border: 1px solid;
michael@0 19 }
michael@0 20 #container {
michael@0 21 overflow: auto;
michael@0 22 width: 600px;
michael@0 23 height: 600px;
michael@0 24 }
michael@0 25 #rootview pre {
michael@0 26 margin: 20px 0 20px 20px;
michael@0 27 padding: 0;
michael@0 28 overflow: auto;
michael@0 29 display: block;
michael@0 30 width: 100px;
michael@0 31 height: 100.5px;
michael@0 32 font-size: 16px;
michael@0 33 }
michael@0 34 </style>
michael@0 35 <div id="rootview" onscroll="onScrollView(event);">
michael@0 36 <div id="container">
michael@0 37 <pre id="subview1" onscroll="onScrollView(event);">
michael@0 38 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 39 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 40 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 41 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 42 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 43 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 44 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 45 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 46 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 47 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 48 </pre>
michael@0 49 <pre id="subview2" onscroll="onScrollView(event);">
michael@0 50 Text.
michael@0 51 Text.
michael@0 52 Text.
michael@0 53 Text.
michael@0 54 Text.
michael@0 55 Text.
michael@0 56 Text.
michael@0 57 Text.
michael@0 58 Text.
michael@0 59 Text.
michael@0 60 </pre>
michael@0 61 <pre id="subview3" onscroll="onScrollView(event);">
michael@0 62 Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text.
michael@0 63 </pre>
michael@0 64 </div>
michael@0 65 </div>
michael@0 66 <div id="content" style="display: none">
michael@0 67 </div>
michael@0 68 <pre id="test">
michael@0 69 </pre>
michael@0 70 </body>
michael@0 71
michael@0 72 <script class="testbody" type="application/javascript">
michael@0 73 <![CDATA[
michael@0 74
michael@0 75 function ok(aCondition, aMessage)
michael@0 76 {
michael@0 77 window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
michael@0 78 }
michael@0 79
michael@0 80 function is(aLeft, aRight, aMessage)
michael@0 81 {
michael@0 82 window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
michael@0 83 }
michael@0 84
michael@0 85 function isnot(aLeft, aRight, aMessage)
michael@0 86 {
michael@0 87 window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
michael@0 88 }
michael@0 89
michael@0 90 var gCurrentTestListStatus = { nextListIndex: 0 };
michael@0 91 var gCurrentTest;
michael@0 92
michael@0 93 const kListenEvent_None = 0;
michael@0 94 const kListenEvent_OnScroll = 1;
michael@0 95 const kListenEvent_OnScrollFailed = 2;
michael@0 96 const kListenEvent_OnTransactionTimeout = 4;
michael@0 97 const kListenEvent_All = kListenEvent_OnScroll |
michael@0 98 kListenEvent_OnScrollFailed |
michael@0 99 kListenEvent_OnTransactionTimeout;
michael@0 100 var gLitesnEvents = kListenEvent_None;
michael@0 101
michael@0 102 /**
michael@0 103 * At unexpected transaction timeout, we need to stop *all* timers. But it is
michael@0 104 * difficult and it can be create more complex testing code. So, we should use
michael@0 105 * only one timer at one time. For that, we must store the timer id to this
michael@0 106 * variable. And the functions which may be called via a timer must clear the
michael@0 107 * current timer by |_clearTimer| function.
michael@0 108 */
michael@0 109 var gTimer;
michael@0 110
michael@0 111 var gPrefSvc = Components.classes["@mozilla.org/preferences-service;1"].
michael@0 112 getService(Components.interfaces.nsIPrefBranch);
michael@0 113 const kPrefSmoothScroll = "general.smoothScroll";
michael@0 114 const kPrefNameTimeout = "mousewheel.transaction.timeout";
michael@0 115 const kPrefNameIgnoreMoveDelay = "mousewheel.transaction.ignoremovedelay";
michael@0 116
michael@0 117 const kDefaultTimeout = gPrefSvc.getIntPref(kPrefNameTimeout);
michael@0 118 const kDefaultIgnoreMoveDelay = gPrefSvc.getIntPref(kPrefNameIgnoreMoveDelay);
michael@0 119
michael@0 120 gPrefSvc.setBoolPref(kPrefSmoothScroll, false);
michael@0 121
michael@0 122 var gTimeout, gIgnoreMoveDelay;
michael@0 123 var gEnoughForTimeout, gEnoughForIgnoreMoveDelay;
michael@0 124
michael@0 125 function setTimeoutPrefs(aTimeout, aIgnoreMoveDelay)
michael@0 126 {
michael@0 127 gPrefSvc.setIntPref(kPrefNameTimeout, aTimeout);
michael@0 128 gPrefSvc.setIntPref(kPrefNameIgnoreMoveDelay, aIgnoreMoveDelay);
michael@0 129 gTimeout = aTimeout;
michael@0 130 gIgnoreMoveDelay = aIgnoreMoveDelay;
michael@0 131 gEnoughForTimeout = gTimeout * 2;
michael@0 132 gEnoughForIgnoreMoveDelay = gIgnoreMoveDelay * 1.2;
michael@0 133 }
michael@0 134
michael@0 135 function resetTimeoutPrefs()
michael@0 136 {
michael@0 137 if (gTimeout == kDefaultTimeout)
michael@0 138 return;
michael@0 139 setTimeoutPrefs(kDefaultTimeout, kDefaultIgnoreMoveDelay);
michael@0 140 initTestList();
michael@0 141 }
michael@0 142
michael@0 143 function growUpTimeoutPrefs()
michael@0 144 {
michael@0 145 if (gTimeout != kDefaultTimeout)
michael@0 146 return;
michael@0 147 setTimeoutPrefs(5000, 1000);
michael@0 148 initTestList();
michael@0 149 }
michael@0 150
michael@0 151 // setting enough time for testing.
michael@0 152 gPrefSvc.setIntPref(kPrefNameTimeout, gTimeout);
michael@0 153 gPrefSvc.setIntPref(kPrefNameIgnoreMoveDelay, gIgnoreMoveDelay);
michael@0 154
michael@0 155 var gRootView = document.getElementById("rootview");
michael@0 156 var gSubView1 = document.getElementById("subview1");
michael@0 157 var gSubView2 = document.getElementById("subview2");
michael@0 158 var gSubView3 = document.getElementById("subview3");
michael@0 159
michael@0 160 gRootView.addEventListener("MozMouseScrollFailed", onMouseScrollFailed, false);
michael@0 161 gRootView.addEventListener("MozMouseScrollTransactionTimeout",
michael@0 162 onTransactionTimeout, false);
michael@0 163
michael@0 164 function finish()
michael@0 165 {
michael@0 166 window.close();
michael@0 167 }
michael@0 168
michael@0 169 function onload()
michael@0 170 {
michael@0 171 runNextTestList();
michael@0 172 }
michael@0 173
michael@0 174 function onunload()
michael@0 175 {
michael@0 176 resetTimeoutPrefs();
michael@0 177 gPrefSvc.clearUserPref(kPrefSmoothScroll);
michael@0 178 disableNonTestMouseEvents(false);
michael@0 179 window.opener.wrappedJSObject.SimpleTest.finish();
michael@0 180 }
michael@0 181
michael@0 182 const kSubView1Offset = { x: 20, y: 20 };
michael@0 183 const kSubView2Offset = { x: 20, y: 20 + 100 + 20 };
michael@0 184 const kSubView3Offset = { x: 20, y: 20 + (100 + 20) * 2 };
michael@0 185
michael@0 186 function _getSubViewTestPtForV(aPt)
michael@0 187 {
michael@0 188 return { x: aPt.x + 10, y: aPt.y + 10 };
michael@0 189 }
michael@0 190
michael@0 191 const kPtInRootViewForV = { x: kSubView1Offset.x + 10,
michael@0 192 y: kSubView1Offset.y - 10 };
michael@0 193 const kPtInSubView1ForV = _getSubViewTestPtForV(kSubView1Offset);
michael@0 194 const kPtInSubView2ForV = _getSubViewTestPtForV(kSubView2Offset);
michael@0 195 const kPtInSubView3ForV = _getSubViewTestPtForV(kSubView3Offset);
michael@0 196
michael@0 197 function _convertTestPtForH(aPt)
michael@0 198 {
michael@0 199 return { x: aPt.y, y: aPt.x };
michael@0 200 }
michael@0 201
michael@0 202 const kPtInRootViewForH = _convertTestPtForH(kPtInRootViewForV);
michael@0 203 const kPtInSubView1ForH = _convertTestPtForH(kPtInSubView1ForV);
michael@0 204 const kPtInSubView2ForH = _convertTestPtForH(kPtInSubView2ForV);
michael@0 205 const kPtInSubView3ForH = _convertTestPtForH(kPtInSubView3ForV);
michael@0 206
michael@0 207 /**
michael@0 208 * Define the tests here:
michael@0 209 * Scrolls are processed async always. Therefore, we need to call all tests
michael@0 210 * by timer. gTestLists is array of testing lists. In other words, an item
michael@0 211 * of gTestList is a group of one or more testing. Each items has following
michael@0 212 * properties:
michael@0 213 *
michael@0 214 * - retryWhenTransactionTimeout
michael@0 215 * The testing of wheel transaction might be fialed randomly by
michael@0 216 * timeout. Then, automatically the failed test list will be retested
michael@0 217 * automatically only this number of times.
michael@0 218 *
michael@0 219 * - steps
michael@0 220 * This property is array of testing. Each steps must have following
michael@0 221 * properties at least.
michael@0 222 *
michael@0 223 * - func
michael@0 224 * This property means function which will be called via
michael@0 225 * |setTimeout|. The function cannot have params. If you need
michael@0 226 * some additional parameters, you can specify some original
michael@0 227 * properties for the test function. If you do so, you should
michael@0 228 * document it in the testing function.
michael@0 229 * - delay
michael@0 230 * This property means delay time until the function to be called.
michael@0 231 * I.e., the value used for the second param of |setTimeout|.
michael@0 232 *
michael@0 233 * And also you need one more property when you call a testing function.
michael@0 234 *
michael@0 235 * - description
michael@0 236 * This property is description of the test. This is used for
michael@0 237 * logging.
michael@0 238 *
michael@0 239 * At testing, you can access to current step via |gCurrentTest|.
michael@0 240 */
michael@0 241
michael@0 242 var gTestLists;
michael@0 243 function initTestList()
michael@0 244 {
michael@0 245 gTestLists = [
michael@0 246 /**************************************************************************
michael@0 247 * Continuous scrolling test for |gRootView|
michael@0 248 * |gRootView| has both scrollbars and it has three children which are
michael@0 249 * |gSubView1|, |gSubView2| and |gSubView3|. They have scrollbars. If
michael@0 250 * the current transaction targets |gRootView|, other children should not
michael@0 251 * be scrolled even if the wheel events are fired on them.
michael@0 252 **************************************************************************/
michael@0 253 { retryWhenTransactionTimeout: 5,
michael@0 254 steps: [
michael@0 255 // Vertical case
michael@0 256 { func: initElements, delay: 0, forVertical: true,
michael@0 257 description: "initElements" },
michael@0 258 { func: clearWheelTransaction, delay: 0,
michael@0 259 description: "clearWheelTransaction" },
michael@0 260 // Vertical wheel events should scroll |gRootView| even if the position
michael@0 261 // of wheel events in a child view which has scrollbar.
michael@0 262 { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 263 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 264 description: "Continuous scrolling test for root view (vertical/forward)" },
michael@0 265 { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 266 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 267 description: "Continuous scrolling test for root view (vertical/backward)" }
michael@0 268 ]
michael@0 269 },
michael@0 270
michael@0 271
michael@0 272 { retryWhenTransactionTimeout: 5,
michael@0 273 steps: [
michael@0 274 // Horizontal case
michael@0 275 { func: initElements, delay: 0, forVertical: false,
michael@0 276 description: "initElements" },
michael@0 277 { func: clearWheelTransaction, delay: 0,
michael@0 278 description: "clearWheelTransaction" },
michael@0 279 // Horizontal wheel events should scroll |gRootView| even if the
michael@0 280 // position of wheel events in a child view which has scrollbar.
michael@0 281 { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 282 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 283 description: "Continuous scrolling test for root view (horizontal/forward)" },
michael@0 284 { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 285 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 286 description: "Continuous scrolling test for root view (horizontal/backward)" }
michael@0 287 ]
michael@0 288 },
michael@0 289
michael@0 290
michael@0 291 /**************************************************************************
michael@0 292 * Continuous scrolling test for |gSubView1|
michael@0 293 * |gSubView1| has both scrollbars.
michael@0 294 **************************************************************************/
michael@0 295 { retryWhenTransactionTimeout: 5,
michael@0 296 steps: [
michael@0 297 // Vertical case
michael@0 298 { func: initElements, delay: 0, forVertical: true,
michael@0 299 description: "initElements" },
michael@0 300 { func: clearWheelTransaction, delay: 0,
michael@0 301 description: "clearWheelTransaction" },
michael@0 302 // Vertical wheel events should scroll |gSubView1|.
michael@0 303 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 304 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 305 description: "Continuous scrolling test for sub view 1 (vertical/forward)" },
michael@0 306 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 307 isForward: false, isVertical: true, expectedView: gSubView1,
michael@0 308 description: "Continuous scrolling test for sub view 1 (vertical/backward)" }
michael@0 309 ]
michael@0 310 },
michael@0 311
michael@0 312
michael@0 313 { retryWhenTransactionTimeout: 5,
michael@0 314 steps: [
michael@0 315 // Horizontal case
michael@0 316 { func: initElements, delay: 0, forVertical: false,
michael@0 317 description: "initElements" },
michael@0 318 { func: clearWheelTransaction, delay: 0,
michael@0 319 description: "clearWheelTransaction" },
michael@0 320 // Horitontal wheel events should scroll |gSubView1|.
michael@0 321 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 322 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 323 description: "Continuous scrolling test for sub view 1 (horizontal/forward)" },
michael@0 324 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 325 isForward: false, isVertical: false, expectedView: gSubView1,
michael@0 326 description: "Continuous scrolling test for sub view 1 (horizontal/backward)" }
michael@0 327 ]
michael@0 328 },
michael@0 329
michael@0 330
michael@0 331 /**************************************************************************
michael@0 332 * Continuous scrolling test for |gSubView2|
michael@0 333 * |gSubView2| has only vertical scrollbar.
michael@0 334 **************************************************************************/
michael@0 335 { retryWhenTransactionTimeout: 5,
michael@0 336 steps: [
michael@0 337 // Vertical case
michael@0 338 { func: initElements, delay: 0, forVertical: true,
michael@0 339 description: "initElements" },
michael@0 340 { func: clearWheelTransaction, delay: 0,
michael@0 341 description: "clearWheelTransaction" },
michael@0 342 // Vertical wheel events should scroll |gSubView2|.
michael@0 343 { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForV,
michael@0 344 isForward: true, isVertical: true, expectedView: gSubView2,
michael@0 345 description: "Continuous scrolling test for sub view 2 (vertical/forward)" },
michael@0 346 { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForV,
michael@0 347 isForward: false, isVertical: true, expectedView: gSubView2,
michael@0 348 description: "Continuous scrolling test for sub view 2 (vertical/backward)" }
michael@0 349 ]
michael@0 350 },
michael@0 351
michael@0 352
michael@0 353 { retryWhenTransactionTimeout: 5,
michael@0 354 steps: [
michael@0 355 // Horizontal case
michael@0 356 { func: initElements, delay: 0, forVertical: false,
michael@0 357 description: "initElements" },
michael@0 358 { func: clearWheelTransaction, delay: 0,
michael@0 359 description: "clearWheelTransaction" },
michael@0 360 // Horizontal wheel events should scroll its nearest scrollable ancestor
michael@0 361 // view, i.e., it is |gRootView|.
michael@0 362 { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForH,
michael@0 363 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 364 description: "Continuous scrolling test for sub view 2 (horizontal/forward)" },
michael@0 365 { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForH,
michael@0 366 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 367 description: "Continuous scrolling test for sub view 2 (horizontal/backward)" }
michael@0 368 ]
michael@0 369 },
michael@0 370
michael@0 371
michael@0 372 /**************************************************************************
michael@0 373 * Continuous scrolling test for |gSubView3|
michael@0 374 * |gSubView3| has only horizontal scrollbar.
michael@0 375 **************************************************************************/
michael@0 376 { retryWhenTransactionTimeout: 5,
michael@0 377 steps: [
michael@0 378 // Vertical case
michael@0 379 { func: initElements, delay: 0, forVertical: true,
michael@0 380 description: "initElements" },
michael@0 381 { func: clearWheelTransaction, delay: 0,
michael@0 382 description: "clearWheelTransaction" },
michael@0 383 // Vertical wheel events should scroll its nearest scrollable ancestor
michael@0 384 // view, i.e., it is |gRootView|.
michael@0 385 { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForV,
michael@0 386 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 387 description: "Continuous scrolling test for sub view 3 (vertical/forward)" },
michael@0 388 { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForV,
michael@0 389 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 390 description: "Continuous scrolling test for sub view 3 (vertical/backward)" }
michael@0 391 ]
michael@0 392 },
michael@0 393
michael@0 394
michael@0 395 { retryWhenTransactionTimeout: 5,
michael@0 396 steps: [
michael@0 397 // Horizontal case
michael@0 398 { func: initElements, delay: 0, forVertical: false,
michael@0 399 description: "initElements" },
michael@0 400 { func: clearWheelTransaction, delay: 0,
michael@0 401 description: "clearWheelTransaction" },
michael@0 402 // Horitontal wheel events should scroll |gSubView3|.
michael@0 403 { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForH,
michael@0 404 isForward: true, isVertical: false, expectedView: gSubView3,
michael@0 405 description: "Continuous scrolling test for sub view 3 (horizontal/forward)" },
michael@0 406 { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForH,
michael@0 407 isForward: false, isVertical: false, expectedView: gSubView3,
michael@0 408 description: "Continuous scrolling test for sub view 3 (horizontal/backward)" }
michael@0 409 ]
michael@0 410 },
michael@0 411
michael@0 412
michael@0 413 /**************************************************************************
michael@0 414 * Don't reset transaction by a different direction wheel event
michael@0 415 * Even if a wheel event doesn't same direction as last wheel event, the
michael@0 416 * current transaction should not be reset.
michael@0 417 **************************************************************************/
michael@0 418 { retryWhenTransactionTimeout: 5,
michael@0 419 steps: [
michael@0 420 // Vertical -> Horizontal
michael@0 421 { func: initElements, delay: 0, forVertical: true,
michael@0 422 description: "initElements" },
michael@0 423 { func: clearWheelTransaction, delay: 0,
michael@0 424 description: "clearWheelTransaction" },
michael@0 425 // Create a transaction which targets |gRootView| by a vertical wheel
michael@0 426 // event.
michael@0 427 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 428 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 429 description: "Don't reset transaction by a different direction wheel event (1-1)" },
michael@0 430 // Scroll back to top-most for easy cursor position specifying.
michael@0 431 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 432 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 433 description: "Don't reset transaction by a different direction wheel event (1-2)" },
michael@0 434 // Send a horizontal wheel event over |gSubView1| but |gRootView| should
michael@0 435 // be scrolled.
michael@0 436 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 437 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 438 canFailRandomly: { possibleView: gSubView1 },
michael@0 439 description: "Don't reset transaction by a different direction wheel event (1-3)" }
michael@0 440 ]
michael@0 441 },
michael@0 442
michael@0 443
michael@0 444 { retryWhenTransactionTimeout: 5,
michael@0 445 steps: [
michael@0 446 // Horizontal -> Vertical
michael@0 447 { func: initElements, delay: 0, forVertical: false,
michael@0 448 description: "initElements" },
michael@0 449 { func: clearWheelTransaction, delay: 0,
michael@0 450 description: "clearWheelTransaction" },
michael@0 451 // Create a transaction which targets |gRootView| by a horizontal wheel
michael@0 452 // event.
michael@0 453 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 454 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 455 description: "Don't reset transaction by a different direction wheel event (2-1)" },
michael@0 456 // Scroll back to left-most for easy cursor position specifying.
michael@0 457 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 458 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 459 description: "Don't reset transaction by a different direction wheel event (2-2)" },
michael@0 460 // Send a vertical wheel event over |gSubView1| but |gRootView| should
michael@0 461 // be scrolled.
michael@0 462 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 463 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 464 canFailRandomly: { possibleView: gSubView1 },
michael@0 465 description: "Don't reset transaction by a different direction wheel event (2-3)" }
michael@0 466 ]
michael@0 467 },
michael@0 468
michael@0 469
michael@0 470 /**************************************************************************
michael@0 471 * Don't reset transaction even if a wheel event cannot scroll
michael@0 472 * Even if a wheel event cannot scroll to specified direction in the
michael@0 473 * current target view, the transaction should not be reset. E.g., there
michael@0 474 * are some devices which can scroll obliquely. If so, probably, users
michael@0 475 * cannot input only intended direction.
michael@0 476 **************************************************************************/
michael@0 477 { retryWhenTransactionTimeout: 5,
michael@0 478 steps: [
michael@0 479 // A view only has vertical scrollbar case.
michael@0 480 { func: initElements, delay: 0, forVertical: true,
michael@0 481 description: "initElements" },
michael@0 482 { func: clearWheelTransaction, delay: 0,
michael@0 483 description: "clearWheelTransaction" },
michael@0 484 // Create a transaction which targets |gSubView2|.
michael@0 485 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView2ForV,
michael@0 486 isForward: true, isVertical: true, expectedView: gSubView2,
michael@0 487 description: "Don't reset transaction even if a wheel event cannot scroll (1-1)" },
michael@0 488 // |gSubView2| doesn't have horizontal scrollbar but should not scroll
michael@0 489 // any views.
michael@0 490 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView2ForV,
michael@0 491 isForward: true, isVertical: false, expectedView: null,
michael@0 492 description: "Don't reset transaction even if a wheel event cannot scroll (1-2)" }
michael@0 493 ]
michael@0 494 },
michael@0 495
michael@0 496
michael@0 497 { retryWhenTransactionTimeout: 5,
michael@0 498 steps: [
michael@0 499 // A view only has horizontal scrollbar case.
michael@0 500 { func: initElements, delay: 0, forVertical: true,
michael@0 501 description: "initElements" },
michael@0 502 { func: clearWheelTransaction, delay: 0,
michael@0 503 description: "clearWheelTransaction" },
michael@0 504 // Create a transaction which targets |gSubView3|.
michael@0 505 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView3ForV,
michael@0 506 isForward: true, isVertical: false, expectedView: gSubView3,
michael@0 507 description: "Don't reset transaction even if a wheel event cannot scroll (2-1)" },
michael@0 508 // |gSubView3| doesn't have vertical scrollbar but should not scroll any
michael@0 509 // views.
michael@0 510 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView3ForV,
michael@0 511 isForward: true, isVertical: true, expectedView: null,
michael@0 512 description: "Don't reset transaction even if a wheel event cannot scroll (2-2)" }
michael@0 513 ]
michael@0 514 },
michael@0 515
michael@0 516
michael@0 517 /**************************************************************************
michael@0 518 * Reset transaction by mouse down/mouse up events
michael@0 519 * Mouse down and mouse up events should cause resetting the current
michael@0 520 * transaction.
michael@0 521 **************************************************************************/
michael@0 522 { retryWhenTransactionTimeout: 5,
michael@0 523 steps: [
michael@0 524 // Vertical case
michael@0 525 { func: initElements, delay: 0, forVertical: true,
michael@0 526 description: "initElements" },
michael@0 527 { func: clearWheelTransaction, delay: 0,
michael@0 528 description: "clearWheelTransaction" },
michael@0 529 // Create a transaction which targets |gRootView|.
michael@0 530 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 531 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 532 description: "Reset transaction by mouse down/mouse up events (v-1)" },
michael@0 533 // Scroll back to top-most for easy cursor position specifying.
michael@0 534 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 535 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 536 description: "Reset transaction by mouse down/mouse up events (v-2)" },
michael@0 537 // Send mouse button events which should reset the current transaction.
michael@0 538 // So, the next wheel event should scroll |gSubView1|.
michael@0 539 { func: sendMouseButtonEvents, delay: 0,
michael@0 540 description: "sendMouseButtonEvents" },
michael@0 541 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 542 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 543 description: "Reset transaction by mouse down/mouse up events (v-3)" }
michael@0 544 ]
michael@0 545 },
michael@0 546
michael@0 547
michael@0 548 { retryWhenTransactionTimeout: 5,
michael@0 549 steps: [
michael@0 550 // Horizontal case
michael@0 551 { func: initElements, delay: 0, forVertical: false,
michael@0 552 description: "initElements" },
michael@0 553 { func: clearWheelTransaction, delay: 0,
michael@0 554 description: "clearWheelTransaction" },
michael@0 555 // Create a transaction which targets |gRootView|.
michael@0 556 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 557 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 558 description: "Reset transaction by mouse down/mouse up events (h-1)" },
michael@0 559 // Scroll back to left-most for easy cursor position specifying.
michael@0 560 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 561 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 562 description: "Reset transaction by mouse down/mouse up events (h-2)" },
michael@0 563 // Send mouse button events which should reset the current transaction.
michael@0 564 // So, the next wheel event should scroll |gSubView1|.
michael@0 565 { func: sendMouseButtonEvents, delay: 0,
michael@0 566 description: "sendMouseButtonEvents" },
michael@0 567 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 568 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 569 description: "Reset transaction by mouse down/mouse up events (h-3)" }
michael@0 570 ]
michael@0 571 },
michael@0 572
michael@0 573
michael@0 574 /**************************************************************************
michael@0 575 * Reset transaction by a key event
michael@0 576 * A key event should cause resetting the current transaction.
michael@0 577 **************************************************************************/
michael@0 578 { retryWhenTransactionTimeout: 5,
michael@0 579 steps: [
michael@0 580 // Vertical case
michael@0 581 { func: initElements, delay: 0, forVertical: true,
michael@0 582 description: "initElements" },
michael@0 583 { func: clearWheelTransaction, delay: 0,
michael@0 584 description: "clearWheelTransaction" },
michael@0 585 // Create a transaction which targets |gRootView|.
michael@0 586 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 587 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 588 description: "Reset transaction by a key event (v-1)" },
michael@0 589 // Scroll back to top-most for easy cursor position specifying.
michael@0 590 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 591 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 592 description: "Reset transaction by a key event (v-2)" },
michael@0 593 // Send a key event which should reset the current transaction. So, the
michael@0 594 // next wheel event should scroll |gSubView1|.
michael@0 595 { func: sendKeyEvents, delay: 0, key: "a",
michael@0 596 description: "sendKeyEvents" },
michael@0 597 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 598 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 599 description: "Reset transaction by a key event (v-3)" }
michael@0 600 ]
michael@0 601 },
michael@0 602
michael@0 603
michael@0 604 { retryWhenTransactionTimeout: 5,
michael@0 605 steps: [
michael@0 606 // Horizontal case
michael@0 607 { func: initElements, delay: 0, forVertical: false,
michael@0 608 description: "initElements" },
michael@0 609 { func: clearWheelTransaction, delay: 0,
michael@0 610 description: "clearWheelTransaction" },
michael@0 611 // Create a transaction which targets |gRootView|.
michael@0 612 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 613 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 614 description: "Reset transaction by a key event (h-1)" },
michael@0 615 // Scroll back to left-most for easy cursor position specifying.
michael@0 616 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 617 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 618 description: "Reset transaction by a key event (h-2)" },
michael@0 619 // Send a key event which should reset the current transaction. So, the
michael@0 620 // next wheel event should scroll |gSubView1|.
michael@0 621 { func: sendKeyEvents, delay: 0, key: "a",
michael@0 622 description: "sendKeyEvents" },
michael@0 623 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 624 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 625 description: "Reset transaction by a key event (h-3)" }
michael@0 626 ]
michael@0 627 },
michael@0 628
michael@0 629
michael@0 630 /**************************************************************************
michael@0 631 * Reset transaction by a mouse move event
michael@0 632 * A mouse move event can cause reseting the current transaction even if
michael@0 633 * mouse cursor is inside the target view of current transaction. Only
michael@0 634 * when a wheel event is fired after |gIgnoreMoveDelay| milliseconds since
michael@0 635 * the first mouse move event from last wheel event, the transaction
michael@0 636 * should be reset.
michael@0 637 **************************************************************************/
michael@0 638 { retryWhenTransactionTimeout: 5,
michael@0 639 steps: [
michael@0 640 // Vertical case
michael@0 641 { func: initElements, delay: 0, forVertical: true,
michael@0 642 description: "initElements" },
michael@0 643 { func: clearWheelTransaction, delay: 0,
michael@0 644 description: "clearWheelTransaction" },
michael@0 645 // Create a transaction which targets |gRootView|.
michael@0 646 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 647 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 648 description: "Reset transaction by a mouse move event (v-1)" },
michael@0 649 // Scroll back to top-most for easy cursor position specifying.
michael@0 650 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 651 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 652 description: "Reset transaction by a mouse move event (v-2)" },
michael@0 653 // Send a mouse move event immediately after last wheel event, then,
michael@0 654 // current transaction should be kept.
michael@0 655 { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForV,
michael@0 656 description: "sendMouseMoveEvent" },
michael@0 657 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 658 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 659 canFailRandomly: { possibleView: gSubView1 },
michael@0 660 description: "Reset transaction by a mouse move event (v-3)" },
michael@0 661 // Scroll back to top-most for easy cursor position specifying.
michael@0 662 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 663 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 664 canFailRandomly: { possibleView: gSubView1 },
michael@0 665 description: "Reset transaction by a mouse move event (v-4)" },
michael@0 666 // Send a mouse move event after |gIgnoreMoveDelay| milliseconds since
michael@0 667 // last wheel event, then, current transaction should be kept.
michael@0 668 { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay,
michael@0 669 offset: kPtInSubView1ForV,
michael@0 670 description: "sendMouseMoveEvent" },
michael@0 671 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 672 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 673 canFailRandomly: { possibleView: gSubView1 },
michael@0 674 description: "Reset transaction by a mouse move event (v-5)" },
michael@0 675 // Scroll back to top-most for easy cursor position specifying.
michael@0 676 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 677 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 678 canFailRandomly: { possibleView: gSubView1 },
michael@0 679 description: "Reset transaction by a mouse move event (v-6)" },
michael@0 680 // Send a wheel event after |gIgnoreMoveDelay| milliseconds since last
michael@0 681 // mouse move event but it is fired immediately after the last wheel
michael@0 682 // event, then, current transaction should be kept.
michael@0 683 { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForV,
michael@0 684 description: "sendMouseMoveEvent" },
michael@0 685 { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay,
michael@0 686 offset: kPtInSubView1ForV,
michael@0 687 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 688 canFailRandomly: { possibleView: gSubView1 },
michael@0 689 description: "Reset transaction by a mouse move event (v-7)" },
michael@0 690 // Scroll back to top-most for easy cursor position specifying.
michael@0 691 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 692 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 693 canFailRandomly: { possibleView: gSubView1 },
michael@0 694 description: "Reset transaction by a mouse move event (v-8)" },
michael@0 695 // Send a wheel event after |gIgnoreMoveDelay| milliseconds have passed
michael@0 696 // since last mouse move event which is fired after |gIgnoreMoveDelay|
michael@0 697 // milliseconds since last wheel event, then, current transaction should
michael@0 698 // be reset.
michael@0 699 { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay,
michael@0 700 offset: kPtInSubView1ForV,
michael@0 701 description: "sendMouseMoveEvent" },
michael@0 702 { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay,
michael@0 703 offset: kPtInSubView1ForV,
michael@0 704 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 705 canFailRandomly: { possibleView: gRootView },
michael@0 706 description: "Reset transaction by a mouse move event (v-9)" }
michael@0 707 ]
michael@0 708 },
michael@0 709
michael@0 710
michael@0 711 { retryWhenTransactionTimeout: 5,
michael@0 712 steps: [
michael@0 713 // Horizontal case
michael@0 714 { func: initElements, delay: 0, forVertical: false,
michael@0 715 description: "initElements" },
michael@0 716 { func: clearWheelTransaction, delay: 0,
michael@0 717 description: "clearWheelTransaction" },
michael@0 718 // Create a transaction which targets |gRootView|.
michael@0 719 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 720 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 721 canFailRandomly: { possibleView: gSubView1 },
michael@0 722 description: "Reset transaction by a mouse move event (h-1)" },
michael@0 723 // Scroll back to top-most for easy cursor position specifying.
michael@0 724 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 725 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 726 canFailRandomly: { possibleView: gSubView1 },
michael@0 727 description: "Reset transaction by a mouse move event (h-2)" },
michael@0 728 // Send a mouse move event immediately after last wheel event, then,
michael@0 729 // current transaction should be kept.
michael@0 730 { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForH,
michael@0 731 description: "sendMouseMoveEvent" },
michael@0 732 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 733 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 734 canFailRandomly: { possibleView: gSubView1 },
michael@0 735 description: "Reset transaction by a mouse move event (h-3)" },
michael@0 736 // Scroll back to top-most for easy cursor position specifying.
michael@0 737 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 738 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 739 canFailRandomly: { possibleView: gSubView1 },
michael@0 740 description: "Reset transaction by a mouse move event (h-4)" },
michael@0 741 // Send a mouse move event after |gIgnoreMoveDelay| milliseconds since
michael@0 742 // last wheel event, then, current transaction should be kept.
michael@0 743 { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay,
michael@0 744 offset: kPtInSubView1ForH,
michael@0 745 description: "sendMouseMoveEvent" },
michael@0 746 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 747 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 748 canFailRandomly: { possibleView: gSubView1 },
michael@0 749 description: "Reset transaction by a mouse move event (h-5)" },
michael@0 750 // Scroll back to top-most for easy cursor position specifying.
michael@0 751 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 752 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 753 canFailRandomly: { possibleView: gSubView1 },
michael@0 754 description: "Reset transaction by a mouse move event (h-6)" },
michael@0 755 // Send a wheel event after |gIgnoreMoveDelay| milliseconds since last
michael@0 756 // mouse move event but it is fired immediately after the last wheel
michael@0 757 // event, then, current transaction should be kept.
michael@0 758 { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForH,
michael@0 759 description: "sendMouseMoveEvent" },
michael@0 760 { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay,
michael@0 761 offset: kPtInSubView1ForH,
michael@0 762 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 763 canFailRandomly: { possibleView: gSubView1 },
michael@0 764 description: "Reset transaction by a mouse move event (h-7)" },
michael@0 765 // Scroll back to top-most for easy cursor position specifying.
michael@0 766 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 767 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 768 canFailRandomly: { possibleView: gSubView1 },
michael@0 769 description: "Reset transaction by a mouse move event (h-8)" },
michael@0 770 // Send a wheel event after |gIgnoreMoveDelay| milliseconds have passed
michael@0 771 // since last mouse move event which is fired after |gIgnoreMoveDelay|
michael@0 772 // milliseconds since last wheel event, then, current transaction should
michael@0 773 // be reset.
michael@0 774 { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay,
michael@0 775 offset: kPtInSubView1ForH,
michael@0 776 description: "sendMouseMoveEvent" },
michael@0 777 { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay,
michael@0 778 offset: kPtInSubView1ForH,
michael@0 779 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 780 canFailRandomly: { possibleView: gRootView },
michael@0 781 description: "Reset transaction by a mouse move event (h-9)" }
michael@0 782 ]
michael@0 783 },
michael@0 784
michael@0 785
michael@0 786 /**************************************************************************
michael@0 787 * Reset transaction by a mouse move event on outside of view
michael@0 788 * When mouse cursor is moved to outside of the current target view, the
michael@0 789 * transaction should be reset immediately.
michael@0 790 **************************************************************************/
michael@0 791 { retryWhenTransactionTimeout: 5,
michael@0 792 steps: [
michael@0 793 // Vertical case
michael@0 794 { func: initElements, delay: 0, forVertical: true,
michael@0 795 description: "initElements" },
michael@0 796 { func: clearWheelTransaction, delay: 0,
michael@0 797 description: "clearWheelTransaction" },
michael@0 798 // Create a transaction which targets |gSubView1|.
michael@0 799 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 800 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 801 description: "Reset transaction by a mouse move event on outside of view (v-1)" },
michael@0 802 // Send mouse move event over |gRootView|.
michael@0 803 { func: sendMouseMoveEvent, delay: 0, offset: kPtInRootViewForV,
michael@0 804 description: "sendMouseMoveEvent" },
michael@0 805 // Send Wheel event over |gRootView| which should be scrolled.
michael@0 806 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 807 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 808 description: "Reset transaction by a mouse move event on outside of view (v-2)" }
michael@0 809 ]
michael@0 810 },
michael@0 811
michael@0 812
michael@0 813 { retryWhenTransactionTimeout: 5,
michael@0 814 steps: [
michael@0 815 // Horizontal case
michael@0 816 { func: initElements, delay: 0, forVertical: false,
michael@0 817 description: "initElements" },
michael@0 818 { func: clearWheelTransaction, delay: 0,
michael@0 819 description: "clearWheelTransaction" },
michael@0 820 // Create a transaction which targets |gSubView1|.
michael@0 821 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 822 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 823 description: "Reset transaction by a mouse move event on outside of view (h-1)" },
michael@0 824 // Send mouse move event over |gRootView|.
michael@0 825 { func: sendMouseMoveEvent, delay: 0, offset: kPtInRootViewForH,
michael@0 826 description: "sendMouseMoveEvent" },
michael@0 827 // Send Wheel event over |gRootView| which should be scrolled.
michael@0 828 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 829 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 830 description: "Reset transaction by a mouse move event on outside of view (h-2)" }
michael@0 831 ]
michael@0 832 },
michael@0 833
michael@0 834
michael@0 835 /**************************************************************************
michael@0 836 * Timeout test
michael@0 837 * A view should not be scrolled during another to be transaction for
michael@0 838 * another view scrolling. However, a wheel event which is sent after
michael@0 839 * timeout, a view which is under the mouse cursor should be scrolled.
michael@0 840 **************************************************************************/
michael@0 841 { retryWhenTransactionTimeout: 5,
michael@0 842 steps: [
michael@0 843 // Vertical case
michael@0 844 { func: initElements, delay: 0, forVertical: true,
michael@0 845 description: "initElements" },
michael@0 846 { func: clearWheelTransaction, delay: 0,
michael@0 847 description: "clearWheelTransaction" },
michael@0 848 // First, create a transaction which should target the |gRootView|.
michael@0 849 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 850 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 851 description: "Timeout test (v-1)" },
michael@0 852 // Scroll back to top-most for easy cursor position specifying.
michael@0 853 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV,
michael@0 854 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 855 description: "Timeout test (v-2)" },
michael@0 856 // A wheel event over |gSubView1| should not scroll it during current
michael@0 857 // transaction.
michael@0 858 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 859 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 860 canFailRandomly: { possibleView: gSubView1 },
michael@0 861 description: "Timeout test (v-3)" },
michael@0 862 // Scroll back to top-most again.
michael@0 863 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 864 isForward: false, isVertical: true, expectedView: gRootView,
michael@0 865 canFailRandomly: { possibleView: gSubView1 },
michael@0 866 description: "Timeout test (v-4)" },
michael@0 867 // A wheel event over |gSubView1| after timeout should scroll
michael@0 868 // |gSubView1|.
michael@0 869 { func: testOneTimeScroll, delay: gEnoughForTimeout,
michael@0 870 offset: kPtInSubView1ForV,
michael@0 871 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 872 isTimeoutTesting: true,
michael@0 873 description: "Timeout test (v-5)" }
michael@0 874 ]
michael@0 875 },
michael@0 876
michael@0 877
michael@0 878 { retryWhenTransactionTimeout: 5,
michael@0 879 steps: [
michael@0 880 // Horizontal case
michael@0 881 { func: initElements, delay: 0, forVertical: false,
michael@0 882 description: "initElements" },
michael@0 883 { func: clearWheelTransaction, delay: 0,
michael@0 884 description: "clearWheelTransaction" },
michael@0 885 // First, create a transaction which should target the |gRootView|.
michael@0 886 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 887 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 888 description: "Timeout test (h-1)" },
michael@0 889 // Scroll back to left-most for easy cursor position specifying.
michael@0 890 { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH,
michael@0 891 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 892 description: "Timeout test (h-2)" },
michael@0 893 // A wheel event over |gSubView1| should not scroll it during current
michael@0 894 // transaction.
michael@0 895 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 896 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 897 canFailRandomly: { possibleView: gSubView1 },
michael@0 898 description: "Timeout test (h-3)" },
michael@0 899 // Scroll back to left-most again.
michael@0 900 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 901 isForward: false, isVertical: false, expectedView: gRootView,
michael@0 902 canFailRandomly: { possibleView: gSubView1 },
michael@0 903 description: "Timeout test (h-4)" },
michael@0 904 // A wheel event over |gSubView1| after timeout should scroll
michael@0 905 // |gSubView1|.
michael@0 906 { func: testOneTimeScroll, delay: gEnoughForTimeout,
michael@0 907 offset: kPtInSubView1ForH,
michael@0 908 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 909 isTimeoutTesting: true,
michael@0 910 description: "Timeout test (h-5)" }
michael@0 911 ]
michael@0 912 },
michael@0 913
michael@0 914
michael@0 915 /**************************************************************************
michael@0 916 * Timeout test even with many wheel events
michael@0 917 * This tests whether timeout is occurred event if wheel events are sent.
michael@0 918 * The transaction should not be updated by non-scrollable wheel events.
michael@0 919 **************************************************************************/
michael@0 920 { retryWhenTransactionTimeout: 5,
michael@0 921 steps: [
michael@0 922 // Vertical case
michael@0 923 { func: initElements, delay: 0, forVertical: true,
michael@0 924 description: "initElements" },
michael@0 925 { func: clearWheelTransaction, delay: 0,
michael@0 926 description: "clearWheelTransaction" },
michael@0 927 // Scroll |gSubView1| to bottom-most.
michael@0 928 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 929 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 930 description: "Timeout test even with many wheel events (v-1)" },
michael@0 931 // Don't scroll any views before timeout.
michael@0 932 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 933 isForward: true, isVertical: true, expectedView: null,
michael@0 934 canFailRandomly: { possibleView: gRootView },
michael@0 935 description: "Timeout test even with many wheel events (v-2)" },
michael@0 936 // Recreate a transaction which is scrolling |gRootView| after time out.
michael@0 937 { func: testRestartScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 938 isForward: true, isVertical: true, expectedView: gRootView,
michael@0 939 description: "Timeout test even with many wheel events (v-3)" }
michael@0 940 ]
michael@0 941 },
michael@0 942
michael@0 943
michael@0 944 { retryWhenTransactionTimeout: 5,
michael@0 945 steps: [
michael@0 946 // Horizontal case
michael@0 947 { func: initElements, delay: 0, forVertical: false,
michael@0 948 description: "initElements" },
michael@0 949 { func: clearWheelTransaction, delay: 0,
michael@0 950 description: "clearWheelTransaction" },
michael@0 951 // Scroll |gSubView1| to right-most.
michael@0 952 { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 953 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 954 description: "Timeout test even with many wheel events (h-1)" },
michael@0 955 // Don't scroll any views before timeout.
michael@0 956 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 957 isForward: true, isVertical: false, expectedView: null,
michael@0 958 canFailRandomly: { possibleView: gRootView },
michael@0 959 description: "Timeout test even with many wheel events (h-2)" },
michael@0 960 // Recreate a transaction which is scrolling |gRootView| after time out.
michael@0 961 { func: testRestartScroll, delay: 0, offset: kPtInSubView1ForH,
michael@0 962 isForward: true, isVertical: false, expectedView: gRootView,
michael@0 963 description: "Timeout test even with many wheel events (h-3)" }
michael@0 964 ]
michael@0 965 },
michael@0 966
michael@0 967
michael@0 968 /**************************************************************************
michael@0 969 * Very large scrolling wheel event
michael@0 970 * If the delta value is larger than the scrolling page size, it should be
michael@0 971 * scrolled only one page instead of the delta value.
michael@0 972 **************************************************************************/
michael@0 973 { retryWhenTransactionTimeout: 5,
michael@0 974 steps: [
michael@0 975 { func: initElements, delay: 0, forVertical: true,
michael@0 976 description: "initElements" },
michael@0 977 { func: clearWheelTransaction, delay: 0,
michael@0 978 description: "clearWheelTransaction" },
michael@0 979 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 980 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 981 delta: 5000,
michael@0 982 description: "Very large delta scrolling (v-1)" },
michael@0 983 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 984 isForward: true, isVertical: true, expectedView: gSubView1,
michael@0 985 delta: 5000,
michael@0 986 description: "Very large delta scrolling (v-2)" },
michael@0 987 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 988 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 989 delta: 5000,
michael@0 990 description: "Very large delta scrolling (h-1)" },
michael@0 991 { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV,
michael@0 992 isForward: true, isVertical: false, expectedView: gSubView1,
michael@0 993 delta: 5000,
michael@0 994 description: "Very large delta scrolling (h-2)" }
michael@0 995 ]
michael@0 996 }
michael@0 997 ];
michael@0 998 }
michael@0 999
michael@0 1000 /******************************************************************************
michael@0 1001 * Actions for preparing tests
michael@0 1002 ******************************************************************************/
michael@0 1003
michael@0 1004 function initElements()
michael@0 1005 {
michael@0 1006 _clearTimer();
michael@0 1007
michael@0 1008 function resetScrollPosition(aElement)
michael@0 1009 {
michael@0 1010 aElement.scrollTop = 0;
michael@0 1011 aElement.scrollLeft = 0;
michael@0 1012 }
michael@0 1013
michael@0 1014 function initInRootView(aElement, aPt)
michael@0 1015 {
michael@0 1016 aElement.offset =
michael@0 1017 gCurrentTest.forVertical ? aPt : { x: aPt.y, y: aPt.x };
michael@0 1018 }
michael@0 1019
michael@0 1020 const kDisplay = gCurrentTest.forVertical ? "block" : "inline-block";
michael@0 1021 gSubView1.style.display = kDisplay;
michael@0 1022 gSubView2.style.display = kDisplay;
michael@0 1023 gSubView3.style.display = kDisplay;
michael@0 1024
michael@0 1025 resetScrollPosition(gRootView);
michael@0 1026 resetScrollPosition(gSubView1);
michael@0 1027 resetScrollPosition(gSubView2);
michael@0 1028 resetScrollPosition(gSubView3);
michael@0 1029
michael@0 1030 runNextTestStep();
michael@0 1031 }
michael@0 1032
michael@0 1033 function clearWheelTransaction()
michael@0 1034 {
michael@0 1035 _clearTimer();
michael@0 1036 _clearTransaction();
michael@0 1037 runNextTestStep();
michael@0 1038 }
michael@0 1039
michael@0 1040 function sendKeyEvents()
michael@0 1041 {
michael@0 1042 _clearTimer();
michael@0 1043 synthesizeKey(gCurrentTest.key, {}, window);
michael@0 1044 runNextTestStep();
michael@0 1045 }
michael@0 1046
michael@0 1047 function sendMouseButtonEvents()
michael@0 1048 {
michael@0 1049 _clearTimer();
michael@0 1050 synthesizeMouse(gRootView, -1, -1, { type:"mousedown" }, window);
michael@0 1051 synthesizeMouse(gRootView, -1, -1, { type:"mouseup" }, window);
michael@0 1052 runNextTestStep();
michael@0 1053 }
michael@0 1054
michael@0 1055 function sendMouseMoveEvent()
michael@0 1056 {
michael@0 1057 _clearTimer();
michael@0 1058 _fireMouseMoveEvent(gCurrentTest.offset);
michael@0 1059 runNextTestStep();
michael@0 1060 }
michael@0 1061
michael@0 1062 /******************************************************************************
michael@0 1063 * Utilities for testing functions
michael@0 1064 ******************************************************************************/
michael@0 1065
michael@0 1066 function _clearTransaction()
michael@0 1067 {
michael@0 1068 synthesizeMouse(gRootView, -1, -1, { type:"mousedown" }, window);
michael@0 1069 synthesizeMouse(gRootView, -1, -1, { type:"mouseup" }, window);
michael@0 1070 }
michael@0 1071
michael@0 1072 function _saveScrollPositions()
michael@0 1073 {
michael@0 1074 function save(aElement)
michael@0 1075 {
michael@0 1076 aElement.prevTop = aElement.scrollTop;
michael@0 1077 aElement.prevLeft = aElement.scrollLeft;
michael@0 1078 }
michael@0 1079 save(gRootView);
michael@0 1080 save(gSubView1);
michael@0 1081 save(gSubView2);
michael@0 1082 save(gSubView3);
michael@0 1083 }
michael@0 1084
michael@0 1085 function _fireMouseMoveEvent(aOffset)
michael@0 1086 {
michael@0 1087 synthesizeMouse(gRootView, aOffset.x, aOffset.y, { type:"mousemove" }, window);
michael@0 1088 }
michael@0 1089
michael@0 1090 function _fireWheelScrollEvent(aOffset, aIsVertical, aForward, aDelta)
michael@0 1091 {
michael@0 1092 var event = { deltaMode: WheelEvent.DOM_DELTA_LINE };
michael@0 1093 if (aIsVertical) {
michael@0 1094 event.deltaY = aForward ? aDelta : -aDelta;
michael@0 1095 } else {
michael@0 1096 event.deltaX = aForward ? aDelta : -aDelta;
michael@0 1097 }
michael@0 1098 synthesizeWheel(gRootView, aOffset.x, aOffset.y, event, window);
michael@0 1099 }
michael@0 1100
michael@0 1101 function _canScroll(aElement, aIsVertical, aForward)
michael@0 1102 {
michael@0 1103 if (aIsVertical) {
michael@0 1104 if (!aForward)
michael@0 1105 return aElement.scrollTop > 0;
michael@0 1106 return aElement.scrollHeight > aElement.scrollTop + aElement.clientHeight;
michael@0 1107 }
michael@0 1108 if (!aForward)
michael@0 1109 return aElement.scrollLeft > 0;
michael@0 1110 return aElement.scrollWidth > aElement.scrollLeft + aElement.clientWidth;
michael@0 1111 }
michael@0 1112
michael@0 1113 const kNotScrolled = 0;
michael@0 1114 const kScrolledToTop = 1;
michael@0 1115 const kScrolledToBottom = 2;
michael@0 1116 const kScrolledToLeft = 4;
michael@0 1117 const kScrolledToRight = 8;
michael@0 1118
michael@0 1119 const kScrolledVertical = kScrolledToTop | kScrolledToBottom;
michael@0 1120 const kScrolledHorizontal = kScrolledToLeft | kScrolledToRight;
michael@0 1121
michael@0 1122 function _getScrolledState(aElement)
michael@0 1123 {
michael@0 1124 var ret = kNotScrolled;
michael@0 1125 if (aElement.scrollTop != aElement.prevTop) {
michael@0 1126 ret |= aElement.scrollTop < aElement.prevTop ? kScrolledToTop :
michael@0 1127 kScrolledToBottom;
michael@0 1128 }
michael@0 1129 if (aElement.scrollLeft != aElement.prevLeft) {
michael@0 1130 ret |= aElement.scrollLeft < aElement.prevLeft ? kScrolledToLeft :
michael@0 1131 kScrolledToRight;
michael@0 1132 }
michael@0 1133 return ret;
michael@0 1134 }
michael@0 1135
michael@0 1136 function _getExpectedScrolledState()
michael@0 1137 {
michael@0 1138 return gCurrentTest.isVertical ?
michael@0 1139 gCurrentTest.isForward ? kScrolledToBottom : kScrolledToTop :
michael@0 1140 gCurrentTest.isForward ? kScrolledToRight : kScrolledToLeft;
michael@0 1141 }
michael@0 1142
michael@0 1143 function _getScrolledStateText(aScrolledState)
michael@0 1144 {
michael@0 1145 if (aScrolledState == kNotScrolled)
michael@0 1146 return "Not scrolled";
michael@0 1147
michael@0 1148 var s = "scrolled to ";
michael@0 1149 if (aScrolledState & kScrolledVertical) {
michael@0 1150 s += aScrolledState & kScrolledToTop ? "backward" : "forward";
michael@0 1151 s += " (vertical)"
michael@0 1152 if (aScrolledState & kScrolledHorizontal)
michael@0 1153 s += " and to ";
michael@0 1154 }
michael@0 1155 if (aScrolledState & kScrolledHorizontal) {
michael@0 1156 s += aScrolledState & kScrolledToLeft ? "backward" : "forward";
michael@0 1157 s += " (horizontal)"
michael@0 1158 }
michael@0 1159 return s;
michael@0 1160 }
michael@0 1161
michael@0 1162 function _getCurrentTestList()
michael@0 1163 {
michael@0 1164 return gTestLists[gCurrentTestListStatus.nextListIndex - 1];
michael@0 1165 }
michael@0 1166
michael@0 1167 function _clearTimer()
michael@0 1168 {
michael@0 1169 clearTimeout(gTimer);
michael@0 1170 gTimer = 0;
michael@0 1171 }
michael@0 1172
michael@0 1173 /******************************************************************************
michael@0 1174 * Testing functions
michael@0 1175 ******************************************************************************/
michael@0 1176
michael@0 1177 /**
michael@0 1178 * Note that testing functions must set following variables:
michael@0 1179 *
michael@0 1180 * gCurrentTest.repeatTest: See comment in |continueTest|.
michael@0 1181 * gCurrentTest.autoRepeatDelay: See comment in |continueTest|.
michael@0 1182 * gListenScrollEvent: When this is not true, the event handlers ignores the
michael@0 1183 * events.
michael@0 1184 */
michael@0 1185
michael@0 1186 function testContinuousScroll()
michael@0 1187 {
michael@0 1188 /**
michael@0 1189 * Testing continuous scrolling. This function synthesizes a wheel event. If
michael@0 1190 * the test was success, this function will be recalled automatically.
michael@0 1191 * And when a generating wheel event cannot scroll the expected view, this
michael@0 1192 * function fires the wheel event only one time.
michael@0 1193 *
michael@0 1194 * @param gCurrentTest.offset
michael@0 1195 * The cursor position of firing wheel event. The values are offset
michael@0 1196 * from |gRootView|.
michael@0 1197 * @param gCurrentTest.isVertical
michael@0 1198 * Whether the wheel event is for virtical scrolling or horizontal.
michael@0 1199 * @param gCurrentTest.isForward
michael@0 1200 * Whether the wheel event is to forward or to backward.
michael@0 1201 * @param gCurrentTest.expectedView
michael@0 1202 * The expected view which will be scrolled by wheel event. This
michael@0 1203 * value must not be null.
michael@0 1204 */
michael@0 1205
michael@0 1206 _clearTimer();
michael@0 1207 _saveScrollPositions();
michael@0 1208 if (!gCurrentTest.expectedView) {
michael@0 1209 runNextTestStep();
michael@0 1210 return;
michael@0 1211 }
michael@0 1212
michael@0 1213 gLitesnEvents = kListenEvent_All;
michael@0 1214 gCurrentTest.repeatTest = true;
michael@0 1215 gCurrentTest.autoRepeatDelay = 0;
michael@0 1216
michael@0 1217 if (!_canScroll(gCurrentTest.expectedView,
michael@0 1218 gCurrentTest.isVertical, gCurrentTest.isForward)) {
michael@0 1219 gCurrentTest.expectedView = null;
michael@0 1220 }
michael@0 1221 var delta = gCurrentTest.delta ? gCurrentTest.delta : 4;
michael@0 1222 _fireWheelScrollEvent(gCurrentTest.offset,
michael@0 1223 gCurrentTest.isVertical, gCurrentTest.isForward, delta);
michael@0 1224 }
michael@0 1225
michael@0 1226 function testOneTimeScroll()
michael@0 1227 {
michael@0 1228 /**
michael@0 1229 * Testing one wheel event. |runNextTestStep| will be called immediately
michael@0 1230 * after this function by |onScrollView| or |onTimeout|.
michael@0 1231 *
michael@0 1232 * @param gCurrentTest.offset
michael@0 1233 * The cursor position of firing wheel event. The values are offset
michael@0 1234 * from |gRootView|.
michael@0 1235 * @param gCurrentTest.isVertical
michael@0 1236 * Whether the wheel event is for virtical scrolling or horizontal.
michael@0 1237 * @param gCurrentTest.isForward
michael@0 1238 * Whether the wheel event is to forward or to backward.
michael@0 1239 * @param gCurrentTest.expectedView
michael@0 1240 * The expected view which will be scrolled by wheel event. This
michael@0 1241 * value can be null. It means any views should not be scrolled.
michael@0 1242 */
michael@0 1243
michael@0 1244 _clearTimer();
michael@0 1245 _saveScrollPositions();
michael@0 1246
michael@0 1247 gLitesnEvents = kListenEvent_All;
michael@0 1248 gCurrentTest.repeatTest = false;
michael@0 1249 gCurrentTest.autoRepeatDelay = 0;
michael@0 1250
michael@0 1251 var delta = gCurrentTest.delta ? gCurrentTest.delta : 4;
michael@0 1252 _fireWheelScrollEvent(gCurrentTest.offset,
michael@0 1253 gCurrentTest.isVertical, gCurrentTest.isForward, delta);
michael@0 1254 }
michael@0 1255
michael@0 1256 function testRestartScroll()
michael@0 1257 {
michael@0 1258 /**
michael@0 1259 * Testing restart to scroll in expected view after timeout from the current
michael@0 1260 * transaction. This function recall this itself until to success this test
michael@0 1261 * or timeout from this test.
michael@0 1262 *
michael@0 1263 * @param gCurrentTest.offset
michael@0 1264 * The cursor position of firing wheel event. The values are offset
michael@0 1265 * from |gRootView|.
michael@0 1266 * @param gCurrentTest.isVertical
michael@0 1267 * Whether the wheel event is for virtical scrolling or horizontal.
michael@0 1268 * @param gCurrentTest.isForward
michael@0 1269 * Whether the wheel event is to forward or to backward.
michael@0 1270 * @param gCurrentTest.expectedView
michael@0 1271 * The expected view which will be scrolled by wheel event. This
michael@0 1272 * value must not be null.
michael@0 1273 */
michael@0 1274
michael@0 1275 _clearTimer();
michael@0 1276 _saveScrollPositions();
michael@0 1277
michael@0 1278 if (!gCurrentTest.wasTransactionTimeout) {
michael@0 1279 gCurrentTest.repeatTest = true;
michael@0 1280 gCurrentTest.autoRepeatDelay = gTimeout / 3;
michael@0 1281 gLitesnEvents = kListenEvent_All;
michael@0 1282 gCurrentTest.isTimeoutTesting = true;
michael@0 1283 if (gCurrentTest.expectedView) {
michael@0 1284 gCurrentTest.expectedViewAfterTimeout = gCurrentTest.expectedView;
michael@0 1285 gCurrentTest.expectedView = null;
michael@0 1286 }
michael@0 1287 } else {
michael@0 1288 gCurrentTest.repeatTest = false;
michael@0 1289 gCurrentTest.autoRepeatDelay = 0;
michael@0 1290 gLitesnEvents = kListenEvent_All;
michael@0 1291 gCurrentTest.isTimeoutTesting = false;
michael@0 1292 gCurrentTest.expectedView = gCurrentTest.expectedViewAfterTimeout;
michael@0 1293 }
michael@0 1294
michael@0 1295 var delta = gCurrentTest.delta ? gCurrentTest.delta : 4;
michael@0 1296 _fireWheelScrollEvent(gCurrentTest.offset,
michael@0 1297 gCurrentTest.isVertical, gCurrentTest.isForward, delta);
michael@0 1298 }
michael@0 1299
michael@0 1300 /******************************************************************************
michael@0 1301 * Event handlers
michael@0 1302 ******************************************************************************/
michael@0 1303
michael@0 1304 function onScrollView(aEvent)
michael@0 1305 {
michael@0 1306 /**
michael@0 1307 * Scroll event handler of |gRootView|, |gSubView1|, |gSubView2| and
michael@0 1308 * |gSubView3|. If testing is failed, this function cancels all left tests.
michael@0 1309 * For checking the event is expected, the event firer must call
michael@0 1310 * |_saveScrollPositions|.
michael@0 1311 *
michael@0 1312 * @param gCurrentTest.expectedView
michael@0 1313 * The expected view which should be scrolled by the wheel event.
michael@0 1314 * This value can be null. It means any views should not be
michael@0 1315 * scrolled.
michael@0 1316 * @param gCurrentTest.isVertical
michael@0 1317 * The expected view should be scrolled vertical or horizontal.
michael@0 1318 * @param gCurrentTest.isForward
michael@0 1319 * The expected view should be scrolled to forward or backward.
michael@0 1320 * @param gCurrentTest.canFailRandomly
michael@0 1321 * If this is not undefined, this test can fail by unexpected view
michael@0 1322 * scrolling which is caused by unexpected timeout. If this is
michael@0 1323 * defined, |gCurrentTest.possibleView| must be set. If the view is
michael@0 1324 * same as the event target, the failure can be random. At this
michael@0 1325 * time, we should retry the current test list.
michael@0 1326 */
michael@0 1327
michael@0 1328 if (!(gLitesnEvents & kListenEvent_OnScroll))
michael@0 1329 return;
michael@0 1330
michael@0 1331 // Now testing a timeout, but a view is scrolled before timeout.
michael@0 1332 if (gCurrentTest.isTimeoutTesting && !gCurrentTest.wasTransactionTimeout) {
michael@0 1333 is(aEvent.target.id, "",
michael@0 1334 "The view scrolled before timeout (the expected view after timeout is " +
michael@0 1335 gCurrentTest.expectedView ? gCurrentTest.expectedView.id : "null" +
michael@0 1336 "): " + gCurrentTest.description);
michael@0 1337 runNextTestList();
michael@0 1338 return;
michael@0 1339 }
michael@0 1340
michael@0 1341 // Check whether the scrolled event should be fired or not.
michael@0 1342 if (!gCurrentTest.expectedView) {
michael@0 1343 is(aEvent.target.id, "",
michael@0 1344 "no views should be scrolled (" +
michael@0 1345 _getScrolledStateText(_getScrolledState(aEvent.target)) + "): " +
michael@0 1346 gCurrentTest.description);
michael@0 1347 runNextTestList();
michael@0 1348 return;
michael@0 1349 }
michael@0 1350
michael@0 1351 // Check whether the scrolled view is expected or not.
michael@0 1352 if (aEvent.target != gCurrentTest.expectedView) {
michael@0 1353 // If current test can fail randomly and the possible view is same as the
michael@0 1354 // event target, this failure may be caused by unexpected timeout.
michael@0 1355 // At this time, we should retry the current tests with slower settings.
michael@0 1356 if (gCurrentTest.canFailRandomly &&
michael@0 1357 gCurrentTest.canFailRandomly.possibleView == aEvent.target &&
michael@0 1358 gCurrentTestListStatus.retryWhenTransactionTimeout > 0) {
michael@0 1359 gCurrentTestListStatus.retryWhenTransactionTimeout--;
michael@0 1360 retryCurrentTestList();
michael@0 1361 return;
michael@0 1362 }
michael@0 1363 is(aEvent.target.id, gCurrentTest.expectedView.id,
michael@0 1364 "wrong view was scrolled: " + gCurrentTest.description);
michael@0 1365 runNextTestList();
michael@0 1366 return;
michael@0 1367 }
michael@0 1368
michael@0 1369 // Check whether the scrolling direction is expected or not.
michael@0 1370 var expectedState = _getExpectedScrolledState();
michael@0 1371 var currentState = _getScrolledState(aEvent.target);
michael@0 1372 if (expectedState != currentState) {
michael@0 1373 is(_getScrolledStateText(currentState),
michael@0 1374 _getScrolledStateText(expectedState),
michael@0 1375 "scrolled to wrong direction: " + gCurrentTest.description);
michael@0 1376 runNextTestList();
michael@0 1377 return;
michael@0 1378 }
michael@0 1379
michael@0 1380 ok(true, "passed: " + gCurrentTest.description);
michael@0 1381 continueTest();
michael@0 1382 }
michael@0 1383
michael@0 1384 function onMouseScrollFailed()
michael@0 1385 {
michael@0 1386 /**
michael@0 1387 * Scroll failed event handler. If testing is failed, this function cancels
michael@0 1388 * all remains of current test-list, and go to next test-list.
michael@0 1389 *
michael@0 1390 * NOTE: This event is fired immediately after |_fireWheelScrollEvent|.
michael@0 1391 *
michael@0 1392 * @param gCurrentTest.expectedView
michael@0 1393 * The expected view which should be scrolled by the wheel event.
michael@0 1394 * This value can be null. It means any views should not be
michael@0 1395 * scrolled. When this is not null, this event means the test may
michael@0 1396 * be failed.
michael@0 1397 */
michael@0 1398
michael@0 1399 if (!(gLitesnEvents & kListenEvent_OnScrollFailed))
michael@0 1400 return;
michael@0 1401
michael@0 1402 ok(!gCurrentTest.expectedView,
michael@0 1403 "failed to scroll on current target: " + gCurrentTest.description);
michael@0 1404 if (gCurrentTest.expectedView) {
michael@0 1405 runNextTestList();
michael@0 1406 return;
michael@0 1407 }
michael@0 1408
michael@0 1409 continueTest();
michael@0 1410 }
michael@0 1411
michael@0 1412 function onTransactionTimeout()
michael@0 1413 {
michael@0 1414 /**
michael@0 1415 * Scroll transaction timeout event handler. If the timeout is unexpected,
michael@0 1416 * i.e., |gCurrentTest.isTimeoutTesting| is not true, this function retry
michael@0 1417 * the current test-list. However, if the current test-list failed by timeout
michael@0 1418 * |gCurrentTestListStatus.retryWhenTransactionTimeout| times already, marking
michael@0 1419 * to failed the current test-list, and go to next test-list.
michael@0 1420 *
michael@0 1421 * @param gCurrentTest.expectedView
michael@0 1422 * The expected view which should be scrolled by the wheel event.
michael@0 1423 * This value can be null. It means any views should not be
michael@0 1424 * scrolled. When this is not null, this event means the testing may
michael@0 1425 * be failed.
michael@0 1426 * @param gCurrentTest.isTimeoutTesting
michael@0 1427 * If this value is true, the current testing have waited this
michael@0 1428 * event. Otherwise, the testing may be failed.
michael@0 1429 * @param gCurrentTestListStatus.retryWhenTransactionTimeout
michael@0 1430 * If |gCurrentTest.isTimeoutTesting| is not true but this event is
michael@0 1431 * fired, the failure may be randomly. Then, this event handler
michael@0 1432 * retry to test the current test-list until this cound will be zero.
michael@0 1433 */
michael@0 1434
michael@0 1435 if (!gCurrentTest.isTimeoutTesting &&
michael@0 1436 gCurrentTestListStatus.retryWhenTransactionTimeout > 0) {
michael@0 1437 gCurrentTestListStatus.retryWhenTransactionTimeout--;
michael@0 1438 // retry current test list
michael@0 1439 retryCurrentTestList();
michael@0 1440 return;
michael@0 1441 }
michael@0 1442
michael@0 1443 gCurrentTest.wasTransactionTimeout = true;
michael@0 1444
michael@0 1445 if (!(gLitesnEvents & kListenEvent_OnTransactionTimeout))
michael@0 1446 return;
michael@0 1447
michael@0 1448 ok(gCurrentTest.isTimeoutTesting,
michael@0 1449 "transaction timeout: " + gCurrentTest.description);
michael@0 1450 if (!gCurrentTest.isTimeoutTesting) {
michael@0 1451 runNextTestList();
michael@0 1452 return;
michael@0 1453 }
michael@0 1454
michael@0 1455 continueTest();
michael@0 1456 }
michael@0 1457
michael@0 1458 /******************************************************************************
michael@0 1459 * Main function for this tests
michael@0 1460 ******************************************************************************/
michael@0 1461
michael@0 1462 function runNextTestStep()
michael@0 1463 {
michael@0 1464 // When this is first time or the current test list is finised, load next
michael@0 1465 // test-list.
michael@0 1466 _clearTimer();
michael@0 1467 if (!gCurrentTest)
michael@0 1468 runNextTestList();
michael@0 1469 else
michael@0 1470 runTestStepAt(gCurrentTestListStatus.nextStepIndex);
michael@0 1471 }
michael@0 1472
michael@0 1473 function runNextTestList()
michael@0 1474 {
michael@0 1475 _clearTimer();
michael@0 1476
michael@0 1477 gLitesnEvents = kListenEvent_None;
michael@0 1478 _clearTransaction();
michael@0 1479 resetTimeoutPrefs();
michael@0 1480 if (gCurrentTestListStatus.nextListIndex >= gTestLists.length) {
michael@0 1481 finish();
michael@0 1482 return;
michael@0 1483 }
michael@0 1484
michael@0 1485 gCurrentTestListStatus.nextListIndex++;
michael@0 1486 gCurrentTestListStatus.retryWhenTransactionTimeout =
michael@0 1487 _getCurrentTestList().retryWhenTransactionTimeout;
michael@0 1488 runTestStepAt(0);
michael@0 1489 }
michael@0 1490
michael@0 1491 function runTestStepAt(aStepIndex)
michael@0 1492 {
michael@0 1493 _clearTimer();
michael@0 1494
michael@0 1495 disableNonTestMouseEvents(true);
michael@0 1496
michael@0 1497 // load a step of testing.
michael@0 1498 gCurrentTestListStatus.nextStepIndex = aStepIndex;
michael@0 1499 gCurrentTest =
michael@0 1500 _getCurrentTestList().steps[gCurrentTestListStatus.nextStepIndex++];
michael@0 1501 if (gCurrentTest) {
michael@0 1502 gCurrentTest.wasTransactionTimeout = false;
michael@0 1503 gTimer = setTimeout(gCurrentTest.func, gCurrentTest.delay);
michael@0 1504 } else {
michael@0 1505 // If current test-list doesn't have more testing, go to next test-list
michael@0 1506 // after cleaning up the current transaction.
michael@0 1507 _clearTransaction();
michael@0 1508 runNextTestList();
michael@0 1509 }
michael@0 1510 }
michael@0 1511
michael@0 1512 function retryCurrentTestList()
michael@0 1513 {
michael@0 1514 _clearTimer();
michael@0 1515
michael@0 1516 gLitesnEvents = kListenEvent_None;
michael@0 1517 _clearTransaction();
michael@0 1518 ok(true, "WARNING: retry current test-list...");
michael@0 1519 growUpTimeoutPrefs(); // retry the test with longer timeout settings.
michael@0 1520 runTestStepAt(0);
michael@0 1521 }
michael@0 1522
michael@0 1523 function continueTest()
michael@0 1524 {
michael@0 1525 /**
michael@0 1526 * This function is called from an event handler when a test succeeded.
michael@0 1527 *
michael@0 1528 * @param gCurrentTest.repeatTest
michael@0 1529 * When this is true, onScrollView calls |gCurrentTest.func|. So,
michael@0 1530 * same test can repeat. Otherwise, this calls |runNextTestStep|.
michael@0 1531 * @param gCurrentTest.autoRepeatDelay
michael@0 1532 * The delay value in milliseconds, this is used to call
michael@0 1533 * |gCurrentTest.func| via |setTimeout|.
michael@0 1534 */
michael@0 1535
michael@0 1536 _clearTimer();
michael@0 1537 gLitesnEvents = kListenEvent_OnTransactionTimeout;
michael@0 1538
michael@0 1539 // We should call each functions via setTimeout. Because sometimes this test
michael@0 1540 // is broken by stack overflow.
michael@0 1541 if (gCurrentTest.repeatTest) {
michael@0 1542 gTimer = setTimeout(gCurrentTest.func, gCurrentTest.autoRepeatDelay);
michael@0 1543 } else {
michael@0 1544 gTimer = setTimeout(runNextTestStep, 0);
michael@0 1545 }
michael@0 1546 }
michael@0 1547
michael@0 1548 ]]>
michael@0 1549 </script>
michael@0 1550
michael@0 1551 </window>

mercurial