mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 15:58:47 +00:00
LibWeb: Use JS::HeapFunction for WebIDL promise reaction steps
Switching away from SafeFunction immediately backfired here, as we're dealing with two layers of captures, not one. Let's do the correct fix, which is to use HeapFunction. This makes the API and its behavior explicit, and keeps captures alive as long as the HeapFunction is alive. Fixes #23819.
This commit is contained in:
parent
f1eb837c3d
commit
ffac32d20e
Notes:
sideshowbarker
2024-07-16 18:26:46 +09:00
Author: https://github.com/awesomekling
Commit: ffac32d20e
Pull-request: https://github.com/SerenityOS/serenity/pull/23815
Reviewed-by: https://github.com/ADKaster
5 changed files with 68 additions and 76 deletions
|
@ -828,7 +828,7 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
|
|||
auto& loading_promise = record->load_requested_modules(state);
|
||||
|
||||
// 6. Upon fulfillment of loadingPromise, run the following steps:
|
||||
WebIDL::upon_fulfillment(loading_promise, [&realm, record, &module_script, on_complete](auto const&) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
WebIDL::upon_fulfillment(loading_promise, JS::create_heap_function(realm.heap(), [&realm, record, &module_script, on_complete](JS::Value) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
// 1. Perform record.Link().
|
||||
auto linking_result = record->link(realm.vm());
|
||||
|
||||
|
@ -840,10 +840,10 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
|
|||
on_complete->function()(module_script);
|
||||
|
||||
return JS::js_undefined();
|
||||
});
|
||||
}));
|
||||
|
||||
// 7. Upon rejection of loadingPromise, run the following steps:
|
||||
WebIDL::upon_rejection(loading_promise, [state, &module_script, on_complete](auto const&) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
WebIDL::upon_rejection(loading_promise, JS::create_heap_function(realm.heap(), [state, &module_script, on_complete](JS::Value) -> WebIDL::ExceptionOr<JS::Value> {
|
||||
// 1. If state.[[ParseError]] is not null, set moduleScript's error to rethrow to state.[[ParseError]] and run
|
||||
// onComplete given moduleScript.
|
||||
if (!state->parse_error.is_null()) {
|
||||
|
@ -857,7 +857,7 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
|
|||
}
|
||||
|
||||
return JS::js_undefined();
|
||||
});
|
||||
}));
|
||||
|
||||
fetch_client.clean_up_after_running_callback();
|
||||
realm.vm().pop_execution_context();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue