mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibWeb: Port PromiseRejectionEvent to new String
This commit is contained in:
parent
bb7ae423d5
commit
dd2d029952
5 changed files with 11 additions and 10 deletions
|
@ -138,7 +138,7 @@ JS::VM& main_thread_vm()
|
||||||
/* .promise = */ promise,
|
/* .promise = */ promise,
|
||||||
/* .reason = */ promise.result(),
|
/* .reason = */ promise.result(),
|
||||||
};
|
};
|
||||||
auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), HTML::EventNames::rejectionhandled, event_init).release_value_but_fixme_should_propagate_errors();
|
auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), String::from_deprecated_string(HTML::EventNames::rejectionhandled).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors();
|
||||||
window.dispatch_event(promise_rejection_event);
|
window.dispatch_event(promise_rejection_event);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,18 +9,18 @@
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return MUST_OR_THROW_OOM(realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init));
|
return MUST_OR_THROW_OOM(realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init));
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return create(realm, event_name, event_init);
|
return create(realm, event_name, event_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, DeprecatedFlyString 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.to_deprecated_fly_string(), event_init)
|
||||||
, m_promise(const_cast<JS::Promise*>(event_init.promise.cell()))
|
, m_promise(const_cast<JS::Promise*>(event_init.promise.cell()))
|
||||||
, m_reason(event_init.reason)
|
, m_reason(event_init.reason)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <LibJS/Heap/Handle.h>
|
#include <LibJS/Heap/Handle.h>
|
||||||
#include <LibJS/Runtime/Promise.h>
|
#include <LibJS/Runtime/Promise.h>
|
||||||
#include <LibJS/Runtime/Value.h>
|
#include <LibJS/Runtime/Value.h>
|
||||||
|
@ -23,8 +24,8 @@ class PromiseRejectionEvent final : public DOM::Event {
|
||||||
WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event);
|
WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init = {});
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {});
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
||||||
|
|
||||||
virtual ~PromiseRejectionEvent() override;
|
virtual ~PromiseRejectionEvent() override;
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ public:
|
||||||
JS::Value reason() const { return m_reason; }
|
JS::Value reason() const { return m_reason; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PromiseRejectionEvent(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
PromiseRejectionEvent(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
||||||
|
|
||||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#import <DOM/Event.idl>
|
#import <DOM/Event.idl>
|
||||||
|
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker), UseNewAKString]
|
||||||
interface PromiseRejectionEvent : Event {
|
interface PromiseRejectionEvent : Event {
|
||||||
constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
|
constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
|
||||||
// FIXME: This currently assumes that global is a WindowObject.
|
// FIXME: This currently assumes that global is a WindowObject.
|
||||||
auto& window = verify_cast<HTML::Window>(global);
|
auto& window = verify_cast<HTML::Window>(global);
|
||||||
|
|
||||||
auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init).release_value_but_fixme_should_propagate_errors();
|
auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), String::from_deprecated_string(HTML::EventNames::unhandledrejection).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
||||||
bool not_handled = window.dispatch_event(*promise_rejection_event);
|
bool not_handled = window.dispatch_event(*promise_rejection_event);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue