| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09: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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// <reference types="node"/>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 'use strict'; | 
					
						
							|  |  |  | (function(global: any) { | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | // add custom properties to Native Error
 | 
					
						
							|  |  |  | const NativeError = global['Error']; | 
					
						
							|  |  |  | NativeError.customProperty = 'customProperty'; | 
					
						
							|  |  |  | NativeError.customFunction = function() {}; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | // add fake cordova polyfill for test
 | 
					
						
							|  |  |  | const fakeCordova = function() {}; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | (fakeCordova as any).exec = function( | 
					
						
							|  |  |  |     success: Function, error: Function, service: string, action: string, args: any[]) { | 
					
						
							|  |  |  |   if (action === 'successAction') { | 
					
						
							|  |  |  |     success(); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     error(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | global.cordova = fakeCordova; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | const TestTarget = global.TestTarget = function() {}; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | Object.defineProperties(TestTarget.prototype, { | 
					
						
							|  |  |  |   'onprop1': {configurable: true, writable: true}, | 
					
						
							|  |  |  |   'onprop2': {configurable: true, writable: true}, | 
					
						
							|  |  |  |   'onprop3': { | 
					
						
							|  |  |  |     configurable: true, | 
					
						
							|  |  |  |     get: function() { | 
					
						
							|  |  |  |       return this._onprop3; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |     set: function(_value) { | 
					
						
							|  |  |  |       this._onprop3 = _value; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   '_onprop3': {configurable: true, writable: true, value: function() {}}, | 
					
						
							|  |  |  |   'addEventListener': { | 
					
						
							|  |  |  |     configurable: true, | 
					
						
							|  |  |  |     writable: true, | 
					
						
							|  |  |  |     value: function(eventName: string, callback: Function) { | 
					
						
							|  |  |  |       if (!this.events) { | 
					
						
							|  |  |  |         this.events = {}; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |       const Zone = global.Zone; | 
					
						
							|  |  |  |       this.events.eventName = {zone: Zone.current, callback: callback}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   'removeEventListener': { | 
					
						
							|  |  |  |     configurable: true, | 
					
						
							|  |  |  |     writable: true, | 
					
						
							|  |  |  |     value: function(eventName: string, callback: Function) { | 
					
						
							|  |  |  |       if (!this.events) { | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |       this.events.eventName = null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   'dispatchEvent': { | 
					
						
							|  |  |  |     configurable: true, | 
					
						
							|  |  |  |     writable: true, | 
					
						
							|  |  |  |     value: function(eventName: string) { | 
					
						
							|  |  |  |       const zoneCallback = this.events && this.events.eventName; | 
					
						
							|  |  |  |       zoneCallback && zoneCallback.zone.run(zoneCallback.callback, this, [{type: eventName}]); | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | // Zone symbol prefix may be set in *-env-setup.ts (browser & node),
 | 
					
						
							|  |  |  | // but this file is used in multiple scenarios, and Zone isn't loaded at this point yet.
 | 
					
						
							|  |  |  | const zoneSymbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  | global['__Zone_ignore_on_properties'] = | 
					
						
							|  |  |  |     [{target: TestTarget.prototype, ignoreProperties: ['prop1']}]; | 
					
						
							|  |  |  | global[zoneSymbolPrefix + 'FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; | 
					
						
							|  |  |  | // will not monkey patch scroll and wheel event.
 | 
					
						
							|  |  |  | global[zoneSymbolPrefix + 'UNPATCHED_EVENTS'] = ['scroll', 'wheel']; | 
					
						
							|  |  |  | // touchstart and scroll will be passive by default.
 | 
					
						
							|  |  |  | global[zoneSymbolPrefix + 'PASSIVE_EVENTS'] = ['touchstart', 'scroll']; | 
					
						
							| 
									
										
										
										
											2019-06-01 00:56:07 +09:00
										 |  |  | })(typeof window === 'object' && window || typeof self === 'object' && self || global); |