1
+ /******/ ( function ( modules ) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = { } ;
4
+
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__ ( moduleId ) {
7
+
8
+ /******/ // Check if module is in cache
9
+ /******/ if ( installedModules [ moduleId ] )
10
+ /******/ return installedModules [ moduleId ] . exports ;
11
+
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules [ moduleId ] = {
14
+ /******/ exports : { } ,
15
+ /******/ id : moduleId ,
16
+ /******/ loaded : false
17
+ /******/ } ;
18
+
19
+ /******/ // Execute the module function
20
+ /******/ modules [ moduleId ] . call ( module . exports , module , module . exports , __webpack_require__ ) ;
21
+
22
+ /******/ // Flag the module as loaded
23
+ /******/ module . loaded = true ;
24
+
25
+ /******/ // Return the exports of the module
26
+ /******/ return module . exports ;
27
+ /******/ }
28
+
29
+
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__ . m = modules ;
32
+
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__ . c = installedModules ;
35
+
36
+ /******/ // __webpack_public_path__
37
+ /******/ __webpack_require__ . p = "" ;
38
+
39
+ /******/ // Load entry module and return exports
40
+ /******/ return __webpack_require__ ( 0 ) ;
41
+ /******/ } )
42
+ /************************************************************************/
43
+ /******/ ( [
44
+ /* 0 */
45
+ /***/ function ( module , exports ) {
46
+
47
+ ( function ( ) {
48
+ var AsyncTestZoneSpec = ( function ( ) {
49
+ function AsyncTestZoneSpec ( finishCallback , failCallback , namePrefix ) {
50
+ this . _pendingMicroTasks = false ;
51
+ this . _pendingMacroTasks = false ;
52
+ this . _pendingEventTasks = false ;
53
+ this . _alreadyErrored = false ;
54
+ this . runZone = Zone . current ;
55
+ // ZoneSpec implementation below.
56
+ this . name = 'asyncTestZone' ;
57
+ this . _finishCallback = finishCallback ;
58
+ this . _failCallback = failCallback ;
59
+ this . name = 'asyncTestZone for ' + namePrefix ;
60
+ }
61
+ AsyncTestZoneSpec . prototype . _finishCallbackIfDone = function ( ) {
62
+ var _this = this ;
63
+ if ( ! ( this . _pendingMicroTasks || this . _pendingMacroTasks || this . _pendingEventTasks ) ) {
64
+ // We do this because we would like to catch unhandled rejected promises.
65
+ // To do this quickly when there are native promises, we must run using an unwrapped
66
+ // promise implementation.
67
+ var symbol = Zone . __symbol__ ;
68
+ var NativePromise = window [ symbol ( 'Promise' ) ] ;
69
+ if ( NativePromise ) {
70
+ NativePromise . resolve ( true ) [ symbol ( 'then' ) ] ( function ( ) {
71
+ if ( ! _this . _alreadyErrored ) {
72
+ _this . runZone . run ( _this . _finishCallback ) ;
73
+ }
74
+ } ) ;
75
+ }
76
+ else {
77
+ // For implementations which do not have nativePromise, use setTimeout(0). This is slower,
78
+ // but it also works because Zones will handle errors when rejected promises have no
79
+ // listeners after one macrotask.
80
+ this . runZone . run ( function ( ) {
81
+ setTimeout ( function ( ) {
82
+ if ( ! _this . _alreadyErrored ) {
83
+ _this . _finishCallback ( ) ;
84
+ }
85
+ } , 0 ) ;
86
+ } ) ;
87
+ }
88
+ }
89
+ } ;
90
+ AsyncTestZoneSpec . prototype . onInvoke = function ( parentZoneDelegate , currentZone , targetZone , delegate , applyThis , applyArgs , source ) {
91
+ try {
92
+ return parentZoneDelegate . invoke ( targetZone , delegate , applyThis , applyArgs , source ) ;
93
+ }
94
+ finally {
95
+ this . _finishCallbackIfDone ( ) ;
96
+ }
97
+ } ;
98
+ AsyncTestZoneSpec . prototype . onHandleError = function ( parentZoneDelegate , currentZone , targetZone , error ) {
99
+ // Let the parent try to handle the error.
100
+ var result = parentZoneDelegate . handleError ( targetZone , error ) ;
101
+ if ( result ) {
102
+ this . _failCallback ( error . message ? error . message : 'unknown error' ) ;
103
+ this . _alreadyErrored = true ;
104
+ }
105
+ return false ;
106
+ } ;
107
+ AsyncTestZoneSpec . prototype . onScheduleTask = function ( delegate , currentZone , targetZone , task ) {
108
+ if ( task . type == 'macroTask' && task . source == 'setInterval' ) {
109
+ this . _failCallback ( 'Cannot use setInterval from within an async zone test.' ) ;
110
+ return ;
111
+ }
112
+ return delegate . scheduleTask ( targetZone , task ) ;
113
+ } ;
114
+ AsyncTestZoneSpec . prototype . onHasTask = function ( delegate , current , target , hasTaskState ) {
115
+ delegate . hasTask ( target , hasTaskState ) ;
116
+ if ( hasTaskState . change == 'microTask' ) {
117
+ this . _pendingMicroTasks = hasTaskState . microTask ;
118
+ this . _finishCallbackIfDone ( ) ;
119
+ }
120
+ else if ( hasTaskState . change == 'macroTask' ) {
121
+ this . _pendingMacroTasks = hasTaskState . macroTask ;
122
+ this . _finishCallbackIfDone ( ) ;
123
+ }
124
+ else if ( hasTaskState . change == 'eventTask' ) {
125
+ this . _finishCallbackIfDone ( ) ;
126
+ }
127
+ } ;
128
+ return AsyncTestZoneSpec ;
129
+ } ( ) ) ;
130
+ // Export the class so that new instances can be created with proper
131
+ // constructor params.
132
+ Zone [ 'AsyncTestZoneSpec' ] = AsyncTestZoneSpec ;
133
+ } ) ( ) ;
134
+
135
+
136
+ /***/ }
137
+ /******/ ] ) ;
0 commit comments