Module: wine Branch: master Commit: 5a07f80ebeef3aa164e6172eea79348589de17b8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5a07f80ebeef3aa164e6172eea...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jun 16 19:30:18 2016 +0200
mshtml: Added IHTMLButtonElement::value property implementation.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmlinput.c | 26 ++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index 0b6eb33..5e0d53b 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -1634,15 +1634,33 @@ static HRESULT WINAPI HTMLButtonElement_get_type(IHTMLButtonElement *iface, BSTR static HRESULT WINAPI HTMLButtonElement_put_value(IHTMLButtonElement *iface, BSTR v) { HTMLButtonElement *This = impl_from_IHTMLButtonElement(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 = nsIDOMHTMLButtonElement_SetValue(This->nsbutton, &nsstr); + nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) { + ERR("SetValue failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; }
static HRESULT WINAPI HTMLButtonElement_get_value(IHTMLButtonElement *iface, BSTR *p) { HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString value_str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&value_str, NULL); + nsres = nsIDOMHTMLButtonElement_GetValue(This->nsbutton, &value_str); + return return_nsstr(nsres, &value_str, p); }
static HRESULT WINAPI HTMLButtonElement_put_name(IHTMLButtonElement *iface, BSTR v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 9788e56..27af54d 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -6944,11 +6944,45 @@ static void _test_button_type(unsigned line, IHTMLElement *elem, const char *ext IHTMLButtonElement_Release(button); }
+#define test_button_value(a,b) _test_button_value(__LINE__,a,b) +static void _test_button_value(unsigned line, IHTMLElement *elem, const char *exvalue) +{ + IHTMLButtonElement *button = _get_button_iface(line, (IUnknown*)elem); + BSTR str; + HRESULT hres; + + hres = IHTMLButtonElement_get_value(button, &str); + ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres); + if(exvalue) + ok_(__FILE__,line)(!strcmp_wa(str, exvalue), "value = %s, expected %s\n", wine_dbgstr_w(str), exvalue); + else + ok_(__FILE__,line)(!str, "value = %s, expected NULL\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IHTMLButtonElement_Release(button); +} + +#define set_button_value(a,b) _set_button_value(__LINE__,a,b) +static void _set_button_value(unsigned line, IHTMLElement *elem, const char *value) +{ + IHTMLButtonElement *button = _get_button_iface(line, (IUnknown*)elem); + BSTR str = a2bstr(value); + HRESULT hres; + + hres = IHTMLButtonElement_put_value(button, str); + ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres); + IHTMLButtonElement_Release(button); + + _test_button_value(line, elem, value); +} + static void test_button_elem(IHTMLElement *elem) { test_button_name(elem, NULL); set_button_name(elem, "button name"); test_button_type(elem, "submit"); + test_button_value(elem, NULL); + set_button_value(elem, "val");
test_elem_istextedit(elem, VARIANT_TRUE); }