LibWeb/HTML: Make environments top level creation URL nullable

This is explicitly set to null for Workers.
This commit is contained in:
Shannon Booth 2025-04-21 16:57:31 +12:00 committed by Andrew Kaster
parent a786269687
commit 96f38dc180
Notes: github-actions[bot] 2025-04-22 15:30:49 +00:00
6 changed files with 8 additions and 7 deletions

View file

@ -548,7 +548,7 @@ bool is_secure_context(Environment const& environment)
}
// 2. If the result of Is url potentially trustworthy? given environment's top-level creation URL is "Potentially Trustworthy", then return true.
if (SecureContexts::is_url_potentially_trustworthy(environment.top_level_creation_url) == SecureContexts::Trustworthiness::PotentiallyTrustworthy)
if (SecureContexts::is_url_potentially_trustworthy(environment.top_level_creation_url.value()) == SecureContexts::Trustworthiness::PotentiallyTrustworthy)
return true;
// 3. Return false.

View file

@ -33,7 +33,8 @@ public:
URL::URL creation_url;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-creation-url
URL::URL top_level_creation_url;
// Null or a URL that represents the creation URL of the "top-level" environment. It is null for workers and worklets.
Optional<URL::URL> top_level_creation_url;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-origin
URL::Origin top_level_origin;
@ -51,7 +52,7 @@ public:
protected:
Environment() = default;
Environment(String id, URL::URL creation_url, URL::URL top_level_creation_url, URL::Origin top_level_origin, GC::Ptr<BrowsingContext> target_browsing_context)
Environment(String id, URL::URL creation_url, Optional<URL::URL> top_level_creation_url, URL::Origin top_level_origin, GC::Ptr<BrowsingContext> target_browsing_context)
: id(move(id))
, creation_url(move(creation_url))
, top_level_creation_url(move(top_level_creation_url))

View file

@ -34,7 +34,7 @@ ErrorOr<Web::HTML::SerializedEnvironmentSettingsObject> decode(Decoder& decoder)
object.id = TRY(decoder.decode<String>());
object.creation_url = TRY(decoder.decode<URL::URL>());
object.top_level_creation_url = TRY(decoder.decode<URL::URL>());
object.top_level_creation_url = TRY(decoder.decode<Optional<URL::URL>>());
object.top_level_origin = TRY(decoder.decode<URL::Origin>());
object.api_url_character_encoding = TRY(decoder.decode<String>());
object.api_base_url = TRY(decoder.decode<URL::URL>());

View file

@ -22,7 +22,7 @@ enum class CanUseCrossOriginIsolatedAPIs {
struct SerializedEnvironmentSettingsObject {
String id;
URL::URL creation_url;
URL::URL top_level_creation_url;
Optional<URL::URL> top_level_creation_url;
URL::Origin top_level_origin;
String api_url_character_encoding;