LibWeb+LibURL: Consolidate Origin parsing and serialization into LibURL

Because of the previous awkward factoring of Origin we had two
implementations of Origin serializing and creation. Move the
implementation of DOMURL::url_origin into URL::origin, and
instead use the implemenation of URL::Origin::serialize for
serialization (replacing URL::serialize_origin).

This happens to fix 8 URL subtests as the two implemenations had
diverged, and URL::serialize_origin was previously missing the spec
changes of: whatwg/url@eee49fd and whatwg/url@fff33c3
This commit is contained in:
Shannon Booth 2024-10-05 17:03:51 +13:00 committed by Andreas Kling
commit 501f92b54e
Notes: github-actions[bot] 2024-10-05 08:47:31 +00:00
21 changed files with 77 additions and 101 deletions

View file

@ -173,8 +173,8 @@ 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<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)))) {
if (!url.origin().is_same_origin(last_url->origin())
&& (request_origin == nullptr || !request_origin->is_same_origin(last_url->origin()))) {
return true;
}
@ -328,7 +328,7 @@ void Request::add_origin_header()
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<URL::Origin>() && !m_origin.get<URL::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
if (m_origin.has<URL::Origin>() && !m_origin.get<URL::Origin>().is_same_origin(current_url().origin()))
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
break;
// -> Otherwise
@ -368,7 +368,7 @@ bool Request::cross_origin_embedder_policy_allows_credentials() const
if (request_origin == nullptr)
return false;
return request_origin->is_same_origin(DOMURL::url_origin(current_url())) && !has_redirect_tainted_origin();
return request_origin->is_same_origin(current_url().origin()) && !has_redirect_tainted_origin();
}
StringView request_destination_to_string(Request::Destination destination)