mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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
|
@ -580,8 +580,8 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
// 4. Set settings's execution context to context.
|
||||
.execution_context = move(context),
|
||||
|
||||
// 5. Set settings's principal realm to O's associated realm
|
||||
.principal_realm = object.shape().realm(),
|
||||
// 5. Set settings's principal realm to O's associated realm's principal realm
|
||||
.principal_realm = HTML::principal_realm(object.shape().realm()),
|
||||
|
||||
// 6. Set settings's module map to a new module map, initially empty.
|
||||
.module_map = realm.create<HTML::ModuleMap>(),
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Some event...
|
|
@ -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