Jacek Caban : mshtml: Added IHTMLFormElement::item implementation.

Alexandre Julliard julliard at winehq.org
Tue May 11 12:09:40 CDT 2010


Module: wine
Branch: master
Commit: 5bb9172af2fcc53ba36ebe7a2540664998f3e0c1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5bb9172af2fcc53ba36ebe7a2540664998f3e0c1

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 11 17:58:09 2010 +0200

mshtml: Added IHTMLFormElement::item implementation.

---

 dlls/mshtml/htmlform.c  |   15 ++++++++++++-
 dlls/mshtml/tests/dom.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c
index bcb6e6e..6ca8e92 100644
--- a/dlls/mshtml/htmlform.c
+++ b/dlls/mshtml/htmlform.c
@@ -299,7 +299,20 @@ static HRESULT WINAPI HTMLFormElement_item(IHTMLFormElement *iface, VARIANT name
         VARIANT index, IDispatch **pdisp)
 {
     HTMLFormElement *This = HTMLFORM_THIS(iface);
-    FIXME("(%p)->(v v %p)\n", This, pdisp);
+
+    TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
+
+    if(!pdisp)
+        return E_INVALIDARG;
+    *pdisp = NULL;
+
+    if(V_VT(&name) == VT_I4) {
+        if(V_I4(&name) < 0)
+            return E_INVALIDARG;
+        return htmlform_item(This, V_I4(&name), pdisp);
+    }
+
+    FIXME("Unsupported args\n");
     return E_NOTIMPL;
 }
 
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index c91adda..e8657f4 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2964,6 +2964,48 @@ static void test_select_elem(IHTMLSelectElement *select)
     IDispatch_Release(disp);
 }
 
+static void test_form_item(IHTMLElement *elem)
+{
+    IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
+    IDispatch *disp, *disp2;
+    VARIANT name, index;
+    HRESULT hres;
+
+    V_VT(&index) = VT_EMPTY;
+    V_VT(&name) = VT_I4;
+    V_I4(&name) = -1;
+    disp = (void*)0xdeadbeef;
+    hres = IHTMLFormElement_item(form, name, index, &disp);
+    ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
+    ok(!disp, "disp = %p\n", disp);
+
+    V_I4(&name) = 2;
+    disp = (void*)0xdeadbeef;
+    hres = IHTMLFormElement_item(form, name, index, &disp);
+    ok(hres == S_OK, "item failed: %08x\n", hres);
+    ok(!disp, "disp = %p\n", disp);
+
+    V_I4(&name) = 1;
+    hres = IHTMLFormElement_item(form, name, index, NULL);
+    ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
+
+    disp = NULL;
+    hres = IHTMLFormElement_item(form, name, index, &disp);
+    ok(hres == S_OK, "item failed: %08x\n", hres);
+    ok(disp != NULL, "disp = NULL\n");
+    test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
+
+    V_VT(&index) = VT_I4;
+    V_I4(&index) = 1;
+    disp2 = NULL;
+    hres = IHTMLFormElement_item(form, name, index, &disp2);
+    ok(hres == S_OK, "item failed: %08x\n", hres);
+    ok(disp2 != NULL, "disp = NULL\n");
+    ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
+    IDispatch_Release(disp2);
+    IDispatch_Release(disp);
+}
+
 static void test_create_option_elem(IHTMLDocument2 *doc)
 {
     IHTMLOptionElement *option;
@@ -6112,6 +6154,15 @@ static void test_elems2(IHTMLDocument2 *doc)
         IHTMLElement_Release(elem);
     }
 
+    test_elem_set_innerhtml((IUnknown*)div,
+            "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
+    elem = get_elem_by_id(doc, "form", TRUE);
+    if(elem) {
+        test_form_length((IUnknown*)elem, 2);
+        test_form_item(elem);
+        IHTMLElement_Release(elem);
+    }
+
     IHTMLElement_Release(div);
 }
 




More information about the wine-cvs mailing list