Piotr Caban : mshtml: Added IHTMLFormElement_{get/ put}_method implementation.

Alexandre Julliard julliard at winehq.org
Thu Oct 28 12:19:51 CDT 2010


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Oct 28 00:42:03 2010 +0200

mshtml: Added IHTMLFormElement_{get/put}_method implementation.

---

 dlls/mshtml/htmlform.c  |   42 ++++++++++++++++++++++++++++++++++++++----
 dlls/mshtml/tests/dom.c |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c
index 8e16917..954ede8 100644
--- a/dlls/mshtml/htmlform.c
+++ b/dlls/mshtml/htmlform.c
@@ -202,16 +202,50 @@ static HRESULT WINAPI HTMLFormElement_get_encoding(IHTMLFormElement *iface, BSTR
 
 static HRESULT WINAPI HTMLFormElement_put_method(IHTMLFormElement *iface, BSTR v)
 {
+    static const WCHAR postW[] = {'P','O','S','T',0};
+    static const WCHAR getW[] = {'G','E','T',0};
+
     HTMLFormElement *This = HTMLFORM_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
-    return E_NOTIMPL;
+    nsAString method_str;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+
+    if(lstrcmpiW(v, postW) && lstrcmpiW(v, getW)) {
+        WARN("unrecognized method\n");
+        return E_INVALIDARG;
+    }
+
+    nsAString_InitDepend(&method_str, v);
+    nsres = nsIDOMHTMLFormElement_SetMethod(This->nsform, &method_str);
+    nsAString_Finish(&method_str);
+    if(NS_FAILED(nsres))
+        return E_FAIL;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLFormElement_get_method(IHTMLFormElement *iface, BSTR *p)
 {
     HTMLFormElement *This = HTMLFORM_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsAString method_str;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsAString_Init(&method_str, NULL);
+    nsres = nsIDOMHTMLFormElement_GetMethod(This->nsform, &method_str);
+    if(NS_SUCCEEDED(nsres)) {
+        const PRUnichar *method;
+        nsAString_GetData(&method_str, &method);
+
+        *p = SysAllocString(method);
+        if(!*p)
+            return E_OUTOFMEMORY;
+    }else
+        return E_FAIL;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDispatch **p)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index f7a5ee0..7e4343f 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2595,6 +2595,40 @@ static void _test_form_put_action(unsigned line, IUnknown *unk, const char *acti
     _test_form_action(line, unk, action);
 }
 
+#define test_form_method(f,a) _test_form_method(__LINE__,f,a)
+static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
+{
+    IHTMLFormElement *form = _get_form_iface(line, unk);
+    BSTR method = (void*)0xdeadbeef;
+    HRESULT hres;
+
+    hres = IHTMLFormElement_get_method(form, &method);
+    ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
+    if(ex)
+        ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
+    else
+        ok_(__FILE__,line)(!method, "method=%p\n", method);
+
+    SysFreeString(method);
+    IHTMLFormElement_Release(form);
+}
+
+#define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
+static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
+{
+    IHTMLFormElement *form = _get_form_iface(line, unk);
+    BSTR tmp = a2bstr(method);
+    HRESULT hres;
+
+    hres = IHTMLFormElement_put_method(form, tmp);
+    ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
+    SysFreeString(tmp);
+    IHTMLFormElement_Release(form);
+
+    if(exp_hres == S_OK)
+        _test_form_method(line, unk, method);
+}
+
 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
 {
@@ -6290,6 +6324,10 @@ static void test_elems2(IHTMLDocument2 *doc)
         test_form_item(elem);
         test_form_action((IUnknown*)elem, NULL);
         test_form_put_action((IUnknown*)elem, "about:blank");
+        test_form_method((IUnknown*)elem, "get");
+        test_form_put_method((IUnknown*)elem, S_OK, "post");
+        test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
+        test_form_method((IUnknown*)elem, "post");
         IHTMLElement_Release(elem);
     }
 




More information about the wine-cvs mailing list