Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/mshtml_private_iface.idl | 46 +++++ dlls/mshtml/tests/documentmode.js | 10 ++ dlls/mshtml/xmlhttprequest.c | 243 +++++++++++++++++++++++++++ 4 files changed, 300 insertions(+)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index ca637e5..d8b4dde 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -282,6 +282,7 @@ typedef struct EventTarget EventTarget; XIID(IWineHTMLElementPrivate) \ XIID(IWineHTMLWindowPrivate) \ XIID(IWineHTMLWindowCompatPrivate) \ + XIID(IWineXMLHttpRequestPrivate) \ XIID(IWineMSHTMLConsole)
typedef enum { diff --git a/dlls/mshtml/mshtml_private_iface.idl b/dlls/mshtml/mshtml_private_iface.idl index a273e33..972f9b3 100644 --- a/dlls/mshtml/mshtml_private_iface.idl +++ b/dlls/mshtml/mshtml_private_iface.idl @@ -139,4 +139,50 @@ interface IWineDOMTokenList : IDispatch HRESULT toString([retval, out] BSTR *String); }
+const long DISPID_IWINEXMLHTTPREQUESTPRIVATE_OVERRIDEMIMETYPE = 5; +[ + odl, + oleautomation, + dual, + hidden, + uuid(08ef0edd-5fb8-4178-a2f0-9f686e00441c) +] +interface IWineXMLHttpRequestPrivate : IDispatch +{ + [propget, id(1)] + HRESULT response([retval, out] VARIANT *p); + [propput, id(2)] + HRESULT responseType([in] BSTR v); + [propget, id(2)] + HRESULT responseType([retval, out] BSTR *p); + [propget, id(3)] + HRESULT upload([retval, out] IDispatch **p); + [propput, id(4)] + HRESULT withCredentials([in] VARIANT_BOOL v); + [propget, id(4)] + HRESULT withCredentials([retval, out] VARIANT_BOOL *p); + [id(DISPID_IWINEXMLHTTPREQUESTPRIVATE_OVERRIDEMIMETYPE)] + HRESULT overrideMimeType([in] BSTR mimeType); + [propput, id(DISPID_EVPROP_ONERROR)] + HRESULT onerror([in] VARIANT v); + [propget, id(DISPID_EVPROP_ONERROR)] + HRESULT onerror([retval, out] VARIANT *p); + [propput, id(DISPID_EVPROP_ONABORT)] + HRESULT onabort([in] VARIANT v); + [propget, id(DISPID_EVPROP_ONABORT)] + HRESULT onabort([retval, out] VARIANT *p); + [propput, id(DISPID_EVPROP_PROGRESS)] + HRESULT onprogress([in] VARIANT v); + [propget, id(DISPID_EVPROP_PROGRESS)] + HRESULT onprogress([retval, out] VARIANT *p); + [propput, id(DISPID_EVPROP_LOADSTART)] + HRESULT onloadstart([in] VARIANT v); + [propget, id(DISPID_EVPROP_LOADSTART)] + HRESULT onloadstart([retval, out] VARIANT *p); + [propput, id(DISPID_EVPROP_LOADEND)] + HRESULT onloadend([in] VARIANT v); + [propget, id(DISPID_EVPROP_LOADEND)] + HRESULT onloadend([retval, out] VARIANT *p); +} + } /* library MSHTML_private */ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 8503523..f2da811 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -397,8 +397,18 @@ sync_test("xhr_props", function() { test_exposed("addEventListener", v >= 9); test_exposed("removeEventListener", v >= 9); test_exposed("dispatchEvent", v >= 9); + test_exposed("onabort", v >= 10); + test_exposed("onerror", v >= 10); + test_exposed("onloadend", v >= 10); + test_exposed("onloadstart", v >= 10); + test_exposed("onprogress", v >= 10); test_exposed("ontimeout", true); + test_exposed("overrideMimeType", v >= 11); + test_exposed("response", v >= 10); + test_exposed("responseType", v >= 10); test_exposed("timeout", true); + test_exposed("upload", v >= 10); + test_exposed("withCredentials", v >= 10); });
sync_test("stylesheet_props", function() { diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 966dc8d..12356f1 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -97,6 +97,7 @@ static HRESULT return_nscstr(nsresult nsres, nsACString *nscstr, BSTR *p) static const eventid_t events[] = { EVENTID_READYSTATECHANGE, EVENTID_LOAD, + EVENTID_ERROR, EVENTID_TIMEOUT, };
@@ -111,6 +112,7 @@ struct HTMLXMLHttpRequest { EventTarget event_target; IHTMLXMLHttpRequest IHTMLXMLHttpRequest_iface; IHTMLXMLHttpRequest2 IHTMLXMLHttpRequest2_iface; + IWineXMLHttpRequestPrivate IWineXMLHttpRequestPrivate_iface; IProvideClassInfo2 IProvideClassInfo2_iface; LONG ref; nsIXMLHttpRequest *nsxhr; @@ -240,6 +242,8 @@ static HRESULT WINAPI HTMLXMLHttpRequest_QueryInterface(IHTMLXMLHttpRequest *ifa *ppv = &This->IHTMLXMLHttpRequest_iface; }else if(IsEqualGUID(&IID_IHTMLXMLHttpRequest2, riid)) { *ppv = &This->IHTMLXMLHttpRequest2_iface; + }else if(IsEqualGUID(&IID_IWineXMLHttpRequestPrivate, riid)) { + *ppv = &This->IWineXMLHttpRequestPrivate_iface; }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) { *ppv = &This->IProvideClassInfo2_iface; }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) { @@ -841,6 +845,238 @@ static const IHTMLXMLHttpRequest2Vtbl HTMLXMLHttpRequest2Vtbl = { HTMLXMLHttpRequest2_get_ontimeout };
+static inline HTMLXMLHttpRequest *impl_from_IWineXMLHttpRequestPrivate(IWineXMLHttpRequestPrivate *iface) +{ + return CONTAINING_RECORD(iface, HTMLXMLHttpRequest, IWineXMLHttpRequestPrivate_iface); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_QueryInterface(IWineXMLHttpRequestPrivate *iface, REFIID riid, void **ppv) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IHTMLXMLHttpRequest_QueryInterface(&This->IHTMLXMLHttpRequest_iface, riid, ppv); +} + +static ULONG WINAPI HTMLXMLHttpRequest_private_AddRef(IWineXMLHttpRequestPrivate *iface) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IHTMLXMLHttpRequest_AddRef(&This->IHTMLXMLHttpRequest_iface); +} + +static ULONG WINAPI HTMLXMLHttpRequest_private_Release(IWineXMLHttpRequestPrivate *iface) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IHTMLXMLHttpRequest_Release(&This->IHTMLXMLHttpRequest_iface); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_GetTypeInfoCount(IWineXMLHttpRequestPrivate *iface, UINT *pctinfo) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IDispatchEx_GetTypeInfoCount(&This->event_target.dispex.IDispatchEx_iface, pctinfo); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_GetTypeInfo(IWineXMLHttpRequestPrivate *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IDispatchEx_GetTypeInfo(&This->event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_GetIDsOfNames(IWineXMLHttpRequestPrivate *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IDispatchEx_GetIDsOfNames(&This->event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames, + lcid, rgDispId); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_Invoke(IWineXMLHttpRequestPrivate *iface, DISPID dispIdMember, REFIID riid, LCID lcid, + WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + return IDispatchEx_Invoke(&This->event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_response(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_responseType(IWineXMLHttpRequestPrivate *iface, BSTR v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_responseType(IWineXMLHttpRequestPrivate *iface, BSTR *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_upload(IWineXMLHttpRequestPrivate *iface, IDispatch **p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_withCredentials(IWineXMLHttpRequestPrivate *iface, VARIANT_BOOL v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%x)\n", This, v); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_withCredentials(IWineXMLHttpRequestPrivate *iface, VARIANT_BOOL *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_overrideMimeType(IWineXMLHttpRequestPrivate *iface, BSTR mimeType) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_w(mimeType)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onerror(IWineXMLHttpRequestPrivate *iface, VARIANT v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + return set_event_handler(&This->event_target, EVENTID_ERROR, &v); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onerror(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + TRACE("(%p)->(%p)\n", This, p); + + return get_event_handler(&This->event_target, EVENTID_ERROR, p); +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onabort(IWineXMLHttpRequestPrivate *iface, VARIANT v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onabort(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onprogress(IWineXMLHttpRequestPrivate *iface, VARIANT v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onprogress(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadstart(IWineXMLHttpRequestPrivate *iface, VARIANT v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onloadstart(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadend(IWineXMLHttpRequestPrivate *iface, VARIANT v) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onloadend(IWineXMLHttpRequestPrivate *iface, VARIANT *p) +{ + HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + + FIXME("(%p)->(%p)\n", This, p); + + return E_NOTIMPL; +} + +static const IWineXMLHttpRequestPrivateVtbl WineXMLHttpRequestPrivateVtbl = { + HTMLXMLHttpRequest_private_QueryInterface, + HTMLXMLHttpRequest_private_AddRef, + HTMLXMLHttpRequest_private_Release, + HTMLXMLHttpRequest_private_GetTypeInfoCount, + HTMLXMLHttpRequest_private_GetTypeInfo, + HTMLXMLHttpRequest_private_GetIDsOfNames, + HTMLXMLHttpRequest_private_Invoke, + HTMLXMLHttpRequest_private_get_response, + HTMLXMLHttpRequest_private_put_responseType, + HTMLXMLHttpRequest_private_get_responseType, + HTMLXMLHttpRequest_private_get_upload, + HTMLXMLHttpRequest_private_put_withCredentials, + HTMLXMLHttpRequest_private_get_withCredentials, + HTMLXMLHttpRequest_private_overrideMimeType, + HTMLXMLHttpRequest_private_put_onerror, + HTMLXMLHttpRequest_private_get_onerror, + HTMLXMLHttpRequest_private_put_onabort, + HTMLXMLHttpRequest_private_get_onabort, + HTMLXMLHttpRequest_private_put_onprogress, + HTMLXMLHttpRequest_private_get_onprogress, + HTMLXMLHttpRequest_private_put_onloadstart, + HTMLXMLHttpRequest_private_get_onloadstart, + HTMLXMLHttpRequest_private_put_onloadend, + HTMLXMLHttpRequest_private_get_onloadend +}; + static inline HTMLXMLHttpRequest *impl_from_IProvideClassInfo2(IProvideClassInfo2 *iface) { return CONTAINING_RECORD(iface, HTMLXMLHttpRequest, IProvideClassInfo2_iface); @@ -987,9 +1223,15 @@ static void HTMLXMLHttpRequest_init_dispex_info(dispex_data_t *info, compat_mode {DISPID_IHTMLXMLHTTPREQUEST_OPEN, HTMLXMLHttpRequest_open_hook}, {DISPID_UNKNOWN} }; + static const dispex_hook_t private_ie10_hooks[] = { + {DISPID_IWINEXMLHTTPREQUESTPRIVATE_OVERRIDEMIMETYPE}, + {DISPID_UNKNOWN} + };
EventTarget_init_dispex_info(info, compat_mode); dispex_info_add_interface(info, IHTMLXMLHttpRequest_tid, compat_mode >= COMPAT_MODE_IE10 ? xhr_hooks : NULL); + if(compat_mode >= COMPAT_MODE_IE10) + dispex_info_add_interface(info, IWineXMLHttpRequestPrivate_tid, compat_mode == COMPAT_MODE_IE10 ? private_ie10_hooks : NULL); }
static event_target_vtbl_t HTMLXMLHttpRequest_event_target_vtbl = { @@ -1123,6 +1365,7 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor
ret->IHTMLXMLHttpRequest_iface.lpVtbl = &HTMLXMLHttpRequestVtbl; ret->IHTMLXMLHttpRequest2_iface.lpVtbl = &HTMLXMLHttpRequest2Vtbl; + ret->IWineXMLHttpRequestPrivate_iface.lpVtbl = &WineXMLHttpRequestPrivateVtbl; ret->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl; EventTarget_Init(&ret->event_target, (IUnknown*)&ret->IHTMLXMLHttpRequest_iface, &HTMLXMLHttpRequest_dispex, This->window->doc->document_mode);
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/script.c | 2 ++ dlls/mshtml/tests/xhr.js | 20 ++++++++++++++++++++ dlls/mshtml/xmlhttprequest.c | 9 +++++---- 3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c index 401e130..e368824 100644 --- a/dlls/mshtml/tests/script.c +++ b/dlls/mshtml/tests/script.c @@ -3079,6 +3079,8 @@ static void report_data(ProtocolHandler *This)
hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, &IID_IHttpNegotiate, (void**)&http_negotiate); IServiceProvider_Release(service_provider); + if(This->delay && hres == E_FAIL) /* aborted too quickly */ + return; ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08lx\n", hres);
hres = IUri_GetDisplayUri(This->uri, &url); diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index 6228f73..dd86331 100644 --- a/dlls/mshtml/tests/xhr.js +++ b/dlls/mshtml/tests/xhr.js @@ -41,6 +41,25 @@ function test_xhr() { xhr.send("Testing..."); }
+function test_abort() { + var xhr = new XMLHttpRequest(); + if(!("onabort" in xhr)) { next_test(); return; } + + xhr.onreadystatechange = function() { + if(xhr.readyState != 4) + return; + todo_wine_if(v < 10). + ok(v >= 10, "onreadystatechange called"); + } + xhr.onload = function() { ok(false, "onload called"); } + xhr.onabort = function(e) { next_test(); } + + xhr.open("POST", "echo.php?delay", true); + xhr.setRequestHeader("X-Test", "True"); + xhr.send("Abort Test"); + xhr.abort(); +} + function test_timeout() { var xhr = new XMLHttpRequest(); var v = document.documentMode; @@ -74,5 +93,6 @@ function test_timeout() {
var tests = [ test_xhr, + test_abort, test_timeout ]; diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 12356f1..54e84cf 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -97,6 +97,7 @@ static HRESULT return_nscstr(nsresult nsres, nsACString *nscstr, BSTR *p) static const eventid_t events[] = { EVENTID_READYSTATECHANGE, EVENTID_LOAD, + EVENTID_ABORT, EVENTID_ERROR, EVENTID_TIMEOUT, }; @@ -982,18 +983,18 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onabort(IWineXMLHttpRequest { 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_ABORT, &v); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onabort(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_ABORT, p); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onprogress(IWineXMLHttpRequestPrivate *iface, VARIANT v)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116314
Your paranoid android.
=== w7u_adm (32 bit report) ===
mshtml: events.c:1089: Test failed: unexpected call img_onerror events: Timeout
=== w10pro64 (32 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w10pro64_zh_CN (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
I tried to add tests but they seem unreliable, in that sometimes it doesn't fire at all.
dlls/mshtml/htmlevent.c | 2 ++ dlls/mshtml/htmlevent.h | 1 + dlls/mshtml/xmlhttprequest.c | 9 +++++---- 3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 49392bf..cf0de22 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -175,6 +175,8 @@ static const event_info_t event_info[] = { EVENT_FIXME}, {L"paste", EVENT_TYPE_CLIPBOARD, DISPID_EVMETH_ONPASTE, EVENT_FIXME | EVENT_BUBBLES | EVENT_CANCELABLE}, + {L"progress", EVENT_TYPE_PROGRESS, DISPID_EVPROP_PROGRESS, + EVENT_BIND_TO_TARGET}, {L"readystatechange", EVENT_TYPE_EVENT, DISPID_EVMETH_ONREADYSTATECHANGE, 0}, {L"resize", EVENT_TYPE_UIEVENT, DISPID_EVMETH_ONRESIZE, diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 58dbc43..3f399da 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -50,6 +50,7 @@ typedef enum { EVENTID_MOUSEWHEEL, EVENTID_MSTHUMBNAILCLICK, EVENTID_PASTE, + EVENTID_PROGRESS, EVENTID_READYSTATECHANGE, EVENTID_RESIZE, EVENTID_SCROLL, diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 54e84cf..b5973c3 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -97,6 +97,7 @@ static HRESULT return_nscstr(nsresult nsres, nsACString *nscstr, BSTR *p) static const eventid_t events[] = { EVENTID_READYSTATECHANGE, EVENTID_LOAD, + EVENTID_PROGRESS, EVENTID_ABORT, EVENTID_ERROR, EVENTID_TIMEOUT, @@ -1001,18 +1002,18 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onprogress(IWineXMLHttpRequ { 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_PROGRESS, &v); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onprogress(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_PROGRESS, p); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadstart(IWineXMLHttpRequestPrivate *iface, VARIANT v)
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlevent.c | 2 ++ dlls/mshtml/htmlevent.h | 1 + dlls/mshtml/tests/xhr.js | 13 ++++++++++++- dlls/mshtml/xmlhttprequest.c | 9 +++++---- 4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index cf0de22..a718ad4 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"loadstart", EVENT_TYPE_PROGRESS, DISPID_EVPROP_LOADSTART, + EVENT_BIND_TO_TARGET}, {L"message", EVENT_TYPE_MESSAGE, DISPID_EVMETH_ONMESSAGE, 0}, {L"mousedown", EVENT_TYPE_MOUSE, DISPID_EVMETH_ONMOUSEDOWN, diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 3f399da..6af8119 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -41,6 +41,7 @@ typedef enum { EVENTID_KEYPRESS, EVENTID_KEYUP, EVENTID_LOAD, + EVENTID_LOADSTART, EVENTID_MESSAGE, EVENTID_MOUSEDOWN, EVENTID_MOUSEMOVE, diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index dd86331..d706897 100644 --- a/dlls/mshtml/tests/xhr.js +++ b/dlls/mshtml/tests/xhr.js @@ -18,7 +18,7 @@
function test_xhr() { var xhr = new XMLHttpRequest(); - var complete_cnt = 0; + var complete_cnt = 0, loadstart = false;
xhr.onreadystatechange = function() { if(xhr.readyState != 4) @@ -31,10 +31,21 @@ function test_xhr() { xhr.ontimeout = function() { ok(false, "ontimeout called"); } var onload_func = xhr.onload = function() { ok(xhr.statusText === "OK", "statusText = " + xhr.statusText); + if("onloadstart" in xhr) + ok(loadstart, "onloadstart not fired"); if(complete_cnt++) next_test(); }; ok(xhr.onload === onload_func, "xhr.onload != onload_func"); + if("onloadstart" in xhr) { + xhr.onloadstart = function(e) { + ok(complete_cnt == 0, "onloadstart fired after onload"); + 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"); + loadstart = true; + }; + }
xhr.open("POST", "echo.php", true); xhr.setRequestHeader("X-Test", "True"); diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index b5973c3..b783d04 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -97,6 +97,7 @@ static HRESULT return_nscstr(nsresult nsres, nsACString *nscstr, BSTR *p) static const eventid_t events[] = { EVENTID_READYSTATECHANGE, EVENTID_LOAD, + EVENTID_LOADSTART, EVENTID_PROGRESS, EVENTID_ABORT, EVENTID_ERROR, @@ -1020,18 +1021,18 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadstart(IWineXMLHttpReq { 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_LOADSTART, &v); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_get_onloadstart(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_LOADSTART, p); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onloadend(IWineXMLHttpRequestPrivate *iface, VARIANT v)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116316
Your paranoid android.
=== w7u_el (32 bit report) ===
mshtml: script.c:644: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1654521664704 expected 1654521664782"
=== w1064_2qxl (64 bit report) ===
mshtml: script.c:3114: Test failed: ReportResult failed: 80ef0001
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@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 = {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116317
Your paranoid android.
=== w10pro64_ar (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/xhr.js | 6 ++++++ dlls/mshtml/xmlhttprequest.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index 0f11b78..c450384 100644 --- a/dlls/mshtml/tests/xhr.js +++ b/dlls/mshtml/tests/xhr.js @@ -57,6 +57,12 @@ function test_xhr() {
xhr.open("POST", "echo.php", true); xhr.setRequestHeader("X-Test", "True"); + if("withCredentials" in xhr) { + ok(xhr.withCredentials === false, "default withCredentials = " + xhr.withCredentials); + xhr.withCredentials = true; + ok(xhr.withCredentials === true, "withCredentials = " + xhr.withCredentials); + xhr.withCredentials = false; + } xhr.send("Testing..."); }
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index d12a98d..8fa91e9 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -941,18 +941,24 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_put_withCredentials(IWineXMLHtt { HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface);
- FIXME("(%p)->(%x)\n", This, v); + TRACE("(%p)->(%x)\n", This, v);
- return E_NOTIMPL; + return map_nsresult(nsIXMLHttpRequest_SetWithCredentials(This->nsxhr, !!v)); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_get_withCredentials(IWineXMLHttpRequestPrivate *iface, VARIANT_BOOL *p) { HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + nsresult nsres; + cpp_bool b;
- FIXME("(%p)->(%p)\n", This, p); + TRACE("(%p)->(%p)\n", This, p);
- return E_NOTIMPL; + nsres = nsIXMLHttpRequest_GetWithCredentials(This->nsxhr, &b); + if(NS_FAILED(nsres)) + return map_nsresult(nsres); + *p = b ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; }
static HRESULT WINAPI HTMLXMLHttpRequest_private_overrideMimeType(IWineXMLHttpRequestPrivate *iface, BSTR mimeType)
Signed-off-by: Jacek Caban jacek@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116318
Your paranoid android.
=== w10pro64_ar (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w10pro64_ja (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w10pro64_zh_CN (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
For some reason, Gecko returns an XML document here, but native follows the spec.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/script.c | 10 ++++++- dlls/mshtml/tests/xhr.js | 57 ++++++++++++++++++++++++++++++++++-- dlls/mshtml/xmlhttprequest.c | 29 ++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c index e368824..efd161d 100644 --- a/dlls/mshtml/tests/script.c +++ b/dlls/mshtml/tests/script.c @@ -3043,6 +3043,7 @@ typedef struct { IInternetProtocolSink *sink; BINDINFO bind_info;
+ BSTR content_type; IStream *stream; char *data; ULONG size; @@ -3068,6 +3069,7 @@ static void report_data(ProtocolHandler *This) IServiceProvider *service_provider; IHttpNegotiate *http_negotiate; WCHAR *addl_headers = NULL; + WCHAR headers_buf[128]; BSTR headers, url; HRESULT hres;
@@ -3091,7 +3093,10 @@ static void report_data(ProtocolHandler *This)
CoTaskMemFree(addl_headers);
- headers = SysAllocString(L"HTTP/1.1 200 OK\r\n\r\n"); + if(This->content_type) + swprintf(headers_buf, ARRAY_SIZE(headers_buf), L"HTTP/1.1 200 OK\r\nContent-Type: %s\r\n", This->content_type); + + headers = SysAllocString(This->content_type ? headers_buf : L"HTTP/1.1 200 OK\r\n\r\n"); hres = IHttpNegotiate_OnResponse(http_negotiate, 200, headers, NULL, NULL); ok(hres == S_OK, "OnResponse failed: %08lx\n", hres); SysFreeString(headers); @@ -3250,6 +3255,7 @@ static ULONG WINAPI Protocol_Release(IInternetProtocolEx *iface) if(This->uri) IUri_Release(This->uri); ReleaseBindInfo(&This->bind_info); + SysFreeString(This->content_type); HeapFree(GetProcessHeap(), 0, This); }
@@ -3424,6 +3430,8 @@ static HRESULT WINAPI ProtocolEx_StartEx(IInternetProtocolEx *iface, IUri *uri, if(SUCCEEDED(hres)) { if(!lstrcmpW(query, L"?delay")) This->delay = 1000; + else if(!wcsncmp(query, L"?content-type=", sizeof("?content-type=")-1)) + This->content_type = SysAllocString(query + sizeof("?content-type=")-1); SysFreeString(query); }
diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index c450384..303c4ad 100644 --- a/dlls/mshtml/tests/xhr.js +++ b/dlls/mshtml/tests/xhr.js @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a name="test">wine</a>"; + function test_xhr() { var xhr = new XMLHttpRequest(); var complete_cnt = 0, loadstart = false; @@ -24,7 +26,9 @@ function test_xhr() { if(xhr.readyState != 4) return;
- ok(xhr.responseText === "Testing...", "unexpected responseText " + xhr.responseText); + ok(xhr.responseText === xml, "unexpected responseText " + xhr.responseText); + ok(xhr.responseXML !== null, "unexpected null responseXML"); + if(complete_cnt++ && !("onloadend" in xhr)) next_test(); } @@ -63,7 +67,55 @@ function test_xhr() { ok(xhr.withCredentials === true, "withCredentials = " + xhr.withCredentials); xhr.withCredentials = false; } - xhr.send("Testing..."); + xhr.send(xml); +} + +function test_content_types() { + var xhr = new XMLHttpRequest(), types, i = 0; + var v = document.documentMode; + + var types = [ + "", + "text/plain", + "text/html", + "wine/xml", + "xml" + ]; + var xml_types = [ + "text/xmL", + "apPliCation/xml", + "image/SvG+xml", + "Wine/Test+xml", + "++Xml", + "+xMl" + ]; + + function onload() { + ok(xhr.responseText === xml, "unexpected responseText " + xhr.responseText); + if(v < 10 || types === xml_types) + ok(xhr.responseXML !== null, "unexpected null responseXML for " + types[i]); + else + ok(xhr.responseXML === null, "unexpected non-null responseXML for " + types[i]); + + if(++i >= types.length) { + if(types === xml_types) { + next_test(); + return; + } + types = xml_types; + i = 0; + } + xhr = new XMLHttpRequest(); + xhr.onload = onload; + xhr.open("POST", "echo.php?content-type=" + types[i], true); + xhr.setRequestHeader("X-Test", "True"); + xhr.send(xml); + } + + xhr.onload = onload; + xhr.open("POST", "echo.php?content-type=" + types[i], true); + xhr.setRequestHeader("X-Test", "True"); + xhr.send(xml); }
function test_abort() { @@ -118,6 +170,7 @@ function test_timeout() {
var tests = [ test_xhr, + test_content_types, test_abort, test_timeout ]; diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 8fa91e9..0fadc10 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -374,6 +374,35 @@ static HRESULT WINAPI HTMLXMLHttpRequest_get_responseXML(IHTMLXMLHttpRequest *if
TRACE("(%p)->(%p)\n", This, p);
+ if(dispex_compat_mode(&This->event_target.dispex) >= COMPAT_MODE_IE10) { + nsACString header, nscstr; + BOOL non_xml = FALSE; + const char *type; + nsresult nsres; + + nsACString_InitDepend(&header, "Content-Type"); + nsACString_InitDepend(&nscstr, NULL); + nsres = nsIXMLHttpRequest_GetResponseHeader(This->nsxhr, &header, &nscstr); + nsACString_Finish(&header); + if(NS_FAILED(nsres)) + type = NULL; + else { + nsACString_GetData(&nscstr, &type); + if(!type[0]) + type = NULL; + } + if(type && stricmp(type, "text/xml") && stricmp(type, "application/xml")) { + size_t len = strlen(type); + non_xml = len < 4 || stricmp(type + len - 4, "+xml"); + } + nsACString_Finish(&nscstr); + + if(non_xml) { + *p = NULL; + return S_OK; + } + } + hres = CoCreateInstance(&CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void**)&xmldoc); if(FAILED(hres)) { ERR("CoCreateInstance failed: %08lx\n", hres);
On 6/6/22 14:24, Gabriel Ivăncescu wrote:
For some reason, Gecko returns an XML document here, but native follows the spec.
That doesn't really make sense, Gecko is not involved because we currently use msxml instead of Gecko here. I guess you're referring to your future patches, in which case the question is what's "some reason"? Looking at Gecko sources, it returns XML document only for XML_HTTP_RESPONSE_TYPE_DEFAULT and XML_HTTP_RESPONSE_TYPE_DOCUMENT response type. What's wrong with that?
Similar question applies to overrideMimeType, why can't we let Gecko handle that?
Jacek
On 06/06/2022 20:40, Jacek Caban wrote:
On 6/6/22 14:24, Gabriel Ivăncescu wrote:
For some reason, Gecko returns an XML document here, but native follows the spec.
That doesn't really make sense, Gecko is not involved because we currently use msxml instead of Gecko here. I guess you're referring to your future patches, in which case the question is what's "some reason"? Looking at Gecko sources, it returns XML document only for XML_HTTP_RESPONSE_TYPE_DEFAULT and XML_HTTP_RESPONSE_TYPE_DOCUMENT response type. What's wrong with that?
Similar question applies to overrideMimeType, why can't we let Gecko handle that?
Jacek
I meant if we use Gecko's responseXML to check whether it's NULL or not. For "default" case (no override), Gecko returns a non-NULL xml doc, even if Content-Type is not valid the way IE treats it. So we can't use it to check this (I tried it first since it's simpler).
It does do the right thing with overrideMimeType, but if we use it, we'll override *any* content type, which is not good either. Well at least not good enough to match native IE.
Thanks, Gabriel
On 6/6/22 20:21, Gabriel Ivăncescu wrote:
On 06/06/2022 20:40, Jacek Caban wrote:
On 6/6/22 14:24, Gabriel Ivăncescu wrote:
For some reason, Gecko returns an XML document here, but native follows the spec.
That doesn't really make sense, Gecko is not involved because we currently use msxml instead of Gecko here. I guess you're referring to your future patches, in which case the question is what's "some reason"? Looking at Gecko sources, it returns XML document only for XML_HTTP_RESPONSE_TYPE_DEFAULT and XML_HTTP_RESPONSE_TYPE_DOCUMENT response type. What's wrong with that?
Similar question applies to overrideMimeType, why can't we let Gecko handle that?
Jacek
I meant if we use Gecko's responseXML to check whether it's NULL or not. For "default" case (no override), Gecko returns a non-NULL xml doc, even if Content-Type is not valid the way IE treats it. So we can't use it to check this (I tried it first since it's simpler).
It does do the right thing with overrideMimeType, but if we use it, we'll override *any* content type, which is not good either. Well at least not good enough to match native IE.
The whole thing seems to me like working around a problem somewhere else. My guess would be nsio.c, which has hacks for things like GetContentType(), but it's hard to tell without looking deeper. Did you rule that out somehow?
Jacek
On 07/06/2022 20:16, Jacek Caban wrote:
On 6/6/22 20:21, Gabriel Ivăncescu wrote:
On 06/06/2022 20:40, Jacek Caban wrote:
On 6/6/22 14:24, Gabriel Ivăncescu wrote:
For some reason, Gecko returns an XML document here, but native follows the spec.
That doesn't really make sense, Gecko is not involved because we currently use msxml instead of Gecko here. I guess you're referring to your future patches, in which case the question is what's "some reason"? Looking at Gecko sources, it returns XML document only for XML_HTTP_RESPONSE_TYPE_DEFAULT and XML_HTTP_RESPONSE_TYPE_DOCUMENT response type. What's wrong with that?
Similar question applies to overrideMimeType, why can't we let Gecko handle that?
Jacek
I meant if we use Gecko's responseXML to check whether it's NULL or not. For "default" case (no override), Gecko returns a non-NULL xml doc, even if Content-Type is not valid the way IE treats it. So we can't use it to check this (I tried it first since it's simpler).
It does do the right thing with overrideMimeType, but if we use it, we'll override *any* content type, which is not good either. Well at least not good enough to match native IE.
The whole thing seems to me like working around a problem somewhere else. My guess would be nsio.c, which has hacks for things like GetContentType(), but it's hard to tell without looking deeper. Did you rule that out somehow?
Jacek
I haven't looked into that, I wasn't aware it affects XMLHttpRequests. Skimming through it, it doesn't look like it would affect it (text/html is invalid in IE, not sure if Gecko treats it as valid XML to parse), but I'll investigate it more tomorrow.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116319
Your paranoid android.
=== w7u_el (32 bit report) ===
mshtml: script.c:644: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1654524524751 expected 1654524524829"
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/xhr.js | 14 +++++++++++- dlls/mshtml/xmlhttprequest.c | 43 ++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index 303c4ad..3ae86e6 100644 --- a/dlls/mshtml/tests/xhr.js +++ b/dlls/mshtml/tests/xhr.js @@ -71,7 +71,7 @@ function test_xhr() { }
function test_content_types() { - var xhr = new XMLHttpRequest(), types, i = 0; + var xhr = new XMLHttpRequest(), types, i = 0, override = false; var v = document.documentMode;
var types = [ @@ -97,6 +97,18 @@ function test_content_types() { else ok(xhr.responseXML === null, "unexpected non-null responseXML for " + types[i]);
+ if(("overrideMimeType" in xhr) && !override) { + override = true; + xhr = new XMLHttpRequest(); + xhr.onload = onload; + xhr.open("POST", "echo.php", true); + xhr.setRequestHeader("X-Test", "True"); + xhr.overrideMimeType(types[i]); + xhr.send(xml); + return; + } + override = false; + if(++i >= types.length) { if(types === xml_types) { next_test(); diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 0fadc10..ee1549a 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -121,6 +121,7 @@ struct HTMLXMLHttpRequest { LONG ref; nsIXMLHttpRequest *nsxhr; XMLHttpReqEventListener *event_listener; + char *type_override; };
static void detach_xhr_event_listener(XMLHttpReqEventListener *event_listener) @@ -283,6 +284,7 @@ static ULONG WINAPI HTMLXMLHttpRequest_Release(IHTMLXMLHttpRequest *iface) release_event_target(&This->event_target); release_dispex(&This->event_target.dispex); nsIXMLHttpRequest_Release(This->nsxhr); + heap_free(This->type_override); heap_free(This); }
@@ -380,16 +382,20 @@ static HRESULT WINAPI HTMLXMLHttpRequest_get_responseXML(IHTMLXMLHttpRequest *if const char *type; nsresult nsres;
- nsACString_InitDepend(&header, "Content-Type"); nsACString_InitDepend(&nscstr, NULL); - nsres = nsIXMLHttpRequest_GetResponseHeader(This->nsxhr, &header, &nscstr); - nsACString_Finish(&header); - if(NS_FAILED(nsres)) - type = NULL; + if(This->type_override) + type = This->type_override; else { - nsACString_GetData(&nscstr, &type); - if(!type[0]) + nsACString_InitDepend(&header, "Content-Type"); + nsres = nsIXMLHttpRequest_GetResponseHeader(This->nsxhr, &header, &nscstr); + nsACString_Finish(&header); + if(NS_FAILED(nsres)) type = NULL; + else { + nsACString_GetData(&nscstr, &type); + if(!type[0]) + type = NULL; + } } if(type && stricmp(type, "text/xml") && stricmp(type, "application/xml")) { size_t len = strlen(type); @@ -993,10 +999,29 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_get_withCredentials(IWineXMLHtt static HRESULT WINAPI HTMLXMLHttpRequest_private_overrideMimeType(IWineXMLHttpRequestPrivate *iface, BSTR mimeType) { HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface); + WCHAR *lowercase = NULL; + char *type = NULL; + nsAString nsstr;
- FIXME("(%p)->(%s)\n", This, debugstr_w(mimeType)); + TRACE("(%p)->(%s)\n", This, debugstr_w(mimeType));
- return E_NOTIMPL; + if(mimeType) { + if(!(lowercase = heap_strdupW(mimeType))) + return E_OUTOFMEMORY; + _wcslwr(lowercase); + if(!(type = heap_strdupWtoA(lowercase))) { + heap_free(lowercase); + return E_OUTOFMEMORY; + } + } + heap_free(This->type_override); + This->type_override = type; + + nsAString_InitDepend(&nsstr, lowercase); + nsIXMLHttpRequest_SlowOverrideMimeType(This->nsxhr, &nsstr); + nsAString_Finish(&nsstr); + heap_free(lowercase); + return S_OK; }
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onerror(IWineXMLHttpRequestPrivate *iface, VARIANT v)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116320
Your paranoid android.
=== w7u_el (32 bit report) ===
mshtml: script.c:644: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1654525952767 expected 1654525952830"
=== w1064 (32 bit report) ===
mshtml: script.c:3119: Test failed: ReportResult failed: 80ef0001