mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +00:00
LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
This commit is contained in:
parent
109b190a19
commit
b75b7f0c0d
178 changed files with 565 additions and 565 deletions
|
@ -43,12 +43,12 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
|
|||
else if (auto const* blob_handle = object.get_pointer<JS::Handle<FileAPI::Blob>>()) {
|
||||
// FIXME: "set stream to the result of running object’s get stream"
|
||||
(void)blob_handle;
|
||||
stream = realm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
stream = MUST_OR_THROW_OOM(realm.heap().allocate<Streams::ReadableStream>(realm, realm));
|
||||
}
|
||||
// 4. Otherwise, set stream to a new ReadableStream object, and set up stream.
|
||||
else {
|
||||
// FIXME: "set up stream"
|
||||
stream = realm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
stream = MUST_OR_THROW_OOM(realm.heap().allocate<Streams::ReadableStream>(realm, realm));
|
||||
}
|
||||
|
||||
// 5. Assert: stream is a ReadableStream object.
|
||||
|
|
|
@ -17,7 +17,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// The new Headers(init) constructor steps are:
|
||||
auto headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
|
||||
auto headers = MUST_OR_THROW_OOM(realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm)));
|
||||
|
||||
// 1. Set this’s guard to "none".
|
||||
headers->m_guard = Guard::None;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::Bindings {
|
|||
template<>
|
||||
void Intrinsics::create_web_prototype_and_constructor<HeadersIteratorPrototype>(JS::Realm& realm)
|
||||
{
|
||||
auto prototype = heap().allocate<HeadersIteratorPrototype>(realm, realm);
|
||||
auto prototype = heap().allocate<HeadersIteratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_prototypes.set("HeadersIterator"sv, prototype);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace Web::Fetch {
|
|||
|
||||
JS::NonnullGCPtr<HeadersIterator> HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind);
|
||||
return headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
|
|
|
@ -34,7 +34,7 @@ WebIDL::ExceptionOr<Body> Body::clone() const
|
|||
|
||||
// FIXME: 1. Let « out1, out2 » be the result of teeing body’s stream.
|
||||
// FIXME: 2. Set body’s stream to out1.
|
||||
auto out2 = vm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
auto out2 = MUST_OR_THROW_OOM(vm.heap().allocate<Streams::ReadableStream>(realm, realm));
|
||||
|
||||
// 3. Return a body whose stream is out2 and other members are copied from body.
|
||||
return Body { JS::make_handle(out2), m_source, m_length };
|
||||
|
|
|
@ -85,14 +85,14 @@ JS::NonnullGCPtr<Request> Request::create(JS::Realm& realm, JS::NonnullGCPtr<Inf
|
|||
{
|
||||
// 1. Let requestObject be a new Request object with realm.
|
||||
// 2. Set requestObject’s request to request.
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, request);
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, request).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard.
|
||||
request_object->m_headers = realm.heap().allocate<Headers>(realm, realm, request->header_list());
|
||||
request_object->m_headers = realm.heap().allocate<Headers>(realm, realm, request->header_list()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
request_object->m_headers->set_guard(guard);
|
||||
|
||||
// 4. Set requestObject’s signal to a new AbortSignal object with realm.
|
||||
request_object->m_signal = realm.heap().allocate<DOM::AbortSignal>(realm, realm);
|
||||
request_object->m_signal = realm.heap().allocate<DOM::AbortSignal>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 5. Return requestObject.
|
||||
return request_object;
|
||||
|
@ -104,7 +104,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm));
|
||||
auto request_object = MUST_OR_THROW_OOM(realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm)));
|
||||
|
||||
// 1. Let request be null.
|
||||
JS::GCPtr<Infrastructure::Request> input_request;
|
||||
|
@ -389,14 +389,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
|
|||
|
||||
// 28. Set this’s signal to a new AbortSignal object with this’s relevant Realm.
|
||||
auto& this_relevant_realm = HTML::relevant_realm(*request_object);
|
||||
request_object->m_signal = realm.heap().allocate<DOM::AbortSignal>(this_relevant_realm, this_relevant_realm);
|
||||
request_object->m_signal = MUST_OR_THROW_OOM(realm.heap().allocate<DOM::AbortSignal>(this_relevant_realm, this_relevant_realm));
|
||||
|
||||
// 29. If signal is not null, then make this’s signal follow signal.
|
||||
if (input_signal != nullptr)
|
||||
request_object->m_signal->follow(*input_signal);
|
||||
|
||||
// 30. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is request’s header list and guard is "request".
|
||||
request_object->m_headers = realm.heap().allocate<Headers>(realm, realm, request->header_list());
|
||||
request_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate<Headers>(realm, realm, request->header_list()));
|
||||
request_object->m_headers->set_guard(Headers::Guard::Request);
|
||||
|
||||
// 31. If this’s request’s mode is "no-cors", then:
|
||||
|
|
|
@ -77,10 +77,10 @@ JS::NonnullGCPtr<Response> Response::create(JS::Realm& realm, JS::NonnullGCPtr<I
|
|||
{
|
||||
// 1. Let responseObject be a new Response object with realm.
|
||||
// 2. Set responseObject’s response to response.
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, response);
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, response).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard.
|
||||
response_object->m_headers = realm.heap().allocate<Headers>(realm, realm, response->header_list());
|
||||
response_object->m_headers = realm.heap().allocate<Headers>(realm, realm, response->header_list()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
response_object->m_headers->set_guard(guard);
|
||||
|
||||
// 4. Return responseObject.
|
||||
|
@ -136,14 +136,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::construct_impl(JS::Rea
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm));
|
||||
auto response_object = MUST_OR_THROW_OOM(realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm)));
|
||||
|
||||
// 1. Set this’s response to a new response.
|
||||
// NOTE: This is done at the beginning as the 'this' value Response object
|
||||
// cannot exist with a null Infrastructure::Response.
|
||||
|
||||
// 2. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is this’s response’s header list and guard is "response".
|
||||
response_object->m_headers = realm.heap().allocate<Headers>(realm, realm, response_object->response()->header_list());
|
||||
response_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate<Headers>(realm, realm, response_object->response()->header_list()));
|
||||
response_object->m_headers->set_guard(Headers::Guard::Response);
|
||||
|
||||
// 3. Let bodyWithType be null.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue