Coverage Report

Created: 2025-11-16 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/Bindings/Intrinsics.h>
8
#include <LibWeb/Bindings/MessageChannelPrototype.h>
9
#include <LibWeb/DOM/Document.h>
10
#include <LibWeb/HTML/MessageChannel.h>
11
#include <LibWeb/HTML/MessagePort.h>
12
13
namespace Web::HTML {
14
15
JS_DEFINE_ALLOCATOR(MessageChannel);
16
17
WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageChannel>> MessageChannel::construct_impl(JS::Realm& realm)
18
0
{
19
0
    return realm.heap().allocate<MessageChannel>(realm, realm);
20
0
}
21
22
MessageChannel::MessageChannel(JS::Realm& realm)
23
0
    : PlatformObject(realm)
24
0
{
25
    // 1. Set this's port 1 to a new MessagePort in this's relevant Realm.
26
0
    m_port1 = MessagePort::create(realm);
27
28
    // 2. Set this's port 2 to a new MessagePort in this's relevant Realm.
29
0
    m_port2 = MessagePort::create(realm);
30
31
    // 3. Entangle this's port 1 and this's port 2.
32
0
    m_port1->entangle_with(*m_port2);
33
0
}
34
35
0
MessageChannel::~MessageChannel() = default;
36
37
void MessageChannel::visit_edges(Cell::Visitor& visitor)
38
0
{
39
0
    Base::visit_edges(visitor);
40
0
    visitor.visit(m_port1);
41
0
    visitor.visit(m_port2);
42
0
}
43
44
void MessageChannel::initialize(JS::Realm& realm)
45
0
{
46
0
    Base::initialize(realm);
47
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(MessageChannel);
48
0
}
49
50
MessagePort* MessageChannel::port1()
51
0
{
52
0
    return m_port1;
53
0
}
54
55
MessagePort* MessageChannel::port2()
56
0
{
57
0
    return m_port2;
58
0
}
59
60
MessagePort const* MessageChannel::port1() const
61
0
{
62
0
    return m_port1;
63
0
}
64
65
MessagePort const* MessageChannel::port2() const
66
0
{
67
0
    return m_port2;
68
0
}
69
70
}