mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-02 09:00:34 +08:00
fix($$RAFProvider): check for webkitCancelRequestAnimationFrame
Android 4.3 only supports webkitCancelRequestAnimationFrame. Closes #6526
This commit is contained in:
@@ -8,7 +8,8 @@ function $$RAFProvider(){ //rAF
|
||||
|
||||
var cancelAnimationFrame = $window.cancelAnimationFrame ||
|
||||
$window.webkitCancelAnimationFrame ||
|
||||
$window.mozCancelAnimationFrame;
|
||||
$window.mozCancelAnimationFrame ||
|
||||
$window.webkitCancelRequestAnimationFrame;
|
||||
|
||||
var rafSupported = !!requestAnimationFrame;
|
||||
var raf = rafSupported
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user