1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

LibWeb: Implement the JS host hooks for promises, job callbacks and more

This overrides the JS host hooks to follow the spec for queuing
promises, making/calling job callbacks, unhandled promise rejection
handling and FinalizationRegistry queuing.

This also allows us to drop the on_call_stack_emptied hook in
Document::interpreter().
This commit is contained in:
Luke Wilde 2022-02-06 03:32:26 +00:00 committed by Linus Groh
parent 4c1c6ef91c
commit 17aeb99e9e
7 changed files with 290 additions and 20 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -7,6 +8,7 @@
#pragma once
#include <LibJS/Forward.h>
#include <LibJS/Runtime/JobCallback.h>
#include <LibJS/Runtime/VM.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
@ -18,6 +20,20 @@ struct WebEngineCustomData final : public JS::VM::CustomData {
HTML::EventLoop event_loop;
};
struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData {
WebEngineCustomJobCallbackData(HTML::EnvironmentSettingsObject& incumbent_settings, OwnPtr<JS::ExecutionContext> active_script_context)
: incumbent_settings(incumbent_settings)
, active_script_context(move(active_script_context))
{
}
virtual ~WebEngineCustomJobCallbackData() override { }
HTML::EnvironmentSettingsObject& incumbent_settings;
OwnPtr<JS::ExecutionContext> active_script_context;
};
HTML::ClassicScript* active_script();
JS::VM& main_thread_vm();
}