3 #scrollable { overflow: scroll; height:
100px; width:
100px; }
4 #scrollable div { height:
2000px; }
7 <p>Tests that we only fire one scroll event per frame (and by association that it happens at raf time).
</p>
14 var scrollable
= document
.getElementById('scrollable');
15 var output
= document
.getElementById('output');
18 if (window
.testRunner
) {
19 testRunner
.dumpAsText();
20 testRunner
.waitUntilDone();
24 var scrollsSinceLastFrame
= 0;
25 var remainingTicks
= 20;
27 scrollable
.onscroll = function() {
28 ++scrollsSinceLastFrame
;
31 // FIXME: we need a better way of waiting for layout/repainting to happen
32 var timerId
= setInterval(function() {
33 scrollable
.scrollTop
+= 1;
34 if (!--remainingTicks
)
35 clearInterval(timerId
);
39 if (scrollsSinceLastFrame
> 1) {
40 document
.body
.appendChild(document
.createTextNode('FAIL'));
44 requestAnimationFrame(raf
);
47 document
.body
.appendChild(document
.createTextNode('PASS'));
48 if (window
.testRunner
)
49 testRunner
.notifyDone();
51 scrollsSinceLastFrame
= 0;
54 requestAnimationFrame(raf
);