Coverage Report

Created: 2025-08-28 06:26

/src/serenity/Userland/Libraries/LibWeb/HTML/UserActivation.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/Bindings/Intrinsics.h>
8
#include <LibWeb/Bindings/UserActivationPrototype.h>
9
#include <LibWeb/HTML/UserActivation.h>
10
#include <LibWeb/HTML/Window.h>
11
12
namespace Web::HTML {
13
14
JS_DEFINE_ALLOCATOR(UserActivation);
15
16
WebIDL::ExceptionOr<JS::NonnullGCPtr<UserActivation>> UserActivation::construct_impl(JS::Realm& realm)
17
0
{
18
0
    return realm.heap().allocate<UserActivation>(realm, realm);
19
0
}
20
21
UserActivation::UserActivation(JS::Realm& realm)
22
0
    : PlatformObject(realm)
23
0
{
24
0
}
25
26
void UserActivation::initialize(JS::Realm& realm)
27
0
{
28
0
    Base::initialize(realm);
29
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(UserActivation);
30
0
}
31
32
// https://html.spec.whatwg.org/multipage/interaction.html#dom-useractivation-hasbeenactive
33
bool UserActivation::has_been_active() const
34
0
{
35
    // The hasBeenActive getter steps are to return true if this's relevant global object has sticky activation, and false otherwise.
36
0
    return verify_cast<HTML::Window>(relevant_global_object(*this)).has_sticky_activation();
37
0
}
38
39
// https://html.spec.whatwg.org/multipage/interaction.html#dom-useractivation-isactive
40
bool UserActivation::is_active() const
41
0
{
42
    // The isActive getter steps are to return true if this's relevant global object has transient activation, and false otherwise.
43
0
    return verify_cast<HTML::Window>(relevant_global_object(*this)).has_transient_activation();
44
0
}
45
46
}