LibWeb+LibURL: Move HTML::Origin to URL::Origin

While Origin is defined in the HTML spec - this leaves us with quite an
awkward relationship as the URL spec makes use of AO's from what is
defined in the HTML spec.

To simplify this factoring, relocate Origin into LibURL.
This commit is contained in:
Shannon Booth 2024-10-05 15:33:34 +13:00 committed by Andreas Kling
parent e9dd05b2b5
commit dc401f49ea
Notes: github-actions[bot] 2024-10-05 08:47:56 +00:00
55 changed files with 143 additions and 157 deletions

View file

@ -4656,6 +4656,7 @@ void generate_prototype_implementation(IDL::Interface const& interface, StringBu
#include <LibJS/Runtime/TypedArray.h>
#include <LibJS/Runtime/Value.h>
#include <LibJS/Runtime/ValueInlines.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/@prototype_class@.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/Intrinsics.h>
@ -4665,7 +4666,6 @@ void generate_prototype_implementation(IDL::Interface const& interface, StringBu
#include <LibWeb/DOM/NodeFilter.h>
#include <LibWeb/DOM/Range.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h>
@ -4930,6 +4930,7 @@ void generate_global_mixin_implementation(IDL::Interface const& interface, Strin
#include <LibJS/Runtime/TypedArray.h>
#include <LibJS/Runtime/Value.h>
#include <LibJS/Runtime/ValueInlines.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/@class_name@.h>
#include <LibWeb/Bindings/@prototype_name@.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
@ -4939,7 +4940,6 @@ void generate_global_mixin_implementation(IDL::Interface const& interface, Strin
#include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/DOM/NodeFilter.h>
#include <LibWeb/DOM/Range.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h>

View file

@ -96,6 +96,16 @@ ErrorOr<URL::URL> decode(Decoder& decoder)
return url;
}
template<>
ErrorOr<URL::Origin> decode(Decoder& decoder)
{
auto scheme = TRY(decoder.decode<ByteString>());
auto host = TRY(decoder.decode<URL::Host>());
u16 port = TRY(decoder.decode<u16>());
return URL::Origin { move(scheme), move(host), port };
}
template<>
ErrorOr<File> decode(Decoder& decoder)
{

View file

@ -23,6 +23,7 @@
#include <LibIPC/File.h>
#include <LibIPC/Forward.h>
#include <LibIPC/Message.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
namespace IPC {
@ -104,6 +105,9 @@ ErrorOr<UnixDateTime> decode(Decoder&);
template<>
ErrorOr<URL::URL> decode(Decoder&);
template<>
ErrorOr<URL::Origin> decode(Decoder&);
template<>
ErrorOr<File> decode(Decoder&);

View file

@ -20,6 +20,7 @@
#include <LibCore/System.h>
#include <LibIPC/Encoder.h>
#include <LibIPC/File.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
namespace IPC {
@ -114,6 +115,16 @@ ErrorOr<void> encode(Encoder& encoder, URL::URL const& value)
return {};
}
template<>
ErrorOr<void> encode(Encoder& encoder, URL::Origin const& origin)
{
TRY(encoder.encode<ByteString>(origin.scheme()));
TRY(encoder.encode(origin.host()));
TRY(encoder.encode(origin.port()));
return {};
}
template<>
ErrorOr<void> encode(Encoder& encoder, File const& file)
{

View file

@ -104,6 +104,9 @@ ErrorOr<void> encode(Encoder&, UnixDateTime const&);
template<>
ErrorOr<void> encode(Encoder&, URL::URL const&);
template<>
ErrorOr<void> encode(Encoder&, URL::Origin const&);
template<>
ErrorOr<void> encode(Encoder&, File const&);

View file

@ -7,6 +7,7 @@
#pragma once
namespace URL {
class Origin;
class URL;
class Parser;

View file

@ -8,17 +8,15 @@
#pragma once
#include <AK/ByteString.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibURL/Parser.h>
#include <LibURL/URL.h>
namespace Web::HTML {
namespace URL {
class Origin {
public:
Origin() = default;
Origin(Optional<ByteString> const& scheme, URL::Host const& host, u16 port)
Origin(Optional<ByteString> const& scheme, Host const& host, u16 port)
: m_scheme(scheme)
, m_host(host)
, m_port(port)
@ -32,7 +30,7 @@ public:
{
return m_scheme.map([](auto& str) { return str.view(); }).value_or(StringView {});
}
URL::Host const& host() const { return m_host; }
Host const& host() const { return m_host; }
u16 port() const { return m_port; }
// https://html.spec.whatwg.org/multipage/origin.html#same-origin
@ -88,7 +86,7 @@ public:
result.append("://"sv);
// 4. Append origin's host, serialized, to result.
result.append(URL::Parser::serialize_host(host()).release_value_but_fixme_should_propagate_errors().to_byte_string());
result.append(Parser::serialize_host(host()).release_value_but_fixme_should_propagate_errors().to_byte_string());
// 5. If origin's port is non-null, append a U+003A COLON character (:), and origin's port, serialized, to result.
if (port() != 0) {
@ -100,7 +98,7 @@ public:
}
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-effective-domain
Optional<URL::Host> effective_domain() const
Optional<Host> effective_domain() const
{
// 1. If origin is an opaque origin, then return null.
if (is_opaque())
@ -116,7 +114,7 @@ public:
private:
Optional<ByteString> m_scheme;
URL::Host m_host;
Host m_host;
u16 m_port { 0 };
};
@ -124,8 +122,8 @@ private:
namespace AK {
template<>
struct Traits<Web::HTML::Origin> : public DefaultTraits<Web::HTML::Origin> {
static unsigned hash(Web::HTML::Origin const& origin)
struct Traits<URL::Origin> : public DefaultTraits<URL::Origin> {
static unsigned hash(URL::Origin const& origin)
{
auto hash_without_host = pair_int_hash(origin.scheme().hash(), origin.port());
if (origin.host().has<Empty>())
@ -134,11 +132,3 @@ struct Traits<Web::HTML::Origin> : public DefaultTraits<Web::HTML::Origin> {
}
};
} // namespace AK
namespace IPC {
template<>
ErrorOr<void> encode(Encoder&, Web::HTML::Origin const&);
template<>
ErrorOr<Web::HTML::Origin> decode(Decoder&);
}

View file

@ -418,7 +418,6 @@ set(SOURCES
HTML/NavigatorBeacon.cpp
HTML/NavigatorID.cpp
HTML/Numbers.cpp
HTML/Origin.cpp
HTML/PageTransitionEvent.cpp
HTML/PolicyContainers.cpp
HTML/PopStateEvent.cpp

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/DOMImplementationPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/MainThreadVM.h>
@ -14,7 +15,6 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/DOM/XMLDocument.h>
#include <LibWeb/HTML/HTMLDocument.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/Namespace.h>
namespace Web::DOM {

View file

@ -18,6 +18,7 @@
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibURL/Origin.h>
#include <LibUnicode/Segmenter.h>
#include <LibWeb/Animations/Animation.h>
#include <LibWeb/Animations/AnimationPlaybackEvent.h>
@ -98,7 +99,6 @@
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/PopStateEvent.h>
#include <LibWeb/HTML/Scripting/ClassicScript.h>
@ -723,12 +723,12 @@ JS::GCPtr<HTML::WindowProxy const> Document::default_view() const
return const_cast<Document*>(this)->default_view();
}
HTML::Origin Document::origin() const
URL::Origin Document::origin() const
{
return m_origin;
}
void Document::set_origin(HTML::Origin const& origin)
void Document::set_origin(URL::Origin const& origin)
{
m_origin = origin;
}

View file

@ -18,6 +18,7 @@
#include <LibCore/Forward.h>
#include <LibJS/Console.h>
#include <LibJS/Forward.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibUnicode/Forward.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
@ -32,7 +33,6 @@
#include <LibWeb/HTML/History.h>
#include <LibWeb/HTML/LazyLoadingElement.h>
#include <LibWeb/HTML/NavigationType.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/VisibilityState.h>
@ -148,8 +148,8 @@ public:
String url_string() const { return MUST(m_url.to_string()); }
String document_uri() const { return url_string(); }
HTML::Origin origin() const;
void set_origin(HTML::Origin const& origin);
URL::Origin origin() const;
void set_origin(URL::Origin const& origin);
HTML::OpenerPolicy const& opener_policy() const { return m_opener_policy; }
void set_opener_policy(HTML::OpenerPolicy policy) { m_opener_policy = move(policy); }
@ -877,7 +877,7 @@ private:
String m_referrer;
// https://dom.spec.whatwg.org/#concept-document-origin
HTML::Origin m_origin;
URL::Origin m_origin;
JS::GCPtr<HTMLCollection> m_applets;
JS::GCPtr<HTMLCollection> m_anchors;

View file

@ -23,7 +23,7 @@ JS::NonnullGCPtr<DOM::Document> create_document_for_inline_content(JS::GCPtr<HTM
auto& vm = navigable->vm();
// 1. Let origin be a new opaque origin.
HTML::Origin origin {};
URL::Origin origin {};
// 2. Let coop be a new opener policy.
auto coop = HTML::OpenerPolicy {};

View file

@ -12,6 +12,7 @@
#include <LibJS/Heap/DeferGC.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibRegex/Regex.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/Bindings/NodePrototype.h>
#include <LibWeb/DOM/Attr.h>
@ -38,7 +39,6 @@
#include <LibWeb/HTML/HTMLStyleElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Layout/Node.h>

View file

@ -479,7 +479,7 @@ void DOMURL::set_hash(String const& hash)
}
// https://url.spec.whatwg.org/#concept-url-origin
HTML::Origin url_origin(URL::URL const& url)
URL::Origin url_origin(URL::URL const& url)
{
// FIXME: We should probably have an extended version of URL::URL for LibWeb instead of standalone functions like this.
@ -497,14 +497,14 @@ HTML::Origin url_origin(URL::URL const& url)
// 3. If pathURL is failure, then return a new opaque origin.
if (!path_url.is_valid())
return HTML::Origin {};
return URL::Origin {};
// 4. If pathURLs scheme is "http", "https", or "file", then return pathURLs origin.
if (path_url.scheme().is_one_of("http"sv, "https"sv, "file"sv))
return url_origin(path_url);
// 5. Return a new opaque origin.
return HTML::Origin {};
return URL::Origin {};
}
// -> "ftp"
@ -514,7 +514,7 @@ HTML::Origin url_origin(URL::URL const& url)
// -> "wss"
if (url.scheme().is_one_of("ftp"sv, "http"sv, "https"sv, "ws"sv, "wss"sv)) {
// Return the tuple origin (urls scheme, urls host, urls port, null).
return HTML::Origin(url.scheme().to_byte_string(), url.host(), url.port().value_or(0));
return URL::Origin(url.scheme().to_byte_string(), url.host(), url.port().value_or(0));
}
// -> "file"
@ -522,12 +522,12 @@ HTML::Origin url_origin(URL::URL const& url)
if (url.scheme() == "file"sv || url.scheme() == "resource"sv) {
// Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.
// Note: We must return an origin with the `file://' protocol for `file://' iframes to work from `file://' pages.
return HTML::Origin(url.scheme().to_byte_string(), String {}, 0);
return URL::Origin(url.scheme().to_byte_string(), String {}, 0);
}
// -> Otherwise
// Return a new opaque origin.
return HTML::Origin {};
return URL::Origin {};
}
// https://url.spec.whatwg.org/#concept-domain

View file

@ -92,7 +92,7 @@ private:
JS::NonnullGCPtr<URLSearchParams> m_query;
};
HTML::Origin url_origin(URL::URL const&);
URL::Origin url_origin(URL::URL const&);
bool host_is_domain(URL::Host const&);
// https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path

View file

@ -69,8 +69,8 @@ bool tao_check(Infrastructure::Request const& request, Infrastructure::Response
// validates the results of the TAO check, the nested document would still have access to the full timing
// information, but the container document would not.
if (request.mode() == Infrastructure::Request::Mode::Navigate
&& request.origin().has<HTML::Origin>()
&& !DOMURL::url_origin(request.current_url()).is_same_origin(request.origin().get<HTML::Origin>())) {
&& request.origin().has<URL::Origin>()
&& !DOMURL::url_origin(request.current_url()).is_same_origin(request.origin().get<URL::Origin>())) {
return false;
}

View file

@ -152,7 +152,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS:
// - requests unsafe-request flag is not set or requests header list is empty
&& (!request.unsafe_request() || request.header_list()->is_empty())) {
// 1. Assert: requests origin is same origin with requests clients origin.
VERIFY(request.origin().has<HTML::Origin>() && request.origin().get<HTML::Origin>().is_same_origin(request.client()->origin()));
VERIFY(request.origin().has<URL::Origin>() && request.origin().get<URL::Origin>().is_same_origin(request.client()->origin()));
// 2. Let onPreloadedResponseAvailable be an algorithm that runs the following step given a response
// response: set fetchParamss preloaded response candidate to response.
@ -353,7 +353,7 @@ WebIDL::ExceptionOr<JS::GCPtr<PendingResponse>> main_fetch(JS::Realm& realm, Inf
// -> requests current URLs scheme is "data"
// -> requests mode is "navigate" or "websocket"
else if (
(request->origin().has<HTML::Origin>() && DOMURL::url_origin(request->current_url()).is_same_origin(request->origin().get<HTML::Origin>()) && request->response_tainting() == Infrastructure::Request::ResponseTainting::Basic)
(request->origin().has<URL::Origin>() && DOMURL::url_origin(request->current_url()).is_same_origin(request->origin().get<URL::Origin>()) && request->response_tainting() == Infrastructure::Request::ResponseTainting::Basic)
|| request->current_url().scheme() == "data"sv
|| (request->mode() == Infrastructure::Request::Mode::Navigate || request->mode() == Infrastructure::Request::Mode::WebSocket)) {
// 1. Set requests response tainting to "basic".
@ -919,7 +919,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm& r
else if (request->current_url().scheme() == "file"sv || request->current_url().scheme() == "resource"sv) {
// For now, unfortunate as it is, file: URLs are left as an exercise for the reader.
// When in doubt, return a network error.
if (request->origin().has<HTML::Origin>() && (request->origin().get<HTML::Origin>().is_opaque() || request->origin().get<HTML::Origin>().scheme() == "file"sv || request->origin().get<HTML::Origin>().scheme() == "resource"sv))
if (request->origin().has<URL::Origin>() && (request->origin().get<URL::Origin>().is_opaque() || request->origin().get<URL::Origin>().scheme() == "file"sv || request->origin().get<URL::Origin>().scheme() == "resource"sv))
return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params));
else
return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'file:' or 'resource:' URL blocked"sv));
@ -1200,8 +1200,8 @@ WebIDL::ExceptionOr<JS::GCPtr<PendingResponse>> http_redirect_fetch(JS::Realm& r
// locationURLs origin, then return a network error.
if (request->mode() == Infrastructure::Request::Mode::CORS
&& location_url.includes_credentials()
&& request->origin().has<HTML::Origin>()
&& !request->origin().get<HTML::Origin>().is_same_origin(DOMURL::url_origin(location_url))) {
&& request->origin().has<URL::Origin>()
&& !request->origin().get<URL::Origin>().is_same_origin(DOMURL::url_origin(location_url))) {
return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode and different URL and request origin must not include credentials in redirect URL"sv));
}

View file

@ -172,7 +172,7 @@ bool Request::has_redirect_tainted_origin() const
}
// 2. If urls origin is not same origin with lastURLs origin and requests origin is not same origin with lastURLs origin, then return true.
auto const* request_origin = m_origin.get_pointer<HTML::Origin>();
auto const* request_origin = m_origin.get_pointer<URL::Origin>();
if (!DOMURL::url_origin(url).is_same_origin(DOMURL::url_origin(*last_url))
&& (request_origin == nullptr || !request_origin->is_same_origin(DOMURL::url_origin(*last_url)))) {
return true;
@ -194,7 +194,7 @@ String Request::serialize_origin() const
return "null"_string;
// 2. Return requests origin, serialized.
return MUST(String::from_byte_string(m_origin.get<HTML::Origin>().serialize()));
return MUST(String::from_byte_string(m_origin.get<URL::Origin>().serialize()));
}
// https://fetch.spec.whatwg.org/#byte-serializing-a-request-origin
@ -321,14 +321,14 @@ void Request::add_origin_header()
case ReferrerPolicy::ReferrerPolicy::StrictOriginWhenCrossOrigin:
// If requests origin is a tuple origin, its scheme is "https", and requests current URLs scheme is
// not "https", then set serializedOrigin to `null`.
if (m_origin.has<HTML::Origin>() && m_origin.get<HTML::Origin>().scheme() == "https"sv && current_url().scheme() != "https"sv)
if (m_origin.has<URL::Origin>() && m_origin.get<URL::Origin>().scheme() == "https"sv && current_url().scheme() != "https"sv)
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
break;
// -> "same-origin"
case ReferrerPolicy::ReferrerPolicy::SameOrigin:
// If requests origin is not same origin with requests current URLs origin, then set serializedOrigin
// to `null`.
if (m_origin.has<HTML::Origin>() && !m_origin.get<HTML::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
if (m_origin.has<URL::Origin>() && !m_origin.get<URL::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
break;
// -> Otherwise
@ -364,7 +364,7 @@ bool Request::cross_origin_embedder_policy_allows_credentials() const
// 4. If requests origin is same origin with requests current URLs origin and request does not have a redirect-tainted origin, then return true.
// 5. Return false.
auto const* request_origin = m_origin.get_pointer<HTML::Origin>();
auto const* request_origin = m_origin.get_pointer<URL::Origin>();
if (request_origin == nullptr)
return false;

View file

@ -17,10 +17,10 @@
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/HTML/Scripting/Environments.h>
@ -170,7 +170,7 @@ public:
struct InternalPriority { };
using BodyType = Variant<Empty, ByteBuffer, JS::NonnullGCPtr<Body>>;
using OriginType = Variant<Origin, HTML::Origin>;
using OriginType = Variant<Origin, URL::Origin>;
using PolicyContainerType = Variant<PolicyContainer, HTML::PolicyContainer>;
using ReferrerType = Variant<Referrer, URL::URL>;
using ReservedClientType = JS::GCPtr<HTML::Environment>;

View file

@ -6,14 +6,14 @@
#pragma once
#include <LibURL/Origin.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Origin.h>
namespace Web::Fetch::Infrastructure {
// https://fetch.spec.whatwg.org/#network-partition-key
struct NetworkPartitionKey {
HTML::Origin top_level_origin;
URL::Origin top_level_origin;
// FIXME: See https://github.com/whatwg/fetch/issues/1035
// This is the document origin in other browsers
void* second_key = nullptr;
@ -32,6 +32,6 @@ class AK::Traits<Web::Fetch::Infrastructure::NetworkPartitionKey> : public Defau
public:
static unsigned hash(Web::Fetch::Infrastructure::NetworkPartitionKey const& partition_key)
{
return ::AK::Traits<Web::HTML::Origin>::hash(partition_key.top_level_origin);
return ::AK::Traits<URL::Origin>::hash(partition_key.top_level_origin);
}
};

View file

@ -7,12 +7,12 @@
*/
#include <AK/StringBuilder.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/Crypto/Crypto.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/FileAPI/Blob.h>
#include <LibWeb/FileAPI/BlobURLStore.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Scripting/Environments.h>
namespace Web::FileAPI {

View file

@ -484,7 +484,6 @@ class NavigationDestination;
class NavigationHistoryEntry;
class NavigationTransition;
class Navigator;
class Origin;
class PageTransitionEvent;
class Path2D;
class Plugin;

View file

@ -59,16 +59,16 @@ bool url_matches_about_srcdoc(URL::URL const& url)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#determining-the-origin
HTML::Origin determine_the_origin(Optional<URL::URL> const& url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> source_origin)
URL::Origin determine_the_origin(Optional<URL::URL> const& url, SandboxingFlagSet sandbox_flags, Optional<URL::Origin> source_origin)
{
// 1. If sandboxFlags has its sandboxed origin browsing context flag set, then return a new opaque origin.
if (has_flag(sandbox_flags, SandboxingFlagSet::SandboxedOrigin)) {
return HTML::Origin {};
return URL::Origin {};
}
// 2. If url is null, then return a new opaque origin.
if (!url.has_value()) {
return HTML::Origin {};
return URL::Origin {};
}
// 3. If url is about:srcdoc, then:
@ -144,7 +144,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
[[maybe_unused]] auto unsafe_context_creation_time = HighResolutionTime::unsafe_shared_current_time();
// 3. Let creatorOrigin be null.
Optional<Origin> creator_origin = {};
Optional<URL::Origin> creator_origin = {};
// 4. Let creatorBaseURL be null.
Optional<URL::URL> creator_base_url = {};

View file

@ -15,10 +15,10 @@
#include <LibGfx/Size.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibURL/Origin.h>
#include <LibWeb/DOM/Position.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/SessionHistoryEntry.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
@ -145,7 +145,7 @@ private:
JS::GCPtr<BrowsingContext> m_opener_browsing_context;
// https://html.spec.whatwg.org/multipage/document-sequences.html#opener-origin-at-creation
Optional<HTML::Origin> m_opener_origin_at_creation;
Optional<URL::Origin> m_opener_origin_at_creation;
// https://html.spec.whatwg.org/multipage/browsers.html#is-popup
TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };
@ -168,7 +168,7 @@ private:
JS::GCPtr<BrowsingContext> m_previous_sibling;
};
HTML::Origin determine_the_origin(Optional<URL::URL> const&, SandboxingFlagSet, Optional<HTML::Origin> source_origin);
URL::Origin determine_the_origin(Optional<URL::URL> const&, SandboxingFlagSet, Optional<URL::Origin> source_origin);
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr<DOM::Element> embedder);

View file

@ -6,9 +6,9 @@
#pragma once
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/HTML/CrossOrigin/OpenerPolicy.h>
#include <LibWeb/HTML/Origin.h>
namespace Web::HTML {
@ -24,7 +24,7 @@ struct OpenerPolicyEnforcementResult {
URL::URL url;
// An origin origin.
Origin origin;
URL::Origin origin;
// An opener policy.
OpenerPolicy opener_policy;

View file

@ -7,11 +7,11 @@
#include <AK/Assertions.h>
#include <AK/Vector.h>
#include <LibJS/Runtime/PropertyKey.h>
#include <LibURL/Origin.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
#include <LibWeb/HTML/Origin.h>
namespace Web::HTML {
@ -38,7 +38,7 @@ void check_if_access_between_two_browsing_contexts_should_be_reported(
auto* accessor_top_document = accessor.top_level_browsing_context()->active_document();
// 4. Let accessorInclusiveAncestorOrigins be the list obtained by taking the origin of the active document of each of accessor's active document's inclusive ancestor navigables.
Vector<Origin> accessor_inclusive_ancestor_origins = {};
Vector<URL::Origin> accessor_inclusive_ancestor_origins = {};
auto accessor_inclusive_ancestors = accessor.active_document()->ancestor_navigables();
accessor_inclusive_ancestor_origins.ensure_capacity(accessor_inclusive_ancestors.size());
for (auto const& ancestor : accessor_inclusive_ancestors) {
@ -52,7 +52,7 @@ void check_if_access_between_two_browsing_contexts_should_be_reported(
auto* accessed_top_document = accessed->top_level_browsing_context()->active_document();
// 6. Let accessedInclusiveAncestorOrigins be the list obtained by taking the origin of the active document of each of accessed's active document's inclusive ancestor navigables.
Vector<Origin> accessed_inclusive_ancestor_origins = {};
Vector<URL::Origin> accessed_inclusive_ancestor_origins = {};
auto accessed_inclusive_ancestors = accessed->active_document()->ancestor_navigables();
accessed_inclusive_ancestor_origins.ensure_capacity(accessed_inclusive_ancestors.size());
for (auto const& ancestor : accessed_inclusive_ancestors) {

View file

@ -8,10 +8,10 @@
#pragma once
#include <LibJS/Heap/Cell.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/POSTResource.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/ReferrerPolicy/ReferrerPolicy.h>
@ -49,11 +49,11 @@ public:
[[nodiscard]] ReferrerPolicy::ReferrerPolicy request_referrer_policy() const { return m_request_referrer_policy; }
void set_request_referrer_policy(ReferrerPolicy::ReferrerPolicy request_referrer_policy) { m_request_referrer_policy = move(request_referrer_policy); }
[[nodiscard]] Optional<HTML::Origin> initiator_origin() const { return m_initiator_origin; }
void set_initiator_origin(Optional<HTML::Origin> initiator_origin) { m_initiator_origin = move(initiator_origin); }
[[nodiscard]] Optional<URL::Origin> initiator_origin() const { return m_initiator_origin; }
void set_initiator_origin(Optional<URL::Origin> initiator_origin) { m_initiator_origin = move(initiator_origin); }
[[nodiscard]] Optional<HTML::Origin> origin() const { return m_origin; }
void set_origin(Optional<HTML::Origin> origin) { m_origin = move(origin); }
[[nodiscard]] Optional<URL::Origin> origin() const { return m_origin; }
void set_origin(Optional<URL::Origin> origin) { m_origin = move(origin); }
[[nodiscard]] Optional<URL::URL> const& about_base_url() const { return m_about_base_url; }
void set_about_base_url(Optional<URL::URL> url) { m_about_base_url = move(url); }
@ -91,10 +91,10 @@ private:
ReferrerPolicy::ReferrerPolicy m_request_referrer_policy { ReferrerPolicy::DEFAULT_REFERRER_POLICY };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-initiator-origin
Optional<HTML::Origin> m_initiator_origin;
Optional<URL::Origin> m_initiator_origin;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-origin
Optional<HTML::Origin> m_origin;
Optional<URL::Origin> m_origin;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-about-base-url
Optional<URL::URL> m_about_base_url = {};

View file

@ -5,13 +5,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/HTMLIFrameElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Layout/FrameBox.h>

View file

@ -86,7 +86,7 @@ private:
URL::URL base_url;
// origin
// An origin
HTML::Origin origin;
URL::Origin origin;
// environment
// An environment
JS::GCPtr<HTML::EnvironmentSettingsObject> environment;

View file

@ -26,7 +26,7 @@ u32 ListOfAvailableImages::Key::hash() const
u32 mode_hash = static_cast<u32>(mode);
u32 origin_hash = 0;
if (origin.has_value())
origin_hash = Traits<HTML::Origin>::hash(origin.value());
origin_hash = Traits<URL::Origin>::hash(origin.value());
cached_hash = pair_int_hash(url_hash, pair_int_hash(mode_hash, origin_hash));
}
return cached_hash.value();

View file

@ -8,10 +8,10 @@
#include <AK/HashMap.h>
#include <LibJS/Heap/Cell.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/CORSSettingAttribute.h>
#include <LibWeb/HTML/Origin.h>
namespace Web::HTML {
@ -24,7 +24,7 @@ public:
struct Key {
URL::URL url;
HTML::CORSSettingAttribute mode;
Optional<HTML::Origin> origin;
Optional<URL::Origin> origin;
[[nodiscard]] bool operator==(Key const& other) const;
[[nodiscard]] u32 hash() const;

View file

@ -10,6 +10,7 @@
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibCore/Socket.h>
#include <LibIPC/File.h>
#include <LibWeb/Bindings/Transferable.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/Forward.h>

View file

@ -779,7 +779,7 @@ static WebIDL::ExceptionOr<Navigable::NavigationParamsVariant> create_navigation
auto response_holder = ResponseHolder::create(vm);
// 10. Let responseOrigin be null.
Optional<HTML::Origin> response_origin;
Optional<URL::Origin> response_origin;
// 11. Let fetchController be null.
JS::GCPtr<Fetch::Infrastructure::FetchController> fetch_controller = nullptr;
@ -1537,7 +1537,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate_to_a_fragment(URL::URL const& url,
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#evaluate-a-javascript:-url
WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> Navigable::evaluate_javascript_url(URL::URL const& url, Origin const& new_document_origin, String navigation_id)
WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> Navigable::evaluate_javascript_url(URL::URL const& url, URL::Origin const& new_document_origin, String navigation_id)
{
auto& vm = this->vm();
auto& realm = active_window()->realm();
@ -1640,7 +1640,7 @@ WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> Navigable::evaluate_javascript_url
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-to-a-javascript:-url
WebIDL::ExceptionOr<void> Navigable::navigate_to_a_javascript_url(URL::URL const& url, HistoryHandlingBehavior history_handling, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id)
WebIDL::ExceptionOr<void> Navigable::navigate_to_a_javascript_url(URL::URL const& url, HistoryHandlingBehavior history_handling, URL::Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id)
{
// 1. Assert: historyHandling is "replace".
VERIFY(history_handling == HistoryHandlingBehavior::Replace);

View file

@ -150,8 +150,8 @@ public:
WebIDL::ExceptionOr<void> navigate_to_a_fragment(URL::URL const&, HistoryHandlingBehavior, UserNavigationInvolvement, Optional<SerializationRecord> navigation_api_state, String navigation_id);
WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> evaluate_javascript_url(URL::URL const&, Origin const& new_document_origin, String navigation_id);
WebIDL::ExceptionOr<void> navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id);
WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> evaluate_javascript_url(URL::URL const&, URL::Origin const& new_document_origin, String navigation_id);
WebIDL::ExceptionOr<void> navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, URL::Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id);
bool allowed_by_sandboxing_to_navigate(Navigable const& target, SourceSnapshotParams const&);

View file

@ -6,6 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
@ -17,7 +18,6 @@
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/HTML/Window.h>

View file

@ -9,12 +9,12 @@
#include <AK/Optional.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibURL/Origin.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/CrossOrigin/OpenerPolicy.h>
#include <LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
@ -50,7 +50,7 @@ struct NavigationParams : JS::Cell {
Fetch::Infrastructure::Request::ReservedClientType reserved_environment;
// an origin to use for the new Document
Origin origin;
URL::Origin origin;
// a policy container to use for the new Document
PolicyContainer policy_container;
@ -90,7 +90,7 @@ struct NonFetchSchemeNavigationParams : JS::Cell {
bool source_snapshot_has_transient_activation = { false };
// an origin possibly for use in a user-facing prompt to confirm the invocation of an external software package
Origin initiator_origin;
URL::Origin initiator_origin;
// FIXME: a NavigationTimingType used for creating the navigation timing entry for the new Document

View file

@ -1,32 +0,0 @@
/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibWeb/HTML/Origin.h>
namespace IPC {
template<>
ErrorOr<void> encode(Encoder& encoder, Web::HTML::Origin const& origin)
{
TRY(encoder.encode<ByteString>(origin.scheme()));
TRY(encoder.encode(origin.host()));
TRY(encoder.encode(origin.port()));
return {};
}
template<>
ErrorOr<Web::HTML::Origin> decode(Decoder& decoder)
{
auto scheme = TRY(decoder.decode<ByteString>());
auto host = TRY(decoder.decode<URL::Host>());
u16 port = TRY(decoder.decode<u16>());
return Web::HTML::Origin { move(scheme), move(host), port };
}
}

View file

@ -25,14 +25,14 @@ public:
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
String api_url_character_encoding() override { return m_api_url_character_encoding; }
URL::URL api_base_url() override { return m_url; }
Origin origin() override { return m_origin; }
URL::Origin origin() override { return m_origin; }
PolicyContainer policy_container() override { return m_policy_container; }
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { return CanUseCrossOriginIsolatedAPIs::No; }
private:
String m_api_url_character_encoding;
URL::URL m_url;
HTML::Origin m_origin;
URL::Origin m_origin;
HTML::PolicyContainer m_policy_container;
};

View file

@ -8,10 +8,10 @@
#pragma once
#include <LibJS/Forward.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Scripting/ModuleMap.h>
#include <LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h>
@ -34,7 +34,7 @@ public:
URL::URL top_level_creation_url;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-origin
Origin top_level_origin;
URL::Origin top_level_origin;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-target-browsing-context
JS::GCPtr<BrowsingContext> target_browsing_context;
@ -77,7 +77,7 @@ public:
virtual URL::URL api_base_url() = 0;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-origin
virtual Origin origin() = 0;
virtual URL::Origin origin() = 0;
// A policy container https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-policy-container
virtual PolicyContainer policy_container() = 0;

View file

@ -34,10 +34,10 @@ 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_origin = TRY(decoder.decode<Web::HTML::Origin>());
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>());
object.origin = TRY(decoder.decode<Web::HTML::Origin>());
object.origin = TRY(decoder.decode<URL::Origin>());
object.policy_container = TRY(decoder.decode<Web::HTML::PolicyContainer>());
object.cross_origin_isolated_capability = TRY(decoder.decode<Web::HTML::CanUseCrossOriginIsolatedAPIs>());

View file

@ -8,8 +8,8 @@
#include <AK/String.h>
#include <LibIPC/Forward.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/PolicyContainers.h>
namespace Web::HTML {
@ -23,11 +23,11 @@ struct SerializedEnvironmentSettingsObject {
String id;
URL::URL creation_url;
URL::URL top_level_creation_url;
Origin top_level_origin;
URL::Origin top_level_origin;
String api_url_character_encoding;
URL::URL api_base_url;
Origin origin;
URL::Origin origin;
PolicyContainer policy_container;
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability;
};

View file

@ -29,7 +29,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, JS::GCPtr<Environment> reserved_environment, URL::URL top_level_creation_url, Origin top_level_origin)
void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, JS::GCPtr<Environment> reserved_environment, URL::URL top_level_creation_url, URL::Origin top_level_origin)
{
// 1. Let realm be the value of execution context's Realm component.
auto realm = execution_context->realm;
@ -104,7 +104,7 @@ URL::URL WindowEnvironmentSettingsObject::api_base_url()
}
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:concept-settings-object-origin
Origin WindowEnvironmentSettingsObject::origin()
URL::Origin WindowEnvironmentSettingsObject::origin()
{
// Return the origin of window's associated Document.
return m_window->associated_document().origin();

View file

@ -16,14 +16,14 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject {
JS_DECLARE_ALLOCATOR(WindowEnvironmentSettingsObject);
public:
static void setup(Page&, URL::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, JS::GCPtr<Environment>, URL::URL top_level_creation_url, Origin top_level_origin);
static void setup(Page&, URL::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, JS::GCPtr<Environment>, URL::URL top_level_creation_url, URL::Origin top_level_origin);
virtual ~WindowEnvironmentSettingsObject() override;
virtual JS::GCPtr<DOM::Document> responsible_document() override;
virtual String api_url_character_encoding() override;
virtual URL::URL api_base_url() override;
virtual Origin origin() override;
virtual URL::Origin origin() override;
virtual PolicyContainer policy_container() override;
virtual CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override;

View file

@ -61,7 +61,7 @@ URL::URL WorkerEnvironmentSettingsObject::api_base_url()
return m_global_scope->url();
}
Origin WorkerEnvironmentSettingsObject::origin()
URL::Origin WorkerEnvironmentSettingsObject::origin()
{
// FIXME: Return a unique opaque origin if worker global scope's url's scheme is "data", and inherited origin otherwise.
return m_origin;

View file

@ -31,7 +31,7 @@ public:
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
String api_url_character_encoding() override { return m_api_url_character_encoding; }
URL::URL api_base_url() override;
Origin origin() override;
URL::Origin origin() override;
PolicyContainer policy_container() override;
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override;
@ -39,7 +39,7 @@ private:
virtual void visit_edges(JS::Cell::Visitor&) override;
String m_api_url_character_encoding;
HTML::Origin m_origin;
URL::Origin m_origin;
JS::NonnullGCPtr<WorkerGlobalScope> m_global_scope;
};

View file

@ -99,7 +99,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable
document_state->set_document(document);
// initiator origin: null if opener is null; otherwise, document's origin
document_state->set_initiator_origin(opener ? Optional<Origin> {} : document->origin());
document_state->set_initiator_origin(opener ? Optional<URL::Origin> {} : document->origin());
// origin: document's origin
document_state->set_origin(document->origin());

View file

@ -17,6 +17,7 @@
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Shape.h>
#include <LibTextCodec/Decoder.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/WindowExposedInterfaces.h>
#include <LibWeb/Bindings/WindowPrototype.h>
@ -45,7 +46,6 @@
#include <LibWeb/HTML/MessageEvent.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/Navigator.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/PageTransitionEvent.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/Scripting/Environments.h>
@ -415,7 +415,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::local_storage()
{
// FIXME: Implement according to spec.
static HashMap<Origin, JS::Handle<Storage>> local_storage_per_origin;
static HashMap<URL::Origin, JS::Handle<Storage>> local_storage_per_origin;
auto storage = local_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle<Storage> {
return Storage::create(realm());
});
@ -426,7 +426,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::local_storage()
WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::session_storage()
{
// FIXME: Implement according to spec.
static HashMap<Origin, JS::Handle<Storage>> session_storage_per_origin;
static HashMap<URL::Origin, JS::Handle<Storage>> session_storage_per_origin;
auto storage = session_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle<Storage> {
return Storage::create(realm());
});
@ -1017,7 +1017,7 @@ WebIDL::ExceptionOr<void> Window::window_post_message_steps(JS::Value message, W
auto& incumbent_settings = incumbent_settings_object();
// 3. Let targetOrigin be options["targetOrigin"].
Variant<String, Origin> target_origin = options.target_origin;
Variant<String, URL::Origin> target_origin = options.target_origin;
// 4. If targetOrigin is a single U+002F SOLIDUS character (/), then set targetOrigin to incumbentSettings's origin.
if (options.target_origin == "/"sv) {
@ -1048,7 +1048,7 @@ WebIDL::ExceptionOr<void> Window::window_post_message_steps(JS::Value message, W
// associated Document's origin is not same origin with targetOrigin, then return.
// NOTE: Due to step 4 and 5 above, the only time it's not '*' is if target_origin contains an Origin.
if (!target_origin.has<String>()) {
auto const& actual_target_origin = target_origin.get<Origin>();
auto const& actual_target_origin = target_origin.get<URL::Origin>();
if (!document()->origin().is_same_origin(actual_target_origin))
return;
}

View file

@ -5,10 +5,10 @@
*/
#include <AK/String.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
// FIXME: This is an ad-hoc implementation of the "autoplay" policy-controlled feature:
@ -26,7 +26,7 @@ AutoplayAllowlist::AutoplayAllowlist() = default;
AutoplayAllowlist::~AutoplayAllowlist() = default;
// https://w3c.github.io/webappsec-permissions-policy/#is-feature-enabled
Decision AutoplayAllowlist::is_allowed_for_origin(DOM::Document const& document, HTML::Origin const& origin) const
Decision AutoplayAllowlist::is_allowed_for_origin(DOM::Document const& document, URL::Origin const& origin) const
{
// FIXME: 1. Let policy be documents Permissions Policy
// FIXME: 2. If policys inherited policy for feature is Disabled, return "Disabled".

View file

@ -18,7 +18,7 @@ class AutoplayAllowlist {
public:
static AutoplayAllowlist& the();
Decision is_allowed_for_origin(DOM::Document const&, HTML::Origin const&) const;
Decision is_allowed_for_origin(DOM::Document const&, URL::Origin const&) const;
void enable_globally();
ErrorOr<void> enable_for_origins(ReadonlySpan<String>);
@ -27,7 +27,7 @@ private:
AutoplayAllowlist();
~AutoplayAllowlist();
using Patterns = Vector<HTML::Origin>;
using Patterns = Vector<URL::Origin>;
struct Global { };
Optional<Variant<Patterns, Global>> m_allowlist;

View file

@ -38,7 +38,7 @@ ErrorOr<JS::NonnullGCPtr<SVGDecodedImageData>> SVGDecodedImageData::create(JS::R
auto navigation_params = navigable->heap().allocate_without_realm<HTML::NavigationParams>();
navigation_params->navigable = navigable;
navigation_params->response = response;
navigation_params->origin = HTML::Origin {};
navigation_params->origin = URL::Origin {};
navigation_params->policy_container = HTML::PolicyContainer {};
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
navigation_params->opener_policy = HTML::OpenerPolicy {};

View file

@ -6,15 +6,15 @@
#include <AK/IPv4Address.h>
#include <AK/IPv6Address.h>
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/SecureContexts/AbstractOperations.h>
namespace Web::SecureContexts {
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const& origin)
Trustworthiness is_origin_potentially_trustworthy(URL::Origin const& origin)
{
// 1. If origin is an opaque origin, return "Not Trustworthy".
if (origin.is_opaque())

View file

@ -17,7 +17,7 @@ enum class Trustworthiness {
NotTrustworthy,
};
[[nodiscard]] Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const&);
[[nodiscard]] Trustworthiness is_origin_potentially_trustworthy(URL::Origin const&);
[[nodiscard]] Trustworthiness is_url_potentially_trustworthy(URL::URL const&);
}

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Optional.h>
#include <LibURL/Origin.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Origin.h>
namespace Web::StorageAPI {
@ -17,7 +17,7 @@ struct StorageKey {
// A storage key is a tuple consisting of an origin (an origin). [HTML]
// NOTE: This is expected to change; see Client-Side Storage Partitioning https://privacycg.github.io/storage-partitioning/.
HTML::Origin origin;
URL::Origin origin;
friend bool operator==(StorageKey const& a, StorageKey const& b)
{

View file

@ -8,6 +8,7 @@
#include <AK/QuickSort.h>
#include <LibJS/Runtime/ArrayBuffer.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/WebSocketPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
@ -19,7 +20,6 @@
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/MessageEvent.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/WebIDL/AbstractOperations.h>

View file

@ -17,6 +17,7 @@
#include <LibJS/Runtime/FunctionObject.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibTextCodec/Decoder.h>
#include <LibURL/Origin.h>
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentLoading.h>
@ -35,7 +36,6 @@
#include <LibWeb/FileAPI/Blob.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLEncodingDetection.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>