mshtml: Added IHTMLInputElement::maxLength implementation.

This commit is contained in:
Jacek Caban 2012-07-13 14:45:46 +02:00 committed by Alexandre Julliard
parent 9caf3431cd
commit 4c96957fc6
2 changed files with 50 additions and 5 deletions

View File

@ -18,6 +18,7 @@
#include <stdarg.h>
#include <assert.h>
#include <limits.h>
#define COBJMACROS
@ -273,15 +274,34 @@ static HRESULT WINAPI HTMLInputElement_get_size(IHTMLInputElement *iface, LONG *
static HRESULT WINAPI HTMLInputElement_put_maxLength(IHTMLInputElement *iface, LONG v)
{
HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
FIXME("(%p)->(%d)\n", This, v);
return E_NOTIMPL;
nsresult nsres;
TRACE("(%p)->(%d)\n", This, v);
nsres = nsIDOMHTMLInputElement_SetMaxLength(This->nsinput, v);
if(NS_FAILED(nsres)) {
/* FIXME: Gecko throws an error on negative values, while MSHTML should accept them */
FIXME("SetMaxLength failed\n");
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLInputElement_get_maxLength(IHTMLInputElement *iface, LONG *p)
{
HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
PRInt32 max_length;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMHTMLInputElement_GetMaxLength(This->nsinput, &max_length);
assert(nsres == NS_OK);
/* Gecko reports -1 as default value, while MSHTML uses INT_MAX */
*p = max_length == -1 ? INT_MAX : max_length;
return S_OK;
}
static HRESULT WINAPI HTMLInputElement_select(IHTMLInputElement *iface)

View File

@ -2704,11 +2704,33 @@ static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VAR
HRESULT hres;
hres = IHTMLInputElement_put_checked(input, b);
ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
ok_(__FILE__,line) (hres == S_OK, "put_checked failed: %08x\n", hres);
_test_input_get_checked(line, input, b);
}
#define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
static void _test_input_maxlength(unsigned line, IHTMLInputElement *input, LONG exl)
{
LONG maxlength = 0xdeadbeef;
HRESULT hres;
hres = IHTMLInputElement_get_maxLength(input, &maxlength);
ok_(__FILE__,line) (hres == S_OK, "get_maxLength failed: %08x\n", hres);
ok_(__FILE__,line) (maxlength == exl, "maxLength=%x, expected %d\n", maxlength, exl);
}
#define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
static void _test_input_set_maxlength(unsigned line, IHTMLInputElement *input, LONG l)
{
HRESULT hres;
hres = IHTMLInputElement_put_maxLength(input, l);
ok_(__FILE__,line) (hres == S_OK, "put_maxLength failed: %08x\n", hres);
_test_input_maxlength(line, input, l);
}
#define test_input_value(o,t) _test_input_value(__LINE__,o,t)
static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
{
@ -5295,6 +5317,9 @@ static void test_elems(IHTMLDocument2 *doc)
test_input_set_checked(input, VARIANT_TRUE);
test_input_set_checked(input, VARIANT_FALSE);
test_input_maxlength(input, 0x7fffffff);
test_input_set_maxlength(input, 30);
test_input_name(input, NULL);
test_input_set_name(input, "test");