From df25f0d9a6d08ab5bd58e430619809d7ff58b936 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 17 Feb 2011 14:29:48 +1100 Subject: [PATCH] mshtml: Implement IHTMLAnchorElement_put_href. --- 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 90ece1de00f..ae3dd180d7d 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 c6e49eff04b..06743d2b538 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); }