Zhenbo Li : mshtml: Add IHTMLXMLHttpRequest:: statusText property implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Aug 6 10:15:43 CDT 2015


Module: wine
Branch: master
Commit: 74d07b7b0a95e9324a3e3029d9cf548eaa3332ae
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=74d07b7b0a95e9324a3e3029d9cf548eaa3332ae

Author: Zhenbo Li <litimetal at gmail.com>
Date:   Wed Aug  5 09:21:57 2015 +0800

mshtml: Add IHTMLXMLHttpRequest::statusText property implementation.

---

 dlls/mshtml/tests/xmlhttprequest.c | 20 +++++++-------
 dlls/mshtml/xmlhttprequest.c       | 53 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/dlls/mshtml/tests/xmlhttprequest.c b/dlls/mshtml/tests/xmlhttprequest.c
index 713dedf..005e27c 100644
--- a/dlls/mshtml/tests/xmlhttprequest.c
+++ b/dlls/mshtml/tests/xmlhttprequest.c
@@ -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;
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c
index 5b5cf87..7be0f4c 100644
--- a/dlls/mshtml/xmlhttprequest.c
+++ b/dlls/mshtml/xmlhttprequest.c
@@ -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)




More information about the wine-cvs mailing list