From: Gabriel Ivăncescu gabrielopcode@gmail.com
We have to special case empty string since Gecko special cases them, but IE does not.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/tests/xhr.js | 16 ++++++++++++++-- dlls/mshtml/xmlhttprequest.c | 23 +++++++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/tests/xhr.js b/dlls/mshtml/tests/xhr.js index 303c4add7b4..8d9af26a943 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 = [ @@ -95,7 +95,19 @@ function test_content_types() { 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]); + ok(xhr.responseXML === null, "unexpected non-null responseXML for " + (override ? "overriden " : "") + 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) { diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index c165218bdef..f21114abcac 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -978,10 +978,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); + static const WCHAR generic_type[] = L"application/octet-stream"; + const WCHAR *type = NULL; + WCHAR *lowercase = NULL; + nsAString nsstr; + nsresult nsres;
- FIXME("(%p)->(%s)\n", This, debugstr_w(mimeType)); + TRACE("(%p)->(%s)\n", This, debugstr_w(mimeType));
- return E_NOTIMPL; + if(mimeType) { + if(mimeType[0]) { + if(!(lowercase = heap_strdupW(mimeType))) + return E_OUTOFMEMORY; + _wcslwr(lowercase); + type = lowercase; + }else + type = generic_type; + } + + nsAString_InitDepend(&nsstr, type); + nsres = nsIXMLHttpRequest_SlowOverrideMimeType(This->nsxhr, &nsstr); + nsAString_Finish(&nsstr); + heap_free(lowercase); + return map_nsresult(nsres); }
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_onerror(IWineXMLHttpRequestPrivate *iface, VARIANT v)