Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: LayoutTests/fast/events/scroll-event-raf-timing.html

Issue 644093003: NOP refactor to make various layout tests use setTimeout 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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>
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/font-face-css-change-while-loading.html ('k') | LayoutTests/http/tests/inspector/inspector-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698