Coverage Report

Created: 2026-02-14 08:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/NavigationDestination.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibJS/Heap/Heap.h>
8
#include <LibJS/Runtime/Realm.h>
9
#include <LibWeb/Bindings/Intrinsics.h>
10
#include <LibWeb/Bindings/NavigationDestinationPrototype.h>
11
#include <LibWeb/HTML/NavigationDestination.h>
12
#include <LibWeb/HTML/NavigationHistoryEntry.h>
13
14
namespace Web::HTML {
15
16
JS_DEFINE_ALLOCATOR(NavigationDestination);
17
18
JS::NonnullGCPtr<NavigationDestination> NavigationDestination::create(JS::Realm& realm)
19
0
{
20
0
    return realm.heap().allocate<NavigationDestination>(realm, realm);
21
0
}
22
23
NavigationDestination::NavigationDestination(JS::Realm& realm)
24
0
    : Bindings::PlatformObject(realm)
25
0
{
26
0
}
27
28
0
NavigationDestination::~NavigationDestination() = default;
29
30
void NavigationDestination::initialize(JS::Realm& realm)
31
0
{
32
0
    Base::initialize(realm);
33
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(NavigationDestination);
34
0
}
35
36
void NavigationDestination::visit_edges(JS::Cell::Visitor& visitor)
37
0
{
38
0
    Base::visit_edges(visitor);
39
0
    visitor.visit(m_entry);
40
0
}
41
42
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-url
43
WebIDL::ExceptionOr<String> NavigationDestination::url() const
44
0
{
45
    // The url getter steps are to return this's URL, serialized.
46
0
    return TRY_OR_THROW_OOM(vm(), String::from_byte_string(m_url.serialize()));
47
0
}
48
49
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-key
50
String NavigationDestination::key() const
51
0
{
52
    // The key getter steps are:
53
54
    // 1. If this's entry is null, then return the empty string.
55
    // 2. Return this's entry's key.
56
0
    return (m_entry == nullptr) ? String {} : m_entry->key();
57
0
}
58
59
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-id
60
String NavigationDestination::id() const
61
0
{
62
    // The id getter steps are:
63
64
    // 1. If this's entry is null, then return the empty string.
65
    // 2. Return this's entry's ID.
66
0
    return (m_entry == nullptr) ? String {} : m_entry->id();
67
0
}
68
69
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-index
70
i64 NavigationDestination::index() const
71
0
{
72
    // The index getter steps are:
73
74
    // 1. If this's entry is null, then return -1.
75
    // 2. Return this's entry's index.
76
0
    return (m_entry == nullptr) ? -1 : m_entry->index();
77
0
}
78
79
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-samedocument
80
bool NavigationDestination::same_document() const
81
0
{
82
    // The sameDocument getter steps are to return this's is same document.
83
0
    return m_is_same_document;
84
0
}
85
86
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationdestination-getstate
87
WebIDL::ExceptionOr<JS::Value> NavigationDestination::get_state()
88
0
{
89
    // The getState() method steps are to return StructuredDeserialize(this's state).
90
0
    return structured_deserialize(vm(), m_state, realm(), {});
91
0
}
92
93
}