mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-03 07:32:00 +00:00
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.
41 lines
1.2 KiB
HTML
41 lines
1.2 KiB
HTML
<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>
|