blob: e9f2b53aa2e412a74792debe325c0dfcdf4c3614 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
var callbackFired = false;
var cancelFired = false;
function firstRequestAnimationFrame() {
return new Promise(resolve => {
window.requestAnimationFrame(() => {
window.cancelAnimationFrame(secondCallbackId);
cancelFired = true;
resolve();
});
});
}
function secondRequestAnimationFrame() {
return new Promise(resolve => {
secondCallbackId = window.requestAnimationFrame(() => {
callbackFired = true;
resolve();
});
setTimeout(resolve, 100);
});
}
description("Tests one requestAnimationFrame callback cancelling a second");
window.jsTestIsAsync = true;
Promise.all([firstRequestAnimationFrame(), secondRequestAnimationFrame()]).then(() => {
shouldBeFalse("callbackFired");
shouldBeTrue("cancelFired");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>