mshtml: Added IHTMLFormElement::get_length implementation.
authorJacek Caban <jacek@codeweavers.com>
Fri, 7 May 2010 13:19:48 +0000 (15:19 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 7 May 2010 14:00:16 +0000 (16:00 +0200)
dlls/mshtml/htmlform.c
dlls/mshtml/tests/dom.c

index 68860560148432caab635ec877ab93dbd4c42c07..c33937d13a1acf6d6cae7f391d95c32ddcc3602a 100644 (file)
@@ -238,8 +238,19 @@ static HRESULT WINAPI HTMLFormElement_put_length(IHTMLFormElement *iface, LONG v
 static HRESULT WINAPI HTMLFormElement_get_length(IHTMLFormElement *iface, LONG *p)
 {
     HTMLFormElement *This = HTMLFORM_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    PRInt32 length;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsres = nsIDOMHTMLFormElement_GetLength(This->nsform, &length);
+    if(NS_FAILED(nsres)) {
+        ERR("GetLength failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    *p = length;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLFormElement__newEnum(IHTMLFormElement *iface, IUnknown **p)
index 58ecec2ceaf50cf17ec8752f7ad59835c1da92ad..6f33ee24d9343f9da6bd70a1a78af5e04e699c33 100644 (file)
@@ -684,6 +684,17 @@ static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
     return select;
 }
 
+#define get_form_iface(u) _get_form_iface(__LINE__,u)
+static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
+{
+    IHTMLFormElement *form;
+    HRESULT hres;
+
+    hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
+    ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
+    return form;
+}
+
 #define get_text_iface(u) _get_text_iface(__LINE__,u)
 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
 {
@@ -2389,6 +2400,20 @@ static void _test_elem_client_rect(unsigned line, IUnknown *unk)
     IHTMLElement2_Release(elem);
 }
 
+#define test_form_length(e,l) _test_form_length(__LINE__,e,l)
+static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
+{
+    IHTMLFormElement *form = _get_form_iface(line, unk);
+    LONG len = 0xdeadbeef;
+    HRESULT hres;
+
+    hres = IHTMLFormElement_get_length(form, &len);
+    ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
+    ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
+
+    IHTMLFormElement_Release(form);
+}
+
 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
 {
@@ -5818,6 +5843,13 @@ static void test_elems(IHTMLDocument2 *doc)
 
     IHTMLElement_Release(elem);
 
+    elem = get_doc_elem_by_id(doc, "frm");
+    ok(elem != NULL, "elem == NULL\n");
+    if(elem) {
+        test_form_length((IUnknown*)elem, 0);
+        IHTMLElement_Release(elem);
+    }
+
     test_stylesheets(doc);
     test_create_option_elem(doc);
     test_create_img_elem(doc);