mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
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.
This commit is contained in:
parent
45838579c3
commit
cc164dc1e2
1 changed files with 12 additions and 9 deletions
|
@ -4,18 +4,21 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/Window.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)
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
auto vm = JS::VM::create();
|
||||
auto realm = JS::Realm::create(*vm);
|
||||
auto window = Web::HTML::Window::create(*realm);
|
||||
auto document = Web::DOM::Document::create(*window);
|
||||
(void)Web::parse_css_stylesheet(Web::CSS::Parser::ParsingContext(document), { data, 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue