625 Commits

Author SHA1 Message Date
arturovt b0569fdb3f fix(zone.js): harden zoneSymbolEventNames and patches against __proto__ key
Initialize `zoneSymbolEventNames` and `patches` with `Object.create(null)` instead of `{}`.

This is a hardening change rather than a fix for an exploitable vulnerability. Calling `addEventListener('__proto__', fn)` is not directly attacker-controlled; its presence already implies an application bug. However, if such a call does occur, the current implementation can behave unexpectedly depending on the environment.

For `zoneSymbolEventNames`, accessing `zoneSymbolEventNames['__proto__']` on a plain object invokes the inherited `__proto__` accessor and returns `Object.prototype`, which is truthy. This causes `prepareEventNames()` to be skipped, leaving `symbolEventName` undefined and eventually leading to a runtime error when `window['undefined'] = []` is executed.

In Node.js environments running with `--disable-proto=throw`, the assignment:

```ts id="z8n4qm"
zoneSymbolEventNames['__proto__'] = {};
```

throws immediately because it triggers the disabled `__proto__` setter.

The `patches` registry has a similar issue. A `__proto__` key passed to `__load_patch()` bypasses the duplicate-patch check and reaches:

```ts id="f3v7kx"
patches['__proto__'] = fn(...);
```

which invokes the `__proto__` setter and changes the prototype of the `patches` object.

Using `Object.create(null)` removes the inherited `__proto__` accessor entirely, causing these keys to behave like ordinary properties rather than interacting with JavaScript's prototype machinery.

As part of this change, `patches.hasOwnProperty(name)` is also updated to:

```ts id="n2c8wp"
Object.prototype.hasOwnProperty.call(patches, name)
```

since null-prototype objects do not inherit `hasOwnProperty`.

(cherry picked from commit 2d33fd55ff)
2026-06-24 12:19:35 -04:00
arturovt 21bdff55da fix(zone.js): harden zoneSymbolEventNames against __proto__ key (defense-in-depth)
Initialize zoneSymbolEventNames with Object.create(null) instead of {}.

This is hardening only. addEventListener('__proto__', fn) is not
directly attacker-controllable — its presence in an application is
itself an application bug and a prerequisite for any issue here.

Without this change, if that application bug exists, two unexpected
behaviors follow depending on environment:

Browser: zoneSymbolEventNames['__proto__'] reads the __proto__ getter
and returns Object.prototype (truthy), bypassing prepareEventNames.
symbolEventName resolves to undefined and window['undefined'] = []
throws TypeError.

Node.js + --disable-proto=throw: the assignment
zoneSymbolEventNames['__proto__'] = {} inside prepareEventNames
triggers the disabled __proto__ setter and throws.

Using Object.create(null) removes the __proto__ accessor from the
map so the key is treated as a plain missing property in both cases.

(cherry picked from commit fd7c2daf4d)
2026-06-11 16:41:12 +00:00
Angular Robot 6fee7aaf89 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-06-01 16:31:26 +02:00
arturovt 2d3db59321 fix(zone.js): validate __Zone_symbol_prefix to prevent DOM clobbering attacks
Previously, `__Zone_symbol_prefix` was read directly from `globalThis` without validating its type:

const symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__';

This made it possible for DOM clobbering to interfere with Zone’s internal symbol handling. If an attacker injected a DOM element with the same name (for example via a form field or anchor ID), `global['__Zone_symbol_prefix']` could resolve to a DOM element instead of a string. Because DOM elements are truthy, the fallback would not be used, and Zone would construct invalid internal keys (e.g. “[object HTMLFormElement]...”), breaking patching and lookup logic in subtle ways.

This prevents DOM clobbering from influencing Zone’s internal symbol generation and keeps the patching system stable even in the presence of malicious or unexpected global values.

(cherry picked from commit e50f504b2f)
2026-05-29 14:54:21 +02:00
Angular Robot d88b796518 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-05-27 16:41:13 -07:00
Andrew Scott d9f9a0835c fix(zone.js): avoid type error on custom object rejection with rejection property
Ensure that when a custom object with a 'rejection' property is thrown as a raw promise rejection, the unhandled promise rejection error logger does not crash with a TypeError while trying to access undefined zone properties.

Also wrap microtask queue draining and task frame counter updates with defensive try-finally blocks to guarantee internal scheduler states are properly reset under any potential call stack exception unwinding scenarios.

(cherry picked from commit fa7580061b)
2026-05-27 10:45:20 -07:00
Angular Robot 4f048e7de3 build: update dependency typescript to v6.0.3
See associated pull request for more information.
2026-05-04 13:05:58 -07:00
hawkgs 9fa4be9d09 test(zone.js): vitest patch for testing (#68395)
Test `fakeAsync` API in Vitest when Zone.js `vitest` patch applied.

PR Close #68395
2026-04-30 15:44:35 -07:00
Charles Lyding 62c6e3b7ee feat(zone.js): support vitest patching in zone.js/testing (#68395)
To support `fakeAsync` usage while using `vitest` as a test runner, Zone.js
now provides patching when using the `zone.js/testing` package import.
This patching is similar to that of the existing jasmine, mocha, and jest
functionality.

PR Close #68395
2026-04-30 15:44:35 -07:00
Matthieu Riegler 7f3f3d7da1 ci: remove remainings of saucelabs tests
Those haven't been used for a while.
2026-04-22 14:41:03 -07:00
Angular Robot 56ff89c92d build: update all non-major dependencies
See associated pull request for more information.
2026-04-17 14:26:35 -07:00
arturovt fc6a7eea68 fix(zone.js): allow draining microtasks in Promise.then (through flag)
These changes are essentially the same as those introduced in
angular#45273, but they include backward compatibility
for applications that explicitly rely on the order in which microtasks are drained.

This is critically important for our code and other third-party code, which is
beyond our control, to work properly. If a microtask is scheduled within an event
listener to be executed "later", it should indeed be executed later and not synchronously,
as this would break the expected flow of code execution.

The simple code that reproduces the behavior that exists now:

```ts
Zone.current.fork({name: 'child'}).run(() => {
  const div = document.createElement('div');
  div.style.height = '200px';
  div.style.width = '200px';
  div.style.backgroundColor = 'red';
  document.body.appendChild(div);

  function listener() {
    Promise.resolve().then(() => {
      div.style.height = '400px';
    });
  }

  div.addEventListener('fakeEvent', listener);
  div.dispatchEvent(new Event('fakeEvent'));
  console.log(div.getBoundingClientRect().height); // 400
});
```

The code above logs 400 as the height, but it should actually log 200 because the
height is updated in a microtask within the event listener.

When using Angular with microfrontend applications, especially when other apps might be
using React, zone.js can disrupt the classical order of operations. For example, when using a
`react-component/trigger`, it schedules a microtask within an event listener using
`Promise.resolve().then(...)` to determine whether the event needs to be re-dispatched.
The event is re-dispatched when the layout has changed, which is why a microtask is used.

With this change, we introduce a global configuration flag,
`__zone_symbol__enable_native_microtask_draining`, to allow consumers to enable
microtask draining within a browser microtask.

This flag is necessary to prevent any breaking changes resulting from this modification.
The previous attempt to address this issue caused a significant number of failures in g3.
Therefore, we are hiding that fix behind the configuration flag.

Closes angular#44446
Closes angular#55590
Closes angular#51328
2026-04-15 10:31:28 -04:00
Angular Robot 0007723a03 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-03-25 13:32:59 -07:00
Kristiyan Kostadinov 9ee4f83705 build: update to TypeScript 6 stable
Updates the repo to the stable version of TypeScript 6.
2026-03-25 12:57:49 -07:00
Angular Robot 621c9083de build: update cross-repo angular dependencies
See associated pull request for more information.
2026-03-20 15:22:17 -07:00
Angular Robot ada150c693 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-03-13 16:26:41 -06:00
Angular Robot 81d0807242 build: update all non-major dependencies
See associated pull request for more information.
2026-03-12 16:08:35 -06:00
Alan Agius 667219230a test: remove duplicate tests (#67518)
These tests are duplicate and have been removed.

PR Close #67518
2026-03-11 13:37:33 -07:00
Alan Agius 4febb8ad31 build: update aspect_rules_js to 3.0.2 (#67518)
This updates the major version of `aspect_rules_js`.

PR Close #67518
2026-03-11 13:37:33 -07:00
Andrew Scott b8fb51c462 build(dev-infra): add release automation script for zone.js
This commit introduces a new release automation script for zone.js, located at
packages/zone.js/tools/release.mts.
2026-03-03 09:14:35 -08:00
Alan Agius 6d07890d63 build: update all non-major dependencies
See associated pull request for more information.

Closes #67035 as a pr takeover
2026-02-25 08:31:32 -08:00
Andrew Scott ac8b5ff938 release: cut the zone.js-0.16.1 release 2026-02-19 00:26:30 +00:00
Andrew Scott 98610aabaf docs(zone.js): update release and publish commands in DEVELOPER.md 2026-02-18 08:47:53 -08:00
Andrew Scott d99e336a03 docs(zone.js): update build command in DEVELOPER.md 2026-02-18 08:47:53 -08:00
Andrew Scott c2f7eaa833 docs(zone.js): update instructions to use pnpm 2026-02-18 08:47:53 -08:00
Andrew Scott fc557f0276 fix(zone.js): support passthrough of Promise.try API
When Zone patches Promise, it uses ZoneAwarePromise. The new Promise.try API was undefined on ZoneAwarePromise, making it unavailable when zone was present. This change gracefully passes through Promise.try to the native Promise implementation, if available, without patching it to execute in the right zone (our stance is not to add new patches but avoid destructively making new APIs unavailable).

Fixes #67057
2026-02-17 11:32:49 -08:00
Kristiyan Kostadinov 81cabc1477 feat(core): add support for TypeScript 6
Updates the project to support TypeScript 6 and accounts for some of the breakages.
2026-02-17 08:40:38 -08:00
Angular Robot 11767cabe4 build: update Jasmine to 6.0.0
Jasmine enables `forbidDuplicateNames: true` by default. So we also need to desambiguate duplicate spec names.
2026-02-09 12:15:57 -08:00
Shuaib Hasan Akib 0c6604f478 refactor(common): update copyright to Google LLC
Replaces outdated Google Inc copyright headers with Google LLC to align with current licensing standards.
2026-02-09 07:51:36 -08:00
Angular Robot df3258cfc4 build: update all non-major dependencies
See associated pull request for more information.
2026-01-29 12:22:40 -08:00
Angular Robot 9989c5fb78 build: update dependency @csstools/css-color-parser to v4
See associated pull request for more information.
2026-01-16 10:30:20 -08:00
Kristiyan Kostadinov 52bc0208f9 build: move zone.js build off deprecated flag
The Zone.js build was depending on the `--outFile` flag from TypeScript which is deprecated. These changes switch to using `--outDir` and copying the files out of the directory instead.
2026-01-16 09:28:47 -08:00
Angular Robot 54fc393d27 build: update dependency @csstools/css-calc to v3
See associated pull request for more information.
2026-01-16 09:20:05 -08:00
Angular Robot ebc52ff434 build: update all non-major dependencies
See associated pull request for more information.
2026-01-15 10:52:48 -08:00
SkyZeroZx 85ce5f3ce7 docs: update copyright year 2026-01-07 12:28:34 -05:00
Matthieu Riegler 6270bba056 ci: reformat files
This is after we've slightly changed a rule in #66056
2025-12-16 14:44:19 -08:00
Matthieu Riegler af77b89e2a ci: reformat files
This is after we've slightly changed a rule in #66056
2025-12-16 09:24:36 -08:00
Joey Perrott 349133374f build: update repository to use node 22.21.1 in bazel
The repository was updated to use node 22.21.1 via nvm, but bazel had not been updated to match
2025-12-09 09:19:13 -08:00
Matthieu Riegler 9d1d742f1b build: enable angular formatting on all html files
This should also be safe on any html file that isn't an angular template
2025-12-08 10:19:45 -08:00
Angular Robot 009ca4bc70 build: update all non-major dependencies
See associated pull request for more information.
2025-12-04 11:31:29 -08:00
Angular Robot e681c871d3 build: update all non-major dependencies
See associated pull request for more information.
2025-11-26 13:08:42 -05:00
Jessica Janiuk 58014cb01a release: cut the zone.js-0.16.0 release 2025-11-19 12:38:52 -08:00
Angular Robot d99b7437d1 build: update all non-major dependencies
See associated pull request for more information.
2025-11-17 08:04:29 -08:00
Angular Robot 3cde920ecf build: update all non-major dependencies
See associated pull request for more information.
2025-11-07 07:43:44 -08:00
Alan Agius 26fed34e0e build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
Angular Robot 2b71181288 build: update all non-major dependencies
See associated pull request for more information.
2025-11-05 15:13:37 -08:00
Andrew Scott 48abe007d9 fix(zone.js): Support jasmine v6
This fixes the jasmine patch to ensure we are patching the private APIs
off of the right location, which changed in v6.

see https://github.com/jasmine/jasmine/commit/168ff0a751b6280b170ce097410d77a4c7c1f449
2025-10-24 18:46:04 +02:00
Angular Robot 77ead34cc7 build: update dependency vitest to v4 (#64635)
See associated pull request for more information.

PR Close #64635
2025-10-24 09:35:52 +02:00
Andrew Scott ced2fa5253 refactor(zone.js): Improve missing proxy zone error for jest imported (#64497)
test functions

This improves the fakeAsync error message when importing it, describe,
etc from jest

We will not be further expanding the ZoneJS patches to support
additional use-cases.

fixes #47603

PR Close #64497
2025-10-22 23:26:23 +00:00
Angular Robot fad6e1351e build: update all non-major dependencies (#64514)
See associated pull request for more information.

PR Close #64514
2025-10-20 16:13:17 +00:00