(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState)
| 197 | } |
| 198 | |
| 199 | onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) { |
| 200 | delegate.hasTask(target, hasTaskState); |
| 201 | // We should only trigger finishCallback when the target zone is the AsyncTestZone |
| 202 | // Consider the following cases. |
| 203 | // |
| 204 | // const childZone = asyncTestZone.fork({ |
| 205 | // name: 'child', |
| 206 | // onHasTask: ... |
| 207 | // }); |
| 208 | // |
| 209 | // So we have nested zones declared the onHasTask hook, in this case, |
| 210 | // the onHasTask will be triggered twice, and cause the finishCallbackIfDone() |
| 211 | // is also be invoked twice. So we need to only trigger the finishCallbackIfDone() |
| 212 | // when the current zone is the same as the target zone. |
| 213 | if (current !== target) { |
| 214 | return; |
| 215 | } |
| 216 | if (hasTaskState.change == 'microTask') { |
| 217 | this._pendingMicroTasks = hasTaskState.microTask; |
| 218 | this._finishCallbackIfDone(); |
| 219 | } else if (hasTaskState.change == 'macroTask') { |
| 220 | this._pendingMacroTasks = hasTaskState.macroTask; |
| 221 | this._finishCallbackIfDone(); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | export function patchAsyncTest(Zone: ZoneType): void { |
nothing calls this directly
no test coverage detected