2019-05-31 11:56:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-05-31 11:56:07 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
(function(_global) {
|
2020-04-13 19:40:21 -04:00
|
|
|
var mark = _global['__zone_symbol__mark'];
|
|
|
|
var measure = _global['__zone_symbol__measure'];
|
|
|
|
var zone = _global['__zone_symbol__callbackZone'];
|
|
|
|
var testRunner = _global['__zone_symbol__testRunner'];
|
|
|
|
var raf = _global['requestAnimationFrame'];
|
|
|
|
var cancel = _global['cancelAnimationFrame'];
|
|
|
|
var nativeRaf = _global['__zone_symbol__requestAnimationFrame'];
|
|
|
|
var nativeCancel = _global['__zone_symbol__cancelAnimationFrame'];
|
|
|
|
var testTarget = {
|
|
|
|
title: 'requestAnimationFrame',
|
|
|
|
times: 10,
|
|
|
|
before: function() {
|
|
|
|
_global['__zone_symbol__callbackContext'].measureName = 'requestAnimationFrame_callback';
|
|
|
|
_global['__zone_symbol__callbackContext'].type = 'macroTask';
|
|
|
|
_global['__zone_symbol__callbackContext'].source = 'requestAnimationFrame';
|
|
|
|
},
|
|
|
|
apis: [
|
|
|
|
{
|
|
|
|
supportClear: true,
|
|
|
|
method: 'requestAnimationFrame',
|
|
|
|
nativeMethod: '__zone_symbol__requestAnimationFrame',
|
|
|
|
clearMethod: 'cancelAnimationFrame',
|
|
|
|
nativeClearMethod: '__zone_symbol__cancelAnimationFrame',
|
|
|
|
run: function() {
|
|
|
|
return raf(function() {});
|
|
|
|
},
|
|
|
|
runClear: function(timerId) {
|
|
|
|
return cancel(timerId);
|
|
|
|
},
|
|
|
|
nativeRun: function() {
|
|
|
|
return nativeRaf(function() {});
|
|
|
|
},
|
|
|
|
nativeRunClear: function(timerId) {
|
|
|
|
return nativeCancel(timerId);
|
|
|
|
}
|
2019-05-31 11:56:07 -04:00
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
{
|
|
|
|
isCallback: true,
|
|
|
|
supportClear: false,
|
|
|
|
method: 'requestAnimationFrame_callback',
|
|
|
|
nativeMethod: 'native_requestAnimationFrame_callback',
|
|
|
|
run: function() {
|
|
|
|
zone.run(function() {
|
|
|
|
raf(function() {});
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
nativeRun: function() {
|
|
|
|
var func = function() {};
|
|
|
|
nativeRaf(function() {
|
|
|
|
mark('native_requestAnimationFrame_callback');
|
|
|
|
func.apply(this, arguments);
|
|
|
|
measure('native_requestAnimationFrame_callback', 'native_requestAnimationFrame_callback');
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
}
|
2020-04-13 19:40:21 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
};
|
|
|
|
return testRunner(testTarget);
|
2019-05-31 11:56:07 -04:00
|
|
|
}(typeof window === 'undefined' ? global : window));
|