mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibWeb: Update workarounds for fetching CORS cross-origin responses
Now that the processResponseConsumeBody algorithm receives the internal response body of the fetched object, we do not need to go out of our way to read its body from outside of fetch. However, several elements do still need to manually inspect the internal response for other data, such as response headers and status. Note that HTMLScriptElement already does the new workaround as a proper spec step.
This commit is contained in:
parent
6406a561ef
commit
8ff8309202
4 changed files with 65 additions and 164 deletions
|
@ -840,6 +840,10 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(AK::URL const& url_re
|
|||
fetch_algorithms_input.process_response = [this, byte_range = move(byte_range), failure_callback = move(failure_callback)](auto response) mutable {
|
||||
auto& realm = this->realm();
|
||||
|
||||
// FIXME: If the response is CORS cross-origin, we must use its internal response to query any of its data. See:
|
||||
// https://github.com/whatwg/html/issues/9355
|
||||
response = response->unsafe_response();
|
||||
|
||||
// 1. Let global be the media element's node document's relevant global object.
|
||||
auto& global = document().realm().global_object();
|
||||
|
||||
|
@ -882,14 +886,6 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(AK::URL const& url_re
|
|||
|
||||
// 5. Otherwise, incrementally read response's body given updateMedia, processEndOfMedia, an empty algorithm, and global.
|
||||
|
||||
// FIXME: Spec issue: If the response is CORS-cross-origin, we need to read from its internal response instead.
|
||||
// https://github.com/whatwg/html/issues/3483
|
||||
// https://github.com/whatwg/html/issues/9066
|
||||
if (response->type() == Fetch::Infrastructure::Response::Type::Opaque || response->type() == Fetch::Infrastructure::Response::Type::OpaqueRedirect) {
|
||||
auto& filtered_response = static_cast<Fetch::Infrastructure::FilteredResponse&>(*response);
|
||||
response = filtered_response.internal_response();
|
||||
}
|
||||
|
||||
VERIFY(response->body().has_value());
|
||||
auto empty_algorithm = [](auto) {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue