/* * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::WebIDL { using ReactionSteps = JS::SafeFunction(JS::Value)>; JS::NonnullGCPtr create_promise(JS::Realm&); JS::NonnullGCPtr create_resolved_promise(JS::Realm&, JS::Value); JS::NonnullGCPtr create_rejected_promise(JS::Realm&, JS::Value); void resolve_promise(JS::VM&, JS::PromiseCapability const&, JS::Value = JS::js_undefined()); void reject_promise(JS::VM&, JS::PromiseCapability const&, JS::Value); JS::NonnullGCPtr react_to_promise(JS::PromiseCapability const&, Optional on_fulfilled_callback, Optional on_rejected_callback); JS::NonnullGCPtr upon_fulfillment(JS::PromiseCapability const&, ReactionSteps); JS::NonnullGCPtr upon_rejection(JS::PromiseCapability const&, ReactionSteps); void mark_promise_as_handled(JS::PromiseCapability const&); }