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