1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

LibWeb: Add XMLHttpRequest::timeout setter and getter

This commit is contained in:
Kenneth Myhra 2022-04-23 21:42:15 +02:00 committed by Linus Groh
parent 1e1d59cc25
commit 8b42c05648
3 changed files with 24 additions and 0 deletions

View file

@ -693,4 +693,23 @@ DOM::ExceptionOr<void> XMLHttpRequest::override_mime_type(String const& mime)
return {};
}
// https://xhr.spec.whatwg.org/#ref-for-dom-xmlhttprequest-timeout%E2%91%A2
DOM::ExceptionOr<void> XMLHttpRequest::set_timeout(u32 timeout)
{
// 1. If the current global object is a Window object and thiss synchronous flag is set,
// then throw an "InvalidAccessError" DOMException.
auto& global_object = wrapper()->global_object();
if (global_object.class_name() == "WindowObject" && m_synchronous)
return DOM::InvalidAccessError::create("Use of XMLHttpRequest's timeout attribute is not supported in the synchronous mode in window context.");
// 2. Set thiss timeout to the given value.
m_timeout = timeout;
return {};
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-timeout
u32 XMLHttpRequest::timeout() const { return m_timeout; }
}