angular-cn/packages/platform-browser/test
JiaLiPassion 284123c6ba fix(core): should fake a top event task when coalescing events to prevent draining microTaskQueue too early. (#36841)
Close #36839.

This is a known issue of zone.js,

```
(window as any)[(Zone as any).__symbol__('setTimeout')](() => {
  let log = '';
  button.addEventListener('click', () => {
    Zone.current.scheduleMicroTask('test', () => log += 'microtask;');
    log += 'click;';
  });
  button.click();
  expect(log).toEqual('click;microtask;');
  done();
});
```

Since in this case, we use native `setTimeout` which is not a ZoneTask,
so zone.js consider the button click handler as the top Task then drain the
microTaskQueue after the click at once, which is not correct(too early).

This case was an edge case and not reported by the users, until we have the
new option ngZoneEventCoalescing, since the event coalescing will happen
in native requestAnimationFrame, so it will not be a ZoneTask, and zone.js will
consider any Task happen in the change detection stage as the top task, and if
there are any microTasks(such as Promise.then) happen in the process, it may be
drained earlier than it should be, so to prevent this situation, we need to schedule
a fake event task and run the change detection check in this fake event task,
so the Task happen in the change detection stage will not be
considered as top ZoneTask.

PR Close #36841
2020-06-11 18:54:22 -07:00
..
browser build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
dom fix(core): should fake a top event task when coalescing events to prevent draining microTaskQueue too early. (#36841) 2020-06-11 18:54:22 -07:00
security build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
static_assets refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
BUILD.bazel build: enable platform-browser tests on Saucelabs (#36797) 2020-04-28 15:10:27 -07:00
browser_util_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
testing_public_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00