a zip code crypto-currency system good for red ONLY

zone-testing.js 67KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  10. typeof define === 'function' && define.amd ? define(factory) :
  11. (factory());
  12. }(this, (function () { 'use strict';
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. /**
  21. * @fileoverview
  22. * @suppress {globalThis}
  23. */
  24. var NEWLINE = '\n';
  25. var IGNORE_FRAMES = {};
  26. var creationTrace = '__creationTrace__';
  27. var ERROR_TAG = 'STACKTRACE TRACKING';
  28. var SEP_TAG = '__SEP_TAG__';
  29. var sepTemplate = SEP_TAG + '@[native]';
  30. var LongStackTrace = /** @class */ (function () {
  31. function LongStackTrace() {
  32. this.error = getStacktrace();
  33. this.timestamp = new Date();
  34. }
  35. return LongStackTrace;
  36. }());
  37. function getStacktraceWithUncaughtError() {
  38. return new Error(ERROR_TAG);
  39. }
  40. function getStacktraceWithCaughtError() {
  41. try {
  42. throw getStacktraceWithUncaughtError();
  43. }
  44. catch (err) {
  45. return err;
  46. }
  47. }
  48. // Some implementations of exception handling don't create a stack trace if the exception
  49. // isn't thrown, however it's faster not to actually throw the exception.
  50. var error = getStacktraceWithUncaughtError();
  51. var caughtError = getStacktraceWithCaughtError();
  52. var getStacktrace = error.stack ?
  53. getStacktraceWithUncaughtError :
  54. (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError);
  55. function getFrames(error) {
  56. return error.stack ? error.stack.split(NEWLINE) : [];
  57. }
  58. function addErrorStack(lines, error) {
  59. var trace = getFrames(error);
  60. for (var i = 0; i < trace.length; i++) {
  61. var frame = trace[i];
  62. // Filter out the Frames which are part of stack capturing.
  63. if (!IGNORE_FRAMES.hasOwnProperty(frame)) {
  64. lines.push(trace[i]);
  65. }
  66. }
  67. }
  68. function renderLongStackTrace(frames, stack) {
  69. var longTrace = [stack ? stack.trim() : ''];
  70. if (frames) {
  71. var timestamp = new Date().getTime();
  72. for (var i = 0; i < frames.length; i++) {
  73. var traceFrames = frames[i];
  74. var lastTime = traceFrames.timestamp;
  75. var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime;
  76. separator = separator.replace(/[^\w\d]/g, '_');
  77. longTrace.push(sepTemplate.replace(SEP_TAG, separator));
  78. addErrorStack(longTrace, traceFrames.error);
  79. timestamp = lastTime.getTime();
  80. }
  81. }
  82. return longTrace.join(NEWLINE);
  83. }
  84. Zone['longStackTraceZoneSpec'] = {
  85. name: 'long-stack-trace',
  86. longStackTraceLimit: 10,
  87. // add a getLongStackTrace method in spec to
  88. // handle handled reject promise error.
  89. getLongStackTrace: function (error) {
  90. if (!error) {
  91. return undefined;
  92. }
  93. var trace = error[Zone.__symbol__('currentTaskTrace')];
  94. if (!trace) {
  95. return error.stack;
  96. }
  97. return renderLongStackTrace(trace, error.stack);
  98. },
  99. onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) {
  100. if (Error.stackTraceLimit > 0) {
  101. // if Error.stackTraceLimit is 0, means stack trace
  102. // is disabled, so we don't need to generate long stack trace
  103. // this will improve performance in some test(some test will
  104. // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698
  105. var currentTask = Zone.currentTask;
  106. var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || [];
  107. trace = [new LongStackTrace()].concat(trace);
  108. if (trace.length > this.longStackTraceLimit) {
  109. trace.length = this.longStackTraceLimit;
  110. }
  111. if (!task.data)
  112. task.data = {};
  113. task.data[creationTrace] = trace;
  114. }
  115. return parentZoneDelegate.scheduleTask(targetZone, task);
  116. },
  117. onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) {
  118. if (Error.stackTraceLimit > 0) {
  119. // if Error.stackTraceLimit is 0, means stack trace
  120. // is disabled, so we don't need to generate long stack trace
  121. // this will improve performance in some test(some test will
  122. // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698
  123. var parentTask = Zone.currentTask || error.task;
  124. if (error instanceof Error && parentTask) {
  125. var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
  126. try {
  127. error.stack = error.longStack = longStack;
  128. }
  129. catch (err) {
  130. }
  131. }
  132. }
  133. return parentZoneDelegate.handleError(targetZone, error);
  134. }
  135. };
  136. function captureStackTraces(stackTraces, count) {
  137. if (count > 0) {
  138. stackTraces.push(getFrames((new LongStackTrace()).error));
  139. captureStackTraces(stackTraces, count - 1);
  140. }
  141. }
  142. function computeIgnoreFrames() {
  143. if (Error.stackTraceLimit <= 0) {
  144. return;
  145. }
  146. var frames = [];
  147. captureStackTraces(frames, 2);
  148. var frames1 = frames[0];
  149. var frames2 = frames[1];
  150. for (var i = 0; i < frames1.length; i++) {
  151. var frame1 = frames1[i];
  152. if (frame1.indexOf(ERROR_TAG) == -1) {
  153. var match = frame1.match(/^\s*at\s+/);
  154. if (match) {
  155. sepTemplate = match[0] + SEP_TAG + ' (http://localhost)';
  156. break;
  157. }
  158. }
  159. }
  160. for (var i = 0; i < frames1.length; i++) {
  161. var frame1 = frames1[i];
  162. var frame2 = frames2[i];
  163. if (frame1 === frame2) {
  164. IGNORE_FRAMES[frame1] = true;
  165. }
  166. else {
  167. break;
  168. }
  169. }
  170. }
  171. computeIgnoreFrames();
  172. /**
  173. * @license
  174. * Copyright Google Inc. All Rights Reserved.
  175. *
  176. * Use of this source code is governed by an MIT-style license that can be
  177. * found in the LICENSE file at https://angular.io/license
  178. */
  179. var ProxyZoneSpec = /** @class */ (function () {
  180. function ProxyZoneSpec(defaultSpecDelegate) {
  181. if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; }
  182. this.defaultSpecDelegate = defaultSpecDelegate;
  183. this.name = 'ProxyZone';
  184. this.properties = { 'ProxyZoneSpec': this };
  185. this.propertyKeys = null;
  186. this.lastTaskState = null;
  187. this.isNeedToTriggerHasTask = false;
  188. this.tasks = [];
  189. this.setDelegate(defaultSpecDelegate);
  190. }
  191. ProxyZoneSpec.get = function () {
  192. return Zone.current.get('ProxyZoneSpec');
  193. };
  194. ProxyZoneSpec.isLoaded = function () {
  195. return ProxyZoneSpec.get() instanceof ProxyZoneSpec;
  196. };
  197. ProxyZoneSpec.assertPresent = function () {
  198. if (!ProxyZoneSpec.isLoaded()) {
  199. throw new Error("Expected to be running in 'ProxyZone', but it was not found.");
  200. }
  201. return ProxyZoneSpec.get();
  202. };
  203. ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) {
  204. var _this = this;
  205. var isNewDelegate = this._delegateSpec !== delegateSpec;
  206. this._delegateSpec = delegateSpec;
  207. this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; });
  208. this.propertyKeys = null;
  209. if (delegateSpec && delegateSpec.properties) {
  210. this.propertyKeys = Object.keys(delegateSpec.properties);
  211. this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; });
  212. }
  213. // if set a new delegateSpec, shoulde check whether need to
  214. // trigger hasTask or not
  215. if (isNewDelegate && this.lastTaskState &&
  216. (this.lastTaskState.macroTask || this.lastTaskState.microTask)) {
  217. this.isNeedToTriggerHasTask = true;
  218. }
  219. };
  220. ProxyZoneSpec.prototype.getDelegate = function () {
  221. return this._delegateSpec;
  222. };
  223. ProxyZoneSpec.prototype.resetDelegate = function () {
  224. var delegateSpec = this.getDelegate();
  225. this.setDelegate(this.defaultSpecDelegate);
  226. };
  227. ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) {
  228. if (this.isNeedToTriggerHasTask && this.lastTaskState) {
  229. // last delegateSpec has microTask or macroTask
  230. // should call onHasTask in current delegateSpec
  231. this.isNeedToTriggerHasTask = false;
  232. this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState);
  233. }
  234. };
  235. ProxyZoneSpec.prototype.removeFromTasks = function (task) {
  236. if (!this.tasks) {
  237. return;
  238. }
  239. for (var i = 0; i < this.tasks.length; i++) {
  240. if (this.tasks[i] === task) {
  241. this.tasks.splice(i, 1);
  242. return;
  243. }
  244. }
  245. };
  246. ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () {
  247. if (this.tasks.length === 0) {
  248. return '';
  249. }
  250. var taskInfo = this.tasks.map(function (task) {
  251. var dataInfo = task.data &&
  252. Object.keys(task.data)
  253. .map(function (key) {
  254. return key + ':' + task.data[key];
  255. })
  256. .join(',');
  257. return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}";
  258. });
  259. var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']';
  260. // clear tasks
  261. this.tasks = [];
  262. return pendingTasksInfo;
  263. };
  264. ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) {
  265. if (this._delegateSpec && this._delegateSpec.onFork) {
  266. return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec);
  267. }
  268. else {
  269. return parentZoneDelegate.fork(targetZone, zoneSpec);
  270. }
  271. };
  272. ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) {
  273. if (this._delegateSpec && this._delegateSpec.onIntercept) {
  274. return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source);
  275. }
  276. else {
  277. return parentZoneDelegate.intercept(targetZone, delegate, source);
  278. }
  279. };
  280. ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
  281. this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone);
  282. if (this._delegateSpec && this._delegateSpec.onInvoke) {
  283. return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source);
  284. }
  285. else {
  286. return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
  287. }
  288. };
  289. ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
  290. if (this._delegateSpec && this._delegateSpec.onHandleError) {
  291. return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error);
  292. }
  293. else {
  294. return parentZoneDelegate.handleError(targetZone, error);
  295. }
  296. };
  297. ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) {
  298. if (task.type !== 'eventTask') {
  299. this.tasks.push(task);
  300. }
  301. if (this._delegateSpec && this._delegateSpec.onScheduleTask) {
  302. return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task);
  303. }
  304. else {
  305. return parentZoneDelegate.scheduleTask(targetZone, task);
  306. }
  307. };
  308. ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) {
  309. if (task.type !== 'eventTask') {
  310. this.removeFromTasks(task);
  311. }
  312. this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone);
  313. if (this._delegateSpec && this._delegateSpec.onInvokeTask) {
  314. return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs);
  315. }
  316. else {
  317. return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);
  318. }
  319. };
  320. ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) {
  321. if (task.type !== 'eventTask') {
  322. this.removeFromTasks(task);
  323. }
  324. this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone);
  325. if (this._delegateSpec && this._delegateSpec.onCancelTask) {
  326. return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task);
  327. }
  328. else {
  329. return parentZoneDelegate.cancelTask(targetZone, task);
  330. }
  331. };
  332. ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) {
  333. this.lastTaskState = hasTaskState;
  334. if (this._delegateSpec && this._delegateSpec.onHasTask) {
  335. this._delegateSpec.onHasTask(delegate, current, target, hasTaskState);
  336. }
  337. else {
  338. delegate.hasTask(target, hasTaskState);
  339. }
  340. };
  341. return ProxyZoneSpec;
  342. }());
  343. // Export the class so that new instances can be created with proper
  344. // constructor params.
  345. Zone['ProxyZoneSpec'] = ProxyZoneSpec;
  346. /**
  347. * @license
  348. * Copyright Google Inc. All Rights Reserved.
  349. *
  350. * Use of this source code is governed by an MIT-style license that can be
  351. * found in the LICENSE file at https://angular.io/license
  352. */
  353. var SyncTestZoneSpec = /** @class */ (function () {
  354. function SyncTestZoneSpec(namePrefix) {
  355. this.runZone = Zone.current;
  356. this.name = 'syncTestZone for ' + namePrefix;
  357. }
  358. SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) {
  359. switch (task.type) {
  360. case 'microTask':
  361. case 'macroTask':
  362. throw new Error("Cannot call " + task.source + " from within a sync test.");
  363. case 'eventTask':
  364. task = delegate.scheduleTask(target, task);
  365. break;
  366. }
  367. return task;
  368. };
  369. return SyncTestZoneSpec;
  370. }());
  371. // Export the class so that new instances can be created with proper
  372. // constructor params.
  373. Zone['SyncTestZoneSpec'] = SyncTestZoneSpec;
  374. /**
  375. * @license
  376. * Copyright Google Inc. All Rights Reserved.
  377. *
  378. * Use of this source code is governed by an MIT-style license that can be
  379. * found in the LICENSE file at https://angular.io/license
  380. */
  381. (function () {
  382. var __extends = function (d, b) {
  383. for (var p in b)
  384. if (b.hasOwnProperty(p))
  385. d[p] = b[p];
  386. function __() {
  387. this.constructor = d;
  388. }
  389. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  390. };
  391. var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global;
  392. // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs
  393. // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503)
  394. if (!Zone)
  395. throw new Error('Missing: zone.js');
  396. if (typeof jasmine == 'undefined')
  397. throw new Error('Missing: jasmine.js');
  398. if (jasmine['__zone_patch__'])
  399. throw new Error("'jasmine' has already been patched with 'Zone'.");
  400. jasmine['__zone_patch__'] = true;
  401. var SyncTestZoneSpec = Zone['SyncTestZoneSpec'];
  402. var ProxyZoneSpec = Zone['ProxyZoneSpec'];
  403. if (!SyncTestZoneSpec)
  404. throw new Error('Missing: SyncTestZoneSpec');
  405. if (!ProxyZoneSpec)
  406. throw new Error('Missing: ProxyZoneSpec');
  407. var ambientZone = Zone.current;
  408. // Create a synchronous-only zone in which to run `describe` blocks in order to raise an
  409. // error if any asynchronous operations are attempted inside of a `describe` but outside of
  410. // a `beforeEach` or `it`.
  411. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe'));
  412. var symbol = Zone.__symbol__;
  413. // whether patch jasmine clock when in fakeAsync
  414. var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true;
  415. // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone.
  416. var jasmineEnv = jasmine.getEnv();
  417. ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) {
  418. var originalJasmineFn = jasmineEnv[methodName];
  419. jasmineEnv[methodName] = function (description, specDefinitions) {
  420. return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions));
  421. };
  422. });
  423. ['it', 'xit', 'fit'].forEach(function (methodName) {
  424. var originalJasmineFn = jasmineEnv[methodName];
  425. jasmineEnv[symbol(methodName)] = originalJasmineFn;
  426. jasmineEnv[methodName] = function (description, specDefinitions, timeout) {
  427. arguments[1] = wrapTestInZone(specDefinitions);
  428. return originalJasmineFn.apply(this, arguments);
  429. };
  430. });
  431. ['beforeEach', 'afterEach'].forEach(function (methodName) {
  432. var originalJasmineFn = jasmineEnv[methodName];
  433. jasmineEnv[symbol(methodName)] = originalJasmineFn;
  434. jasmineEnv[methodName] = function (specDefinitions, timeout) {
  435. arguments[0] = wrapTestInZone(specDefinitions);
  436. return originalJasmineFn.apply(this, arguments);
  437. };
  438. });
  439. // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so
  440. // they can work properly in FakeAsyncTest
  441. var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']);
  442. jasmine['clock'] = function () {
  443. var clock = originalClockFn.apply(this, arguments);
  444. if (!clock[symbol('patched')]) {
  445. clock[symbol('patched')] = symbol('patched');
  446. var originalTick_1 = (clock[symbol('tick')] = clock.tick);
  447. clock.tick = function () {
  448. var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
  449. if (fakeAsyncZoneSpec) {
  450. return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments);
  451. }
  452. return originalTick_1.apply(this, arguments);
  453. };
  454. var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate);
  455. clock.mockDate = function () {
  456. var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
  457. if (fakeAsyncZoneSpec) {
  458. var dateTime = arguments.length > 0 ? arguments[0] : new Date();
  459. return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] :
  460. arguments);
  461. }
  462. return originalMockDate_1.apply(this, arguments);
  463. };
  464. // for auto go into fakeAsync feature, we need the flag to enable it
  465. if (enableClockPatch) {
  466. ['install', 'uninstall'].forEach(function (methodName) {
  467. var originalClockFn = (clock[symbol(methodName)] = clock[methodName]);
  468. clock[methodName] = function () {
  469. var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec'];
  470. if (FakeAsyncTestZoneSpec) {
  471. jasmine[symbol('clockInstalled')] = 'install' === methodName;
  472. return;
  473. }
  474. return originalClockFn.apply(this, arguments);
  475. };
  476. });
  477. }
  478. }
  479. return clock;
  480. };
  481. /**
  482. * Gets a function wrapping the body of a Jasmine `describe` block to execute in a
  483. * synchronous-only zone.
  484. */
  485. function wrapDescribeInZone(describeBody) {
  486. return function () {
  487. return syncZone.run(describeBody, this, arguments);
  488. };
  489. }
  490. function runInTestZone(testBody, applyThis, queueRunner, done) {
  491. var isClockInstalled = !!jasmine[symbol('clockInstalled')];
  492. var testProxyZoneSpec = queueRunner.testProxyZoneSpec;
  493. var testProxyZone = queueRunner.testProxyZone;
  494. if (isClockInstalled && enableClockPatch) {
  495. // auto run a fakeAsync
  496. var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')];
  497. if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') {
  498. testBody = fakeAsyncModule.fakeAsync(testBody);
  499. }
  500. }
  501. if (done) {
  502. return testProxyZone.run(testBody, applyThis, [done]);
  503. }
  504. else {
  505. return testProxyZone.run(testBody, applyThis);
  506. }
  507. }
  508. /**
  509. * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to
  510. * execute in a ProxyZone zone.
  511. * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner`
  512. */
  513. function wrapTestInZone(testBody) {
  514. // The `done` callback is only passed through if the function expects at least one argument.
  515. // Note we have to make a function with correct number of arguments, otherwise jasmine will
  516. // think that all functions are sync or async.
  517. return (testBody && (testBody.length ? function (done) {
  518. return runInTestZone(testBody, this, this.queueRunner, done);
  519. } : function () {
  520. return runInTestZone(testBody, this, this.queueRunner);
  521. }));
  522. }
  523. var QueueRunner = jasmine.QueueRunner;
  524. jasmine.QueueRunner = (function (_super) {
  525. __extends(ZoneQueueRunner, _super);
  526. function ZoneQueueRunner(attrs) {
  527. var _this = this;
  528. attrs.onComplete = (function (fn) { return function () {
  529. // All functions are done, clear the test zone.
  530. _this.testProxyZone = null;
  531. _this.testProxyZoneSpec = null;
  532. ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
  533. }; })(attrs.onComplete);
  534. var nativeSetTimeout = _global['__zone_symbol__setTimeout'];
  535. var nativeClearTimeout = _global['__zone_symbol__clearTimeout'];
  536. if (nativeSetTimeout) {
  537. // should run setTimeout inside jasmine outside of zone
  538. attrs.timeout = {
  539. setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout,
  540. clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout
  541. };
  542. }
  543. // create a userContext to hold the queueRunner itself
  544. // so we can access the testProxy in it/xit/beforeEach ...
  545. if (jasmine.UserContext) {
  546. if (!attrs.userContext) {
  547. attrs.userContext = new jasmine.UserContext();
  548. }
  549. attrs.userContext.queueRunner = this;
  550. }
  551. else {
  552. if (!attrs.userContext) {
  553. attrs.userContext = {};
  554. }
  555. attrs.userContext.queueRunner = this;
  556. }
  557. // patch attrs.onException
  558. var onException = attrs.onException;
  559. attrs.onException = function (error) {
  560. if (error &&
  561. error.message ===
  562. 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') {
  563. // jasmine timeout, we can make the error message more
  564. // reasonable to tell what tasks are pending
  565. var proxyZoneSpec = this && this.testProxyZoneSpec;
  566. if (proxyZoneSpec) {
  567. var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo();
  568. error.message += pendingTasksInfo;
  569. }
  570. }
  571. if (onException) {
  572. onException.call(this, error);
  573. }
  574. };
  575. _super.call(this, attrs);
  576. }
  577. ZoneQueueRunner.prototype.execute = function () {
  578. var _this = this;
  579. var zone = Zone.current;
  580. var isChildOfAmbientZone = false;
  581. while (zone) {
  582. if (zone === ambientZone) {
  583. isChildOfAmbientZone = true;
  584. break;
  585. }
  586. zone = zone.parent;
  587. }
  588. if (!isChildOfAmbientZone)
  589. throw new Error('Unexpected Zone: ' + Zone.current.name);
  590. // This is the zone which will be used for running individual tests.
  591. // It will be a proxy zone, so that the tests function can retroactively install
  592. // different zones.
  593. // Example:
  594. // - In beforeEach() do childZone = Zone.current.fork(...);
  595. // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the
  596. // zone outside of fakeAsync it will be able to escape the fakeAsync rules.
  597. // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
  598. // fakeAsync behavior to the childZone.
  599. this.testProxyZoneSpec = new ProxyZoneSpec();
  600. this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec);
  601. if (!Zone.currentTask) {
  602. // if we are not running in a task then if someone would register a
  603. // element.addEventListener and then calling element.click() the
  604. // addEventListener callback would think that it is the top most task and would
  605. // drain the microtask queue on element.click() which would be incorrect.
  606. // For this reason we always force a task when running jasmine tests.
  607. Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); });
  608. }
  609. else {
  610. _super.prototype.execute.call(this);
  611. }
  612. };
  613. return ZoneQueueRunner;
  614. })(QueueRunner);
  615. })();
  616. /**
  617. * @license
  618. * Copyright Google Inc. All Rights Reserved.
  619. *
  620. * Use of this source code is governed by an MIT-style license that can be
  621. * found in the LICENSE file at https://angular.io/license
  622. */
  623. var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global;
  624. var AsyncTestZoneSpec = /** @class */ (function () {
  625. function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {
  626. this.finishCallback = finishCallback;
  627. this.failCallback = failCallback;
  628. this._pendingMicroTasks = false;
  629. this._pendingMacroTasks = false;
  630. this._alreadyErrored = false;
  631. this._isSync = false;
  632. this.runZone = Zone.current;
  633. this.unresolvedChainedPromiseCount = 0;
  634. this.supportWaitUnresolvedChainedPromise = false;
  635. this.name = 'asyncTestZone for ' + namePrefix;
  636. this.properties = { 'AsyncTestZoneSpec': this };
  637. this.supportWaitUnresolvedChainedPromise =
  638. _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true;
  639. }
  640. AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () {
  641. return this.unresolvedChainedPromiseCount > 0;
  642. };
  643. AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () {
  644. var _this = this;
  645. if (!(this._pendingMicroTasks || this._pendingMacroTasks ||
  646. (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) {
  647. // We do this because we would like to catch unhandled rejected promises.
  648. this.runZone.run(function () {
  649. setTimeout(function () {
  650. if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) {
  651. _this.finishCallback();
  652. }
  653. }, 0);
  654. });
  655. }
  656. };
  657. AsyncTestZoneSpec.prototype.patchPromiseForTest = function () {
  658. if (!this.supportWaitUnresolvedChainedPromise) {
  659. return;
  660. }
  661. var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')];
  662. if (patchPromiseForTest) {
  663. patchPromiseForTest();
  664. }
  665. };
  666. AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () {
  667. if (!this.supportWaitUnresolvedChainedPromise) {
  668. return;
  669. }
  670. var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')];
  671. if (unPatchPromiseForTest) {
  672. unPatchPromiseForTest();
  673. }
  674. };
  675. AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) {
  676. if (task.type !== 'eventTask') {
  677. this._isSync = false;
  678. }
  679. if (task.type === 'microTask' && task.data && task.data instanceof Promise) {
  680. // check whether the promise is a chained promise
  681. if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) {
  682. // chained promise is being scheduled
  683. this.unresolvedChainedPromiseCount--;
  684. }
  685. }
  686. return delegate.scheduleTask(target, task);
  687. };
  688. AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) {
  689. if (task.type !== 'eventTask') {
  690. this._isSync = false;
  691. }
  692. return delegate.invokeTask(target, task, applyThis, applyArgs);
  693. };
  694. AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) {
  695. if (task.type !== 'eventTask') {
  696. this._isSync = false;
  697. }
  698. return delegate.cancelTask(target, task);
  699. };
  700. // Note - we need to use onInvoke at the moment to call finish when a test is
  701. // fully synchronous. TODO(juliemr): remove this when the logic for
  702. // onHasTask changes and it calls whenever the task queues are dirty.
  703. // updated by(JiaLiPassion), only call finish callback when no task
  704. // was scheduled/invoked/canceled.
  705. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
  706. try {
  707. this._isSync = true;
  708. return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
  709. }
  710. finally {
  711. var afterTaskCounts = parentZoneDelegate._taskCounts;
  712. if (this._isSync) {
  713. this._finishCallbackIfDone();
  714. }
  715. }
  716. };
  717. AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
  718. // Let the parent try to handle the error.
  719. var result = parentZoneDelegate.handleError(targetZone, error);
  720. if (result) {
  721. this.failCallback(error);
  722. this._alreadyErrored = true;
  723. }
  724. return false;
  725. };
  726. AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) {
  727. delegate.hasTask(target, hasTaskState);
  728. if (hasTaskState.change == 'microTask') {
  729. this._pendingMicroTasks = hasTaskState.microTask;
  730. this._finishCallbackIfDone();
  731. }
  732. else if (hasTaskState.change == 'macroTask') {
  733. this._pendingMacroTasks = hasTaskState.macroTask;
  734. this._finishCallbackIfDone();
  735. }
  736. };
  737. AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved');
  738. return AsyncTestZoneSpec;
  739. }());
  740. // Export the class so that new instances can be created with proper
  741. // constructor params.
  742. Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec;
  743. /**
  744. * @license
  745. * Copyright Google Inc. All Rights Reserved.
  746. *
  747. * Use of this source code is governed by an MIT-style license that can be
  748. * found in the LICENSE file at https://angular.io/license
  749. */
  750. Zone.__load_patch('asynctest', function (global, Zone, api) {
  751. /**
  752. * Wraps a test function in an asynchronous test zone. The test will automatically
  753. * complete when all asynchronous calls within this zone are done.
  754. */
  755. Zone[api.symbol('asyncTest')] = function asyncTest(fn) {
  756. // If we're running using the Jasmine test framework, adapt to call the 'done'
  757. // function when asynchronous activity is finished.
  758. if (global.jasmine) {
  759. // Not using an arrow function to preserve context passed from call site
  760. return function (done) {
  761. if (!done) {
  762. // if we run beforeEach in @angular/core/testing/testing_internal then we get no done
  763. // fake it here and assume sync.
  764. done = function () { };
  765. done.fail = function (e) {
  766. throw e;
  767. };
  768. }
  769. runInTestZone(fn, this, done, function (err) {
  770. if (typeof err === 'string') {
  771. return done.fail(new Error(err));
  772. }
  773. else {
  774. done.fail(err);
  775. }
  776. });
  777. };
  778. }
  779. // Otherwise, return a promise which will resolve when asynchronous activity
  780. // is finished. This will be correctly consumed by the Mocha framework with
  781. // it('...', async(myFn)); or can be used in a custom framework.
  782. // Not using an arrow function to preserve context passed from call site
  783. return function () {
  784. var _this = this;
  785. return new Promise(function (finishCallback, failCallback) {
  786. runInTestZone(fn, _this, finishCallback, failCallback);
  787. });
  788. };
  789. };
  790. function runInTestZone(fn, context, finishCallback, failCallback) {
  791. var currentZone = Zone.current;
  792. var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec'];
  793. if (AsyncTestZoneSpec === undefined) {
  794. throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' +
  795. 'Please make sure that your environment includes zone.js/dist/async-test.js');
  796. }
  797. var ProxyZoneSpec = Zone['ProxyZoneSpec'];
  798. if (ProxyZoneSpec === undefined) {
  799. throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' +
  800. 'Please make sure that your environment includes zone.js/dist/proxy.js');
  801. }
  802. var proxyZoneSpec = ProxyZoneSpec.get();
  803. ProxyZoneSpec.assertPresent();
  804. // We need to create the AsyncTestZoneSpec outside the ProxyZone.
  805. // If we do it in ProxyZone then we will get to infinite recursion.
  806. var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
  807. var previousDelegate = proxyZoneSpec.getDelegate();
  808. proxyZone.parent.run(function () {
  809. var testZoneSpec = new AsyncTestZoneSpec(function () {
  810. // Need to restore the original zone.
  811. if (proxyZoneSpec.getDelegate() == testZoneSpec) {
  812. // Only reset the zone spec if it's
  813. // sill this one. Otherwise, assume
  814. // it's OK.
  815. proxyZoneSpec.setDelegate(previousDelegate);
  816. }
  817. testZoneSpec.unPatchPromiseForTest();
  818. currentZone.run(function () {
  819. finishCallback();
  820. });
  821. }, function (error) {
  822. // Need to restore the original zone.
  823. if (proxyZoneSpec.getDelegate() == testZoneSpec) {
  824. // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK.
  825. proxyZoneSpec.setDelegate(previousDelegate);
  826. }
  827. testZoneSpec.unPatchPromiseForTest();
  828. currentZone.run(function () {
  829. failCallback(error);
  830. });
  831. }, 'test');
  832. proxyZoneSpec.setDelegate(testZoneSpec);
  833. testZoneSpec.patchPromiseForTest();
  834. });
  835. return Zone.current.runGuarded(fn, context);
  836. }
  837. });
  838. /**
  839. * @license
  840. * Copyright Google Inc. All Rights Reserved.
  841. *
  842. * Use of this source code is governed by an MIT-style license that can be
  843. * found in the LICENSE file at https://angular.io/license
  844. */
  845. var __read = (undefined && undefined.__read) || function (o, n) {
  846. var m = typeof Symbol === "function" && o[Symbol.iterator];
  847. if (!m) return o;
  848. var i = m.call(o), r, ar = [], e;
  849. try {
  850. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  851. }
  852. catch (error) { e = { error: error }; }
  853. finally {
  854. try {
  855. if (r && !r.done && (m = i["return"])) m.call(i);
  856. }
  857. finally { if (e) throw e.error; }
  858. }
  859. return ar;
  860. };
  861. var __spread = (undefined && undefined.__spread) || function () {
  862. for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
  863. return ar;
  864. };
  865. (function (global) {
  866. var OriginalDate = global.Date;
  867. var FakeDate = /** @class */ (function () {
  868. function FakeDate() {
  869. if (arguments.length === 0) {
  870. var d = new OriginalDate();
  871. d.setTime(FakeDate.now());
  872. return d;
  873. }
  874. else {
  875. var args = Array.prototype.slice.call(arguments);
  876. return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))();
  877. }
  878. }
  879. FakeDate.now = function () {
  880. var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
  881. if (fakeAsyncTestZoneSpec) {
  882. return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime();
  883. }
  884. return OriginalDate.now.apply(this, arguments);
  885. };
  886. return FakeDate;
  887. }());
  888. FakeDate.UTC = OriginalDate.UTC;
  889. FakeDate.parse = OriginalDate.parse;
  890. // keep a reference for zone patched timer function
  891. var timers = {
  892. setTimeout: global.setTimeout,
  893. setInterval: global.setInterval,
  894. clearTimeout: global.clearTimeout,
  895. clearInterval: global.clearInterval
  896. };
  897. var Scheduler = /** @class */ (function () {
  898. function Scheduler() {
  899. // Next scheduler id.
  900. this.nextId = 1;
  901. // Scheduler queue with the tuple of end time and callback function - sorted by end time.
  902. this._schedulerQueue = [];
  903. // Current simulated time in millis.
  904. this._currentTime = 0;
  905. // Current real time in millis.
  906. this._currentRealTime = OriginalDate.now();
  907. }
  908. Scheduler.prototype.getCurrentTime = function () {
  909. return this._currentTime;
  910. };
  911. Scheduler.prototype.getCurrentRealTime = function () {
  912. return this._currentRealTime;
  913. };
  914. Scheduler.prototype.setCurrentRealTime = function (realTime) {
  915. this._currentRealTime = realTime;
  916. };
  917. Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) {
  918. if (args === void 0) { args = []; }
  919. if (isPeriodic === void 0) { isPeriodic = false; }
  920. if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; }
  921. if (id === void 0) { id = -1; }
  922. var currentId = id < 0 ? this.nextId++ : id;
  923. var endTime = this._currentTime + delay;
  924. // Insert so that scheduler queue remains sorted by end time.
  925. var newEntry = {
  926. endTime: endTime,
  927. id: currentId,
  928. func: cb,
  929. args: args,
  930. delay: delay,
  931. isPeriodic: isPeriodic,
  932. isRequestAnimationFrame: isRequestAnimationFrame
  933. };
  934. var i = 0;
  935. for (; i < this._schedulerQueue.length; i++) {
  936. var currentEntry = this._schedulerQueue[i];
  937. if (newEntry.endTime < currentEntry.endTime) {
  938. break;
  939. }
  940. }
  941. this._schedulerQueue.splice(i, 0, newEntry);
  942. return currentId;
  943. };
  944. Scheduler.prototype.removeScheduledFunctionWithId = function (id) {
  945. for (var i = 0; i < this._schedulerQueue.length; i++) {
  946. if (this._schedulerQueue[i].id == id) {
  947. this._schedulerQueue.splice(i, 1);
  948. break;
  949. }
  950. }
  951. };
  952. Scheduler.prototype.tick = function (millis, doTick) {
  953. if (millis === void 0) { millis = 0; }
  954. var finalTime = this._currentTime + millis;
  955. var lastCurrentTime = 0;
  956. if (this._schedulerQueue.length === 0 && doTick) {
  957. doTick(millis);
  958. return;
  959. }
  960. while (this._schedulerQueue.length > 0) {
  961. var current = this._schedulerQueue[0];
  962. if (finalTime < current.endTime) {
  963. // Done processing the queue since it's sorted by endTime.
  964. break;
  965. }
  966. else {
  967. // Time to run scheduled function. Remove it from the head of queue.
  968. var current_1 = this._schedulerQueue.shift();
  969. lastCurrentTime = this._currentTime;
  970. this._currentTime = current_1.endTime;
  971. if (doTick) {
  972. doTick(this._currentTime - lastCurrentTime);
  973. }
  974. var retval = current_1.func.apply(global, current_1.args);
  975. if (!retval) {
  976. // Uncaught exception in the current scheduled function. Stop processing the queue.
  977. break;
  978. }
  979. }
  980. }
  981. this._currentTime = finalTime;
  982. };
  983. Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) {
  984. if (limit === void 0) { limit = 20; }
  985. if (flushPeriodic === void 0) { flushPeriodic = false; }
  986. if (flushPeriodic) {
  987. return this.flushPeriodic(doTick);
  988. }
  989. else {
  990. return this.flushNonPeriodic(limit, doTick);
  991. }
  992. };
  993. Scheduler.prototype.flushPeriodic = function (doTick) {
  994. if (this._schedulerQueue.length === 0) {
  995. return 0;
  996. }
  997. // Find the last task currently queued in the scheduler queue and tick
  998. // till that time.
  999. var startTime = this._currentTime;
  1000. var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1];
  1001. this.tick(lastTask.endTime - startTime, doTick);
  1002. return this._currentTime - startTime;
  1003. };
  1004. Scheduler.prototype.flushNonPeriodic = function (limit, doTick) {
  1005. var startTime = this._currentTime;
  1006. var lastCurrentTime = 0;
  1007. var count = 0;
  1008. while (this._schedulerQueue.length > 0) {
  1009. count++;
  1010. if (count > limit) {
  1011. throw new Error('flush failed after reaching the limit of ' + limit +
  1012. ' tasks. Does your code use a polling timeout?');
  1013. }
  1014. // flush only non-periodic timers.
  1015. // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing.
  1016. if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; })
  1017. .length === 0) {
  1018. break;
  1019. }
  1020. var current = this._schedulerQueue.shift();
  1021. lastCurrentTime = this._currentTime;
  1022. this._currentTime = current.endTime;
  1023. if (doTick) {
  1024. // Update any secondary schedulers like Jasmine mock Date.
  1025. doTick(this._currentTime - lastCurrentTime);
  1026. }
  1027. var retval = current.func.apply(global, current.args);
  1028. if (!retval) {
  1029. // Uncaught exception in the current scheduled function. Stop processing the queue.
  1030. break;
  1031. }
  1032. }
  1033. return this._currentTime - startTime;
  1034. };
  1035. return Scheduler;
  1036. }());
  1037. var FakeAsyncTestZoneSpec = /** @class */ (function () {
  1038. function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) {
  1039. if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; }
  1040. this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame;
  1041. this.macroTaskOptions = macroTaskOptions;
  1042. this._scheduler = new Scheduler();
  1043. this._microtasks = [];
  1044. this._lastError = null;
  1045. this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')];
  1046. this.pendingPeriodicTimers = [];
  1047. this.pendingTimers = [];
  1048. this.patchDateLocked = false;
  1049. this.properties = { 'FakeAsyncTestZoneSpec': this };
  1050. this.name = 'fakeAsyncTestZone for ' + namePrefix;
  1051. // in case user can't access the construction of FakeAsyncTestSpec
  1052. // user can also define macroTaskOptions by define a global variable.
  1053. if (!this.macroTaskOptions) {
  1054. this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')];
  1055. }
  1056. }
  1057. FakeAsyncTestZoneSpec.assertInZone = function () {
  1058. if (Zone.current.get('FakeAsyncTestZoneSpec') == null) {
  1059. throw new Error('The code should be running in the fakeAsync zone to call this function');
  1060. }
  1061. };
  1062. FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) {
  1063. var _this = this;
  1064. return function () {
  1065. var args = [];
  1066. for (var _i = 0; _i < arguments.length; _i++) {
  1067. args[_i] = arguments[_i];
  1068. }
  1069. fn.apply(global, args);
  1070. if (_this._lastError === null) {
  1071. if (completers.onSuccess != null) {
  1072. completers.onSuccess.apply(global);
  1073. }
  1074. // Flush microtasks only on success.
  1075. _this.flushMicrotasks();
  1076. }
  1077. else {
  1078. if (completers.onError != null) {
  1079. completers.onError.apply(global);
  1080. }
  1081. }
  1082. // Return true if there were no errors, false otherwise.
  1083. return _this._lastError === null;
  1084. };
  1085. };
  1086. FakeAsyncTestZoneSpec._removeTimer = function (timers, id) {
  1087. var index = timers.indexOf(id);
  1088. if (index > -1) {
  1089. timers.splice(index, 1);
  1090. }
  1091. };
  1092. FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) {
  1093. var _this = this;
  1094. return function () {
  1095. FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id);
  1096. };
  1097. };
  1098. FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) {
  1099. var _this = this;
  1100. return function () {
  1101. // Requeue the timer callback if it's not been canceled.
  1102. if (_this.pendingPeriodicTimers.indexOf(id) !== -1) {
  1103. _this._scheduler.scheduleFunction(fn, interval, args, true, false, id);
  1104. }
  1105. };
  1106. };
  1107. FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) {
  1108. var _this = this;
  1109. return function () {
  1110. FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id);
  1111. };
  1112. };
  1113. FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) {
  1114. if (isTimer === void 0) { isTimer = true; }
  1115. var removeTimerFn = this._dequeueTimer(this._scheduler.nextId);
  1116. // Queue the callback and dequeue the timer on success and error.
  1117. var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn });
  1118. var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer);
  1119. if (isTimer) {
  1120. this.pendingTimers.push(id);
  1121. }
  1122. return id;
  1123. };
  1124. FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) {
  1125. FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id);
  1126. this._scheduler.removeScheduledFunctionWithId(id);
  1127. };
  1128. FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) {
  1129. var id = this._scheduler.nextId;
  1130. var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) };
  1131. var cb = this._fnAndFlush(fn, completers);
  1132. // Use the callback created above to requeue on success.
  1133. completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id);
  1134. // Queue the callback and dequeue the periodic timer only on error.
  1135. this._scheduler.scheduleFunction(cb, interval, args, true);
  1136. this.pendingPeriodicTimers.push(id);
  1137. return id;
  1138. };
  1139. FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) {
  1140. FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id);
  1141. this._scheduler.removeScheduledFunctionWithId(id);
  1142. };
  1143. FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () {
  1144. var error = this._lastError || this._uncaughtPromiseErrors[0];
  1145. this._uncaughtPromiseErrors.length = 0;
  1146. this._lastError = null;
  1147. throw error;
  1148. };
  1149. FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () {
  1150. return this._scheduler.getCurrentTime();
  1151. };
  1152. FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () {
  1153. return this._scheduler.getCurrentRealTime();
  1154. };
  1155. FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) {
  1156. this._scheduler.setCurrentRealTime(realTime);
  1157. };
  1158. FakeAsyncTestZoneSpec.patchDate = function () {
  1159. if (global['Date'] === FakeDate) {
  1160. // already patched
  1161. return;
  1162. }
  1163. global['Date'] = FakeDate;
  1164. FakeDate.prototype = OriginalDate.prototype;
  1165. // try check and reset timers
  1166. // because jasmine.clock().install() may
  1167. // have replaced the global timer
  1168. FakeAsyncTestZoneSpec.checkTimerPatch();
  1169. };
  1170. FakeAsyncTestZoneSpec.resetDate = function () {
  1171. if (global['Date'] === FakeDate) {
  1172. global['Date'] = OriginalDate;
  1173. }
  1174. };
  1175. FakeAsyncTestZoneSpec.checkTimerPatch = function () {
  1176. if (global.setTimeout !== timers.setTimeout) {
  1177. global.setTimeout = timers.setTimeout;
  1178. global.clearTimeout = timers.clearTimeout;
  1179. }
  1180. if (global.setInterval !== timers.setInterval) {
  1181. global.setInterval = timers.setInterval;
  1182. global.clearInterval = timers.clearInterval;
  1183. }
  1184. };
  1185. FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () {
  1186. this.patchDateLocked = true;
  1187. FakeAsyncTestZoneSpec.patchDate();
  1188. };
  1189. FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () {
  1190. this.patchDateLocked = false;
  1191. FakeAsyncTestZoneSpec.resetDate();
  1192. };
  1193. FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) {
  1194. if (millis === void 0) { millis = 0; }
  1195. FakeAsyncTestZoneSpec.assertInZone();
  1196. this.flushMicrotasks();
  1197. this._scheduler.tick(millis, doTick);
  1198. if (this._lastError !== null) {
  1199. this._resetLastErrorAndThrow();
  1200. }
  1201. };
  1202. FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () {
  1203. var _this = this;
  1204. FakeAsyncTestZoneSpec.assertInZone();
  1205. var flushErrors = function () {
  1206. if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) {
  1207. // If there is an error stop processing the microtask queue and rethrow the error.
  1208. _this._resetLastErrorAndThrow();
  1209. }
  1210. };
  1211. while (this._microtasks.length > 0) {
  1212. var microtask = this._microtasks.shift();
  1213. microtask.func.apply(microtask.target, microtask.args);
  1214. }
  1215. flushErrors();
  1216. };
  1217. FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) {
  1218. FakeAsyncTestZoneSpec.assertInZone();
  1219. this.flushMicrotasks();
  1220. var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick);
  1221. if (this._lastError !== null) {
  1222. this._resetLastErrorAndThrow();
  1223. }
  1224. return elapsed;
  1225. };
  1226. FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) {
  1227. switch (task.type) {
  1228. case 'microTask':
  1229. var args = task.data && task.data.args;
  1230. // should pass additional arguments to callback if have any
  1231. // currently we know process.nextTick will have such additional
  1232. // arguments
  1233. var additionalArgs = void 0;
  1234. if (args) {
  1235. var callbackIndex = task.data.cbIdx;
  1236. if (typeof args.length === 'number' && args.length > callbackIndex + 1) {
  1237. additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1);
  1238. }
  1239. }
  1240. this._microtasks.push({
  1241. func: task.invoke,
  1242. args: additionalArgs,
  1243. target: task.data && task.data.target
  1244. });
  1245. break;
  1246. case 'macroTask':
  1247. switch (task.source) {
  1248. case 'setTimeout':
  1249. task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2));
  1250. break;
  1251. case 'setImmediate':
  1252. task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1));
  1253. break;
  1254. case 'setInterval':
  1255. task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2));
  1256. break;
  1257. case 'XMLHttpRequest.send':
  1258. throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' +
  1259. task.data['url']);
  1260. case 'requestAnimationFrame':
  1261. case 'webkitRequestAnimationFrame':
  1262. case 'mozRequestAnimationFrame':
  1263. // Simulate a requestAnimationFrame by using a setTimeout with 16 ms.
  1264. // (60 frames per second)
  1265. task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame);
  1266. break;
  1267. default:
  1268. // user can define which macroTask they want to support by passing
  1269. // macroTaskOptions
  1270. var macroTaskOption = this.findMacroTaskOption(task);
  1271. if (macroTaskOption) {
  1272. var args_1 = task.data && task.data['args'];
  1273. var delay = args_1 && args_1.length > 1 ? args_1[1] : 0;
  1274. var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1;
  1275. if (!!macroTaskOption.isPeriodic) {
  1276. // periodic macroTask, use setInterval to simulate
  1277. task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs);
  1278. task.data.isPeriodic = true;
  1279. }
  1280. else {
  1281. // not periodic, use setTimeout to simulate
  1282. task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs);
  1283. }
  1284. break;
  1285. }
  1286. throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source);
  1287. }
  1288. break;
  1289. case 'eventTask':
  1290. task = delegate.scheduleTask(target, task);
  1291. break;
  1292. }
  1293. return task;
  1294. };
  1295. FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) {
  1296. switch (task.source) {
  1297. case 'setTimeout':
  1298. case 'requestAnimationFrame':
  1299. case 'webkitRequestAnimationFrame':
  1300. case 'mozRequestAnimationFrame':
  1301. return this._clearTimeout(task.data['handleId']);
  1302. case 'setInterval':
  1303. return this._clearInterval(task.data['handleId']);
  1304. default:
  1305. // user can define which macroTask they want to support by passing
  1306. // macroTaskOptions
  1307. var macroTaskOption = this.findMacroTaskOption(task);
  1308. if (macroTaskOption) {
  1309. var handleId = task.data['handleId'];
  1310. return macroTaskOption.isPeriodic ? this._clearInterval(handleId) :
  1311. this._clearTimeout(handleId);
  1312. }
  1313. return delegate.cancelTask(target, task);
  1314. }
  1315. };
  1316. FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) {
  1317. try {
  1318. FakeAsyncTestZoneSpec.patchDate();
  1319. return delegate.invoke(target, callback, applyThis, applyArgs, source);
  1320. }
  1321. finally {
  1322. if (!this.patchDateLocked) {
  1323. FakeAsyncTestZoneSpec.resetDate();
  1324. }
  1325. }
  1326. };
  1327. FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) {
  1328. if (!this.macroTaskOptions) {
  1329. return null;
  1330. }
  1331. for (var i = 0; i < this.macroTaskOptions.length; i++) {
  1332. var macroTaskOption = this.macroTaskOptions[i];
  1333. if (macroTaskOption.source === task.source) {
  1334. return macroTaskOption;
  1335. }
  1336. }
  1337. return null;
  1338. };
  1339. FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
  1340. this._lastError = error;
  1341. return false; // Don't propagate error to parent zone.
  1342. };
  1343. return FakeAsyncTestZoneSpec;
  1344. }());
  1345. // Export the class so that new instances can be created with proper
  1346. // constructor params.
  1347. Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec;
  1348. })(typeof window === 'object' && window || typeof self === 'object' && self || global);
  1349. /**
  1350. * @license
  1351. * Copyright Google Inc. All Rights Reserved.
  1352. *
  1353. * Use of this source code is governed by an MIT-style license that can be
  1354. * found in the LICENSE file at https://angular.io/license
  1355. */
  1356. Zone.__load_patch('fakeasync', function (global, Zone, api) {
  1357. var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec'];
  1358. var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec'];
  1359. var _fakeAsyncTestZoneSpec = null;
  1360. /**
  1361. * Clears out the shared fake async zone for a test.
  1362. * To be called in a global `beforeEach`.
  1363. *
  1364. * @experimental
  1365. */
  1366. function resetFakeAsyncZone() {
  1367. if (_fakeAsyncTestZoneSpec) {
  1368. _fakeAsyncTestZoneSpec.unlockDatePatch();
  1369. }
  1370. _fakeAsyncTestZoneSpec = null;
  1371. // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset.
  1372. ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate();
  1373. }
  1374. /**
  1375. * Wraps a function to be executed in the fakeAsync zone:
  1376. * - microtasks are manually executed by calling `flushMicrotasks()`,
  1377. * - timers are synchronous, `tick()` simulates the asynchronous passage of time.
  1378. *
  1379. * If there are any pending timers at the end of the function, an exception will be thrown.
  1380. *
  1381. * Can be used to wrap inject() calls.
  1382. *
  1383. * ## Example
  1384. *
  1385. * {@example core/testing/ts/fake_async.ts region='basic'}
  1386. *
  1387. * @param fn
  1388. * @returns The function wrapped to be executed in the fakeAsync zone
  1389. *
  1390. * @experimental
  1391. */
  1392. function fakeAsync(fn) {
  1393. // Not using an arrow function to preserve context passed from call site
  1394. return function () {
  1395. var args = [];
  1396. for (var _i = 0; _i < arguments.length; _i++) {
  1397. args[_i] = arguments[_i];
  1398. }
  1399. var proxyZoneSpec = ProxyZoneSpec.assertPresent();
  1400. if (Zone.current.get('FakeAsyncTestZoneSpec')) {
  1401. throw new Error('fakeAsync() calls can not be nested');
  1402. }
  1403. try {
  1404. // in case jasmine.clock init a fakeAsyncTestZoneSpec
  1405. if (!_fakeAsyncTestZoneSpec) {
  1406. if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) {
  1407. throw new Error('fakeAsync() calls can not be nested');
  1408. }
  1409. _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec();
  1410. }
  1411. var res = void 0;
  1412. var lastProxyZoneSpec = proxyZoneSpec.getDelegate();
  1413. proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec);
  1414. _fakeAsyncTestZoneSpec.lockDatePatch();
  1415. try {
  1416. res = fn.apply(this, args);
  1417. flushMicrotasks();
  1418. }
  1419. finally {
  1420. proxyZoneSpec.setDelegate(lastProxyZoneSpec);
  1421. }
  1422. if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) {
  1423. throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " +
  1424. "periodic timer(s) still in the queue.");
  1425. }
  1426. if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) {
  1427. throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue.");
  1428. }
  1429. return res;
  1430. }
  1431. finally {
  1432. resetFakeAsyncZone();
  1433. }
  1434. };
  1435. }
  1436. function _getFakeAsyncZoneSpec() {
  1437. if (_fakeAsyncTestZoneSpec == null) {
  1438. _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
  1439. if (_fakeAsyncTestZoneSpec == null) {
  1440. throw new Error('The code should be running in the fakeAsync zone to call this function');
  1441. }
  1442. }
  1443. return _fakeAsyncTestZoneSpec;
  1444. }
  1445. /**
  1446. * Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
  1447. *
  1448. * The microtasks queue is drained at the very start of this function and after any timer callback
  1449. * has been executed.
  1450. *
  1451. * ## Example
  1452. *
  1453. * {@example core/testing/ts/fake_async.ts region='basic'}
  1454. *
  1455. * @experimental
  1456. */
  1457. function tick(millis) {
  1458. if (millis === void 0) { millis = 0; }
  1459. _getFakeAsyncZoneSpec().tick(millis);
  1460. }
  1461. /**
  1462. * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
  1463. * draining the macrotask queue until it is empty. The returned value is the milliseconds
  1464. * of time that would have been elapsed.
  1465. *
  1466. * @param maxTurns
  1467. * @returns The simulated time elapsed, in millis.
  1468. *
  1469. * @experimental
  1470. */
  1471. function flush(maxTurns) {
  1472. return _getFakeAsyncZoneSpec().flush(maxTurns);
  1473. }
  1474. /**
  1475. * Discard all remaining periodic tasks.
  1476. *
  1477. * @experimental
  1478. */
  1479. function discardPeriodicTasks() {
  1480. var zoneSpec = _getFakeAsyncZoneSpec();
  1481. var pendingTimers = zoneSpec.pendingPeriodicTimers;
  1482. zoneSpec.pendingPeriodicTimers.length = 0;
  1483. }
  1484. /**
  1485. * Flush any pending microtasks.
  1486. *
  1487. * @experimental
  1488. */
  1489. function flushMicrotasks() {
  1490. _getFakeAsyncZoneSpec().flushMicrotasks();
  1491. }
  1492. Zone[api.symbol('fakeAsyncTest')] =
  1493. { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync };
  1494. });
  1495. /**
  1496. * @license
  1497. * Copyright Google Inc. All Rights Reserved.
  1498. *
  1499. * Use of this source code is governed by an MIT-style license that can be
  1500. * found in the LICENSE file at https://angular.io/license
  1501. */
  1502. /**
  1503. * Promise for async/fakeAsync zoneSpec test
  1504. * can support async operation which not supported by zone.js
  1505. * such as
  1506. * it ('test jsonp in AsyncZone', async() => {
  1507. * new Promise(res => {
  1508. * jsonp(url, (data) => {
  1509. * // success callback
  1510. * res(data);
  1511. * });
  1512. * }).then((jsonpResult) => {
  1513. * // get jsonp result.
  1514. *
  1515. * // user will expect AsyncZoneSpec wait for
  1516. * // then, but because jsonp is not zone aware
  1517. * // AsyncZone will finish before then is called.
  1518. * });
  1519. * });
  1520. */
  1521. Zone.__load_patch('promisefortest', function (global, Zone, api) {
  1522. var symbolState = api.symbol('state');
  1523. var UNRESOLVED = null;
  1524. var symbolParentUnresolved = api.symbol('parentUnresolved');
  1525. // patch Promise.prototype.then to keep an internal
  1526. // number for tracking unresolved chained promise
  1527. // we will decrease this number when the parent promise
  1528. // being resolved/rejected and chained promise was
  1529. // scheduled as a microTask.
  1530. // so we can know such kind of chained promise still
  1531. // not resolved in AsyncTestZone
  1532. Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() {
  1533. var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')];
  1534. if (oriThen) {
  1535. return;
  1536. }
  1537. oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then;
  1538. Promise.prototype.then = function () {
  1539. var chained = oriThen.apply(this, arguments);
  1540. if (this[symbolState] === UNRESOLVED) {
  1541. // parent promise is unresolved.
  1542. var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec');
  1543. if (asyncTestZoneSpec) {
  1544. asyncTestZoneSpec.unresolvedChainedPromiseCount++;
  1545. chained[symbolParentUnresolved] = true;
  1546. }
  1547. }
  1548. return chained;
  1549. };
  1550. };
  1551. Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() {
  1552. // restore origin then
  1553. var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')];
  1554. if (oriThen) {
  1555. Promise.prototype.then = oriThen;
  1556. Promise[Zone.__symbol__('ZonePromiseThen')] = undefined;
  1557. }
  1558. };
  1559. });
  1560. /**
  1561. * @license
  1562. * Copyright Google Inc. All Rights Reserved.
  1563. *
  1564. * Use of this source code is governed by an MIT-style license that can be
  1565. * found in the LICENSE file at https://angular.io/license
  1566. */
  1567. // load test related files into bundle in correct order
  1568. })));