mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-19 08:11:58 +00:00
LibWeb: Avoid unhandled rejection when reporting module script errors
Report module script evaluation failures without replacing the returned evaluation promise or rethrowing from the reporting reaction. This avoids surfacing the same failure as both a script error and an unhandled promise rejection.
This commit is contained in:
parent
881c1484fe
commit
951e2e1986
Notes:
github-actions[bot]
2026-05-16 07:53:32 +00:00
Author: https://github.com/shannonbooth
Commit: 951e2e1986
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9428
10 changed files with 89 additions and 4 deletions
|
|
@ -301,10 +301,9 @@ WebIDL::Promise* ModuleScript::run(PreventErrorReporting prevent_error_reporting
|
|||
// 8. If preventErrorReporting is false, then upon rejection of evaluationPromise with reason, report the exception given by reason for script.
|
||||
if (prevent_error_reporting == PreventErrorReporting::No) {
|
||||
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
|
||||
evaluation_promise = WebIDL::upon_rejection(*evaluation_promise, GC::create_function(realm.heap(), [&realm](JS::Value reason) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
auto& window_or_worker = as<WindowOrWorkerGlobalScopeMixin>(realm.global_object());
|
||||
window_or_worker.report_an_exception(reason);
|
||||
return throw_completion(reason);
|
||||
WebIDL::upon_rejection(*evaluation_promise, GC::create_function(realm.heap(), [&realm](JS::Value reason) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
as<WindowOrWorkerGlobalScopeMixin>(realm.global_object()).report_an_exception(reason);
|
||||
return JS::js_undefined();
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue