Files
ladybird/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp
Andrew Kaster cc164dc1e2 Fuzzers: Convert FuzzCSSParser to use the MainThreadVM
Instead of trying to create a Window and a Document, and use those to
create a ParsingContext, just use the JS::Realm only constructor to make
sure that bindings are stashed on the main thread VM's realm.
2022-10-01 21:05:32 +01:00

25 lines
724 B
C++

/*
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/Platform/EventLoopPluginSerenity.h>
namespace {
struct Globals {
Globals();
} globals;
Globals::Globals() { Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity); }
}
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
// FIXME: There's got to be a better way to do this "correctly"
auto& vm = Web::Bindings::main_thread_vm();
(void)Web::parse_css_stylesheet(Web::CSS::Parser::ParsingContext(*vm.current_realm()), { data, size });
return 0;
}