summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/animation/script-tests/request-animation-frame-timestamps-advance.js
blob: 7e44ee82710654c03c0640669d2a4e9676cecf4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
jsTestIsAsync = true;

description("Tests the timestamps provided to requestAnimationFrame callbacks advance");

function busyWait(millis) {
    var start = Date.now();
    while (Date.now()-start < millis) {}
}

var firstTimestamp = undefined;
var secondTimestamp = undefined;

window.webkitRequestAnimationFrame(function(timestamp) {
    firstTimestamp = timestamp;
    shouldBeDefined("firstTimestamp");
    window.webkitRequestAnimationFrame(function(timestamp) {
        secondTimestamp = timestamp;
        shouldBeDefined("secondTimestamp");
        shouldBeTrue("secondTimestamp > firstTimestamp");
        finishJSTest();
    });
    busyWait(10);
    if (window.testRunner)
        testRunner.display();
});


if (window.testRunner)
    window.setTimeout(function() {
        testRunner.display();
    });