2019-05-31 11:56:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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 testRunner = _global['__zone_symbol__testRunner'];
|
|
|
|
var setTimeout = _global['setTimeout'];
|
|
|
|
var clearTimeout = _global['clearTimeout'];
|
|
|
|
var nativeSetTimeout = _global['__zone_symbol__setTimeout'];
|
|
|
|
var nativeClearTimeout = _global['__zone_symbol__clearTimeout'];
|
|
|
|
var zone = _global['__zone_symbol__callbackZone'];
|
|
|
|
var testTarget = {
|
|
|
|
title: 'timer',
|
|
|
|
times: 10,
|
|
|
|
before: function() {
|
|
|
|
_global['__zone_symbol__callbackContext'].measureName = 'setTimeout_callback';
|
|
|
|
_global['__zone_symbol__callbackContext'].type = 'macroTask';
|
|
|
|
_global['__zone_symbol__callbackContext'].source = 'setTimeout';
|
|
|
|
},
|
|
|
|
apis: [
|
|
|
|
{
|
|
|
|
supportClear: true,
|
|
|
|
method: 'setTimeout',
|
|
|
|
nativeMethod: '__zone_symbol__setTimeout',
|
|
|
|
clearMethod: 'clearTimeout',
|
|
|
|
nativeClearMethod: '__zone_symbol__clearTimeout',
|
|
|
|
run: function() {
|
|
|
|
return setTimeout(function() {});
|
|
|
|
},
|
|
|
|
runClear: function(timerId) {
|
|
|
|
return clearTimeout(timerId);
|
|
|
|
},
|
|
|
|
nativeRun: function() {
|
|
|
|
return nativeSetTimeout(function() {});
|
|
|
|
},
|
|
|
|
nativeRunClear: function(timerId) {
|
|
|
|
return nativeClearTimeout(timerId);
|
|
|
|
}
|
2019-05-31 11:56:07 -04:00
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
{
|
|
|
|
isCallback: true,
|
|
|
|
supportClear: false,
|
|
|
|
method: 'setTimeout_callback',
|
|
|
|
nativeMethod: 'native_setTimeout_callback',
|
|
|
|
run: function() {
|
|
|
|
zone.run(function() {
|
|
|
|
setTimeout(function() {});
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
nativeRun: function() {
|
|
|
|
var func = function() {};
|
|
|
|
nativeSetTimeout(function() {
|
|
|
|
mark('native_setTimeout_callback');
|
|
|
|
func.apply(this, arguments);
|
|
|
|
measure('native_setTimeout_callback', 'native_setTimeout_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));
|