angular-cn/packages/zone.js/test
JiaLiPassion 0652b29f62 fix(zone.js): setTimeout patch should clean tasksByHandleId cache. (#40586)
Close #40387

Currently zone.js patches `setTimeout` and keeps a `tasksByHandleId` map to keep `timerId` <-> `ZoneTask`
relationship. This is needed so that when `clearTimeout(timerId)` is called, zone.js can find the associated
`ZoneTask`. Now zone.js set the `tasksByHandleId` map in the `scheduleTask` function, but if the `setTimeout`
is running in the `FakeAsyncZoneSpec` or any other `ZoneSpec` with `onScheduleTask` hooks. The `scheduleTask`
in `timer` patch may not be invoked.

For example:

```
fakeAsync(() => {
  setTimeout(() => {});
  tick();
});
```

In this case, the `timerId` kept in the `tasksByHandleId` map is not cleared.
This is because the `FakeAsyncZoneSpec` in the `onScheduleTask` hook looks like this.

```
onScheduleTask(delegate, ..., task) {
  fakeAsyncScheduler.setTimeout(task);
  return task;
}
```

Because `FakeAsyncZoneSpec` handles the task itself and it doesn't call `parentDelegate.onScheduleTask`,
therefore the default `scheduleTask` in the `timer` patch is not invoked.

In this commit, the cleanup logic is moved from `scheduleTask` to `setTimeout` patch entry to
avoid the memory leak.

PR Close #40586
2021-02-09 10:43:05 -08:00
..
assets build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser feat(zone.js): monkey patches queueMicrotask() (#38904) 2020-11-05 11:23:33 -08:00
closure test(zone.js): add zone.js externs test (#39108) 2020-10-22 13:40:08 -07:00
common fix(zone.js): patch child method that overrides an already patched method (#39850) 2020-12-02 12:52:27 -08:00
extra feat(zone.js): upgrade zone.js to angular package format(APF) (#36540) 2020-06-11 11:08:48 -07:00
jest refactor(zone.js): rename several internal apis in fake async zone spec (#39127) 2020-10-13 15:56:22 -07:00
node fix(zone.js): patch nodejs EventEmtter.prototype.off (#37863) 2020-07-24 15:45:00 -07:00
npm_package fix(zone.js): fesm2015 bundle should also be strict module. (#40456) 2021-01-19 09:16:41 -08:00
patch build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
performance build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
promise build: reformat repo to new clang@1.4.0 (#36613) 2020-04-14 12:08:36 -07:00
rxjs fix(zone.js): zone patch rxjs should return null _unsubscribe correctly. (#37091) 2020-07-27 12:10:27 -07:00
typings build: support building with TypeScript 4.1 (#39571) 2020-11-25 11:10:01 -08:00
webdriver test(zone.js): do not run tests on IE 9 and IE 10 (#39189) 2020-10-12 08:27:25 -07:00
zone-spec fix(zone.js): setTimeout patch should clean tasksByHandleId cache. (#40586) 2021-02-09 10:43:05 -08:00
BUILD.bazel feat(zone.js): upgrade zone.js to angular package format(APF) (#36540) 2020-06-11 11:08:48 -07:00
browser-env-setup.ts build: move zone.js to angular repo (#30962) 2019-06-20 11:27:39 -07:00
browser-zone-setup.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_disable_wrap_uncaught_promise_rejection_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_disable_wrap_uncaught_promise_rejection_setup.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_entry_point.ts feat(zone.js): monkey patches queueMicrotask() (#38904) 2020-11-05 11:23:33 -08:00
browser_es2015_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_shadydom_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_shadydom_setup.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
browser_symbol_setup.ts build: move zone.js to angular repo (#30962) 2019-06-20 11:27:39 -07:00
common_tests.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
fake_entry.js build: move zone.js to angular repo (#30962) 2019-06-20 11:27:39 -07:00
jasmine-patch.spec.ts build: support building with TypeScript 4.1 (#39571) 2020-11-25 11:10:01 -08:00
karma_test.bzl refactor(zone.js): refactor zone rollup config (#40481) 2021-01-25 10:43:39 -08:00
main.ts refactor(zone.js): rename BlacklistedStackFrames to InternalZoneJsStackFrames (#38978) 2020-09-28 16:23:41 -04:00
mocha-patch.spec.ts build: support building with TypeScript 4.1 (#39571) 2020-11-25 11:10:01 -08:00
node-env-setup.ts build: move zone.js to angular repo (#30962) 2019-06-20 11:27:39 -07:00
node_bluebird_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node_entry_point_no_patch_clock.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node_error_disable_policy_entry_point.ts refactor(zone.js): rename BlacklistedStackFrames to InternalZoneJsStackFrames (#38978) 2020-09-28 16:23:41 -04:00
node_error_entry_point.ts refactor(zone.js): rename BlacklistedStackFrames to InternalZoneJsStackFrames (#38978) 2020-09-28 16:23:41 -04:00
node_error_lazy_policy_entry_point.ts refactor(zone.js): rename BlacklistedStackFrames to InternalZoneJsStackFrames (#38978) 2020-09-28 16:23:41 -04:00
node_tests.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
saucelabs.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-env-setup-jasmine-no-patch-clock.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-env-setup-jasmine.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-env-setup-mocha.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-util.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test_fake_polyfill.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ws-client.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ws-server.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ws-webworker-context.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
wtf_mock.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
zone_worker_entry_point.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00