1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:48:14 +00:00

LibWeb: Propagate Realm instead of VM more through Fetch

This makes Fetch rely less on using main_thread_vm().current_realm(),
which relies on the dummy execution context if no JavaScript is
currently running.
This commit is contained in:
Luke Wilde 2023-02-28 17:45:49 +00:00 committed by Linus Groh
parent f7ff1fd985
commit 9acc542059
19 changed files with 62 additions and 49 deletions

View file

@ -286,14 +286,14 @@ JS::NonnullGCPtr<Headers> Response::headers() const
// https://fetch.spec.whatwg.org/#dom-response-clone
WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::clone() const
{
auto& vm = this->vm();
auto& realm = this->realm();
// 1. If this is unusable, then throw a TypeError.
if (is_unusable())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Response is unusable"sv };
// 2. Let clonedResponse be the result of cloning thiss response.
auto cloned_response = TRY(m_response->clone(vm));
auto cloned_response = TRY(m_response->clone(realm));
// 3. Return the result of creating a Response object, given clonedResponse, thiss headerss guard, and thiss relevant Realm.
return TRY(Response::create(HTML::relevant_realm(*this), cloned_response, m_headers->guard()));