From 1c60f90ee5ec6b5872b35749fc2b978862b7c3f0 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 23 May 2013 09:48:53 -0700 Subject: [PATCH] Tests for requestAnimationFrame and cancelAnimationFrame --- test/utils.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/utils.js b/test/utils.js index 3b7d6c49..7489f03b 100644 --- a/test/utils.js +++ b/test/utils.js @@ -62,4 +62,30 @@ }); }); + // ---------- + asyncTest("requestAnimationFrame", function() { + var timeWatcher = Util.timeWatcher(); + + OpenSeadragon.requestAnimationFrame(function() { + ok(true, 'frame fired'); + timeWatcher.done(); + }); + }); + + // ---------- + asyncTest("cancelAnimationFrame", function() { + var frameFired = false; + + setTimeout(function() { + strictEqual(frameFired, false, 'the frame never fired'); + start(); + }, 150); + + var frameId = OpenSeadragon.requestAnimationFrame(function() { + frameFired = true; + }); + + OpenSeadragon.cancelAnimationFrame(frameId); + }); + })();