mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibJS: Replace Array.fromAsync with a native JavaScript implementation
This allows us to use the bytecode implementation of await, which
correctly suspends execution contexts and handles completion
injections.
This gains us 4 test262 tests around mutating Array.fromAsync's
iterable whilst it's suspended as well.
This is also one step towards removing spin_until, which the
non-bytecode implementation of await uses.
```
Duration:
-5.98s
Summary:
Diff Tests:
+4 ✅ -4 ❌
Diff Tests:
[...]/Array/fromAsync/asyncitems-array-add-to-singleton.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-add.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-mutate.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-remove.js ❌ -> ✅
```
This commit is contained in:
committed by
Andreas Kling
parent
a63b0cfaba
commit
0eceee0a05
Notes:
github-actions[bot]
2025-11-30 10:56:04 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/0eceee0a05e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6728 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/awesomekling
@@ -101,4 +101,36 @@ describe("normal behavior", () => {
|
||||
|
||||
expect(counter).toBe(1);
|
||||
});
|
||||
|
||||
asyncTest("mapper exception takes priority over iterator closure exception", async () => {
|
||||
let exceptionOrder = [];
|
||||
|
||||
async function* iterator() {
|
||||
try {
|
||||
yield 1;
|
||||
yield 2;
|
||||
} finally {
|
||||
exceptionOrder.push("iterator");
|
||||
throw "iterator exception";
|
||||
}
|
||||
}
|
||||
|
||||
let exception = null;
|
||||
|
||||
try {
|
||||
await Array.fromAsync(iterator(), value => {
|
||||
if (value === 1) {
|
||||
exceptionOrder.push("mapper");
|
||||
throw "mapper exception";
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
expect(exceptionOrder).toEqual(["mapper", "iterator"]);
|
||||
expect(exception).toBe("mapper exception");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user