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 zone = _global['__zone_symbol__callbackZone'];
|
|
|
|
var nativePromise = _global['__zone_symbol__Promise'];
|
|
|
|
var resolved = Promise.resolve(1);
|
|
|
|
var nativeResolved = nativePromise.resolve(1);
|
|
|
|
var testTarget = {
|
|
|
|
title: 'Promise',
|
|
|
|
times: 10,
|
|
|
|
before: function() {
|
|
|
|
_global['__zone_symbol__callbackContext'].measureName = 'Promise_callback';
|
|
|
|
_global['__zone_symbol__callbackContext'].type = 'microTask';
|
|
|
|
_global['__zone_symbol__callbackContext'].source = 'Promise.then';
|
|
|
|
},
|
|
|
|
apis: [
|
|
|
|
{
|
|
|
|
supportClear: false,
|
|
|
|
isAsync: true,
|
|
|
|
method: 'Promise',
|
|
|
|
nativeMethod: 'native_Promise',
|
|
|
|
run: function() {
|
|
|
|
return resolved.then(function() {});
|
2019-05-31 11:56:07 -04:00
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
nativeRun: function() {
|
|
|
|
return nativeResolved['__zone_symbol__then'](function() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
isCallback: true,
|
|
|
|
isAsync: true,
|
|
|
|
supportClear: false,
|
|
|
|
method: 'Promise_callback',
|
|
|
|
nativeMethod: 'native_Promise_callback',
|
|
|
|
run: function() {
|
|
|
|
return zone.run(function() {
|
|
|
|
return Promise.resolve(1).then(function(v) {
|
|
|
|
return v;
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
nativeRun: function() {
|
|
|
|
var func = function() {};
|
|
|
|
return _global['__zone_symbol__Promise'].resolve(1)['__zone_symbol__then'](function() {
|
|
|
|
mark('native_Promise_callback');
|
|
|
|
var result = func.apply(this, arguments);
|
|
|
|
measure('native_Promise_callback', 'native_Promise_callback');
|
|
|
|
return result;
|
|
|
|
});
|
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));
|