Commit c82900e2 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement "text" type response for XMLHttpRequest.

Also basic implementation of arraybuffer/blob with invalid state, mostly to show how the tests will look. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent 6537c36d
......@@ -245,10 +245,55 @@ function test_responseType() {
xhr.send("responseType test");
}
function test_response() {
var xhr = new XMLHttpRequest(), i = 0;
if(!("response" in xhr)) { next_test(); return; }
var types = [
[ "text", "application/octet-stream", function() {
if(xhr.readyState < 3)
ok(xhr.response === "", "response for text with state " + state + " = " + xhr.response);
else if(xhr.readyState === 4)
ok(xhr.response === xml, "response for text = " + xhr.response);
}],
[ "arraybuffer", "image/png", function() {
if(xhr.readyState < 4)
ok(xhr.response === undefined, "response for arraybuffer with state " + state + " = " + xhr.response);
}],
[ "blob", "wine/test", function() {
if(xhr.readyState < 4)
ok(xhr.response === undefined, "response for blob with state " + state + " = " + xhr.response);
}]
];
function onreadystatechange() {
types[i][2]();
if(xhr.readyState < 4)
return;
if(++i >= types.length) {
next_test();
return;
}
xhr = new XMLHttpRequest();
xhr.open("POST", "echo.php?content-type=" + types[i][1], true);
xhr.onreadystatechange = onreadystatechange;
xhr.setRequestHeader("X-Test", "True");
xhr.responseType = types[i][0];
xhr.send(xml);
}
xhr.open("POST", "echo.php?content-type=" + types[i][1], true);
xhr.onreadystatechange = onreadystatechange;
xhr.setRequestHeader("X-Test", "True");
xhr.responseType = types[i][0];
xhr.send(xml);
}
var tests = [
test_xhr,
test_content_types,
test_abort,
test_timeout,
test_responseType
test_responseType,
test_response
];
......@@ -938,10 +938,47 @@ static HRESULT WINAPI HTMLXMLHttpRequest_private_Invoke(IWineXMLHttpRequestPriva
static HRESULT WINAPI HTMLXMLHttpRequest_private_get_response(IWineXMLHttpRequestPrivate *iface, VARIANT *p)
{
HTMLXMLHttpRequest *This = impl_from_IWineXMLHttpRequestPrivate(iface);
HRESULT hres = S_OK;
nsresult nsres;
UINT16 state;
FIXME("(%p)->(%p)\n", This, p);
TRACE("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
switch(This->response_type) {
case response_type_empty:
case response_type_text:
hres = IHTMLXMLHttpRequest_get_responseText(&This->IHTMLXMLHttpRequest_iface, &V_BSTR(p));
if(SUCCEEDED(hres))
V_VT(p) = VT_BSTR;
break;
case response_type_doc:
FIXME("response_type_doc\n");
return E_NOTIMPL;
case response_type_arraybuf:
case response_type_blob:
nsres = nsIXMLHttpRequest_GetReadyState(This->nsxhr, &state);
if(NS_FAILED(nsres) || state < 4) {
V_VT(p) = VT_EMPTY;
break;
}
if(This->response_type == response_type_arraybuf) {
FIXME("response_type_arraybuf\n");
return E_NOTIMPL;
}
FIXME("response_type_blob\n");
return E_NOTIMPL;
case response_type_stream:
FIXME("response_type_stream\n");
return E_NOTIMPL;
default:
assert(0);
}
return hres;
}
static HRESULT WINAPI HTMLXMLHttpRequest_private_put_responseType(IWineXMLHttpRequestPrivate *iface, BSTR v)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment