LibWeb/Fetch: Deserialize abort reason

Deserialize the fetch controllers abort reason according to the spec.
Currently fetch does not support a scenario where this actually happens.
This commit is contained in:
Glenn Skrzypczak 2024-11-24 20:37:13 +01:00 committed by Jelle Raaijmakers
parent 2b1725ea51
commit b263cd11f7
Notes: github-actions[bot] 2024-12-16 11:44:20 +00:00
3 changed files with 66 additions and 12 deletions

View file

@ -44,6 +44,7 @@ public:
void process_next_manual_redirect() const;
[[nodiscard]] GC::Ref<FetchTimingInfo> extract_full_timing_info() const;
void abort(JS::Realm&, Optional<JS::Value>);
JS::Value deserialize_a_serialized_abort_reason(JS::Realm&);
void terminate();
void set_fetch_params(Badge<FetchParams>, GC::Ref<FetchParams> fetch_params) { m_fetch_params = fetch_params; }
@ -77,7 +78,7 @@ private:
// https://fetch.spec.whatwg.org/#fetch-controller-report-timing-steps
// serialized abort reason (default null)
// Null or a Record (result of StructuredSerialize).
HTML::SerializationRecord m_serialized_abort_reason;
Optional<HTML::SerializationRecord> m_serialized_abort_reason;
// https://fetch.spec.whatwg.org/#fetch-controller-next-manual-redirect-steps
// next manual redirect steps (default null)
@ -90,4 +91,22 @@ private:
u64 m_next_fetch_task_id { 0 };
};
class FetchControllerHolder : public JS::Cell {
GC_CELL(FetchControllerHolder, JS::Cell);
GC_DECLARE_ALLOCATOR(FetchControllerHolder);
public:
static GC::Ref<FetchControllerHolder> create(JS::VM&);
[[nodiscard]] GC::Ptr<FetchController> const& controller() const { return m_controller; }
void set_controller(GC::Ref<FetchController> controller) { m_controller = controller; }
private:
FetchControllerHolder();
virtual void visit_edges(Cell::Visitor&) override;
GC::Ptr<FetchController> m_controller;
};
}