Truly independent web browser
LibWeb+LibWebCommon: Give local workers their owner's policy container
Shannon Booth36648a9cd711
diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cppindex a67736210cf..f23bf5555c3 100644--- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp+++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp@@ -704,12 +704,14 @@ SerializedEnvironmentSettingsObject EnvironmentSettingsObject::serialize(){auto serialized_global = [this]() -> SerializedGlobal {bool relevant_settings_object_is_secure_context = is_secure_context(*this);+ auto relevant_settings_object_policy_container = policy_container()->serialize();auto& global = global_object();if (auto const* window = window_from_global_object(global)) {return SerializedWindow {.associated_document {.url = window->associated_document().url(),.relevant_settings_object_is_secure_context = relevant_settings_object_is_secure_context,+ .relevant_settings_object_policy_container = move(relevant_settings_object_policy_container),}};}@@ -719,6 +721,7 @@ SerializedEnvironmentSettingsObject EnvironmentSettingsObject::serialize()auto supported_animation_frame_provider = dedicated_worker_global_scope && dedicated_worker_global_scope->is_supported();return SerializedWorkerGlobalScope {.relevant_settings_object_is_secure_context = relevant_settings_object_is_secure_context,+ .relevant_settings_object_policy_container = move(relevant_settings_object_policy_container),.is_supported_animation_frame_provider = supported_animation_frame_provider,};}();diff --git a/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WorkerGlobalScope.cppindex d1261cd4510..5b983398c0c 100644--- a/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp+++ b/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp@@ -198,9 +198,15 @@ void WorkerGlobalScope::initialize_policy_container(GC::Ref<Fetch::Infrastructur{// 1. If workerGlobalScope's url is local but its scheme is not "blob":if (m_url.has_value() && Fetch::Infrastructure::is_local_url(m_url.value()) && m_url->scheme() != "blob"sv) {- // FIXME: 1. Assert: workerGlobalScope's owner set's size is 1.- // FIXME: 2. Set workerGlobalScope's policy container to a clone of workerGlobalScope's owner set[0]'s relevant settings object's policy container.- dbgln("FIXME: WorkerGlobalScope::initialize_policy_container: Clone owner's policy container for local, non-blob URL.");+ // 1. Assert: workerGlobalScope's owner set's size is 1.+ VERIFY(m_owner_set.size() == 1);++ // 2. Set workerGlobalScope's policy container to a clone of workerGlobalScope's owner set[0]'s relevant+ // settings object's policy container.+ auto const& owner_policy_container = m_owner_set.first().visit([](auto const& owner) -> SerializedPolicyContainer const& {+ return owner.relevant_settings_object_policy_container;+ });+ m_policy_container = create_a_policy_container_from_serialized_policy_container(owner_policy_container);return;}diff --git a/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp b/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.cppindex 7248bf87597..295b18d8490 100644--- a/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp+++ b/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp@@ -16,6 +16,7 @@ ErrorOr<void> encode(Encoder& encoder, Web::HTML::SerializedWindow const& window{TRY(encoder.encode(window.associated_document.url));TRY(encoder.encode(window.associated_document.relevant_settings_object_is_secure_context));+ TRY(encoder.encode(window.associated_document.relevant_settings_object_policy_container));return {};}@@ -27,6 +28,7 @@ ErrorOr<Web::HTML::SerializedWindow> decode(Decoder& decoder).associated_document {.url = TRY(decoder.decode<URL::URL>()),.relevant_settings_object_is_secure_context = TRY(decoder.decode<bool>()),+ .relevant_settings_object_policy_container = TRY(decoder.decode<Web::HTML::SerializedPolicyContainer>()),},};}@@ -35,6 +37,7 @@ template<>ErrorOr<void> encode(Encoder& encoder, Web::HTML::SerializedWorkerGlobalScope const& worker_global_scope){TRY(encoder.encode(worker_global_scope.relevant_settings_object_is_secure_context));+ TRY(encoder.encode(worker_global_scope.relevant_settings_object_policy_container));TRY(encoder.encode(worker_global_scope.is_supported_animation_frame_provider));return {};}@@ -44,6 +47,7 @@ ErrorOr<Web::HTML::SerializedWorkerGlobalScope> decode(Decoder& decoder){return Web::HTML::SerializedWorkerGlobalScope {.relevant_settings_object_is_secure_context = TRY(decoder.decode<bool>()),+ .relevant_settings_object_policy_container = TRY(decoder.decode<Web::HTML::SerializedPolicyContainer>()),.is_supported_animation_frame_provider = TRY(decoder.decode<bool>()),};}diff --git a/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.h b/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.hindex 5125845eba7..fd094e4f094 100644--- a/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.h+++ b/Libraries/LibWebCommon/HTML/Scripting/SerializedEnvironmentSettingsObject.h@@ -25,6 +25,7 @@ enum class CanUseCrossOriginIsolatedAPIs : u8 {struct SerializedDocument {URL::URL url;bool relevant_settings_object_is_secure_context { false };+ SerializedPolicyContainer relevant_settings_object_policy_container;};struct SerializedWindow {@@ -33,6 +34,7 @@ struct SerializedWindow {struct SerializedWorkerGlobalScope {bool relevant_settings_object_is_secure_context { false };+ SerializedPolicyContainer relevant_settings_object_policy_container;// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#concept-AnimationFrameProvider-supported// Whether the serialized global is a DedicatedWorkerGlobalScope that is a supported