mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibJS: Close sync iterator when async wrapper yields rejection
This is a normative change in the ECMA-262 spec. See: https://github.com/tc39/ecma262/commit/ff129b1
This commit is contained in:
Notes:
github-actions[bot]
2025-04-29 11:34:26 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/568524f8ba9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4514
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user