LibWeb: Implement clean_up_after_running_script on a Realm

Taking further steps towards implementing the shadow realm spec :^)
This commit is contained in:
Shannon Booth 2024-10-21 16:18:25 +13:00 committed by Andrew Kaster
commit d6fdaf6b26
Notes: github-actions[bot] 2024-11-01 19:16:25 +00:00
10 changed files with 35 additions and 31 deletions

View file

@ -250,7 +250,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
auto result = finalization_registry.cleanup();
// 5. Clean up after running script with entry.
entry.clean_up_after_running_script();
HTML::clean_up_after_running_script(realm);
// 6. If result is an abrupt completion, then report the exception given by result.[[Value]].
if (result.is_error())
@ -309,15 +309,15 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
// 3. Let result be job().
auto result = job->function()();
// 4. If job settings is not null, then clean up after running script with job settings.
if (job_settings) {
// 4. If realm is not null, then clean up after running script with job settings.
if (realm) {
// IMPLEMENTATION DEFINED: Disassociate the realm execution context from the script or module.
job_settings->realm_execution_context().script_or_module = Empty {};
// IMPLEMENTATION DEFINED: See comment above, we need to clean up the non-standard prepare_to_run_callback() call.
job_settings->clean_up_after_running_callback();
job_settings->clean_up_after_running_script();
HTML::clean_up_after_running_script(*realm);
} else {
// Pop off the dummy execution context. See the above FIXME block about why this is done.
s_main_thread_vm->pop_execution_context();