[PATCH resend] ieframe: add implementation for WebBrowser_get_LocationName

Vijay Kiran Kamuju infyquest at gmail.com
Thu Feb 28 11:26:11 CST 2019


Based on patch from Andrey Turkin

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=12457
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
 dlls/ieframe/tests/webbrowser.c | 24 +++++++++++++++++++++---
 dlls/ieframe/webbrowser.c       | 21 +++++++++++++++++++--
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/dlls/ieframe/tests/webbrowser.c b/dlls/ieframe/tests/webbrowser.c
index 706d5071a9cf..c78af1f78777 100644
--- a/dlls/ieframe/tests/webbrowser.c
+++ b/dlls/ieframe/tests/webbrowser.c
@@ -166,7 +166,7 @@ static HWND container_hwnd, shell_embedding_hwnd;
 static BOOL is_downloading, do_download, is_first_load, use_container_olecmd, test_close, is_http, use_container_dochostui;
 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
-static const char *current_url;
+static const char *current_url, *current_title;
 static int wb_version, expect_update_commands_enable, set_update_commands_enable;
 static BOOL nav_back_todo, nav_forward_todo; /* FIXME */
 
@@ -267,6 +267,22 @@ static void _test_LocationURL(unsigned line, IWebBrowser2 *wb, const char *exurl
     }
 }
 
+#define test_LocationName(a,b) _test_LocationName(__LINE__,a,b)
+static void _test_LocationName(unsigned line, IUnknown *unk, const char *exname)
+{
+    BSTR name = (void*)0xdeadbeef;
+    static const char wine_title[] = "WineHQ - Run Windows applications on Linux, BSD, Solaris and Mac OS X";
+    HRESULT hres;
+
+    hres = IWebBrowser2_get_LocationName(wb, &name);
+    ok_(__FILE__,line) (hres == (*exname ? S_OK : S_FALSE), "get_LocationName failed: %08x\n", hres);
+    if (SUCCEEDED(hres))
+    {
+        ok_(__FILE__,line) (!strcmp_wa(name, exname) || !strcmp_wa(name,wine_title), "unexpected name: %s\n", wine_dbgstr_w(name));
+        SysFreeString(name);
+    }
+}
+
 #define test_ready_state(ex) _test_ready_state(__LINE__,ex)
 static void _test_ready_state(unsigned line, READYSTATE exstate)
 {
@@ -2744,11 +2760,12 @@ static void test_Navigate2(IWebBrowser2 *webbrowser, const char *nav_url)
     HRESULT hres;
 
     test_LocationURL(webbrowser, is_first_load ? "" : current_url);
+    test_LocationName(webbrowser, is_first_load ? "" : current_title);
     test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
 
     is_http = !memcmp(nav_url, "http:", 5);
     V_VT(&url) = VT_BSTR;
-    V_BSTR(&url) = a2bstr(current_url = nav_url);
+    V_BSTR(&url) = a2bstr(current_title = current_url = nav_url);
 
     if((is_file = !strncasecmp(nav_url, "file://", 7)))
         current_url = nav_url + 7;
@@ -3182,7 +3199,7 @@ static void test_put_href(IWebBrowser2 *unk, const char *url)
 
     dwl_flags = DWL_FROM_PUT_HREF;
 
-    str = a2bstr(current_url = url);
+    str = a2bstr(current_title = current_url = url);
     is_first_load = FALSE;
     hres = IHTMLLocation_put_href(location, str);
 
@@ -3728,6 +3745,7 @@ static void test_WebBrowser(DWORD flags, BOOL do_close)
     test_ClassInfo(webbrowser);
     test_EnumVerbs(webbrowser);
     test_LocationURL(webbrowser, "");
+    test_LocationName(webbrowser, "");
     test_ConnectionPoint(webbrowser, TRUE);
     test_ClientSite(webbrowser, &ClientSite, !do_download);
     test_Extent(webbrowser);
diff --git a/dlls/ieframe/webbrowser.c b/dlls/ieframe/webbrowser.c
index 03acf3886989..f93fc5295a7f 100644
--- a/dlls/ieframe/webbrowser.c
+++ b/dlls/ieframe/webbrowser.c
@@ -503,8 +503,25 @@ static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
 {
     WebBrowser *This = impl_from_IWebBrowser2(iface);
-    FIXME("(%p)->(%p)\n", This, LocationName);
-    return E_NOTIMPL;
+    IHTMLDocument2 *doc = NULL;
+    TRACE("(%p)->(%p)\n", This, LocationName);
+
+    WebBrowser_get_Document(This, &doc);
+    if (doc)
+    {
+        HRESULT hres;
+        hres = IHTMLDocument2_get_title(doc, LocationName);
+        if (SUCCEEDED(hres))
+            IHTMLDocument2_Release(doc);
+        return hres;
+    } else if (This->doc_host.url) {
+       *LocationName = SysAllocString(This->doc_host.url);
+        return S_OK;
+    } else {
+        static const WCHAR null_string = {0};
+        *LocationName = SysAllocString(&null_string);
+        return S_FALSE;
+    }
 }
 
 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
-- 
2.17.0




More information about the wine-devel mailing list