Coverage Report

Created: 2025-03-04 07:22

/src/serenity/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/Bindings/DedicatedWorkerGlobalScopeGlobalMixin.h>
10
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
11
#include <LibWeb/HTML/WorkerGlobalScope.h>
12
13
#define ENUMERATE_DEDICATED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \
14
    E(onmessage, HTML::EventNames::message)                       \
15
    E(onmessageerror, HTML::EventNames::messageerror)
16
17
namespace Web::HTML {
18
19
class DedicatedWorkerGlobalScope
20
    : public WorkerGlobalScope
21
    , public Bindings::DedicatedWorkerGlobalScopeGlobalMixin {
22
    WEB_PLATFORM_OBJECT(DedicatedWorkerGlobalScope, WorkerGlobalScope);
23
    JS_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScope);
24
25
public:
26
    virtual ~DedicatedWorkerGlobalScope() override;
27
28
    WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
29
    WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<JS::Handle<JS::Object>> const& transfer);
30
31
0
    void set_name(String name) { m_name = move(name); }
32
0
    String name() const { return m_name; }
33
34
    void close();
35
36
#undef __ENUMERATE
37
#define __ENUMERATE(attribute_name, event_name)       \
38
    void set_##attribute_name(WebIDL::CallbackType*); \
39
    WebIDL::CallbackType* attribute_name();
40
    ENUMERATE_DEDICATED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE)
41
#undef __ENUMERATE
42
43
    virtual void finalize() override;
44
45
private:
46
    DedicatedWorkerGlobalScope(JS::Realm&, JS::NonnullGCPtr<Web::Page>);
47
48
    virtual void initialize_web_interfaces_impl() override;
49
50
    String m_name;
51
};
52
53
}