LibWeb: Push promise rejection handling onto UniversalGlobalScopeMixin

This is needed for shadow realms which don't have a window or worker
global object. Fixes a crash for the attached test.
This commit is contained in:
Shannon Booth 2024-11-28 04:06:02 +13:00 committed by Andreas Kling
commit 6a668f27c7
Notes: github-actions[bot] 2024-11-30 11:07:17 +00:00
9 changed files with 129 additions and 109 deletions

View file

@ -0,0 +1,20 @@
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const shadowRealm = new ShadowRealm();
try {
const result = await new Promise(shadowRealm.evaluate(`
(resolve, reject) => {
(async () => {
throw new Error('An error!');
})().then(resolve, (e) => reject(e.toString()));
}
`));
} catch (e) {
println(e);
}
done();
});
</script>