[PATCH 5/8] mshtml: Implement onloadend for XMLHttpRequest.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Jun 6 07:24:13 CDT 2022


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/mshtml/htmlevent.c      |  2 ++
 dlls/mshtml/htmlevent.h      |  1 +
 dlls/mshtml/tests/xhr.js     | 12 ++++++++++--
 dlls/mshtml/xmlhttprequest.c |  9 +++++----
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index a718ad4..0f6525a 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -157,6 +157,8 @@ static const event_info_t event_info[] = {
         EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE},
     {L"load",              EVENT_TYPE_UIEVENT,   DISPID_EVMETH_ONLOAD,
         EVENT_BIND_TO_TARGET},
+    {L"loadend",           EVENT_TYPE_PROGRESS,  DISPID_EVPROP_LOADEND,
+        EVENT_BIND_TO_TARGET},
     {L"loadstart",         EVENT_TYPE_PROGRESS,  DISPID_EVPROP_LOADSTART,
         EVENT_BIND_TO_TARGET},
     {L"message",           EVENT_TYPE_MESSAGE,   DISPID_EVMETH_ONMESSAGE,
diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h
index 6af8119..615387c 100644
--- a/dlls/mshtml/htmlevent.h
+++ b/dlls/mshtml/htmlevent.h
@@ -41,6 +41,7 @@ typedef enum {
     EVENTID_KEYPRESS,
     EVENTID_KEYUP,
     EVENTID_LOAD,
+    EVENTID_LOADEND,
     EVENTID_LOADSTART,
     EVENTID_MESSAGE,
     EVENTID_MOUSEDOWN,
diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js
index d706897..0f11b78 100644
--- a/dlls/mshtml/tests/xhr.js
+++ b/dlls/mshtml/tests/xhr.js
@@ -25,7 +25,7 @@ function test_xhr() {
             return;
 
         ok(xhr.responseText === "Testing...", "unexpected responseText " + xhr.responseText);
-        if(complete_cnt++)
+        if(complete_cnt++ && !("onloadend" in xhr))
             next_test();
     }
     xhr.ontimeout = function() { ok(false, "ontimeout called"); }
@@ -33,7 +33,7 @@ function test_xhr() {
         ok(xhr.statusText === "OK", "statusText = " + xhr.statusText);
         if("onloadstart" in xhr)
             ok(loadstart, "onloadstart not fired");
-        if(complete_cnt++)
+        if(complete_cnt++ && !("onloadend" in xhr))
             next_test();
     };
     ok(xhr.onload === onload_func, "xhr.onload != onload_func");
@@ -45,6 +45,14 @@ function test_xhr() {
                 ok(props[i] in e, props[i] + " not available in loadstart");
             loadstart = true;
         };
+        xhr.onloadend = function(e) {
+            ok(complete_cnt == 2, "onloadend not fired after onload and onreadystatechange");
+            ok(loadstart, "onloadstart not fired before onloadend");
+            var props = [ "initProgressEvent", "lengthComputable", "loaded", "total" ];
+            for(var i = 0; i < props.length; i++)
+                ok(props[i] in e, props[i] + " not available in loadstart");
+            next_test();
+        };
     }
 
     xhr.open("POST", "echo.php", true);
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c
index b783d04..d12a98d 100644
--- a/dlls/mshtml/xmlhttprequest.c
+++ b/dlls/mshtml/xmlhttprequest.c
@@ -98,6 +98,7 @@ static const eventid_t events[] = {
     EVENTID_READYSTATECHANGE,
     EVENTID_LOAD,
     EVENTID_LOADSTART,
+    EVENTID_LOADEND,
     EVENTID_PROGRESS,
     EVENTID_ABORT,
     EVENTID_ERROR,
@@ -1039,18 +1040,18 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadend(IWineXMLHttpReque
 {
     HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface);
 
-    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
-    return E_NOTIMPL;
+    return set_event_handler(&This->event_target, EVENTID_LOADEND, &v);
 }
 
 static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onloadend(IWineXMLHttpRequestPrivate *iface, VARIANT *p)
 {
     HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface);
 
-    FIXME("(%p)->(%p)\n", This, p);
+    TRACE("(%p)->(%p)\n", This, p);
 
-    return E_NOTIMPL;
+    return get_event_handler(&This->event_target, EVENTID_LOADEND, p);
 }
 
 static const IWineXMLHttpRequestPrivateVtbl WineXMLHttpRequestPrivateVtbl = {
-- 
2.34.1




More information about the wine-devel mailing list