From 71228a8d865f4610d5f62ca7065ea85f01477a36 Mon Sep 17 00:00:00 2001 From: Smrtnyk Date: Fri, 4 Nov 2022 18:12:21 +0100 Subject: [PATCH] LibWeb: Bring XHR::open() closer to spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIXME addressed in open method: 10. If async is false, the current global object is a Window object, and either this’s timeout is not 0 or this’s response type is not the empty string, then throw an "InvalidAccessError" DOMException. --- Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 150ac7b598..3521298759 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -381,8 +381,13 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri parsed_url.set_password(password); } - // FIXME: 10. If async is false, the current global object is a Window object, and either this’s timeout is - // not 0 or this’s response type is not the empty string, then throw an "InvalidAccessError" DOMException. + // 10. If async is false, the current global object is a Window object, and either this’s timeout is + // not 0 or this’s response type is not the empty string, then throw an "InvalidAccessError" DOMException. + if (!async + && is(HTML::current_global_object()) + && (m_timeout != 0 || m_response_type != Bindings::XMLHttpRequestResponseType::Empty)) { + return WebIDL::InvalidAccessError::create(realm(), "synchronous XMLHttpRequests do not support timeout and responseType"); + } // FIXME: 11. Terminate the ongoing fetch operated by the XMLHttpRequest object.