mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibJS: Close sync iterator when async wrapper yields rejection
This is a normative change in the ECMA-262 spec. See:
ff129b1
This commit is contained in:
parent
15faaeb2bb
commit
568524f8ba
Notes:
github-actions[bot]
2025-04-29 11:34:26 +00:00
Author: https://github.com/trflynn89
Commit: 568524f8ba
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4514
3 changed files with 162 additions and 45 deletions
|
@ -77,4 +77,28 @@ describe("normal behavior", () => {
|
|||
checkResult(promise, TestArray);
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
asyncTest("sync iterable is closed upon rejection", async () => {
|
||||
const thenable = {
|
||||
then(resolve, reject) {
|
||||
reject();
|
||||
},
|
||||
};
|
||||
|
||||
let counter = 0;
|
||||
|
||||
function* iterator() {
|
||||
try {
|
||||
yield thenable;
|
||||
} finally {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await Array.fromAsync(iterator());
|
||||
} catch (e) {}
|
||||
|
||||
expect(counter).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue