Hao Peng : mshtml: Add IHTMLAnchorElement::search propertyimplementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Sep 26 16:35:49 CDT 2014
Module: wine
Branch: master
Commit: 268b22e5e8b801ddefe3d1fae9e175fa166099c5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=268b22e5e8b801ddefe3d1fae9e175fa166099c5
Author: Hao Peng <penghao at linuxdeepin.com>
Date: Thu Sep 25 15:51:39 2014 +0800
mshtml: Add IHTMLAnchorElement::search propertyimplementation.
---
dlls/mshtml/htmlanchor.c | 24 +++++++++++++++++++----
dlls/mshtml/tests/dom.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c
index 3057f35..84f4098 100644
--- a/dlls/mshtml/htmlanchor.c
+++ b/dlls/mshtml/htmlanchor.c
@@ -479,15 +479,31 @@ static HRESULT WINAPI HTMLAnchorElement_get_protocol(IHTMLAnchorElement *iface,
static HRESULT WINAPI HTMLAnchorElement_put_search(IHTMLAnchorElement *iface, BSTR v)
{
HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(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 = nsIDOMHTMLAnchorElement_SetSearch(This->nsanchor, &nsstr);
+ nsAString_Finish(&nsstr);
+ if(NS_FAILED(nsres))
+ return E_FAIL;
+
+ return S_OK;
}
static HRESULT WINAPI HTMLAnchorElement_get_search(IHTMLAnchorElement *iface, BSTR *p)
{
HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
- FIXME("(%p)->(%p)\n", This, p);
- return E_NOTIMPL;
+ nsAString search_str;
+ nsresult nsres;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ nsAString_Init(&search_str, NULL);
+ nsres = nsIDOMHTMLAnchorElement_GetSearch(This->nsanchor, &search_str);
+ return return_nsstr(nsres, &search_str, p);
}
static HRESULT WINAPI HTMLAnchorElement_put_hash(IHTMLAnchorElement *iface, BSTR v)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 4dc89e0..4f69e7a 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -1479,6 +1479,37 @@ static void _test_anchor_hostname(unsigned line, IUnknown *unk, const char *host
SysFreeString(str);
}
+#define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
+static void _test_anchor_search(unsigned line, IUnknown *elem, const char *search, BOOL allowbroken)
+{
+ IHTMLAnchorElement *anchor = _get_anchor_iface(line, elem);
+ BSTR str;
+ HRESULT hres;
+
+ hres = IHTMLAnchorElement_get_search(anchor, &str);
+ ok_(__FILE__,line)(hres == S_OK, "get_search failed: %08x\n", hres);
+ if ( ! str && allowbroken)
+ win_skip("skip ie6 incorrect behavior\n");
+ else if(search)
+ ok_(__FILE__,line)(!strcmp_wa(str, search), "search = %s, expected %s\n", wine_dbgstr_w(str), search);
+ else
+ ok_(__FILE__,line)(!str, "search = %s, expected NULL\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+}
+
+#define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
+static void _test_anchor_put_search(unsigned line, IUnknown *unk, const char *search)
+{
+ IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
+ BSTR str;
+ HRESULT hres;
+
+ str = search ? a2bstr(search) : NULL;
+ hres = IHTMLAnchorElement_put_search(anchor, str);
+ ok_(__FILE__,line)(hres == S_OK, "put_search failed: %08x\n", hres);
+ SysFreeString(str);
+}
+
#define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
static void _test_anchor_hash(unsigned line, IHTMLElement *elem, const char *exhash)
{
@@ -7331,8 +7362,25 @@ static void test_elems(IHTMLDocument2 *doc)
test_anchor_put_name((IUnknown*)elem, NULL);
test_anchor_put_name((IUnknown*)elem, "x");
- test_anchor_put_href((IUnknown*)elem, "http://test/#hash");
+ test_anchor_put_href((IUnknown*)elem, "http://test/?how#hash");
test_anchor_hash(elem, "#hash");
+ test_anchor_search((IUnknown*)elem, "?how", FALSE);
+
+ test_anchor_put_search((IUnknown*)elem, "?word=press");
+ test_anchor_search((IUnknown*)elem, "?word=press", FALSE);
+ test_anchor_put_search((IUnknown*)elem, "?????word???press");
+ test_anchor_search((IUnknown*)elem, "?????word???press", FALSE);
+
+ test_anchor_put_search((IUnknown*)elem, "?q=\%E4\%BD\%A0\%E5\%A5\%BD"); /* encoded cjk characters */
+ test_anchor_search((IUnknown*)elem, "?q=\%E4\%BD\%A0\%E5\%A5\%BD", FALSE);
+
+ test_anchor_put_search((IUnknown*)elem, "?how?old=are");
+ test_anchor_search((IUnknown*)elem, "?how?old=are", FALSE);
+
+ /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
+ as part of the pathname, and can not be accessed by get_search. */
+ test_anchor_put_search((IUnknown*)elem, "word=abc");
+ test_anchor_search((IUnknown*)elem, "?word=abc", TRUE);
IHTMLElement_Release(elem);
}
More information about the wine-cvs
mailing list