[PATCH] Implement IHTMLAnchorElement_put_href

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed Feb 16 21:29:48 CST 2011


---
 dlls/mshtml/htmlanchor.c |   14 ++++++++++++--
 dlls/mshtml/tests/dom.c  |   23 +++++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c
index 90ece1d..ae3dd18 100644
--- a/dlls/mshtml/htmlanchor.c
+++ b/dlls/mshtml/htmlanchor.c
@@ -102,8 +102,18 @@ static HRESULT WINAPI HTMLAnchorElement_Invoke(IHTMLAnchorElement *iface, DISPID
 static HRESULT WINAPI HTMLAnchorElement_put_href(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_SetHref(This->nsanchor, &nsstr);
+    nsAString_Finish(&nsstr);
+    if(NS_FAILED(nsres))
+        return E_FAIL;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_href(IHTMLAnchorElement *iface, BSTR *p)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index c6e49ef..06743d2 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -1168,6 +1168,21 @@ static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
     _test_disp_value(line, unk, exhref);
 }
 
+#define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
+static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhref)
+{
+    IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
+    BSTR str;
+    HRESULT hres;
+
+    str = a2bstr(exhref);
+    hres = IHTMLAnchorElement_put_href(anchor, str);
+    ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
+    SysFreeString(str);
+
+    _test_disp_value(line, unk, exhref);
+}
+
 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
 {
@@ -6481,6 +6496,14 @@ static void test_elems(IHTMLDocument2 *doc)
     elem = get_elem_by_id(doc, "a", TRUE);
     if(elem) {
         test_anchor_href((IUnknown*)elem, "http://test/");
+
+        /* Change the href */
+        test_anchor_put_href((IUnknown*)elem, "http://test1/");
+        test_anchor_href((IUnknown*)elem, "http://test1/");
+
+        /* Restore the href */
+        test_anchor_put_href((IUnknown*)elem, "http://test/");
+        test_anchor_href((IUnknown*)elem, "http://test/");
         IHTMLElement_Release(elem);
     }
 
-- 
1.7.1


--------------050007010907060701080604--



More information about the wine-patches mailing list