| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <head> |
| 3 <script src="../../../resources/js-test.js"></script> |
| 4 <style> |
| 5 #spacer { |
| 6 height: 10000px; |
| 7 width: 10000px; |
| 8 } |
| 9 </style> |
| 10 <script> |
| 11 function failTest(why) { |
| 12 testFailed(why); |
| 13 if (testRunner) |
| 14 testRunner.notifyDone(); |
| 15 } |
| 16 |
| 17 function execInNRafs(n, func) { |
| 18 var count = n; |
| 19 var rafCall = function() { |
| 20 count--; |
| 21 if (count <= 0) |
| 22 func(); |
| 23 else |
| 24 requestAnimationFrame(rafCall); |
| 25 }; |
| 26 |
| 27 requestAnimationFrame(rafCall); |
| 28 } |
| 29 |
| 30 internals.settings.setScrollAnimatorEnabled(true); |
| 31 internals.settings.setMockScrollbarsEnabled(false); |
| 32 |
| 33 if (testRunner) { |
| 34 testRunner.waitUntilDone(); |
| 35 } |
| 36 |
| 37 onload = function() { |
| 38 var checkScroll = function() { |
| 39 shouldBe('window.scrollY', '0'); |
| 40 testRunner.notifyDone(); |
| 41 } |
| 42 |
| 43 var numScrolls = 0; |
| 44 window.addEventListener('scroll', function() { |
| 45 ++numScrolls; |
| 46 if (numScrolls == 2) { |
| 47 // This programmatic scroll should cancel the user scroll. |
| 48 window.scrollTo(0, 0); |
| 49 } else if (numScrolls == 3) { |
| 50 // End the test a small delay and check that we haven't scrolled |
| 51 // any more after that delay. |
| 52 shouldBe('window.scrollY', '0'); |
| 53 execInNRafs(10, checkScroll); |
| 54 } else if (numScrolls > 3) { |
| 55 // Fail if we receive any more scrolls. |
| 56 failTest('Continued user scroll after programmatic scroll.'); |
| 57 } |
| 58 }); |
| 59 |
| 60 window.eventSender.keyDown('end'); |
| 61 }; |
| 62 </script> |
| 63 </head> |
| 64 |
| 65 <body> |
| 66 <div id="spacer"></div> |
| 67 </body> |
| OLD | NEW |