angular/packages/zone.js/test/common
JiaLiPassion 08b0c87a94 fix(zone.js): Promise.resolve(subPromise) should return subPromise (#53423)
In the original `Promise` impelmentation, zone.js follow the spec from
https://promisesaplus.com/#point-51.

```
const p1 = Promise.resolve(1);
const p2 = Promise.resolve(p1);

p1 === p2; // false
```
in this case, `p2` should be the same status with `p1` but they are
still different instances.

And for some edge case.

```
class MyPromise extends Promise {
  constructor(sub) {
    super((res) => res(null));
    this.sub = sub;
  }
  then(onFufilled, onRejected) {
    this.sub.then(onFufilled, onRejected);
  }
}

const p1 = new Promise(setTimeout(res), 100);
const myP = new MyPromise(p1);
const r = await myP;
r === 1; // false
```

So in the above code, `myP` is not the same instance with `p1`,
and since `myP` is resolved in constructor, so `await myP` will
just pass without waiting for `p1`.

And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve
`Promise.resolve(subP)` should return `subP`.

```
const p1 = Promise.resolve(1);
const p2 = Promise.resolve(p1);

p1 === p2; // true
```

So the above `MyPromise` can wait for the `p1` correctly.

PR Close #53423
2023-12-11 10:55:12 -08:00
..
Error.spec.ts refactor: update zone.js and tests to work with ESM (#48521) 2022-12-19 19:50:44 +00:00
fetch.spec.ts build: migrate to node 18 (#51609) 2023-09-01 15:12:43 +00:00
microtasks.spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
promise-disable-wrap-uncaught-promise-rejection.spec.ts fix(zone.js): disable wrap uncaught promise rejection should handle primitive value (#38476) 2020-09-24 11:32:44 -04:00
Promise.spec.ts fix(zone.js): Promise.resolve(subPromise) should return subPromise (#53423) 2023-12-11 10:55:12 -08:00
queue-microtask.spec.ts fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js (#50530) 2023-06-07 12:42:33 -07:00
setInterval.spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
setTimeout.spec.ts fix(zone.js): clearTimeout/clearInterval should call on object global (#37858) 2020-07-24 15:22:47 -07:00
task.spec.ts refactor(router): run spell check on router package (#50445) 2023-05-24 13:56:56 +00:00
toString.spec.ts fix(zone.js): zone.js toString patch should check typeof Promise is function (#38350) 2020-08-25 09:51:50 -07:00
util.spec.ts refactor(zone.js): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:16 -07:00
zone.spec.ts build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00