LibWeb: Update PromiseRejectionEvent's promise field to be object

This change was made in the HTML spec to address a comment from the
Gecko team for the Streams API in
a20ca78975

It also opens the door for some more Promise related refactors.
This commit is contained in:
Andrew Kaster 2024-10-25 12:36:25 -06:00 committed by Andrew Kaster
parent 352a66390f
commit 52c449293a
Notes: github-actions[bot] 2024-10-25 20:05:29 +00:00
3 changed files with 8 additions and 8 deletions

View file

@ -24,7 +24,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEve
PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
: DOM::Event(realm, event_name, event_init) : DOM::Event(realm, event_name, event_init)
, m_promise(const_cast<JS::Promise*>(event_init.promise.cell())) , m_promise(*event_init.promise)
, m_reason(event_init.reason) , m_reason(event_init.reason)
{ {
} }

View file

@ -16,7 +16,7 @@
namespace Web::HTML { namespace Web::HTML {
struct PromiseRejectionEventInit : public DOM::EventInit { struct PromiseRejectionEventInit : public DOM::EventInit {
JS::Handle<JS::Promise> promise; JS::Handle<JS::Object> promise;
JS::Value reason; JS::Value reason;
}; };
@ -31,7 +31,7 @@ public:
virtual ~PromiseRejectionEvent() override; virtual ~PromiseRejectionEvent() override;
// Needs to return a pointer for the generated JS bindings to work. // Needs to return a pointer for the generated JS bindings to work.
JS::Promise const* promise() const { return m_promise; } JS::Object const* promise() const { return m_promise; }
JS::Value reason() const { return m_reason; } JS::Value reason() const { return m_reason; }
private: private:
@ -40,7 +40,7 @@ private:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
JS::GCPtr<JS::Promise> m_promise; JS::NonnullGCPtr<JS::Object> m_promise;
JS::Value m_reason; JS::Value m_reason;
}; };

View file

@ -1,15 +1,15 @@
#import <DOM/Event.idl> #import <DOM/Event.idl>
// https://html.spec.whatwg.org/#promiserejectionevent // https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent
[Exposed=(Window,Worker)] [Exposed=*]
interface PromiseRejectionEvent : Event { interface PromiseRejectionEvent : Event {
constructor(DOMString type, PromiseRejectionEventInit eventInitDict); constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
readonly attribute Promise<any> promise; readonly attribute object promise;
readonly attribute any reason; readonly attribute any reason;
}; };
dictionary PromiseRejectionEventInit : EventInit { dictionary PromiseRejectionEventInit : EventInit {
required Promise<any> promise; required object promise;
any reason; any reason;
}; };