From c839f78b8f2d8d910bc2bfc9e41b3e3b67090ec1 Mon Sep 17 00:00:00 2001 From: Traxmaxx Date: Tue, 4 Mar 2014 18:54:08 +0100 Subject: fix($$RAFProvider): check for webkitCancelRequestAnimationFrame Android 4.3 only supports webkitCancelRequestAnimationFrame. Closes #6526 --- test/ng/rafSpec.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/ng/rafSpec.js b/test/ng/rafSpec.js index 8bf76efd..7c67b8c9 100644 --- a/test/ng/rafSpec.js +++ b/test/ng/rafSpec.js @@ -38,11 +38,8 @@ describe('$$rAF', function() { //we need to create our own injector to work around the ngMock overrides var injector = createInjector(['ng', function($provide) { $provide.value('$timeout', timeoutSpy); - $provide.decorator('$window', function($delegate) { - $delegate.requestAnimationFrame = false; - $delegate.webkitRequestAnimationFrame = false; - $delegate.mozRequestAnimationFrame = false; - return $delegate; + $provide.value('$window', { + location : window.location, }); }]); @@ -76,4 +73,29 @@ describe('$$rAF', function() { } })); }); + + describe('mobile', function() { + it('should provide a cancellation method for an older version of Android', function() { + //we need to create our own injector to work around the ngMock overrides + var injector = createInjector(['ng', function($provide) { + $provide.value('$window', { + location : window.location, + webkitRequestAnimationFrame: jasmine.createSpy('$window.webkitRequestAnimationFrame'), + webkitCancelRequestAnimationFrame: jasmine.createSpy('$window.webkitCancelRequestAnimationFrame') + }); + }]); + + var $$rAF = injector.get('$$rAF'); + var $window = injector.get('$window'); + var cancel = $$rAF(function() {}); + + expect($$rAF.supported).toBe(true); + + try { + cancel(); + } catch(e) {} + + expect($window.webkitCancelRequestAnimationFrame).toHaveBeenCalled(); + }); + }); }); -- cgit v1.2.3