mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibWeb: Always assert that principal realm returns a principal realm
There was a bug in the HTML proposal where a synthetic realm settings object's principal realm was a shadow realm if there were nested shadow realms, which this assertion catches more directly (rather than later down the track, where it is used). We were meant to also assert for this case, but we were previously returning early.
This commit is contained in:
parent
27f1e3676f
commit
bb10b0e301
Notes:
github-actions[bot]
2024-11-30 11:07:44 +00:00
Author: https://github.com/shannonbooth
Commit: bb10b0e301
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2631
2 changed files with 6 additions and 6 deletions
|
@ -360,19 +360,19 @@ JS::Realm& current_principal_realm()
|
|||
}
|
||||
|
||||
// https://whatpr.org/html/9893/webappapis.html#concept-principal-realm-of-realm
|
||||
JS::Realm& principal_realm(JS::Realm& realm)
|
||||
JS::Realm& principal_realm(GC::Ref<JS::Realm> realm)
|
||||
{
|
||||
VERIFY(realm.host_defined());
|
||||
VERIFY(realm->host_defined());
|
||||
|
||||
// 1. If realm.[[HostDefined]] is a synthetic realm settings object, then:
|
||||
if (is<Bindings::SyntheticHostDefined>(*realm.host_defined())) {
|
||||
if (is<Bindings::SyntheticHostDefined>(*realm->host_defined())) {
|
||||
// 1. Assert: realm is a synthetic realm.
|
||||
// 2. Set realm to the principal realm of realm.[[HostDefined]].
|
||||
return static_cast<Bindings::SyntheticHostDefined const&>(*realm.host_defined()).synthetic_realm_settings.principal_realm;
|
||||
realm = static_cast<Bindings::SyntheticHostDefined const&>(*realm->host_defined()).synthetic_realm_settings.principal_realm;
|
||||
}
|
||||
|
||||
// 2. Assert: realm.[[HostDefined]] is an environment settings object and realm is a principal realm.
|
||||
VERIFY(is<Bindings::PrincipalHostDefined>(*realm.host_defined()));
|
||||
VERIFY(is<Bindings::PrincipalHostDefined>(*realm->host_defined()));
|
||||
|
||||
// 3. Return realm.
|
||||
return realm;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue