/* * Copyright (c) 2022, Linus Groh * Copyright (c) 2023, networkException * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::WebIDL { using ReactionSteps = JS::SafeFunction(JS::Value)>; // https://webidl.spec.whatwg.org/#es-promise using Promise = JS::PromiseCapability; 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::Realm&, Promise const&, JS::Value = JS::js_undefined()); void reject_promise(JS::Realm&, Promise const&, JS::Value); JS::NonnullGCPtr react_to_promise(Promise const&, Optional on_fulfilled_callback, Optional on_rejected_callback); JS::NonnullGCPtr upon_fulfillment(Promise const&, ReactionSteps); JS::NonnullGCPtr upon_rejection(Promise const&, ReactionSteps); void mark_promise_as_handled(Promise const&); }