mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb: Implement AbortSignal.abort()
This returns an AbortSignal that is already set as aborted.
This commit is contained in:
parent
fa95e5ec0e
commit
3b7c252175
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/tcl3
Commit: 3b7c252175
Pull-request: https://github.com/SerenityOS/serenity/pull/23279
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/kalenikaliaksandr
5 changed files with 43 additions and 1 deletions
|
@ -116,4 +116,20 @@ void AbortSignal::follow(JS::NonnullGCPtr<AbortSignal> parent_signal)
|
|||
});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-abort
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortSignal>> AbortSignal::abort(JS::VM& vm, JS::Value reason)
|
||||
{
|
||||
// 1. Let signal be a new AbortSignal object.
|
||||
auto signal = TRY(construct_impl(*vm.current_realm()));
|
||||
|
||||
// 2. Set signal’s abort reason to reason if it is given; otherwise to a new "AbortError" DOMException.
|
||||
if (reason.is_undefined())
|
||||
reason = WebIDL::AbortError::create(*vm.current_realm(), "Aborted without reason"_fly_string).ptr();
|
||||
|
||||
signal->set_reason(reason);
|
||||
|
||||
// 3. Return signal.
|
||||
return signal;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue