mshtml: Implement IHTMLAnchorElement get/put target.

This commit is contained in:
Alistair Leslie-Hughes 2011-02-18 14:03:41 +11:00 committed by Alexandre Julliard
parent c4d8f7400b
commit 5c186f6a99
2 changed files with 63 additions and 4 deletions

View File

@ -144,15 +144,32 @@ static HRESULT WINAPI HTMLAnchorElement_get_href(IHTMLAnchorElement *iface, BSTR
static HRESULT WINAPI HTMLAnchorElement_put_target(IHTMLAnchorElement *iface, BSTR v) static HRESULT WINAPI HTMLAnchorElement_put_target(IHTMLAnchorElement *iface, BSTR v)
{ {
HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface); HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(v)); nsAString nsstr;
return E_NOTIMPL; nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
nsAString_InitDepend(&nsstr, v);
nsres = nsIDOMHTMLAnchorElement_SetTarget(This->nsanchor, &nsstr);
nsAString_Finish(&nsstr);
if(NS_FAILED(nsres))
return E_FAIL;
return S_OK;
} }
static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p) static HRESULT WINAPI HTMLAnchorElement_get_target(IHTMLAnchorElement *iface, BSTR *p)
{ {
HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface); HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface);
FIXME("(%p)->(%p)\n", This, p); nsAString target_str;
return E_NOTIMPL; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&target_str, NULL);
nsres = nsIDOMHTMLAnchorElement_GetTarget(This->nsanchor, &target_str);
return return_nsstr(nsres, &target_str, p);
} }
static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v) static HRESULT WINAPI HTMLAnchorElement_put_rel(IHTMLAnchorElement *iface, BSTR v)

View File

@ -1124,6 +1124,36 @@ static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhr
_test_disp_value(line, unk, exhref); _test_disp_value(line, unk, exhref);
} }
#define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
static void _test_anchor_get_target(unsigned line, IUnknown *unk, const char *target)
{
IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
BSTR str;
HRESULT hres;
hres = IHTMLAnchorElement_get_target(anchor, &str);
ok_(__FILE__,line)(hres == S_OK, "get_target failed: %08x\n", hres);
if(target)
ok_(__FILE__,line)(!strcmp_wa(str, target), "target = %s, expected %s\n", wine_dbgstr_w(str), target);
else
ok_(__FILE__,line)(str == NULL, "target = %s, expected NULL\n", wine_dbgstr_w(str));
SysFreeString(str);
}
#define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
static void _test_anchor_put_target(unsigned line, IUnknown *unk, const char *target)
{
IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
BSTR str;
HRESULT hres;
str = target ? a2bstr(target) : NULL;
hres = IHTMLAnchorElement_put_target(anchor, str);
ok_(__FILE__,line)(hres == S_OK, "put_target failed: %08x\n", hres);
SysFreeString(str);
}
#define test_option_text(o,t) _test_option_text(__LINE__,o,t) #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text) static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
{ {
@ -6585,6 +6615,18 @@ static void test_elems(IHTMLDocument2 *doc)
/* Restore the href */ /* Restore the href */
test_anchor_put_href((IUnknown*)elem, "http://test/"); test_anchor_put_href((IUnknown*)elem, "http://test/");
test_anchor_href((IUnknown*)elem, "http://test/"); test_anchor_href((IUnknown*)elem, "http://test/");
/* target */
test_anchor_get_target((IUnknown*)elem, NULL);
/* Change the target */
test_anchor_put_target((IUnknown*)elem, "wine");
test_anchor_get_target((IUnknown*)elem, "wine");
/* Restore the target */
test_anchor_put_target((IUnknown*)elem, NULL);
test_anchor_get_target((IUnknown*)elem, NULL);
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
} }