diff options
| author | Traxmaxx | 2014-03-04 18:54:08 +0100 | 
|---|---|---|
| committer | Matias Niemelä | 2014-03-18 21:37:04 -0400 | 
| commit | c839f78b8f2d8d910bc2bfc9e41b3e3b67090ec1 (patch) | |
| tree | e7fcd51ddbaf23ed24286b72a1f8e17bd998528b /test/ng/rafSpec.js | |
| parent | f7ce415c676dc0d458c9f0508dde01f92cf6f00a (diff) | |
| download | angular.js-c839f78b8f2d8d910bc2bfc9e41b3e3b67090ec1.tar.bz2 | |
fix($$RAFProvider): check for webkitCancelRequestAnimationFrame
Android 4.3 only supports webkitCancelRequestAnimationFrame.
Closes #6526
Diffstat (limited to 'test/ng/rafSpec.js')
| -rw-r--r-- | test/ng/rafSpec.js | 32 | 
1 files changed, 27 insertions, 5 deletions
| 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(); +    }); +  });  }); | 
