Commit graph

309 commits

Author SHA1 Message Date
arturovt
b618b5aa86 fix(zone.js): cancel tasks only when they are scheduled or running (#46435)
Currently, there's no check if the task (that is being canceled) has the right state.
Only `scheduled` and `running` tasks can be canceled. If the task has a non-appropriate
state, then an error will be thrown. Cancelation should not throw an error on an already
canceled task, e.g. `clearTimeout` does not throw errors when it's called multiple times
on the same timer.

PR Close #45711

PR Close #46435
2022-10-11 17:20:54 +00:00
Angular Robot
370aa345b1 build: update dependency google-closure-compiler to v20221004 (#47696)
See associated pull request for more information.

PR Close #47696
2022-10-10 16:09:15 +00:00
Alan Agius
b2aa9ce3e5 build: update puppeteer to 18.0.5 (#47584)
This is needed as Angular does not support Chrome 93.

PR Close #47584
2022-09-30 10:53:04 -07:00
JiaLiPassion
86372538ab refactor(zone.js): remove zone-async-tagging from zone.js (#47416)
1. Remove `zone-async-tagging` implementation from zone.js and move the
implementation to `@angular/core`, so `@angular/core` can import this
package more easily for better treeshaking.
2. Add `async tagging zone` implemenation into `@angular/core` package.
So we don't need to get the `AsyncStackTaggingZoneSpec` from `global`
instance, we can import the `class` directly for better treeshaking.
3. Only load this ZoneSpec when `ngDevMode` is `true`.

PR Close #47416
2022-09-23 14:44:38 -07:00
JiaLiPassion
59aa2c06d1 test(zone.js): update jest test code after upgrade to jest 29.0 (#47486)
related to https://github.com/angular/angular/pull/47438
After jest 28, `jest-environment-node` and `jest-environment-jsdom` need
to be installed by the user themselves, and the API has some breaking
changes, so this PR fix these issues to make the zone/jest integration
test code work as expected.

PR Close #47486
2022-09-20 18:12:47 +02:00
Angular Robot
c9991ca49d build: update dependency google-closure-compiler to v20220905 (#47437)
See associated pull request for more information.

PR Close #47437
2022-09-19 17:21:02 +02:00
Kristiyan Kostadinov
7d3df4724d build: update to TypeScript 4.8 final (#47270)
Bumps up to the final version of TS 4.8 and removes some workarounds.

PR Close #47270
2022-08-26 09:46:07 -07:00
Kristiyan Kostadinov
31429eaccc feat(core): support TypeScript 4.8 (#47038)
Adds support for TypeScript 4.8 and resolves some issues that came up as a result of the update.

Most of the issues came from some changes in TypeScript where the `decorators` and `modifiers` properties were removed from most node types, and were combined into a single `modifiers` array. Since we need to continue supporting TS 4.6 and 4.7 until v15, I ended up creating a new `ngtsc/ts_compatibility` directory to make it easier to reuse the new backwards-compatible code.

PR Close #47038
2022-08-16 16:02:47 +00:00
Victor Porof
91954cf20e fix(zone.js): Fix ConsoleTask interface typo (#47090)
Signed-off-by: Victor Porof <[email protected]>

PR Close #47090
2022-08-09 17:03:21 -07:00
JiaLiPassion
58e604ceea release: cut the zone.js-0.11.8 release (#47084)
PR Close #47084
2022-08-09 10:00:55 -07:00
Victor Porof
f23232ff66 feat(zone.js): Update to the simpler Async Stack Tagging v2 API (#46958)
Signed-off-by: Victor Porof <[email protected]>

PR Close #46958
2022-08-04 14:25:35 -07:00
Paul Gschwendtner
b757b1387c build: update dev-infra packages and account for build-tooling split from ng-dev (#46976)
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.

PR Close #46976
2022-08-02 09:37:37 -07:00
Asaf M
4ac2196695 docs: fixed typos (#47008)
Used my script: https://github.com/Uziel302/websites-spell-checker/blob/master/mdnversion

PR Close #47008
2022-08-01 11:15:54 -07:00
J Rob Gant
af4f5df150 refactor(zone.js): remove leftover debugging code using Error.stack (#46989)
Pull request #46672 added some debugging code to trace down the
root cause of its bug, but parts of the debugging code has never
been cleaned up and ended up landing as part of the PR.

This commit removes the code as it might cause unexpected issues.
Likely when e.g. `Error` is patched and would perform XHRs in testing,
unveiling e.g. CORS issues. See #46989.

PR Close #46989
2022-08-01 09:52:29 -07:00
Angular Robot
bba2e252cd build: update dependency google-closure-compiler to v20220719 (#46926)
See associated pull request for more information.

PR Close #46926
2022-08-01 09:39:25 -07:00
Paul Gschwendtner
24f63fa4e3 build: cut zone.js v0.11.7 (#46911)
Bumps the version for the upcoming `0.11.7` zone.js version,
including the changelog.

PR Close #46911
2022-07-21 10:25:37 +00:00
Paul Gschwendtner
6fed377140 test: update tests to not run jasmine done function in sync-test zone from describe block
There are some ZoneJS tests that fork the zone from the `describe` block
for testing the zone patching. This does cause the Jasmine `done`
function later in `it` specs to be invoked in the sync-test zone from
the original `describe` block. The `done` implementation now has
changed with the Karma Jasmine update and breaks because it now causes
tasks to be scheduled.

It is conceptually incorrect/invalid to take the describe sync zone and
run test logic with that sync zone.

```
 An error was thrown in afterAll
  error properties: Object({ originalStack: 'Error: Cannot call jasmine.execute().forceTask from within a sync test (syncTestZone for jasmine.describe#FileReader).
      at new ZoneAwareError (packages/zone.js/test/browser_test_rollup.umd.js:98:37)
      at e.onScheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:158:196)
      at e.scheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:7529)
      at t.scheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:3539)
      at t.scheduleMicroTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:3791)
      at r.execute (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:166:4312)
      at queueRunnerFa ...
      at <Jasmine>
```
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
e545ff9d54 fixup! feat(zone.js): include jasmine describe block name when raising unexpected task error
ds
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
de86285f2e feat(zone.js): include jasmine describe block name when raising unexpected task error
As mentioned in the previous commit that ensured that the Zone name is
included in errors raised by the `SyncTestZoneSpec`, we can now include
the Jasmine describe block descriptions in such errors.

Errors can often happen when users accidentally try to set up Angular
tests without an `it` block. Resulting in errors where it's not clear
at all which describe block (of potentially a large repository) is
involved:

```
 An error was thrown in afterAll
  error properties: Object({ originalStack: 'Error: Cannot call XX from within a sync test.
      at new ZoneAwareError (packages/zone.js/test/browser_test_rollup.umd.js:98:37)
      at e.onScheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:158:196)
      at e.scheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:7529)
      at t.scheduleTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:3539)
      at t.scheduleMicroTask (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:14:3791)
      at r.execute (packages/zone.js/bundles/zone-testing-bundle.umd.min.js:166:4372)
      at queueRunnerFa ...
      at <Jasmine>
```

We now include the describe block description in the error, so that it
is easier to figure out the location of the culprit code.
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
72c2567847 feat(zone.js): include zone name when sync-test zone reports tasks
The sync-test zone is used in e.g. `describe` to raise an error when
there is asynchronous code scheduled in describe blocks. This commit
includes the zone name in such thrown errors to allow for us to include
the jasmine describe name in the error. This will be wired up in the
jasmine zonejs patches separately.
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
c7b1bb1f28 test: fix fake-async-test spec to properly test prefixed animation frame functions
In the fake async test for `zone.js` there is some logic to test various
prefixes of the request animation frame functions. This logic does not
have any effect currently, except for generating the same test at
maximum three times.

This commit fixes the test to actually test what it meant to do
initially.
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
d2b444a8a2 test: update tests to account for karma-jasmine v5.0.0
Karma jasmine updated the `jasmine-core` dependency. Jasmine is now more
strict when:

* The done callback is invoked multiple times
* The done callback is used, while a promise is also returned
* The done callback is treated as error when e.g. a number is returned
  as first argument. This was the case with `requestAnimationFrame`.
2022-07-18 19:19:00 +02:00
Paul Gschwendtner
4e0cee52f0 fix(core): do not invoke jasmine done callback multiple times with waitForAsync
Currently tests written using `waitForAsync` would be prone to Jasmine
warnings or errors (depending on the version) for tests incorrectly
invoking asynchronous jasmine `done` callbacks multiple times.

This can happen because the async test zone logic schedules the
`done` callback to be called using `setTimeout`, but this could
be invoked multiple times, causing multiple `done` invocations to
be scheduled. Most of the issues have been resolved with #45025,
but it does not solve the case of multiple tasks finished and callbacks
being scheduled.

Technically, the current logic is built in way that _should_ result in
`_finishCallbackIfDone` and eventually the `done` callback to be invoked
at maximium once. This is unfortunately not the case in some rather
advanced/unexpected scenarios (like our AngularJS upgrade tests) where
the scenario is the following (and microtasks from before the actual
`waitForAsync` spec are still completing -- which is valid):

```
1. A test `beforeEach` schedules a microtask in the ProxyZone.
2. An actual empty `it` spec executes in the AsyncTestZone` (using e.g. `waitForAsync`).
3. The `onInvoke` invokes `_finishCallbackIfDone` because the spec runs synchronously.
4. We wait the scheduled timeout (see below) to account for unhandled promises.
5. The microtask from (1) finishes and `onHasTask` is invoked.

--> We register a second `_finishCallbackIfDone` even though we have scheduled a timeout.
--> we execute the `done` callback twice because the async zone spec state is "stable"
```
2022-07-18 19:19:00 +02:00
Angular Robot
dbb0dfe707 build: lock file maintenance (#46691)
See associated pull request for more information.

PR Close #46691
2022-07-13 17:07:57 +00:00
Angular Robot
4b03b1c25a build: lock file maintenance (#46819)
See associated pull request for more information.

PR Close #46819
2022-07-13 16:32:25 +00:00
Paul Gschwendtner
1596902825 build: move jasmine seed generation logic to karma config (#46798)
The jasmine seed generator is only used in a single karma configuration
file. Used by the legacy build and the Saucelabs/ZoneJS Karma jobs.

We should move the separate script code directly into the config to make
it clear that the seed generation is not used elsewhere, and to simplify
the Starlark code.

PR Close #46798
2022-07-12 15:54:51 +00:00
JiaLiPassion
848a00956e feat(zone.js): add AsyncStackTaggingZoneSpec implementation (#46693)
Chrome has an experimental API to improve the debug experience of the
async tasks.
The details can be found here https://bugs.chromium.org/p/chromium/issues/detail?id=332624#c29

This commit add the `async stack tagging` support in the `zone.js`.
User can `import 'zone.js/plugins/async-stack-tagging';` to enable this
feature.

PR Close #46693
2022-07-11 20:01:50 +00:00
Angular Robot
4f2c87b988 build: update dependency mocha to v10 (#46619)
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | mocha   | 9.2.2 | 10.0.0 |

PR Close #46619
2022-07-11 18:13:37 +00:00
John Vandenberg
c14c701775 docs: fix spelling (#46713)
PR Close #46713
2022-07-08 20:54:52 +00:00
renovate[bot]
19364cff20 build: update dependency google-closure-compiler to v20220601 (#46565)
PR Close #46565
2022-06-29 10:18:26 -07:00
Paul Gschwendtner
0934011b03 test: avoid test fixture affecting zone in all web tests (#46511)
We have a file called `test-events.js` (named in an ambiguous way
anyway) that runs for all Karma web tests and configures ZoneJS to
not patch the `scroll` event. There are two issues:

1. The patch applies to all web tests. This could cause unexpected
   issues.
2. The file is named ambiguously and also is placed at the project root,
   in a wrong spot.

Additionally, the test doesn't even fail when the file is removed. This
commit applies the Zone config locally to the closest build target and
also reworks the test to actually ensure it's testing what it describes.

PR Close #46511
2022-06-27 15:46:41 -07:00
Andrew Kushnir
2402c47b76 Revert "fix(zone.js): do not silence uncaught promise rejections when the finally is called (#45449)" (#46461)
This reverts commit cb57cdbbd4.

PR Close #46461
2022-06-22 16:04:23 -07:00
arturovt
cb57cdbbd4 fix(zone.js): do not silence uncaught promise rejections when the finally is called (#45449)
The native promise implementation logs unhandled promise rejections after `onFinally`
has been called. We may rely on the `scheduledByFinally` argument, which is `false` by
default, to avoid creating a breaking change; this will also allow us to reduce the number of
changes. The `finally` function should not silence unhandled promise rejections, because
they're not silenced in any implementation. If the `scheduleResolveOrReject` is called within
the `finally` we won't clear unhandled rejections. We'll keep the same behaviour if the
`scheduleResolveOrReject` is called within the `then`.

PR Close #43206

PR Close #45449
2022-06-22 13:23:03 -07:00
JiaLiPassion
1120d540d8 release: cut the zone.js-0.11.6 release (#46232)
PR Close #46232
2022-06-14 19:53:52 +00:00
Renovate Bot
5cfde8b23e build: lock file maintenance (#46104)
PR Close #46104
2022-06-03 10:23:36 -07:00
Kristiyan Kostadinov
1cc158375b build: update to TypeScript 4.7 final (#46132)
Bumps up the repo to the final version of TypeScript 4.7. Also updates AIO to 4.7.

PR Close #46132
2022-05-25 11:37:12 -07:00
Kristiyan Kostadinov
4f309fed02 build: update to TypeScript 4.7 RC (#45966)
Bumps up the repo to the RC version of TypeScript 4.7.

PR Close #45966
2022-05-13 09:36:46 -07:00
Paul Gschwendtner
68a6a075f4 build: clean up references to old master branch (#45856)
Cleans up all references to the `master` branch we renamed to
`main` across Angular.

PR Close #45856
2022-05-04 16:23:33 -07:00
Kristiyan Kostadinov
29039fcdbc feat(core): support TypeScript 4.7 (#45749)
Adds support for TypeScript 4.7. Changes include:
* Bumping the TS version as well as some Bazel dependencies to include https://github.com/bazelbuild/rules_nodejs/pull/3420.
* Adding a backwards-compatibility layer for calls to `updateTypeParameterDeclaration`.
* Making `LView` generic in order to make it easier to type the context based on the usage. Currently the context can be 4 different types which coupled with stricter type checking would required a lot of extra casting all over `core`.
* Fixing a bunch of miscellaneous type errors.
* Removing assertions of `ReferenceEntry.isDefinition` in a few of the language service tests. The field isn't returned by TS anymore and we weren't using it for anything.
* Resolving in error in the language service that was caused by TS attempting to parse HTML files when we try to open them. Previous TS was silently setting them as `ScriptKind.Unknown` and ignoring the errors, but now it throws. I've worked around it by setting them as `ScriptKind.JSX`.

PR Close #45749
2022-04-29 12:19:45 -04:00
Renovate Bot
0840ece9e2 build: lock file maintenance (#45751)
PR Close #45751
2022-04-28 09:39:06 -07:00
Renovate Bot
68357104c9 build: lock file maintenance (#45457)
PR Close #45457
2022-04-15 14:38:16 -07:00
Renovate Bot
b13a453472 build: update dependency google-closure-compiler to v20220405 (#45568)
PR Close #45568
2022-04-11 16:26:25 +00:00
Kristiyan Kostadinov
41223a81f2 build: update to jasmine 4.0 (#45558)
Updates us to version 4.0 of Jasmine and fixes some errors that were the result of us depending upon deprecated APIs. We need to do this both to stay up to date and because it was going to break eventually, because one of the Bazel packages was logging a deprecation warning that version 4.0 was required.

There were also some cases where the state of `ngDevMode` had started leaking out between tests.

PR Close #45558
2022-04-11 16:25:28 +00:00
Jessica Janiuk
7a37fe9f28 Revert "build: update to jasmine 4.0 (#45558)" (#45566)
This reverts commit a248df0682.

PR Close #45566
2022-04-08 19:07:29 +00:00
Kristiyan Kostadinov
a248df0682 build: update to jasmine 4.0 (#45558)
Updates us to version 4.0 of Jasmine and fixes some errors that were the result of us depending upon deprecated APIs. We need to do this both to stay up to date and because it was going to break eventually, because one of the Bazel packages was logging a deprecation warning that version 4.0 was required.

There were also some cases where the state of `ngDevMode` had started leaking out between tests.

PR Close #45558
2022-04-08 15:55:58 +00:00
JiaLiPassion
aebf165359 fix(zone.js): should ignore multiple resolve call (#45283)
Close #44913

The following case is not handled correctly by `zone.js`.
```
const delayedPromise = new Promise((resolve) => {
  setTimeout(resolve, 1, 'timeout');
});

new Promise((resolve) => {
  resolve(delayedPromise);
  resolve('second call');
}).then(console.log);
```

It should output `timeout`, since the promise is resolved by the
1st resolve, the `second call` should be ignored.

So this is a bug that the original implementation not ensure the
`resolve` is only called once.

PR Close #45283
2022-03-25 17:31:03 -07:00
arturovt
4ea70e36b9 fix(zone.js): swallow the error when the element callback is not patchable (#45400)
The `patchCallbacks` is used for patching the `document.registerElement` and
`customElements.define`. We explicitly wrap the patching code into try-catch since
callbacks may be already patched by other web components frameworks (e.g. LWC), and they
make those properties non-writable. This means that patching callback will throw an error
`cannot assign to read-only property`. See this code as an example:
https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186
We don't want to stop the application rendering if we couldn't patch some
callback, e.g. `attributeChangedCallback`.

PR Close #42546

PR Close #45400
2022-03-25 16:31:09 -07:00
Renovate Bot
010a39f856 build: update bazel (#45431)
Update `@bazel` packages to the latest 5.x version.

Some of the changes here are modeled after
angular/dev-infra@40c0ac8559.

Co-Authored-By: George Kalpakas <[email protected]>

PR Close #45431
2022-03-25 12:18:33 -07:00
arturovt
e2eaac34b0 fix(zone.js): read Symbol.species safely (#45369)
We must read `Symbol.species` safely because `this` may be anything. For instance, `this`
may be an object without a prototype (created through `Object.create(null)`); thus
`this.constructor` will be undefined. One of the use cases is SystemJS creating
prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty
object and copies promise properties into that object (within the `getOrCreateLoad`
function). The zone.js then checks if the resolved value has the `then` method and invokes
it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read
properties of undefined (reading 'Symbol(Symbol.species)')`.

PR Close #45369
2022-03-24 18:56:36 -07:00
Tobias Speicher
4ddcf81e61 refactor: replace deprecated String.prototype.substr() (#45397)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <[email protected]>

PR Close #45397
2022-03-24 11:48:09 -07:00