[PATCH 6/8] mshtml: Implement withCredentials for XMLHttpRequest.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Jun 6 07:24:14 CDT 2022


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at 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)
-- 
2.34.1




More information about the wine-devel mailing list