Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=785588 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 785588 --- ordering of scroll-related events</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785588">Mozilla Bug 785588</a> |
michael@0 | 14 | <div id="content"> |
michael@0 | 15 | <div id="d" style="border:2px solid black; width:100px; height:100px; overflow:auto"> |
michael@0 | 16 | <div id="inner" style="height:200px;">Hello</div> |
michael@0 | 17 | </div> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script> |
michael@0 | 21 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 22 | |
michael@0 | 23 | var smoothScrollPref = "general.smoothScroll"; |
michael@0 | 24 | SpecialPowers.setBoolPref(smoothScrollPref, false); |
michael@0 | 25 | |
michael@0 | 26 | var d = document.getElementById("d"); |
michael@0 | 27 | d.scrollTop = 0; |
michael@0 | 28 | var inner = document.getElementById("inner"); |
michael@0 | 29 | |
michael@0 | 30 | var state = "initial"; |
michael@0 | 31 | |
michael@0 | 32 | function onFrame() { |
michael@0 | 33 | is(state, "initial", "Must be in initial state"); |
michael@0 | 34 | ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")"); |
michael@0 | 35 | state = "didOnFrame"; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function onScroll() { |
michael@0 | 39 | is(state, "didOnFrame", "Must have got requestAnimationFrame callback already"); |
michael@0 | 40 | ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")"); |
michael@0 | 41 | SpecialPowers.clearUserPref(smoothScrollPref); |
michael@0 | 42 | SimpleTest.finish(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function doTest() { |
michael@0 | 46 | window.getSelection().collapse(inner.firstChild, 0); |
michael@0 | 47 | window.mozRequestAnimationFrame(onFrame); |
michael@0 | 48 | d.onscroll = onScroll; |
michael@0 | 49 | sendKey("DOWN"); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | SimpleTest.waitForFocus(doTest); |
michael@0 | 53 | </script> |
michael@0 | 54 | </pre> |
michael@0 | 55 | </body> |
michael@0 | 56 | </html> |