mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
LibWeb: Make more JS modules actually run
First, we had a logic typo where we were checking parse errors for non-empty instead of non-null. Fixing this caused more modules to actually start executing. As usual, this tripped on some "empty backup incumbent settings object stack" bugs, so this patch also pushes a module execution context in two places where it makes sense. Co-Authored-By: networkException <networkexception@serenityos.org>
This commit is contained in:
parent
a2c3db8367
commit
2d69a009fb
Notes:
sideshowbarker
2024-07-16 23:51:07 +09:00
Author: https://github.com/awesomekling
Commit: 2d69a009fb
Pull-request: https://github.com/SerenityOS/serenity/pull/22183
Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 29 additions and 6 deletions
|
@ -147,6 +147,12 @@ JS::Promise* JavaScriptModuleScript::run(PreventErrorReporting)
|
|||
auto record = m_record;
|
||||
VERIFY(record);
|
||||
|
||||
// NON-STANDARD: To ensure that LibJS can find the module on the stack, we push a new execution context.
|
||||
auto module_execution_context = JS::ExecutionContext::create(heap());
|
||||
module_execution_context->realm = &settings.realm();
|
||||
module_execution_context->script_or_module = JS::NonnullGCPtr<JS::Module> { *record };
|
||||
vm().push_execution_context(*module_execution_context);
|
||||
|
||||
// 2. Set evaluationPromise to record.Evaluate().
|
||||
auto elevation_promise_or_error = record->evaluate(vm());
|
||||
|
||||
|
@ -161,6 +167,9 @@ JS::Promise* JavaScriptModuleScript::run(PreventErrorReporting)
|
|||
} else {
|
||||
evaluation_promise = elevation_promise_or_error.value();
|
||||
}
|
||||
|
||||
// NON-STANDARD: Pop the execution context mentioned above.
|
||||
vm().pop_execution_context();
|
||||
}
|
||||
|
||||
// FIXME: 7. If preventErrorReporting is false, then upon rejection of evaluationPromise with reason, report the exception given by reason for script.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue