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

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-01-27 19:36:57 +01:00 committed by Alexandre Julliard
parent ee611b198d
commit d7b8526258
2 changed files with 50 additions and 2 deletions

View file

@ -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;

View file

@ -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
};