mshtml: Add IHTMLXMLHttpRequest::statusText property implementation.

This commit is contained in:
Zhenbo Li 2015-08-05 09:21:57 +08:00 committed by Alexandre Julliard
parent 961f4c0a25
commit 74d07b7b0a
2 changed files with 61 additions and 12 deletions

View File

@ -457,11 +457,11 @@ static void test_sync_xhr(IHTMLDocument2 *doc, const char *xml_url)
ok(val == 0, "Expect 0, got %d\n", val);
hres = IHTMLXMLHttpRequest_get_statusText(xhr, NULL);
todo_wine ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
todo_wine ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
todo_wine ok(text == NULL, "Expect NULL, got %p\n", text);
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
ok(text == NULL, "Expect NULL, got %p\n", text);
method = a2bstr("GET");
url = a2bstr(xml_url);
@ -566,8 +566,8 @@ static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url)
text = (BSTR)0xdeadbeef;
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
todo_wine ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
todo_wine ok(text == NULL, "Expect NULL, got %p\n", text);
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
ok(text == NULL, "Expect NULL, got %p\n", text);
val = 0xdeadbeef;
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
@ -600,8 +600,8 @@ static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url)
ok(val == 0, "Expect 0, got %d\n", val);
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
todo_wine ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
todo_wine ok(text == NULL, "Expect NULL, got %p\n", text);
ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres);
ok(text == NULL, "Expect NULL, got %p\n", text);
val = 0xdeadbeef;
hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val);
@ -635,9 +635,9 @@ static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url)
text = NULL;
hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text);
todo_wine ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
todo_wine ok(text != NULL, "text == NULL\n");
todo_wine ok(!strcmp_wa(text, "OK"), "Expected \"OK\", got %s\n", wine_dbgstr_w(text));
ok(hres == S_OK, "get_statusText failed: %08x\n", hres);
ok(text != NULL, "text == NULL\n");
ok(!strcmp_wa(text, "OK"), "Expected \"OK\", got %s\n", wine_dbgstr_w(text));
SysFreeString(text);
val = 0xdeadbeef;

View File

@ -60,6 +60,35 @@ static HRESULT variant_to_nsastr(VARIANT var, nsAString *ret)
}
}
static HRESULT return_nscstr(nsresult nsres, nsACString *nscstr, BSTR *p)
{
const char *str;
int len;
if(NS_FAILED(nsres)) {
ERR("failed: %08x\n", nsres);
nsACString_Finish(nscstr);
return E_FAIL;
}
nsACString_GetData(nscstr, &str);
if(*str) {
len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
*p = SysAllocStringLen(NULL, len);
if(!*p) {
nsACString_Finish(nscstr);
return E_OUTOFMEMORY;
}
MultiByteToWideChar(CP_UTF8, 0, str, -1, *p, len);
}else {
*p = NULL;
}
nsACString_Finish(nscstr);
return S_OK;
}
typedef struct XMLHttpReqEventListener XMLHttpReqEventListener;
typedef struct {
@ -334,8 +363,28 @@ static HRESULT WINAPI HTMLXMLHttpRequest_get_status(IHTMLXMLHttpRequest *iface,
static HRESULT WINAPI HTMLXMLHttpRequest_get_statusText(IHTMLXMLHttpRequest *iface, BSTR *p)
{
HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsACString nscstr;
nsresult nsres;
HRESULT hres;
LONG state;
TRACE("(%p)->(%p)\n", This, p);
if(!p)
return E_POINTER;
hres = IHTMLXMLHttpRequest_get_readyState(iface, &state);
if(FAILED(hres))
return hres;
if(state < 2) {
*p = NULL;
return E_FAIL;
}
nsACString_Init(&nscstr, NULL);
nsres = nsIXMLHttpRequest_GetStatusText(This->nsxhr, &nscstr);
return return_nscstr(nsres, &nscstr, p);
}
static HRESULT WINAPI HTMLXMLHttpRequest_put_onreadystatechange(IHTMLXMLHttpRequest *iface, VARIANT v)