Jacek Caban : mshtml: Make xhr.open async argument optional in IE9+ mode.

Alexandre Julliard julliard at winehq.org
Wed Jan 27 15:35:04 CST 2021


Module: wine
Branch: master
Commit: d7b852625852616b9cf183cc597f4752ad82dc4f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d7b852625852616b9cf183cc597f4752ad82dc4f

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Jan 27 19:36:57 2021 +0100

mshtml: Make xhr.open async argument optional in IE9+ mode.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/tests/documentmode.js | 14 ++++++++++++++
 dlls/mshtml/xmlhttprequest.c      | 38 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index d6589343dff..75ebe082ce0 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -122,6 +122,20 @@ sync_test("xhr_props", function() {
     test_exposed("dispatchEvent", v >= 9);
 });
 
+sync_test("xhr open", function() {
+    var e = false;
+    try {
+        (new XMLHttpRequest()).open("GET", "https://www.winehq.org/");
+    }catch(ex) {
+        e = true;
+    }
+
+    if(document.documentMode < 10)
+        ok(e, "expected exception");
+    else
+        ok(!e, "unexpected exception");
+});
+
 sync_test("style_props", function() {
     var style = document.body.style;
 
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c
index c05d5871286..8790807ce77 100644
--- a/dlls/mshtml/xmlhttprequest.c
+++ b/dlls/mshtml/xmlhttprequest.c
@@ -30,6 +30,7 @@
 
 #include "mshtml_private.h"
 #include "htmlevent.h"
+#include "mshtmdid.h"
 #include "initguid.h"
 #include "msxml6.h"
 #include "objsafe.h"
@@ -475,6 +476,29 @@ static HRESULT WINAPI HTMLXMLHttpRequest_abort(IHTMLXMLHttpRequest *iface)
     return S_OK;
 }
 
+static HRESULT HTMLXMLHttpRequest_open_hook(DispatchEx *dispex, LCID lcid, WORD flags,
+        DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
+{
+    /* If only two arguments were given, implicitly set async to false */
+    if((flags & DISPATCH_METHOD) && dp->cArgs == 2 && !dp->cNamedArgs) {
+        VARIANT args[5];
+        DISPPARAMS new_dp = {args, NULL, ARRAY_SIZE(args), 0};
+        V_VT(args) = VT_EMPTY;
+        V_VT(args+1) = VT_EMPTY;
+        V_VT(args+2) = VT_BOOL;
+        V_BOOL(args+2) = VARIANT_TRUE;
+        args[3] = dp->rgvarg[0];
+        args[4] = dp->rgvarg[1];
+
+        TRACE("implicit async\n");
+
+        return IDispatchEx_InvokeEx(&dispex->IDispatchEx_iface, DISPID_IHTMLXMLHTTPREQUEST_OPEN,
+                                    lcid, flags, &new_dp, res, ei, caller);
+    }
+
+    return S_FALSE; /* fallback to default */
+}
+
 static HRESULT WINAPI HTMLXMLHttpRequest_open(IHTMLXMLHttpRequest *iface, BSTR bstrMethod, BSTR bstrUrl, VARIANT varAsync, VARIANT varUser, VARIANT varPassword)
 {
     HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface);
@@ -847,6 +871,17 @@ static void HTMLXMLHttpRequest_bind_event(DispatchEx *dispex, eventid_t eid)
         This->event_listener->load_event = TRUE;
 }
 
+static void HTMLXMLHttpRequest_init_dispex_info(dispex_data_t *info, compat_mode_t compat_mode)
+{
+    static const dispex_hook_t xhr_hooks[] = {
+        {DISPID_IHTMLXMLHTTPREQUEST_OPEN, HTMLXMLHttpRequest_open_hook},
+        {DISPID_UNKNOWN}
+    };
+
+    EventTarget_init_dispex_info(info, compat_mode);
+    dispex_info_add_interface(info, IHTMLXMLHttpRequest_tid, compat_mode >= COMPAT_MODE_IE10 ? xhr_hooks : NULL);
+}
+
 static event_target_vtbl_t HTMLXMLHttpRequest_event_target_vtbl = {
     {
         NULL,
@@ -858,14 +893,13 @@ static event_target_vtbl_t HTMLXMLHttpRequest_event_target_vtbl = {
 };
 
 static const tid_t HTMLXMLHttpRequest_iface_tids[] = {
-    IHTMLXMLHttpRequest_tid,
     0
 };
 static dispex_static_data_t HTMLXMLHttpRequest_dispex = {
     &HTMLXMLHttpRequest_event_target_vtbl.dispex_vtbl,
     DispHTMLXMLHttpRequest_tid,
     HTMLXMLHttpRequest_iface_tids,
-    EventTarget_init_dispex_info
+    HTMLXMLHttpRequest_init_dispex_info
 };
 
 




More information about the wine-cvs mailing list