Coverage Report

Created: 2025-12-18 07:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
3
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
4
 *
5
 * SPDX-License-Identifier: BSD-2-Clause
6
 */
7
8
#pragma once
9
10
#include <AK/FlyString.h>
11
#include <LibJS/Heap/Handle.h>
12
#include <LibJS/Runtime/Promise.h>
13
#include <LibJS/Runtime/Value.h>
14
#include <LibWeb/DOM/Event.h>
15
16
namespace Web::HTML {
17
18
struct PromiseRejectionEventInit : public DOM::EventInit {
19
    JS::Handle<JS::Promise> promise;
20
    JS::Value reason;
21
};
22
23
class PromiseRejectionEvent final : public DOM::Event {
24
    WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event);
25
    JS_DECLARE_ALLOCATOR(PromiseRejectionEvent);
26
27
public:
28
    [[nodiscard]] static JS::NonnullGCPtr<PromiseRejectionEvent> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& = {});
29
    static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const&);
30
31
    virtual ~PromiseRejectionEvent() override;
32
33
    // Needs to return a pointer for the generated JS bindings to work.
34
0
    JS::Promise const* promise() const { return m_promise; }
35
0
    JS::Value reason() const { return m_reason; }
36
37
private:
38
    PromiseRejectionEvent(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
39
40
    virtual void initialize(JS::Realm&) override;
41
    virtual void visit_edges(Cell::Visitor&) override;
42
43
    JS::GCPtr<JS::Promise> m_promise;
44
    JS::Value m_reason;
45
};
46
47
}