OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <style> | 2 <style> |
3 #scrollable { overflow: scroll; height: 100px; width: 100px; } | 3 #scrollable { overflow: scroll; height: 100px; width: 100px; } |
4 #scrollable div { height: 2000px; } | 4 #scrollable div { height: 2000px; } |
5 </style> | 5 </style> |
6 | 6 |
7 <p>Tests that we only fire one scroll event per frame (and by association that i
t happens at raf time).</p> | 7 <p>Tests that we only fire one scroll event per frame (and by association that i
t happens at raf time).</p> |
8 | 8 |
9 <div id="scrollable"> | 9 <div id="scrollable"> |
10 <div></div> | 10 <div></div> |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 onload = function() { | 23 onload = function() { |
24 var scrollsSinceLastFrame = 0; | 24 var scrollsSinceLastFrame = 0; |
25 var remainingTicks = 20; | 25 var remainingTicks = 20; |
26 | 26 |
27 scrollable.onscroll = function() { | 27 scrollable.onscroll = function() { |
28 ++scrollsSinceLastFrame; | 28 ++scrollsSinceLastFrame; |
29 }; | 29 }; |
30 | 30 |
| 31 // FIXME: we need a better way of waiting for layout/repainting to happen |
31 var timerId = setInterval(function() { | 32 var timerId = setInterval(function() { |
32 scrollable.scrollTop += 1; | 33 scrollable.scrollTop += 1; |
33 if (!--remainingTicks) | 34 if (!--remainingTicks) |
34 clearInterval(timerId); | 35 clearInterval(timerId); |
35 }, 0); | 36 }, 1); |
36 | 37 |
37 function raf() { | 38 function raf() { |
38 if (scrollsSinceLastFrame > 1) { | 39 if (scrollsSinceLastFrame > 1) { |
39 document.body.appendChild(document.createTextNode('FAIL')); | 40 document.body.appendChild(document.createTextNode('FAIL')); |
40 ++failures; | 41 ++failures; |
41 } | 42 } |
42 if (remainingTicks) { | 43 if (remainingTicks) { |
43 requestAnimationFrame(raf); | 44 requestAnimationFrame(raf); |
44 } else { | 45 } else { |
45 if (!failures) | 46 if (!failures) |
46 document.body.appendChild(document.createTextNode('PASS')); | 47 document.body.appendChild(document.createTextNode('PASS')); |
47 if (window.testRunner) | 48 if (window.testRunner) |
48 testRunner.notifyDone(); | 49 testRunner.notifyDone(); |
49 } | 50 } |
50 scrollsSinceLastFrame = 0; | 51 scrollsSinceLastFrame = 0; |
51 } | 52 } |
52 | 53 |
53 requestAnimationFrame(raf); | 54 requestAnimationFrame(raf); |
54 } | 55 } |
55 </script> | 56 </script> |
OLD | NEW |