LibWeb: Create the correct error objects in XHR::handle_errors

Aborts and network errors were accidentally creating TimeoutError
exceptions instead of AbortError and NetworkError respectively.
This commit is contained in:
Luke Wilde 2023-03-23 18:37:21 +00:00 committed by Andreas Kling
parent ac5f4792a8
commit ddec4cd7f2
Notes: sideshowbarker 2024-07-17 01:13:25 +09:00

View File

@ -1112,11 +1112,11 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::handle_errors()
// 3. Otherwise, if xhrs responses aborted flag is set, run the request error steps for xhr, abort, and "AbortError" DOMException.
if (m_response->aborted())
return TRY(request_error_steps(EventNames::abort, WebIDL::TimeoutError::create(realm(), "Aborted"sv)));
return TRY(request_error_steps(EventNames::abort, WebIDL::AbortError::create(realm(), "Aborted"sv)));
// 4. Otherwise, if xhrs response is a network error, then run the request error steps for xhr, error, and "NetworkError" DOMException.
if (m_response->is_network_error())
return TRY(request_error_steps(EventNames::error, WebIDL::TimeoutError::create(realm(), "Network error"sv)));
return TRY(request_error_steps(EventNames::error, WebIDL::NetworkError::create(realm(), "Network error"sv)));
return {};
}