angular/packages/zone.js/test/performance/promise.js
Joey Perrott 9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00

63 lines
2.1 KiB
JavaScript

/**
* @license
* Copyright Google LLC 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.dev/license
*/
(function (_global) {
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 () {});
},
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;
});
});
},
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;
});
},
},
],
};
return testRunner(testTarget);
})(typeof window === 'undefined' ? global : window);