summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-04 21:30:33 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-05 12:46:40 +0200
commit602f927982dc7a1a824c8b85ba7075482a4d170e (patch)
tree9d5210ea51d64e5deab7bba69e6405e364c28ad2 /Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
parent0781bdb23e43412a3e591a9574bdee5c17364aa4 (diff)
downloadserenity-602f927982dc7a1a824c8b85ba7075482a4d170e.zip
LibWeb: Start implementing "create and initialize a Document" from HTML
The way we've been creating DOM::Document has been pretty far from what the spec tells us to do, and this is a first big step towards getting us closer to spec. The new Document::create_and_initialize() is called by FrameLoader after loading a "text/html" resource. We create the JS Realm and the Window object when creating the Document (previously, we'd do it on first access to Document::interpreter().) The realm execution context is owned by the Environment Settings Object.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
index bc5183fce2..e5b6c8e636 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp
@@ -10,17 +10,17 @@
namespace Web::HTML {
-WindowEnvironmentSettingsObject::WindowEnvironmentSettingsObject(Window& window, JS::ExecutionContext& execution_context)
- : EnvironmentSettingsObject(execution_context)
+WindowEnvironmentSettingsObject::WindowEnvironmentSettingsObject(Window& window, NonnullOwnPtr<JS::ExecutionContext> execution_context)
+ : EnvironmentSettingsObject(move(execution_context))
, m_window(window)
{
}
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
-void WindowEnvironmentSettingsObject::setup(AK::URL& creation_url, JS::ExecutionContext& execution_context)
+void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
{
// 1. Let realm be the value of execution context's Realm component.
- auto* realm = execution_context.realm;
+ auto* realm = execution_context->realm;
VERIFY(realm);
// 2. Let window be realm's global object.
@@ -29,17 +29,32 @@ void WindowEnvironmentSettingsObject::setup(AK::URL& creation_url, JS::Execution
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
// NOTE: See the functions defined for this class.
- auto settings_object = adopt_own(*new WindowEnvironmentSettingsObject(window, execution_context));
-
- // FIXME: 4. If reservedEnvironment is non-null, then:
- // FIXME: 1. Set settings object's id to reservedEnvironment's id, target browsing context to reservedEnvironment's target browsing context, and active service worker to reservedEnvironment's active service worker.
- // FIXME: 2. Set reservedEnvironment's id to the empty string.
-
- // FIXME: 5. Otherwise, set settings object's id to a new unique opaque string, settings object's target browsing context to null, and settings object's active service worker to null.
- settings_object->target_browsing_context = nullptr;
-
- // FIXME: 6. Set settings object's creation URL to creationURL, settings object's top-level creation URL to topLevelCreationURL, and settings object's top-level origin to topLevelOrigin.
+ auto settings_object = adopt_own(*new WindowEnvironmentSettingsObject(window, move(execution_context)));
+
+ // 4. If reservedEnvironment is non-null, then:
+ if (reserved_environment.has_value()) {
+ // FIXME: 1. Set settings object's id to reservedEnvironment's id,
+ // target browsing context to reservedEnvironment's target browsing context,
+ // and active service worker to reservedEnvironment's active service worker.
+ settings_object->target_browsing_context = reserved_environment->target_browsing_context;
+
+ // FIXME: 2. Set reservedEnvironment's id to the empty string.
+ }
+
+ // 5. Otherwise, ...
+ else {
+ // FIXME: ...set settings object's id to a new unique opaque string,
+ // settings object's target browsing context to null,
+ // and settings object's active service worker to null.
+ settings_object->target_browsing_context = nullptr;
+ }
+
+ // 6. Set settings object's creation URL to creationURL,
+ // settings object's top-level creation URL to topLevelCreationURL,
+ // and settings object's top-level origin to topLevelOrigin.
settings_object->creation_url = creation_url;
+ settings_object->top_level_creation_url = top_level_creation_url;
+ settings_object->top_level_origin = top_level_origin;
// 7. Set realm's [[HostDefined]] field to settings object.
realm->set_host_defined(move(settings_object));