mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb/HTML: Track secure context as part of Serialized{Document,Worker}
This is somewhat awkward as the spec refers to 'is secure context' with respect to these objects 'relevant settings object'. A natural way of implementing this could be storing a pointer to the relevant settings object like the JS representations of these objects do (and then changing is_secure_context to accept this representation too), but for now it seems much simpler to just store a boolean for this purpose and sidestep both problems above.
This commit is contained in:
committed by
Shannon Booth
parent
cb6a4683ce
commit
025ddd385b
Notes:
github-actions[bot]
2026-02-26 06:24:21 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/025ddd385b7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8144 Reviewed-by: https://github.com/tcl3 ✅
@@ -585,11 +585,19 @@ bool is_non_secure_context(Environment const& environment)
|
||||
SerializedEnvironmentSettingsObject EnvironmentSettingsObject::serialize()
|
||||
{
|
||||
auto serialized_global = [this]() -> SerializedGlobal {
|
||||
if (auto const* window = as_if<Window>(global_object()))
|
||||
return SerializedWindow { .associated_document { .url = window->associated_document().url() } };
|
||||
|
||||
bool relevant_settings_object_is_secure_context = is_secure_context(*this);
|
||||
if (auto const* window = as_if<Window>(global_object())) {
|
||||
return SerializedWindow {
|
||||
.associated_document {
|
||||
.url = window->associated_document().url(),
|
||||
.relevant_settings_object_is_secure_context = relevant_settings_object_is_secure_context,
|
||||
}
|
||||
};
|
||||
}
|
||||
VERIFY(is<WorkerGlobalScope>(global_object()));
|
||||
return SerializedWorkerGlobalScope {};
|
||||
return SerializedWorkerGlobalScope {
|
||||
.relevant_settings_object_is_secure_context = relevant_settings_object_is_secure_context,
|
||||
};
|
||||
}();
|
||||
|
||||
return SerializedEnvironmentSettingsObject {
|
||||
|
||||
@@ -15,6 +15,7 @@ template<>
|
||||
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));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -25,20 +26,24 @@ ErrorOr<Web::HTML::SerializedWindow> decode(Decoder& decoder)
|
||||
return Web::HTML::SerializedWindow {
|
||||
.associated_document {
|
||||
.url = TRY(decoder.decode<URL::URL>()),
|
||||
.relevant_settings_object_is_secure_context = TRY(decoder.decode<bool>()),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Web::HTML::SerializedWorkerGlobalScope const&)
|
||||
ErrorOr<void> encode(Encoder& encoder, Web::HTML::SerializedWorkerGlobalScope const& worker_global_scope)
|
||||
{
|
||||
TRY(encoder.encode(worker_global_scope.relevant_settings_object_is_secure_context));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Web::HTML::SerializedWorkerGlobalScope> decode(Decoder&)
|
||||
ErrorOr<Web::HTML::SerializedWorkerGlobalScope> decode(Decoder& decoder)
|
||||
{
|
||||
return Web::HTML::SerializedWorkerGlobalScope {};
|
||||
return Web::HTML::SerializedWorkerGlobalScope {
|
||||
.relevant_settings_object_is_secure_context = TRY(decoder.decode<bool>()),
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
|
||||
@@ -22,6 +22,7 @@ enum class CanUseCrossOriginIsolatedAPIs : u8 {
|
||||
|
||||
struct SerializedDocument {
|
||||
URL::URL url;
|
||||
bool relevant_settings_object_is_secure_context { false };
|
||||
};
|
||||
|
||||
struct SerializedWindow {
|
||||
@@ -29,6 +30,7 @@ struct SerializedWindow {
|
||||
};
|
||||
|
||||
struct SerializedWorkerGlobalScope {
|
||||
bool relevant_settings_object_is_secure_context { false };
|
||||
};
|
||||
|
||||
using SerializedGlobal = Variant<SerializedWindow, SerializedWorkerGlobalScope>;
|
||||
|
||||
Reference in New Issue
Block a user