@@ -38,11 +38,8 @@ describe('$$rAF', function() {
38
38
//we need to create our own injector to work around the ngMock overrides
39
39
var injector = createInjector ( [ 'ng' , function ( $provide ) {
40
40
$provide . value ( '$timeout' , timeoutSpy ) ;
41
- $provide . decorator ( '$window' , function ( $delegate ) {
42
- $delegate . requestAnimationFrame = false ;
43
- $delegate . webkitRequestAnimationFrame = false ;
44
- $delegate . mozRequestAnimationFrame = false ;
45
- return $delegate ;
41
+ $provide . value ( '$window' , {
42
+ location : window . location ,
46
43
} ) ;
47
44
} ] ) ;
48
45
@@ -76,4 +73,29 @@ describe('$$rAF', function() {
76
73
}
77
74
} ) ) ;
78
75
} ) ;
76
+
77
+ describe ( 'mobile' , function ( ) {
78
+ it ( 'should provide a cancellation method for an older version of Android' , function ( ) {
79
+ //we need to create our own injector to work around the ngMock overrides
80
+ var injector = createInjector ( [ 'ng' , function ( $provide ) {
81
+ $provide . value ( '$window' , {
82
+ location : window . location ,
83
+ webkitRequestAnimationFrame : jasmine . createSpy ( '$window.webkitRequestAnimationFrame' ) ,
84
+ webkitCancelRequestAnimationFrame : jasmine . createSpy ( '$window.webkitCancelRequestAnimationFrame' )
85
+ } ) ;
86
+ } ] ) ;
87
+
88
+ var $$rAF = injector . get ( '$$rAF' ) ;
89
+ var $window = injector . get ( '$window' ) ;
90
+ var cancel = $$rAF ( function ( ) { } ) ;
91
+
92
+ expect ( $$rAF . supported ) . toBe ( true ) ;
93
+
94
+ try {
95
+ cancel ( ) ;
96
+ } catch ( e ) { }
97
+
98
+ expect ( $window . webkitCancelRequestAnimationFrame ) . toHaveBeenCalled ( ) ;
99
+ } ) ;
100
+ } ) ;
79
101
} ) ;
0 commit comments