/src/serenity/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/MainThreadVM.h> |
8 | | #include <LibWeb/CSS/Parser/Parser.h> |
9 | | #include <LibWeb/Platform/EventLoopPluginSerenity.h> |
10 | | |
11 | | namespace { |
12 | | |
13 | | struct Globals { |
14 | | Globals(); |
15 | | } globals; |
16 | | |
17 | | Globals::Globals() |
18 | 0 | { |
19 | 0 | Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity); |
20 | 0 | MUST(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window)); |
21 | 0 | } |
22 | | |
23 | | } |
24 | | |
25 | | extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) |
26 | 88.2k | { |
27 | 88.2k | AK::set_debug_enabled(false); |
28 | | |
29 | | // FIXME: There's got to be a better way to do this "correctly" |
30 | 88.2k | auto& vm = Web::Bindings::main_thread_vm(); |
31 | 88.2k | (void)Web::parse_css_stylesheet(Web::CSS::Parser::ParsingContext(*vm.current_realm()), { data, size }); |
32 | 88.2k | return 0; |
33 | 88.2k | } |