From 445c3050d44dcf355cc868708f4c74bd33ce5607 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sat, 2 Jul 2022 22:33:17 +0200 Subject: [PATCH] LibWeb: Wire up XHR::ontimeout event --- Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index aea9f154b4..06a69c5666 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -638,7 +638,14 @@ DOM::ExceptionOr XMLHttpRequest::send(String body) xhr.set_status(status_code.value_or(0)); xhr.dispatch_event(DOM::Event::create(HTML::EventNames::error)); }, - m_timeout); + m_timeout, + [weak_this = make_weak_ptr()] { + auto strong_this = weak_this.strong_ref(); + if (!strong_this) + return; + auto& xhr = const_cast(*strong_this); + xhr.dispatch_event(DOM::Event::create(EventNames::timeout)); + }); } else { TODO(); }