license import { ifEnvSupports } from '../test-util' ; declare const window ; describe ( 'requestAnimationFrame' , function ( ) { const functions = [ 'requestAnimationFrame' , 'webkitRequestAnimationFrame' , 'mozRequestAnimationFrame' ] ; functions . forEach ( function ( fnName ) { describe ( fnName , ifEnvSupports ( fnName , function ( ) { const originalTimeout = ( < any > jasmine ) . DEFAULT_TIMEOUT_INTERVAL ; beforeEach ( ( ) => { ( < any > jasmine ) . DEFAULT_TIMEOUT_INTERVAL = 10000 ; } ) ; afterEach ( ( ) => { ( < any > jasmine ) . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ; } ) ; const rAF = window [ fnName ] ; it ( 'should be tolerant of invalid arguments' , function ( ) { expect ( function ( ) { rAF ( null ) ; } ) . toThrow ( ) ; } ) ; it ( 'should bind to same zone when called recursively' , function ( done ) { Zone . current . fork ( { name : 'TestZone' } ) . run ( ( ) => { let frames = 0 ; let previousTimeStamp = 0 ; function frameCallback ( timestamp ) { expect ( timestamp ) . toMatch ( /^[\d.]+$/ ) ; expect ( previousTimeStamp ) . not . toBeGreaterThan ( timestamp ) ; previousTimeStamp = timestamp ; if ( frames ++ > 15 ) { ( < any > jasmine ) . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ; return done ( ) ; } rAF ( frameCallback ) ; } rAF ( frameCallback ) ; } ) ; } ) ; } ) ) ; } ) ; } ) ;