LibWeb: Always set [[ErrorToRethrow]] for import validation errors

Corresponds to f6fb04a11f
This commit is contained in:
Sam Atkins 2025-07-08 12:51:06 +01:00 committed by Tim Ledbetter
parent 4e854ca44a
commit 91e8a19391
Notes: github-actions[bot] 2025-07-08 16:10:32 +00:00
3 changed files with 32 additions and 18 deletions

View file

@ -817,7 +817,7 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
return;
}
// 3. Let state be Record { [[ParseError]]: null, [[Destination]]: destination, [[PerformFetch]]: null, [[FetchClient]]: fetchClient }.
// 3. Let state be Record { [[ErrorToRethrow]]: null, [[Destination]]: destination, [[PerformFetch]]: null, [[FetchClient]]: fetchClient }.
auto state = realm.heap().allocate<FetchContext>(JS::js_null(), destination, nullptr, fetch_client);
// 4. If performFetch was given, set state.[[PerformFetch]] to performFetch.
@ -854,10 +854,10 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm,
// 7. Upon rejection of loadingPromise, run the following steps:
GC::create_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
// 1. If state.[[ErrorToRethrow]] is not null, set moduleScript's error to rethrow to state.[[ErrorToRethrow]] and run
// onComplete given moduleScript.
if (!state->parse_error.is_null()) {
module_script.set_error_to_rethrow(state->parse_error);
if (!state->error_to_rethrow.is_null()) {
module_script.set_error_to_rethrow(state->error_to_rethrow);
on_complete->function()(module_script);
}

View file

@ -59,14 +59,14 @@ class FetchContext : public JS::GraphLoadingState::HostDefined {
GC_DECLARE_ALLOCATOR(FetchContext);
public:
JS::Value parse_error; // [[ParseError]]
JS::Value error_to_rethrow; // [[ErrorToRethrow]]
Fetch::Infrastructure::Request::Destination destination; // [[Destination]]
PerformTheFetchHook perform_fetch; // [[PerformFetch]]
GC::Ref<EnvironmentSettingsObject> fetch_client; // [[FetchClient]]
private:
FetchContext(JS::Value parse_error, Fetch::Infrastructure::Request::Destination destination, PerformTheFetchHook perform_fetch, EnvironmentSettingsObject& fetch_client)
: parse_error(parse_error)
FetchContext(JS::Value error_to_rethrow, Fetch::Infrastructure::Request::Destination destination, PerformTheFetchHook perform_fetch, EnvironmentSettingsObject& fetch_client)
: error_to_rethrow(error_to_rethrow)
, destination(destination)
, perform_fetch(perform_fetch)
, fetch_client(fetch_client)
@ -76,7 +76,7 @@ private:
void visit_edges(Visitor& visitor) override
{
Base::visit_edges(visitor);
visitor.visit(parse_error);
visitor.visit(error_to_rethrow);
visitor.visit(perform_fetch);
visitor.visit(fetch_client);
}