Jacek Caban : mshtml: Added IHTMLDocument2::put_domain implementation.

Alexandre Julliard julliard at winehq.org
Tue Jun 21 11:13:48 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jun 21 15:12:25 2016 +0200

mshtml: Added IHTMLDocument2::put_domain implementation.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmldoc.c       | 38 ++++++++++++++++++++++++++++++--------
 dlls/mshtml/tests/htmldoc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index eadb90b..352b757 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -795,24 +795,46 @@ static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
 {
     HTMLDocument *This = impl_from_IHTMLDocument2(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    nsAString nsstr;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    nsAString_InitDepend(&nsstr, v);
+    nsres = nsIDOMHTMLDocument_SetDomain(This->doc_node->nsdoc, &nsstr);
+    nsAString_Finish(&nsstr);
+    if(NS_FAILED(nsres)) {
+        ERR("SetDomain failed: %08x\n", nsres);
+        return E_INVALIDARG;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
 {
     HTMLDocument *This = impl_from_IHTMLDocument2(iface);
-    HRESULT hres;
+    nsAString nsstr;
+    nsresult nsres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    if(!This->window || !This->window->uri) {
-        FIXME("No current URI\n");
-        return E_FAIL;
+    nsAString_Init(&nsstr, NULL);
+    nsres = nsIDOMHTMLDocument_GetDomain(This->doc_node->nsdoc, &nsstr);
+    if(NS_SUCCEEDED(nsres) && This->window && This->window->uri) {
+        const PRUnichar *str;
+        HRESULT hres;
+
+        nsAString_GetData(&nsstr, &str);
+        if(!*str) {
+            TRACE("Gecko returned emptry string, fallback to loaded URL.\n");
+            nsAString_Finish(&nsstr);
+            hres = IUri_GetHost(This->window->uri, p);
+            return FAILED(hres) ? hres : S_OK;
+        }
     }
 
-    hres = IUri_GetHost(This->window->uri, p);
-    return FAILED(hres) ? hres : S_OK;
+    return return_nsstr(nsres, &nsstr, p);
 }
 
 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c
index 5079dc9..90d5b41 100644
--- a/dlls/mshtml/tests/htmldoc.c
+++ b/dlls/mshtml/tests/htmldoc.c
@@ -971,6 +971,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
     case 1014:
         CHECK_EXPECT2(OnChanged_1014);
         return S_OK;
+    case 1029:
     case 1030:
     case 3000022:
     case 3000023:
@@ -7681,6 +7682,37 @@ static void test_cookies(IHTMLDocument2 *doc)
     SysFreeString(str2);
 }
 
+static void test_doc_domain(IHTMLDocument2 *doc)
+{
+    BSTR str;
+    HRESULT hres;
+
+    hres = IHTMLDocument2_get_domain(doc, &str);
+    ok(hres == S_OK, "get_domain failed: %08x\n", hres);
+    ok(!strcmp_wa(str, "test.winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
+    SysFreeString(str);
+
+    str = a2bstr("winehq.org");
+    hres = IHTMLDocument2_put_domain(doc, str);
+    ok(hres == S_OK, "put_domain failed: %08x\n", hres);
+    SysFreeString(str);
+
+    hres = IHTMLDocument2_get_domain(doc, &str);
+    ok(hres == S_OK, "get_domain failed: %08x\n", hres);
+    ok(!strcmp_wa(str, "winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
+    SysFreeString(str);
+
+    str = a2bstr("winehq.com");
+    hres = IHTMLDocument2_put_domain(doc, str);
+    ok(hres == E_INVALIDARG, "put_domain failed: %08x, expected E_INVALIDARG\n", hres);
+    SysFreeString(str);
+
+    hres = IHTMLDocument2_get_domain(doc, &str);
+    ok(hres == S_OK, "get_domain failed: %08x\n", hres);
+    ok(!strcmp_wa(str, "winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
+    SysFreeString(str);
+}
+
 static void test_HTMLDocument_http(BOOL with_wbapp)
 {
     IMoniker *http_mon;
@@ -7718,6 +7750,7 @@ static void test_HTMLDocument_http(BOOL with_wbapp)
     test_GetCurMoniker((IUnknown*)doc, http_mon, NULL, FALSE);
     test_travellog(doc);
     test_binding_ui((IUnknown*)doc);
+    test_doc_domain(doc);
 
     nav_url = nav_serv_url = "http://test.winehq.org/tests/winehq_snapshot/"; /* for valid prev nav_url */
     if(support_wbapp) {




More information about the wine-cvs mailing list