1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibWeb: Implement AbortSignal.throwIfAborted

See: cfe2f1e
This commit is contained in:
Luke Wilde 2021-12-10 19:48:51 +00:00 committed by Idan Horowitz
parent 64040c136e
commit 1a5bf15b4d
3 changed files with 19 additions and 0 deletions

View file

@ -73,6 +73,22 @@ HTML::EventHandler AbortSignal::onabort()
return event_handler_attribute(HTML::EventNames::abort);
}
// https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted
JS::ThrowCompletionOr<void> AbortSignal::throw_if_aborted() const
{
auto& global_object = wrapper()->global_object();
auto& vm = global_object.vm();
// The throwIfAborted() method steps are to throw thiss abort reason, if this is aborted.
if (!aborted())
return {};
// FIXME: Remove this once VM::exception() has been removed.
vm.throw_exception(global_object, m_abort_reason);
return JS::throw_completion(m_abort_reason);
}
void AbortSignal::visit_edges(JS::Cell::Visitor& visitor)
{
visitor.visit(m_abort_reason);