From 62fed2a31d9ff4de881deb0cf92d6061b09a7696 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 21 Sep 2022 10:57:32 +0200 Subject: [PATCH] LibWeb: Add `id` field to Environment This is a unique string that identifies the environment. We just use a simple incrementing number for now. --- Userland/Libraries/LibWeb/HTML/Scripting/Environments.h | 3 ++- .../HTML/Scripting/WindowEnvironmentSettingsObject.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h index b8a0dd4f7e..c8fee5dd64 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h @@ -20,7 +20,8 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/webappapis.html#environment struct Environment { - // FIXME: An id https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id + // An id https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id + String id; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url AK::URL creation_url; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index 72bc8c37df..ad343bc023 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -43,9 +43,11 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull // 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->id = reserved_environment->id; settings_object->target_browsing_context = reserved_environment->target_browsing_context; - // FIXME: 2. Set reservedEnvironment's id to the empty string. + // 2. Set reservedEnvironment's id to the empty string. + reserved_environment->id = String::empty(); } // 5. Otherwise, ... @@ -53,6 +55,8 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull // 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. + static i64 next_id = 1; + settings_object->id = String::number(next_id++); settings_object->target_browsing_context = nullptr; }