mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-18 17:12:54 +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:
parent
f7ff1fd985
commit
9acc542059
Notes:
sideshowbarker
2024-07-17 12:02:22 +09:00
Author: https://github.com/Lubrsi
Commit: 9acc542059
Pull-request: https://github.com/SerenityOS/serenity/pull/17669
Reviewed-by: https://github.com/davidot
Reviewed-by: https://github.com/linusg ✅
19 changed files with 62 additions and 49 deletions
|
@ -195,9 +195,10 @@ ErrorOr<ByteBuffer> Request::byte_serialize_origin() const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-clone
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::clone(JS::VM& vm) const
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::clone(JS::Realm& realm) const
|
||||
{
|
||||
// To clone a request request, run these steps:
|
||||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let newRequest be a copy of request, except for its body.
|
||||
auto new_request = Infrastructure::Request::create(vm);
|
||||
|
@ -242,7 +243,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::clone(JS::VM& vm) const
|
|||
|
||||
// 2. If request’s body is non-null, set newRequest’s body to the result of cloning request’s body.
|
||||
if (auto const* body = m_body.get_pointer<Body>())
|
||||
new_request->set_body(TRY(body->clone()));
|
||||
new_request->set_body(TRY(body->clone(realm)));
|
||||
|
||||
// 3. Return newRequest.
|
||||
return new_request;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue