mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibWeb: Ensure principal realm returned for nested Shadow Realms
Recently reported against the shadow realm proposal after running into issues with WPT tests. In a nested shadow realm, the associated realm is a shadow realm, not the principal realm. One such issue this fixes is a crash when a nested shadow realm performs an operation which requires the principal settings object.
This commit is contained in:
parent
218ac86b67
commit
91007eb476
Notes:
github-actions[bot]
2024-11-30 11:07:04 +00:00
Author: https://github.com/shannonbooth
Commit: 91007eb476
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2631
3 changed files with 44 additions and 2 deletions
|
@ -0,0 +1,41 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function shadowRealmEvalAsync(realm, asyncBody) {
|
||||
return new Promise(realm.evaluate(`
|
||||
(resolve, reject) => {
|
||||
(async () => {
|
||||
${asyncBody}
|
||||
})().then(resolve, (e) => reject(e.toString()));
|
||||
}
|
||||
`));
|
||||
};
|
||||
|
||||
asyncTest(async done => {
|
||||
const outerShadowRealm = new ShadowRealm();
|
||||
|
||||
outerShadowRealm.evaluate(`
|
||||
var innerShadowRealm = new ShadowRealm();
|
||||
`);
|
||||
|
||||
const outerResult = await shadowRealmEvalAsync(outerShadowRealm, `
|
||||
function shadowRealmEvalAsync(realm, asyncBody) {
|
||||
return new Promise(realm.evaluate(\`
|
||||
(resolve, reject) => {
|
||||
(async () => {
|
||||
\${asyncBody}
|
||||
})().then(resolve, (e) => reject(e.toString()));
|
||||
}
|
||||
\`));
|
||||
};
|
||||
|
||||
const innerResult = await shadowRealmEvalAsync(innerShadowRealm, \`
|
||||
return new Event("Some event...").type;
|
||||
\`);
|
||||
|
||||
return innerResult;
|
||||
`);
|
||||
|
||||
println(outerResult);
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue