diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
index 78c11fb5113..811b49b43be 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
@@ -300,14 +300,22 @@ JS::Object& incumbent_global_object()
return incumbent_settings_object().global_object();
}
-// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
-EnvironmentSettingsObject& current_principal_settings_object()
+// https://whatpr.org/html/9893/webappapis.html#current-principal-realm
+JS::Realm& current_principal_realm()
{
+ // FIXME: The current principal realm is the principal realm of the current realm.
auto& event_loop = HTML::main_thread_event_loop();
auto& vm = event_loop.vm();
- // Then, the current settings object is the environment settings object of the current Realm Record.
- return Bindings::host_defined_environment_settings_object(*vm.current_realm());
+ return *vm.current_realm();
+}
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
+// https://whatpr.org/html/9893/webappapis.html#current-principal-settings-object
+EnvironmentSettingsObject& current_principal_settings_object()
+{
+ // Then, the current principal settings object is the environment settings object of the current principal realm.
+ return Bindings::host_defined_environment_settings_object(current_principal_realm());
}
// https://html.spec.whatwg.org/multipage/webappapis.html#current-global-object
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h
index 0bb0a2cf6b6..390fea6b026 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h
@@ -142,7 +142,10 @@ private:
EnvironmentSettingsObject& incumbent_settings_object();
JS::Realm& incumbent_realm();
JS::Object& incumbent_global_object();
+
+JS::Realm& current_principal_realm();
EnvironmentSettingsObject& current_principal_settings_object();
+
JS::Object& current_global_object();
JS::Realm& relevant_realm(JS::Object const&);
EnvironmentSettingsObject& relevant_settings_object(JS::Object const&);