2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
51 "<test /><object id=\"objid\" vspace=100></object><embed />"
52 "<img id=\"imgid\" name=\"WineImg\"/>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 "<form id=\"frm\"></form>"
56 static const char elem_test2_str[] =
57 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
58 "<body><div id=\"divid\"></div></body>"
61 static const char indent_test_str[] =
62 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
63 static const char cond_comment_str[] =
64 "<html><head><title>test</title></head><body>"
65 "<!--[if gte IE 4]> <br> <![endif]-->"
67 static const char frameset_str[] =
68 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
69 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
70 "<frame src=\"about:blank\" id=\"fr3\">"
72 static const char emptydiv_str[] =
73 "<html><head><title>emptydiv test</title></head>"
74 "<body><div id=\"divid\"></div></body></html>";
76 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
77 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
78 static WCHAR wordW[] = {'w','o','r','d',0};
112 static const IID * const none_iids[] = {
117 static const IID * const doc_node_iids[] = {
126 &IID_IConnectionPointContainer,
127 &IID_IInternetHostSecurityManager,
131 static const IID * const doc_obj_iids[] = {
138 &IID_IConnectionPointContainer,
143 static const IID * const elem_iids[] = {
150 &IID_IConnectionPointContainer,
154 static const IID * const body_iids[] = {
160 &IID_IHTMLTextContainer,
161 &IID_IHTMLBodyElement,
163 &IID_IConnectionPointContainer,
167 static const IID * const anchor_iids[] = {
173 &IID_IHTMLAnchorElement,
175 &IID_IConnectionPointContainer,
179 static const IID * const input_iids[] = {
185 &IID_IHTMLInputElement,
186 &IID_IHTMLInputTextElement,
188 &IID_IConnectionPointContainer,
192 static const IID * const select_iids[] = {
198 &IID_IHTMLSelectElement,
200 &IID_IConnectionPointContainer,
204 static const IID * const textarea_iids[] = {
210 &IID_IHTMLTextAreaElement,
212 &IID_IConnectionPointContainer,
216 static const IID * const option_iids[] = {
222 &IID_IHTMLOptionElement,
224 &IID_IConnectionPointContainer,
228 static const IID * const table_iids[] = {
236 &IID_IConnectionPointContainer,
240 static const IID * const script_iids[] = {
246 &IID_IHTMLScriptElement,
248 &IID_IConnectionPointContainer,
252 static const IID * const text_iids[] = {
255 &IID_IHTMLDOMTextNode,
259 static const IID * const location_iids[] = {
265 static const IID * const window_iids[] = {
273 static const IID * const comment_iids[] = {
279 &IID_IHTMLCommentElement,
281 &IID_IConnectionPointContainer,
285 static const IID * const img_iids[] = {
292 &IID_IHTMLImgElement,
293 &IID_IConnectionPointContainer,
297 static const IID * const tr_iids[] = {
305 &IID_IConnectionPointContainer,
309 static const IID * const td_iids[] = {
316 &IID_IConnectionPointContainer,
320 static const IID * const frame_iids[] = {
327 &IID_IHTMLFrameBase2,
329 &IID_IConnectionPointContainer,
333 static const IID * const object_iids[] = {
339 &IID_IHTMLObjectElement,
341 /* FIXME: No IConnectionPointContainer */
345 static const IID * const embed_iids[] = {
351 &IID_IHTMLEmbedElement,
353 /* FIXME: No IConnectionPointContainer */
357 static const IID * const iframe_iids[] = {
364 &IID_IHTMLFrameBase2,
365 &IID_IHTMLIFrameElement,
367 &IID_IConnectionPointContainer,
371 static const IID * const form_iids[] = {
377 &IID_IHTMLFormElement,
379 &IID_IConnectionPointContainer,
383 static const IID * const styleelem_iids[] = {
389 &IID_IHTMLStyleElement,
391 &IID_IConnectionPointContainer,
395 static const IID * const generic_iids[] = {
401 &IID_IHTMLGenericElement,
403 &IID_IConnectionPointContainer,
407 static const IID * const style_iids[] = {
418 static const IID * const cstyle_iids[] = {
422 &IID_IHTMLCurrentStyle,
426 static const IID * const img_factory_iids[] = {
430 &IID_IHTMLImageElementFactory,
440 static const elem_type_info_t elem_type_infos[] = {
441 {"", none_iids, NULL},
442 {"HTML", elem_iids, NULL},
443 {"HEAD", elem_iids, NULL},
444 {"TITLE", elem_iids, NULL},
445 {"BODY", body_iids, &DIID_DispHTMLBody},
446 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
447 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
448 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
449 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
450 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
451 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
452 {"BLOCKQUOTE",elem_iids, NULL},
453 {"P", elem_iids, NULL},
454 {"BR", elem_iids, NULL},
455 {"TABLE", table_iids, &DIID_DispHTMLTable},
456 {"TBODY", elem_iids, NULL},
457 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
458 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
459 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
460 {"!", comment_iids, &DIID_DispHTMLCommentElement},
461 {"IMG", img_iids, &DIID_DispHTMLImg},
462 {"TR", tr_iids, &DIID_DispHTMLTableRow},
463 {"TD", td_iids, NULL},
464 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
465 {"FORM", form_iids, &DIID_DispHTMLFormElement},
466 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
467 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
468 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
469 {"DIV", elem_iids, NULL}
472 static const char *dbgstr_guid(REFIID riid)
476 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
477 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
478 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
479 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
484 static int strcmp_wa(LPCWSTR strw, const char *stra)
487 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
488 return lstrcmpA(stra, buf);
491 static BSTR a2bstr(const char *str)
496 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
497 ret = SysAllocStringLen(NULL, len);
498 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
503 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
505 IUnknown *unk1, *unk2;
510 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
511 IUnknown_Release(unk1);
512 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
513 IUnknown_Release(unk2);
518 static IHTMLDocument2 *create_document(void)
521 IHTMLDocument5 *doc5;
524 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
525 &IID_IHTMLDocument2, (void**)&doc);
526 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
530 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
532 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
533 IHTMLDocument2_Release(doc);
537 IHTMLDocument5_Release(doc5);
541 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
542 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
544 const IID * const *piid;
548 for(piid = iids; *piid; piid++) {
549 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
550 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
552 IUnknown_Release(unk);
556 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
557 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
565 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
566 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
571 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
572 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
573 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
575 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
576 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
578 if(SUCCEEDED(hres)) {
581 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
582 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
584 *iid = type_attr->guid;
588 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
589 ITypeInfo_Release(typeinfo);
592 IDispatchEx_Release(dispex);
596 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
597 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
599 DISPPARAMS dp = {NULL,NULL,0,0};
605 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
606 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
610 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
611 IDispatchEx_Release(dispex);
612 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
614 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
615 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
619 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
620 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
624 if(_test_get_dispid(line, unk, &iid))
625 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
628 _test_disp_value(line, unk, val);
631 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
632 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
636 if(_test_get_dispid(line, unk, &iid))
637 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
638 "unexpected guid %s\n", dbgstr_guid(&iid));
641 _test_disp_value(line, unk, val);
644 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
645 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
650 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
651 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
655 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
656 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
661 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
662 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
666 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
667 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
672 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
673 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
677 #define get_node_iface(u) _get_node_iface(__LINE__,u)
678 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
683 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
684 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
688 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
689 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
694 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
695 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
699 #define get_img_iface(u) _get_img_iface(__LINE__,u)
700 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
702 IHTMLImgElement *img;
705 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
706 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
710 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
711 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
713 IHTMLAnchorElement *anchor;
716 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
717 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
721 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
722 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
724 IHTMLTextAreaElement *textarea;
727 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
728 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
732 #define get_select_iface(u) _get_select_iface(__LINE__,u)
733 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
735 IHTMLSelectElement *select;
738 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
739 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
743 #define get_form_iface(u) _get_form_iface(__LINE__,u)
744 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
746 IHTMLFormElement *form;
749 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
750 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
754 #define get_text_iface(u) _get_text_iface(__LINE__,u)
755 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
757 IHTMLDOMTextNode *text;
760 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
761 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
765 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
766 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
768 IHTMLCommentElement *comment;
771 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
772 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
776 #define get_object_iface(u) _get_object_iface(__LINE__,u)
777 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
779 IHTMLObjectElement *obj;
782 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
783 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
787 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
788 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
790 IHTMLDOMNode *node = _get_node_iface(line, unk);
794 hres = IHTMLDOMNode_get_nodeName(node, &name);
795 IHTMLDOMNode_Release(node);
796 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
797 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
802 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
803 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
805 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
806 IDispatch *disp = (void*)0xdeadbeef;
807 IHTMLDocument2 *doc = NULL;
810 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
811 IHTMLDOMNode2_Release(node);
812 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
815 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
816 IDispatch_Release(disp);
817 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
823 #define get_doc_window(d) _get_doc_window(__LINE__,d)
824 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
826 IHTMLWindow2 *window;
830 hres = IHTMLDocument2_get_parentWindow(doc, &window);
831 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
832 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
837 #define clone_node(n,d) _clone_node(__LINE__,n,d)
838 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
840 IHTMLDOMNode *node = _get_node_iface(line, unk);
841 IHTMLDOMNode *ret = NULL;
844 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
845 IHTMLDOMNode_Release(node);
846 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
847 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
853 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
854 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
856 IHTMLElement *elem = _get_elem_iface(line, unk);
860 hres = IHTMLElement_get_tagName(elem, &tag);
861 IHTMLElement_Release(elem);
862 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
863 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
868 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
869 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
871 _test_elem_tag(line, unk, elem_type_infos[type].tag);
872 _test_ifaces(line, unk, elem_type_infos[type].iids);
874 if(elem_type_infos[type].dispiid && type != ET_A)
875 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
878 #define get_node_type(n) _get_node_type(__LINE__,n)
879 static LONG _get_node_type(unsigned line, IUnknown *unk)
881 IHTMLDOMNode *node = _get_node_iface(line, unk);
885 hres = IHTMLDOMNode_get_nodeType(node, &type);
886 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
888 IHTMLDOMNode_Release(node);
893 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
894 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
896 IHTMLDOMNode *node = _get_node_iface(line, unk);
897 IHTMLDOMChildrenCollection *col = NULL;
901 hres = IHTMLDOMNode_get_childNodes(node, &disp);
902 IHTMLDOMNode_Release(node);
903 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
907 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
908 IDispatch_Release(disp);
909 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
914 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
915 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
917 IHTMLDOMNode *node = NULL;
921 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
922 ok(hres == S_OK, "item failed: %08x\n", hres);
924 node = _get_node_iface(line, (IUnknown*)disp);
925 IDispatch_Release(disp);
930 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
931 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
940 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
942 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
945 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
946 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
948 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
951 VariantClear(&value);
954 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
955 static void _test_elem_offset(unsigned line, IUnknown *unk)
957 IHTMLElement *elem = _get_elem_iface(line, unk);
961 hres = IHTMLElement_get_offsetTop(elem, &l);
962 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
964 hres = IHTMLElement_get_offsetHeight(elem, &l);
965 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
967 hres = IHTMLElement_get_offsetWidth(elem, &l);
968 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
970 IHTMLElement_Release(elem);
973 #define get_doc_node(d) _get_doc_node(__LINE__,d)
974 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
976 IHTMLWindow2 *window;
980 hres = IHTMLDocument2_get_parentWindow(doc, &window);
981 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
983 hres = IHTMLWindow2_get_document(window, &ret);
984 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
985 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
990 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
991 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
996 hres = IHTMLWindow2_get_name(window, &name);
997 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
999 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
1001 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
1002 SysFreeString(name);
1005 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1006 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
1012 hres = IHTMLWindow2_put_name(window, str);
1014 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
1016 _test_window_name(line, window, name);
1019 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1020 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
1025 hres = IHTMLWindow2_get_length(window, &length);
1026 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1027 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1030 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1031 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1033 IHTMLFrameBase2 *base2;
1034 IHTMLWindow2 *window;
1037 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1038 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1041 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1042 IHTMLFrameBase2_Release(base2);
1043 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1044 ok(window != NULL, "contentWindow = NULL\n");
1049 static void test_get_set_attr(IHTMLDocument2 *doc)
1052 IHTMLDocument3 *doc3;
1057 /* grab an element to test with */
1058 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1059 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1061 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1062 IHTMLDocument3_Release(doc3);
1063 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1065 /* get a non-present attribute */
1066 bstr = a2bstr("notAnAttribute");
1067 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1068 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1069 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1071 SysFreeString(bstr);
1073 /* get a present attribute */
1074 bstr = a2bstr("scrollHeight");
1075 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1076 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1077 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1079 SysFreeString(bstr);
1081 /* create a new BSTR attribute */
1082 bstr = a2bstr("newAttribute");
1084 V_VT(&val) = VT_BSTR;
1085 V_BSTR(&val) = a2bstr("the value");
1086 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1087 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1090 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1091 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1092 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1093 ok(strcmp_wa(V_BSTR(&val), "the value") == 0, "variant value should have been L\"the value\", was %s\n", wine_dbgstr_w(V_BSTR(&val)));
1096 /* overwrite the attribute with a BOOL */
1097 V_VT(&val) = VT_BOOL;
1098 V_BOOL(&val) = VARIANT_TRUE;
1099 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1100 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1103 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1104 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1105 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1106 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1109 SysFreeString(bstr);
1111 /* case-insensitive */
1112 bstr = a2bstr("newattribute");
1113 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1114 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1115 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1116 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1118 SysFreeString(bstr);
1120 IHTMLElement_Release(elem);
1123 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1124 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1127 IHTMLDocument3 *doc3;
1130 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1131 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1132 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1133 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1134 IHTMLDocument3_Release(doc3);
1139 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1140 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1142 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1146 hres = IHTMLAnchorElement_get_href(anchor, &str);
1147 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1148 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1151 _test_disp_value(line, unk, exhref);
1154 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1155 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1160 hres = IHTMLOptionElement_get_text(option, &bstr);
1161 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1162 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1163 SysFreeString(bstr);
1166 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1167 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1172 bstr = a2bstr(text);
1173 hres = IHTMLOptionElement_put_text(option, bstr);
1174 SysFreeString(bstr);
1175 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1177 _test_option_text(line, option, text);
1180 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1181 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1186 hres = IHTMLOptionElement_get_value(option, &bstr);
1187 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1188 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1189 SysFreeString(bstr);
1192 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1193 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1198 bstr = a2bstr(value);
1199 hres = IHTMLOptionElement_put_value(option, bstr);
1200 SysFreeString(bstr);
1201 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1203 _test_option_value(line, option, value);
1206 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1207 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1209 VARIANT_BOOL b = 0x100;
1212 hres = IHTMLOptionElement_get_selected(option, &b);
1213 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1214 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1217 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1218 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1222 hres = IHTMLOptionElement_put_selected(option, b);
1223 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1224 _test_option_selected(line, option, b);
1227 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1228 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1230 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1231 BSTR value = (void*)0xdeadbeef;
1234 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1235 IHTMLTextAreaElement_Release(textarea);
1236 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1238 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1240 ok_(__FILE__,line)(!value, "value = %p\n", value);
1241 SysFreeString(value);
1244 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1245 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1247 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1248 BSTR tmp = a2bstr(value);
1251 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1252 IHTMLTextAreaElement_Release(textarea);
1253 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1256 _test_textarea_value(line, unk, value);
1259 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1260 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1262 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1263 VARIANT_BOOL b = 0x100;
1266 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1267 IHTMLTextAreaElement_Release(textarea);
1268 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1269 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1272 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1273 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1275 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1278 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1279 IHTMLTextAreaElement_Release(textarea);
1280 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1282 _test_textarea_readonly(line, unk, b);
1285 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1286 static void _test_textarea_type(unsigned line, IUnknown *unk)
1288 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1289 BSTR type = (void*)0xdeadbeef;
1292 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1293 IHTMLTextAreaElement_Release(textarea);
1294 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1295 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1296 SysFreeString(type);
1299 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1300 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1302 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1306 text = a2bstr(extext);
1307 hres = IHTMLCommentElement_get_text(comment, &text);
1308 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1309 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1311 IHTMLCommentElement_Release(comment);
1312 SysFreeString(text);
1315 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1316 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1318 IHTMLObjectElement *object = _get_object_iface(line, unk);
1323 hres = IHTMLObjectElement_get_vspace(object, &l);
1324 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1325 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1326 IHTMLObjectElement_Release(object);
1329 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1330 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1331 const char *txt, const char *val)
1333 IHTMLOptionElementFactory *factory;
1334 IHTMLOptionElement *option;
1335 IHTMLWindow2 *window;
1336 VARIANT text, value, empty;
1339 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1340 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1342 hres = IHTMLWindow2_get_Option(window, &factory);
1343 IHTMLWindow2_Release(window);
1344 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1346 V_VT(&text) = VT_BSTR;
1347 V_BSTR(&text) = a2bstr(txt);
1348 V_VT(&value) = VT_BSTR;
1349 V_BSTR(&value) = a2bstr(val);
1350 V_VT(&empty) = VT_EMPTY;
1352 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1353 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1355 IHTMLOptionElementFactory_Release(factory);
1356 VariantClear(&text);
1357 VariantClear(&value);
1359 _test_option_text(line, option, txt);
1360 _test_option_value(line, option, val);
1361 _test_option_selected(line, option, VARIANT_FALSE);
1366 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1367 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1372 hres = IHTMLImgElement_get_width(img, &found);
1373 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1374 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1377 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1378 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1382 hres = IHTMLImgElement_put_width(img, width);
1383 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1385 _test_img_width(line, img, width);
1388 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1389 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1394 hres = IHTMLImgElement_get_height(img, &found);
1395 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1396 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1399 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1400 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1404 hres = IHTMLImgElement_put_height(img, height);
1405 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1407 _test_img_height(line, img, height);
1410 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1411 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1412 LONG wdth, LONG hght)
1414 IHTMLImageElementFactory *factory;
1415 IHTMLImgElement *img;
1416 IHTMLWindow2 *window;
1417 VARIANT width, height;
1421 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1422 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1424 hres = IHTMLWindow2_get_Image(window, &factory);
1425 IHTMLWindow2_Release(window);
1426 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1428 test_ifaces((IUnknown*)factory, img_factory_iids);
1429 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1432 snprintf(buf, 16, "%d", wdth);
1433 V_VT(&width) = VT_BSTR;
1434 V_BSTR(&width) = a2bstr(buf);
1436 V_VT(&width) = VT_EMPTY;
1441 snprintf(buf, 16, "%d", hght);
1442 V_VT(&height) = VT_BSTR;
1443 V_BSTR(&height) = a2bstr(buf);
1445 V_VT(&height) = VT_EMPTY;
1449 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1450 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1452 IHTMLImageElementFactory_Release(factory);
1453 VariantClear(&width);
1454 VariantClear(&height);
1456 if(SUCCEEDED(hres)) {
1457 _test_img_width(line, img, wdth);
1458 _test_img_height(line, img, hght);
1465 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1466 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1468 LONG len = 0xdeadbeef;
1471 hres = IHTMLSelectElement_get_length(select, &len);
1472 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1473 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1476 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1477 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1479 IHTMLSelectElement *select = _get_select_iface(line, unk);
1482 hres = IHTMLSelectElement_put_length(select, length);
1483 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1484 _test_select_length(line, select, length);
1485 IHTMLSelectElement_Release(select);
1488 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1489 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1491 LONG idx = 0xdeadbeef;
1494 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1495 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1496 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1499 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1500 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1504 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1505 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1506 _test_select_selidx(line, select, index);
1509 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1510 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1515 hres = IHTMLSelectElement_get_value(select, &val);
1516 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1518 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1520 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1524 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1525 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1531 hres = IHTMLSelectElement_put_value(select, bstr);
1532 SysFreeString(bstr);
1533 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1536 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1537 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1542 hres = IHTMLSelectElement_get_type(select, &type);
1543 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1544 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1545 SysFreeString(type);
1548 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1549 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1554 hres = IHTMLTxtRange_get_text(range, &text);
1555 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1558 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1559 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1561 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1564 SysFreeString(text);
1568 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1569 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1573 hres = IHTMLTxtRange_collapse(range, b);
1574 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1575 _test_range_text(line, range, NULL);
1578 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1579 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1580 VARIANT_BOOL exb, const char *extext)
1582 VARIANT_BOOL b = 0xe0e0;
1585 hres = IHTMLTxtRange_expand(range, unit, &b);
1586 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1587 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1588 _test_range_text(line, range, extext);
1591 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1592 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1594 LONG c = 0xdeadbeef;
1597 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1598 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1599 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1600 _test_range_text(line, range, NULL);
1603 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1604 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1605 LPWSTR unit, LONG cnt, LONG excnt)
1607 LONG c = 0xdeadbeef;
1610 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1611 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1612 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1615 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1616 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1618 LONG c = 0xdeadbeef;
1621 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1622 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1623 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1626 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1627 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1630 BSTR bstr = a2bstr(text);
1632 hres = IHTMLTxtRange_put_text(range, bstr);
1633 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1634 SysFreeString(bstr);
1635 _test_range_text(line, range, NULL);
1638 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1639 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1645 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1646 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1647 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1650 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1651 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1657 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1658 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1659 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1662 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1663 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1664 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1667 test_range_inrange(range1, range2, VARIANT_TRUE);
1668 test_range_inrange(range2, range1, VARIANT_TRUE);
1672 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1673 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1678 hres = IHTMLTxtRange_parentElement(range, &elem);
1679 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1681 _test_elem_type(line, (IUnknown*)elem, type);
1683 IHTMLElement_Release(elem);
1686 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1687 static void _test_elem_collection(unsigned line, IUnknown *unk,
1688 const elem_type_t *elem_types, LONG exlen)
1690 IHTMLElementCollection *col;
1693 VARIANT name, index;
1694 IDispatch *disp, *disp2;
1697 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1698 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1700 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1702 hres = IHTMLElementCollection_get_length(col, &len);
1703 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1704 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1709 V_VT(&index) = VT_EMPTY;
1711 for(i=0; i<len; i++) {
1712 V_VT(&name) = VT_I4;
1714 disp = (void*)0xdeadbeef;
1715 hres = IHTMLElementCollection_item(col, name, index, &disp);
1716 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1717 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1718 if(FAILED(hres) || !disp)
1721 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1724 V_VT(&name) = VT_UINT;
1726 disp2 = (void*)0xdeadbeef;
1727 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1728 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1729 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1731 IDispatch_Release(disp2);
1734 IDispatch_Release(disp);
1737 V_VT(&name) = VT_I4;
1739 disp = (void*)0xdeadbeef;
1740 hres = IHTMLElementCollection_item(col, name, index, &disp);
1741 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1742 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1744 V_VT(&name) = VT_I4;
1746 disp = (void*)0xdeadbeef;
1747 hres = IHTMLElementCollection_item(col, name, index, &disp);
1748 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1749 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1751 IHTMLElementCollection_Release(col);
1754 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1755 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1757 IHTMLElement *elem = _get_elem_iface(line, unk);
1761 hres = IHTMLElement_get_all(elem, &disp);
1762 IHTMLElement_Release(elem);
1763 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1765 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1766 IDispatch_Release(disp);
1769 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1770 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1772 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1773 IHTMLElementCollection *col = NULL;
1774 elem_type_t *types = NULL;
1779 tmp = a2bstr(elem_type_infos[type].tag);
1780 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1782 IHTMLElement2_Release(elem);
1783 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1784 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1787 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1788 for(i=0; i<exlen; i++)
1792 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1794 HeapFree(GetProcessHeap(), 0, types);
1797 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1798 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1803 hres = IHTMLElement_get_innerText(elem, &text);
1804 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1805 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1806 wine_dbgstr_w(text), extext);
1807 SysFreeString(text);
1810 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1811 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1813 IHTMLDOMChildrenCollection *col;
1818 hres = IHTMLElement_put_innerText(elem, str);
1819 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1822 _test_elem_innertext(line, elem, text);
1825 col = _get_child_nodes(line, (IUnknown*)elem);
1826 ok(col != NULL, "col == NULL\n");
1828 LONG length = 0, type;
1831 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1832 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1833 ok(length == 1, "length = %d\n", length);
1835 node = _get_child_item(line, col, 0);
1836 ok(node != NULL, "node == NULL\n");
1838 type = _get_node_type(line, (IUnknown*)node);
1839 ok(type == 3, "type=%d\n", type);
1840 IHTMLDOMNode_Release(node);
1843 IHTMLDOMChildrenCollection_Release(col);
1848 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1849 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1851 IHTMLElement *elem = _get_elem_iface(line, unk);
1855 hres = IHTMLElement_get_innerHTML(elem, &html);
1856 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1858 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1860 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1862 IHTMLElement_Release(elem);
1863 SysFreeString(html);
1866 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1867 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1869 IHTMLElement *elem = _get_elem_iface(line, unk);
1873 html = a2bstr(inner_html);
1874 hres = IHTMLElement_put_innerHTML(elem, html);
1875 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1877 IHTMLElement_Release(elem);
1878 SysFreeString(html);
1881 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1882 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1884 IHTMLElement *elem = _get_elem_iface(line, unk);
1888 html = a2bstr(outer_html);
1889 hres = IHTMLElement_put_outerHTML(elem, html);
1890 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1892 IHTMLElement_Release(elem);
1893 SysFreeString(html);
1896 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1897 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1899 IHTMLElement *elem = _get_elem_iface(line, unk);
1903 hres = IHTMLElement_get_outerHTML(elem, &html);
1904 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1905 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1907 IHTMLElement_Release(elem);
1908 SysFreeString(html);
1911 #define get_first_child(n) _get_first_child(__LINE__,n)
1912 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1914 IHTMLDOMNode *node = _get_node_iface(line, unk);
1915 IHTMLDOMNode *child = NULL;
1918 hres = IHTMLDOMNode_get_firstChild(node, &child);
1919 IHTMLDOMNode_Release(node);
1920 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1925 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1926 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1928 IHTMLDOMNode *node = _get_node_iface(line, unk);
1929 VARIANT_BOOL b = 0xdead;
1932 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1933 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1934 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1936 IHTMLDOMNode_Release(node);
1939 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1940 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1942 IHTMLDOMNode *node = _get_node_iface(line, unk);
1943 IHTMLDOMNode *parent;
1946 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1947 IHTMLDOMNode_Release(node);
1948 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1953 #define node_get_next(u) _node_get_next(__LINE__,u)
1954 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1956 IHTMLDOMNode *node = _get_node_iface(line, unk);
1960 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1961 IHTMLDOMNode_Release(node);
1962 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1967 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1968 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1970 IHTMLElement *elem = _get_elem_iface(line, unk);
1971 IHTMLElement *parent;
1974 hres = IHTMLElement_get_parentElement(elem, &parent);
1975 IHTMLElement_Release(elem);
1976 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1981 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1982 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1984 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1985 VARIANT_BOOL disabled = 100;
1989 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1990 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1991 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1992 IHTMLElement3_Release(elem3);
1995 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1996 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1998 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2002 hres = IHTMLElement3_put_disabled(elem3, b);
2003 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2005 IHTMLElement3_Release(elem3);
2006 _test_elem3_get_disabled(line, unk, b);
2009 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2010 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2012 VARIANT_BOOL disabled = 100;
2015 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2016 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2017 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2019 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2022 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2023 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2025 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2029 hres = IHTMLDOMTextNode_get_length(text, &length);
2030 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2031 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2032 IHTMLDOMTextNode_Release(text);
2035 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2036 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2040 hres = IHTMLSelectElement_put_disabled(select, b);
2041 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2043 _test_select_get_disabled(line, select, b);
2046 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2047 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2049 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2050 IHTMLTextContainer *txtcont;
2051 LONG l = -1, l2 = -1;
2054 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2055 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2056 IHTMLElement2_Release(elem);
2058 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2059 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2061 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2062 IHTMLTextContainer_Release(txtcont);
2063 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2064 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2069 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2070 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2072 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2073 IHTMLTextContainer *txtcont;
2074 LONG l = -1, l2 = -1;
2077 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2078 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2079 IHTMLElement2_Release(elem);
2081 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2082 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2084 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2085 IHTMLTextContainer_Release(txtcont);
2086 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2087 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2092 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2093 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2095 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2096 IHTMLTextContainer *txtcont;
2097 LONG l = -1, l2 = -1;
2100 hres = IHTMLElement2_get_scrollTop(elem, &l);
2101 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2102 IHTMLElement2_Release(elem);
2104 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2105 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2107 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2108 IHTMLTextContainer_Release(txtcont);
2109 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2110 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2115 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2116 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2118 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2119 IHTMLTextContainer *txtcont;
2120 LONG l = -1, l2 = -1;
2123 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2124 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2126 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2127 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2128 IHTMLElement2_Release(elem);
2130 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2131 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2133 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2134 IHTMLTextContainer_Release(txtcont);
2135 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2136 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2139 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2140 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2142 IHTMLImgElement *img = _get_img_iface(line, unk);
2146 hres = IHTMLImgElement_get_src(img, &src);
2147 IHTMLImgElement_Release(img);
2148 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2149 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2153 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2154 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2156 IHTMLImgElement *img = _get_img_iface(line, unk);
2161 hres = IHTMLImgElement_put_src(img, tmp);
2162 IHTMLImgElement_Release(img);
2164 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2166 _test_img_src(line, unk, src);
2169 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2170 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2172 IHTMLImgElement *img = _get_img_iface(line, unk);
2176 hres = IHTMLImgElement_get_alt(img, &alt);
2177 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2179 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2181 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2185 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2186 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2188 IHTMLImgElement *img = _get_img_iface(line, unk);
2193 hres = IHTMLImgElement_put_alt(img, tmp);
2194 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2197 _test_img_alt(line, unk, alt);
2200 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2201 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2203 IHTMLImgElement *img = _get_img_iface(line, unk);
2207 hres = IHTMLImgElement_get_name(img, &sName);
2208 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2209 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2210 IHTMLImgElement_Release(img);
2211 SysFreeString(sName);
2214 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2215 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2220 hres = IHTMLInputElement_get_type(input, &type);
2221 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2222 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2223 SysFreeString(type);
2226 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2227 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2229 BSTR name = (BSTR)0xdeadbeef;
2232 hres = IHTMLInputElement_get_name(input, &name);
2233 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2235 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2237 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2238 SysFreeString(name);
2241 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2242 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2244 BSTR tmp = a2bstr(name);
2247 hres = IHTMLInputElement_put_name(input, tmp);
2248 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2251 _test_input_name(line, input, name);
2254 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2255 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2257 VARIANT_BOOL disabled = 100;
2260 hres = IHTMLInputElement_get_disabled(input, &disabled);
2261 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2262 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2264 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2267 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2268 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2272 hres = IHTMLInputElement_put_disabled(input, b);
2273 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2275 _test_input_get_disabled(line, input, b);
2278 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2279 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2281 VARIANT_BOOL checked = 100;
2284 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2285 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2286 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2289 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2290 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2294 hres = IHTMLInputElement_put_defaultChecked(input, b);
2295 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2297 _test_input_get_defaultchecked(line, input, b);
2300 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2301 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2303 VARIANT_BOOL checked = 100;
2306 hres = IHTMLInputElement_get_checked(input, &checked);
2307 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2308 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2311 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2312 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2316 hres = IHTMLInputElement_put_checked(input, b);
2317 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2319 _test_input_get_checked(line, input, b);
2322 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2323 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2325 IHTMLInputElement *input;
2329 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2330 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2334 hres = IHTMLInputElement_get_value(input, &bstr);
2335 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2337 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2339 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2340 SysFreeString(bstr);
2341 IHTMLInputElement_Release(input);
2344 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2345 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2347 IHTMLInputElement *input;
2351 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2352 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2357 hres = IHTMLInputElement_get_value(input, &bstr);
2358 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2359 SysFreeString(bstr);
2360 IHTMLInputElement_Release(input);
2363 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2364 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2369 hres = IHTMLInputElement_get_src(input, &src);
2370 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2372 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2374 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2378 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2379 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2385 hres = IHTMLInputElement_put_src(input, tmp);
2387 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2389 _test_input_src(line, input, src);
2392 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2393 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2395 IHTMLElement *elem = _get_elem_iface(line, unk);
2396 BSTR class = (void*)0xdeadbeef;
2399 hres = IHTMLElement_get_className(elem, &class);
2400 IHTMLElement_Release(elem);
2401 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2403 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2405 ok_(__FILE__,line) (!class, "class != NULL\n");
2406 SysFreeString(class);
2409 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2410 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2412 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2416 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2417 IHTMLElement2_Release(elem2);
2418 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2419 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2422 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2423 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2425 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2428 hres = IHTMLElement2_put_tabIndex(elem2, index);
2429 IHTMLElement2_Release(elem2);
2430 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2432 _test_elem_tabindex(line, unk, index);
2435 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2436 static void _test_elem_filters(unsigned line, IUnknown *unk)
2438 IHTMLElement *elem = _get_elem_iface(line, unk);
2440 IHTMLFiltersCollection *filters;
2442 hres = IHTMLElement_get_filters(elem, &filters);
2443 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2444 "get_filters failed: %08x\n", hres);
2448 IDispatchEx *dispex;
2450 hres = IHTMLFiltersCollection_get_length(filters, &len);
2451 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2452 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2454 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2455 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2456 "Could not get IDispatchEx interface: %08x\n", hres);
2457 if(SUCCEEDED(hres)) {
2458 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2459 IDispatchEx_Release(dispex);
2462 IHTMLFiltersCollection_Release(filters);
2465 IHTMLElement_Release(elem);
2468 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2469 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2471 IHTMLElement *elem = _get_elem_iface(line, unk);
2475 tmp = class ? a2bstr(class) : NULL;
2476 hres = IHTMLElement_put_className(elem, tmp);
2477 IHTMLElement_Release(elem);
2478 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2481 _test_elem_class(line, unk, class);
2484 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2485 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2487 IHTMLElement *elem = _get_elem_iface(line, unk);
2488 BSTR id = (void*)0xdeadbeef;
2491 hres = IHTMLElement_get_id(elem, &id);
2492 IHTMLElement_Release(elem);
2493 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2496 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2498 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2503 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2504 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2506 IHTMLElement *elem = _get_elem_iface(line, unk);
2507 BSTR tmp = a2bstr(new_id);
2510 hres = IHTMLElement_put_id(elem, tmp);
2511 IHTMLElement_Release(elem);
2513 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2515 _test_elem_id(line, unk, new_id);
2518 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2519 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2521 IHTMLElement *elem = _get_elem_iface(line, unk);
2525 hres = IHTMLElement_get_title(elem, &title);
2526 IHTMLElement_Release(elem);
2527 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2529 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2531 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2533 SysFreeString(title);
2536 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2537 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2539 IHTMLElement *elem = _get_elem_iface(line, unk);
2543 tmp = a2bstr(title);
2544 hres = IHTMLElement_put_title(elem, tmp);
2545 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2547 IHTMLElement_Release(elem);
2551 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2552 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2554 IHTMLDOMNode *node = _get_node_iface(line, unk);
2558 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2559 IHTMLDOMNode_Release(node);
2560 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2563 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2564 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2566 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2572 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2573 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2575 IHTMLDOMNode *node = _get_node_iface(line, unk);
2579 V_VT(&var) = VT_BSTR;
2580 V_BSTR(&var) = a2bstr(val);
2582 hres = IHTMLDOMNode_put_nodeValue(node, var);
2583 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2584 IHTMLDOMNode_Release(node);
2588 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2589 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2591 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2595 hres = IHTMLElement2_get_clientWidth(elem, &l);
2596 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2597 hres = IHTMLElement2_get_clientHeight(elem, &l);
2598 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2600 IHTMLElement2_Release(elem);
2603 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2604 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2606 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2610 hres = IHTMLElement2_get_clientLeft(elem, &l);
2611 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2612 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2614 hres = IHTMLElement2_get_clientTop(elem, &l);
2615 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2616 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2618 IHTMLElement2_Release(elem);
2621 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2622 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2624 IHTMLFormElement *form = _get_form_iface(line, unk);
2625 LONG len = 0xdeadbeef;
2628 hres = IHTMLFormElement_get_length(form, &len);
2629 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2630 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2632 IHTMLFormElement_Release(form);
2635 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2636 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2638 IHTMLFormElement *form = _get_form_iface(line, unk);
2639 BSTR action = (void*)0xdeadbeef;
2642 hres = IHTMLFormElement_get_action(form, &action);
2643 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2645 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2647 ok_(__FILE__,line)(!action, "action=%p\n", action);
2649 SysFreeString(action);
2650 IHTMLFormElement_Release(form);
2653 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2654 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2656 IHTMLFormElement *form = _get_form_iface(line, unk);
2657 BSTR tmp = a2bstr(action);
2660 hres = IHTMLFormElement_put_action(form, tmp);
2661 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2663 IHTMLFormElement_Release(form);
2665 _test_form_action(line, unk, action);
2668 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2669 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2671 IHTMLFormElement *form = _get_form_iface(line, unk);
2672 BSTR method = (void*)0xdeadbeef;
2675 hres = IHTMLFormElement_get_method(form, &method);
2676 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2678 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2680 ok_(__FILE__,line)(!method, "method=%p\n", method);
2682 SysFreeString(method);
2683 IHTMLFormElement_Release(form);
2686 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2687 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2689 IHTMLFormElement *form = _get_form_iface(line, unk);
2690 BSTR tmp = a2bstr(method);
2693 hres = IHTMLFormElement_put_method(form, tmp);
2694 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2696 IHTMLFormElement_Release(form);
2698 if(exp_hres == S_OK)
2699 _test_form_method(line, unk, method);
2702 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2703 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2705 IHTMLFormElement *form = _get_form_iface(line, unk);
2706 BSTR name = (void*)0xdeadbeef;
2709 hres = IHTMLFormElement_get_name(form, &name);
2710 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2712 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2714 ok_(__FILE__,line)(!name, "name=%p\n", name);
2716 SysFreeString(name);
2717 IHTMLFormElement_Release(form);
2720 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2721 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2723 IHTMLFormElement *form = _get_form_iface(line, unk);
2724 BSTR tmp = a2bstr(name);
2727 hres = IHTMLFormElement_put_name(form, tmp);
2728 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2730 IHTMLFormElement_Release(form);
2732 _test_form_name(line, unk, name);
2735 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2736 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2738 IHTMLFormElement *form = _get_form_iface(line, unk);
2739 BSTR encoding = (void*)0xdeadbeef;
2742 hres = IHTMLFormElement_get_encoding(form, &encoding);
2743 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2745 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2747 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2749 SysFreeString(encoding);
2750 IHTMLFormElement_Release(form);
2753 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2754 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2756 IHTMLFormElement *form = _get_form_iface(line, unk);
2757 BSTR tmp = a2bstr(encoding);
2760 hres = IHTMLFormElement_put_encoding(form, tmp);
2761 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2763 IHTMLFormElement_Release(form);
2765 if(exp_hres == S_OK)
2766 _test_form_encoding(line, unk, encoding);
2769 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2770 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2772 IHTMLElement *elem = _get_elem_iface(line, unk);
2773 IHTMLDocument2 *doc;
2778 hres = IHTMLElement_get_document(elem, &disp);
2779 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2780 ok(disp != NULL, "disp == NULL\n");
2782 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2783 IDispatch_Release(disp);
2784 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2789 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2790 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2792 IHTMLDocument2 *doc;
2796 hres = IHTMLWindow2_get_document(window, &doc);
2797 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2798 ok(doc != NULL, "disp == NULL\n");
2803 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2804 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
2809 hres = IHTMLDocument2_get_body(doc, &elem);
2810 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2811 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
2816 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2817 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2819 IHTMLElement *elem = NULL;
2824 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2825 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2826 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2831 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2832 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2834 IHTMLDocument3 *doc3;
2835 IHTMLDOMNode *node = NULL;
2839 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2840 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2843 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2844 IHTMLDocument3_Release(doc3);
2845 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2846 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2851 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2852 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2854 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2855 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2856 IHTMLDOMNode *new_child = NULL;
2859 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2860 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2861 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2862 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2864 IHTMLDOMNode_Release(node);
2865 IHTMLDOMNode_Release(child);
2870 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2871 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2873 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2874 IHTMLDOMNode *new_child = NULL;
2877 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2878 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2879 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2880 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2882 IHTMLDOMNode_Release(node);
2887 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2888 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2890 IHTMLDOMNode *node = _get_node_iface(line, unk);
2891 IHTMLDOMNode *new_node = NULL;
2894 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2895 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2896 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2897 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2899 IHTMLDOMNode_Release(node);
2900 IHTMLDOMNode_Release(new_node);
2903 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2904 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2909 hres = IHTMLDocument2_get_title(doc, &title);
2910 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2911 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2912 SysFreeString(title);
2915 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2916 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2921 tmp = a2bstr(title);
2922 hres = IHTMLDocument2_put_title(doc, tmp);
2923 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2927 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2928 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2933 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2934 LOCALE_USER_DEFAULT, &dispid);
2935 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2938 DISPPARAMS params = {NULL,NULL,0,0};
2939 DISPID dispidNamed = DISPID_PROPERTYPUT;
2944 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2945 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2946 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2949 params.cNamedArgs = 1;
2950 params.rgdispidNamedArgs = &dispidNamed;
2951 V_VT(&arg) = VT_BSTR;
2952 V_BSTR(&arg) = a2bstr("none");
2953 params.rgvarg = &arg;
2954 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2955 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2956 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2959 V_VT(&arg) = VT_BSTR;
2960 V_BSTR(&arg) = a2bstr("dotted");
2961 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2962 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2963 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2966 V_VT(&arg) = VT_BSTR;
2967 V_BSTR(&arg) = a2bstr("dashed");
2968 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2969 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2970 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2973 V_VT(&arg) = VT_BSTR;
2974 V_BSTR(&arg) = a2bstr("solid");
2975 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2976 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2977 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2980 V_VT(&arg) = VT_BSTR;
2981 V_BSTR(&arg) = a2bstr("double");
2982 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2983 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2984 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2987 V_VT(&arg) = VT_BSTR;
2988 V_BSTR(&arg) = a2bstr("groove");
2989 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2990 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2991 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2994 V_VT(&arg) = VT_BSTR;
2995 V_BSTR(&arg) = a2bstr("ridge");
2996 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2997 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2998 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
3001 V_VT(&arg) = VT_BSTR;
3002 V_BSTR(&arg) = a2bstr("inset");
3003 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3004 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3005 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
3008 V_VT(&arg) = VT_BSTR;
3009 V_BSTR(&arg) = a2bstr("outset");
3010 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3011 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3012 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
3015 V_VT(&arg) = VT_BSTR;
3016 V_BSTR(&arg) = a2bstr("invalid");
3017 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3018 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3019 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
3022 params.rgvarg = &vDefault;
3023 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3024 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3025 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
3029 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3030 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
3032 BSTR text = (void*)0xdeadbeef;
3035 hres = IHTMLStyle_get_cssText(style, &text);
3036 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
3038 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
3040 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
3042 SysFreeString(text);
3045 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3046 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
3052 hres = IHTMLStyle_put_cssText(style, tmp);
3053 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3057 static void test_elem_bounding_client_rect(IUnknown *unk)
3059 IHTMLRect *rect, *rect2;
3060 IHTMLElement2 *elem2;
3064 elem2 = get_elem2_iface(unk);
3065 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3066 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3067 IHTMLElement2_Release(elem2);
3068 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3069 ok(rect != NULL, "rect == NULL\n");
3070 ok(rect != rect2, "rect == rect2\n");
3071 IHTMLRect_Release(rect2);
3073 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3076 hres = IHTMLRect_get_top(rect, &l);
3077 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3078 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3081 hres = IHTMLRect_get_left(rect, &l);
3082 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3083 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3086 hres = IHTMLRect_get_bottom(rect, &l);
3087 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3088 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3091 hres = IHTMLRect_get_right(rect, &l);
3092 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3093 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3095 IHTMLRect_Release(rect);
3098 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3099 const elem_type_t *elem_types, LONG len)
3102 VARIANT name, index;
3106 V_VT(&index) = VT_EMPTY;
3107 V_VT(&name) = VT_BSTR;
3108 V_BSTR(&name) = a2bstr(n);
3110 hres = IHTMLElementCollection_item(col, name, index, &disp);
3111 ok(hres == S_OK, "item failed: %08x\n", hres);
3113 test_elem_collection((IUnknown*)disp, elem_types, len);
3114 IDispatch_Release(disp);
3115 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3119 V_VT(&index) = VT_I4;
3121 for(i=0; i<len; i++) {
3123 disp = (void*)0xdeadbeef;
3124 hres = IHTMLElementCollection_item(col, name, index, &disp);
3125 ok(hres == S_OK, "item failed: %08x\n", hres);
3126 ok(disp != NULL, "disp == NULL\n");
3127 if(FAILED(hres) || !disp)
3130 test_elem_type((IUnknown*)disp, elem_types[i]);
3132 IDispatch_Release(disp);
3136 disp = (void*)0xdeadbeef;
3137 hres = IHTMLElementCollection_item(col, name, index, &disp);
3138 ok(hres == S_OK, "item failed: %08x\n", hres);
3139 ok(disp == NULL, "disp != NULL\n");
3142 disp = (void*)0xdeadbeef;
3143 hres = IHTMLElementCollection_item(col, name, index, &disp);
3144 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3145 ok(disp == NULL, "disp != NULL\n");
3148 SysFreeString(V_BSTR(&name));
3151 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3153 IHTMLElementCollection *col;
3155 IDispatch *disp = (void*)0xdeadbeef;
3156 VARIANT name, index;
3159 hres = IHTMLDocument2_get_all(doc, &col);
3160 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3161 ok(col != NULL, "col == NULL\n");
3162 if(FAILED(hres) || !col)
3165 V_VT(&index) = VT_EMPTY;
3166 V_VT(&name) = VT_BSTR;
3167 V_BSTR(&name) = a2bstr(id);
3169 hres = IHTMLElementCollection_item(col, name, index, &disp);
3170 IHTMLElementCollection_Release(col);
3171 SysFreeString(V_BSTR(&name));
3172 ok(hres == S_OK, "item failed: %08x\n", hres);
3173 if(!expect_success) {
3174 ok(disp == NULL, "disp != NULL\n");
3178 ok(disp != NULL, "disp == NULL\n");
3182 elem = get_elem_iface((IUnknown*)disp);
3183 IDispatch_Release(disp);
3188 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3190 IHTMLDocument3 *doc3;
3195 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3196 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3199 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3201 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3203 IHTMLDocument3_Release(doc3);
3208 static void test_select_elem(IHTMLSelectElement *select)
3210 IDispatch *disp, *disp2;
3211 VARIANT name, index;
3214 test_select_type(select, "select-one");
3215 test_select_length(select, 2);
3216 test_select_selidx(select, 0);
3217 test_select_put_selidx(select, 1);
3219 test_select_set_value(select, "val1");
3220 test_select_value(select, "val1");
3222 test_select_get_disabled(select, VARIANT_FALSE);
3223 test_select_set_disabled(select, VARIANT_TRUE);
3224 test_select_set_disabled(select, VARIANT_FALSE);
3227 hres = IHTMLSelectElement_get_options(select, &disp);
3228 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3229 ok(disp != NULL, "options == NULL\n");
3230 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3231 IDispatch_Release(disp);
3233 V_VT(&index) = VT_EMPTY;
3234 V_VT(&name) = VT_I4;
3236 disp = (void*)0xdeadbeef;
3237 hres = IHTMLSelectElement_item(select, name, index, &disp);
3238 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3239 ok(!disp, "disp = %p\n", disp);
3242 disp = (void*)0xdeadbeef;
3243 hres = IHTMLSelectElement_item(select, name, index, &disp);
3244 ok(hres == S_OK, "item failed: %08x\n", hres);
3245 ok(!disp, "disp = %p\n", disp);
3248 hres = IHTMLSelectElement_item(select, name, index, NULL);
3249 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3252 hres = IHTMLSelectElement_item(select, name, index, &disp);
3253 ok(hres == S_OK, "item failed: %08x\n", hres);
3254 ok(disp != NULL, "disp = NULL\n");
3255 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3257 V_VT(&index) = VT_I4;
3260 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3261 ok(hres == S_OK, "item failed: %08x\n", hres);
3262 ok(disp2 != NULL, "disp = NULL\n");
3263 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3264 IDispatch_Release(disp2);
3265 IDispatch_Release(disp);
3268 static void test_form_item(IHTMLElement *elem)
3270 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3271 IDispatch *disp, *disp2;
3272 VARIANT name, index;
3275 V_VT(&index) = VT_EMPTY;
3276 V_VT(&name) = VT_I4;
3278 disp = (void*)0xdeadbeef;
3279 hres = IHTMLFormElement_item(form, name, index, &disp);
3280 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3281 ok(!disp, "disp = %p\n", disp);
3284 disp = (void*)0xdeadbeef;
3285 hres = IHTMLFormElement_item(form, name, index, &disp);
3286 ok(hres == S_OK, "item failed: %08x\n", hres);
3287 ok(!disp, "disp = %p\n", disp);
3290 hres = IHTMLFormElement_item(form, name, index, NULL);
3291 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3294 hres = IHTMLFormElement_item(form, name, index, &disp);
3295 ok(hres == S_OK, "item failed: %08x\n", hres);
3296 ok(disp != NULL, "disp = NULL\n");
3297 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3299 V_VT(&index) = VT_I4;
3302 hres = IHTMLFormElement_item(form, name, index, &disp2);
3303 ok(hres == S_OK, "item failed: %08x\n", hres);
3304 ok(disp2 != NULL, "disp = NULL\n");
3305 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3306 IDispatch_Release(disp2);
3307 IDispatch_Release(disp);
3310 static void test_create_option_elem(IHTMLDocument2 *doc)
3312 IHTMLOptionElement *option;
3314 option = create_option_elem(doc, "test text", "test value");
3316 test_option_put_text(option, "new text");
3317 test_option_put_value(option, "new value");
3318 test_option_put_selected(option, VARIANT_TRUE);
3319 test_option_put_selected(option, VARIANT_FALSE);
3321 IHTMLOptionElement_Release(option);
3324 static void test_create_img_elem(IHTMLDocument2 *doc)
3326 IHTMLImgElement *img;
3328 img = create_img_elem(doc, 10, 15);
3331 test_img_put_width(img, 5);
3332 test_img_put_height(img, 20);
3334 IHTMLImgElement_Release(img);
3338 img = create_img_elem(doc, -1, -1);
3341 test_img_put_width(img, 5);
3342 test_img_put_height(img, 20);
3344 IHTMLImgElement_Release(img);
3348 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3350 IHTMLBodyElement *body;
3351 IHTMLTxtRange *range;
3355 elem = doc_get_body(doc);
3356 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3357 IHTMLElement_Release(elem);
3359 hres = IHTMLBodyElement_createTextRange(body, &range);
3360 IHTMLBodyElement_Release(body);
3361 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3366 static void test_txtrange(IHTMLDocument2 *doc)
3368 IHTMLTxtRange *body_range, *range, *range2;
3369 IHTMLSelectionObject *selection;
3370 IDispatch *disp_range;
3373 body_range = test_create_body_range(doc);
3375 test_range_text(body_range, "test abc 123\r\nit's text");
3377 hres = IHTMLTxtRange_duplicate(body_range, &range);
3378 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3380 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3381 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3382 test_range_isequal(range, range2, VARIANT_TRUE);
3384 test_range_text(range, "test abc 123\r\nit's text");
3385 test_range_text(body_range, "test abc 123\r\nit's text");
3387 test_range_collapse(range, TRUE);
3388 test_range_isequal(range, range2, VARIANT_FALSE);
3389 test_range_inrange(range, range2, VARIANT_FALSE);
3390 test_range_inrange(range2, range, VARIANT_TRUE);
3391 IHTMLTxtRange_Release(range2);
3393 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3394 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3395 test_range_move(range, characterW, 2, 2);
3396 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3398 test_range_collapse(range, FALSE);
3399 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3401 test_range_collapse(range, FALSE);
3402 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3403 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3404 test_range_move(range, characterW, 2, 2);
3405 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3406 test_range_moveend(range, characterW, -5, -5);
3407 test_range_text(range, NULL);
3408 test_range_moveend(range, characterW, 3, 3);
3409 test_range_text(range, "c 1");
3410 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3411 test_range_collapse(range, TRUE);
3412 test_range_move(range, characterW, 4, 4);
3413 test_range_moveend(range, characterW, 1, 1);
3414 test_range_text(range, " ");
3415 test_range_move(range, wordW, 1, 1);
3416 test_range_moveend(range, characterW, 2, 2);
3417 test_range_text(range, "ab");
3419 IHTMLTxtRange_Release(range);
3421 hres = IHTMLTxtRange_duplicate(body_range, &range);
3422 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3424 test_range_text(range, "test abc 123\r\nit's text");
3425 test_range_move(range, characterW, 3, 3);
3426 test_range_moveend(range, characterW, 1, 1);
3427 test_range_text(range, "t");
3428 test_range_moveend(range, characterW, 3, 3);
3429 test_range_text(range, "t ab");
3430 test_range_moveend(range, characterW, -2, -2);
3431 test_range_text(range, "t ");
3432 test_range_move(range, characterW, 6, 6);
3433 test_range_moveend(range, characterW, 3, 3);
3434 test_range_text(range, "123");
3435 test_range_moveend(range, characterW, 2, 2);
3436 test_range_text(range, "123\r\ni");
3438 IHTMLTxtRange_Release(range);
3440 hres = IHTMLTxtRange_duplicate(body_range, &range);
3441 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3443 test_range_move(range, wordW, 1, 1);
3444 test_range_moveend(range, characterW, 2, 2);
3445 test_range_text(range, "ab");
3447 test_range_move(range, characterW, -2, -2);
3448 test_range_moveend(range, characterW, 2, 2);
3449 test_range_text(range, "t ");
3451 test_range_move(range, wordW, 3, 3);
3452 test_range_move(range, wordW, -2, -2);
3453 test_range_moveend(range, characterW, 2, 2);
3454 test_range_text(range, "ab");
3456 test_range_move(range, characterW, -6, -5);
3457 test_range_moveend(range, characterW, -1, 0);
3458 test_range_moveend(range, characterW, -6, 0);
3459 test_range_move(range, characterW, 2, 2);
3460 test_range_moveend(range, characterW, 2, 2);
3461 test_range_text(range, "st");
3462 test_range_moveend(range, characterW, -6, -4);
3463 test_range_moveend(range, characterW, 2, 2);
3465 IHTMLTxtRange_Release(range);
3467 hres = IHTMLTxtRange_duplicate(body_range, &range);
3468 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3470 test_range_move(range, wordW, 2, 2);
3471 test_range_moveend(range, characterW, 2, 2);
3472 test_range_text(range, "12");
3474 test_range_move(range, characterW, 15, 14);
3475 test_range_move(range, characterW, -2, -2);
3476 test_range_moveend(range, characterW, 3, 2);
3477 test_range_text(range, "t");
3478 test_range_moveend(range, characterW, -1, -1);
3479 test_range_text(range, "t");
3480 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3481 test_range_move(range, characterW, -2, -2);
3482 test_range_moveend(range, characterW, 2, 2);
3483 test_range_text(range, "s ");
3484 test_range_move(range, characterW, 100, 7);
3485 test_range_move(range, wordW, 1, 0);
3486 test_range_move(range, characterW, -2, -2);
3487 test_range_moveend(range, characterW, 3, 2);
3488 test_range_text(range, "t");
3490 IHTMLTxtRange_Release(range);
3492 hres = IHTMLTxtRange_duplicate(body_range, &range);
3493 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3495 test_range_collapse(range, TRUE);
3496 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3497 test_range_put_text(range, "word");
3498 test_range_text(body_range, "wordabc 123\r\nit's text");
3499 test_range_text(range, NULL);
3500 test_range_moveend(range, characterW, 3, 3);
3501 test_range_text(range, "abc");
3502 test_range_movestart(range, characterW, -2, -2);
3503 test_range_text(range, "rdabc");
3504 test_range_movestart(range, characterW, 3, 3);
3505 test_range_text(range, "bc");
3506 test_range_movestart(range, characterW, 4, 4);
3507 test_range_text(range, NULL);
3508 test_range_movestart(range, characterW, -3, -3);
3509 test_range_text(range, "c 1");
3510 test_range_movestart(range, characterW, -7, -6);
3511 test_range_text(range, "wordabc 1");
3512 test_range_movestart(range, characterW, 100, 22);
3513 test_range_text(range, NULL);
3515 IHTMLTxtRange_Release(range);
3516 IHTMLTxtRange_Release(body_range);
3518 hres = IHTMLDocument2_get_selection(doc, &selection);
3519 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3521 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3522 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3523 IHTMLSelectionObject_Release(selection);
3525 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3526 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3527 IDispatch_Release(disp_range);
3529 test_range_text(range, NULL);
3530 test_range_moveend(range, characterW, 3, 3);
3531 test_range_text(range, "wor");
3532 test_range_parent(range, ET_BODY);
3533 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3534 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3535 test_range_move(range, characterW, 3, 3);
3536 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3537 test_range_moveend(range, characterW, -4, -4);
3538 test_range_put_text(range, "abc def ");
3539 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3540 test_range_move(range, wordW, 1, 1);
3541 test_range_movestart(range, characterW, -1, -1);
3542 test_range_text(range, " ");
3543 test_range_move(range, wordW, 1, 1);
3544 test_range_moveend(range, characterW, 3, 3);
3545 test_range_text(range, "def");
3546 test_range_put_text(range, "xyz");
3547 test_range_moveend(range, characterW, 1, 1);
3548 test_range_move(range, wordW, 1, 1);
3549 test_range_moveend(range, characterW, 2, 2);
3550 test_range_text(range, "ab");
3552 IHTMLTxtRange_Release(range);
3555 static void test_txtrange2(IHTMLDocument2 *doc)
3557 IHTMLTxtRange *range;
3559 range = test_create_body_range(doc);
3561 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3562 test_range_move(range, characterW, 5, 5);
3563 test_range_moveend(range, characterW, 1, 1);
3564 test_range_text(range, "2");
3565 test_range_move(range, characterW, -3, -3);
3566 test_range_moveend(range, characterW, 3, 3);
3567 test_range_text(range, "c\r\n\r\n1");
3568 test_range_collapse(range, VARIANT_FALSE);
3569 test_range_moveend(range, characterW, 4, 4);
3570 test_range_text(range, "23");
3571 test_range_moveend(range, characterW, 1, 1);
3572 test_range_text(range, "23\r\n\r\n\r\nd");
3573 test_range_moveend(range, characterW, -1, -1);
3574 test_range_text(range, "23");
3575 test_range_moveend(range, characterW, -1, -1);
3576 test_range_text(range, "23");
3577 test_range_moveend(range, characterW, -2, -2);
3578 test_range_text(range, "2");
3580 IHTMLTxtRange_Release(range);
3583 static void test_compatmode(IHTMLDocument2 *doc)
3585 IHTMLDocument5 *doc5;
3589 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3590 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3594 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3595 IHTMLDocument5_Release(doc5);
3596 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3597 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3598 SysFreeString(mode);
3601 static void test_location(IHTMLDocument2 *doc)
3603 IHTMLLocation *location, *location2;
3604 IHTMLWindow2 *window;
3609 hres = IHTMLDocument2_get_location(doc, &location);
3610 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3612 hres = IHTMLDocument2_get_location(doc, &location2);
3613 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3615 ok(location == location2, "location != location2\n");
3616 IHTMLLocation_Release(location2);
3618 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3619 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3621 hres = IHTMLWindow2_get_location(window, &location2);
3622 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3623 ok(location == location2, "location != location2\n");
3624 IHTMLLocation_Release(location2);
3626 test_ifaces((IUnknown*)location, location_iids);
3627 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3629 hres = IHTMLLocation_get_pathname(location, &str);
3630 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3631 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3634 hres = IHTMLLocation_get_href(location, NULL);
3635 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3637 hres = IHTMLLocation_get_href(location, &str);
3638 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3639 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3642 ref = IHTMLLocation_Release(location);
3643 ok(!ref, "location chould be destroyed here\n");
3646 static void test_plugins_col(IOmNavigator *nav)
3648 IHTMLPluginsCollection *col, *col2;
3652 hres = IOmNavigator_get_plugins(nav, &col);
3653 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3655 hres = IOmNavigator_get_plugins(nav, &col2);
3656 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3657 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3658 IHTMLPluginsCollection_Release(col2);
3660 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3662 ref = IHTMLPluginsCollection_Release(col);
3663 ok(!ref, "ref=%d\n", ref);
3666 static void test_navigator(IHTMLDocument2 *doc)
3668 IHTMLWindow2 *window;
3669 IOmNavigator *navigator, *navigator2;
3676 static const WCHAR v40[] = {'4','.','0'};
3678 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3679 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3681 hres = IHTMLWindow2_get_navigator(window, &navigator);
3682 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3683 ok(navigator != NULL, "navigator == NULL\n");
3684 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3686 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3687 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3688 ok(navigator != navigator2, "navigator2 != navihgator\n");
3690 IHTMLWindow2_Release(window);
3691 IOmNavigator_Release(navigator2);
3693 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3694 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3695 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3696 SysFreeString(bstr);
3699 hres = IOmNavigator_get_appName(navigator, &bstr);
3700 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3701 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3702 SysFreeString(bstr);
3705 hres = IOmNavigator_get_platform(navigator, &bstr);
3706 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3708 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3710 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3712 SysFreeString(bstr);
3715 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3716 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3717 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3718 SysFreeString(bstr);
3720 hres = IOmNavigator_toString(navigator, NULL);
3721 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3724 hres = IOmNavigator_toString(navigator, &bstr);
3725 ok(hres == S_OK, "toString failed: %08x\n", hres);
3726 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3727 SysFreeString(bstr);
3730 hres = ObtainUserAgentString(0, buf, &size);
3731 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3734 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3735 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3736 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3737 SysFreeString(bstr);
3739 if(!strncmp(buf, "Mozilla/", 8)) {
3741 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3742 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3743 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3744 SysFreeString(bstr);
3746 skip("nonstandard user agent\n");
3749 test_plugins_col(navigator);
3751 ref = IOmNavigator_Release(navigator);
3752 ok(!ref, "navigator should be destroyed here\n");
3755 static void test_screen(IHTMLWindow2 *window)
3757 IHTMLScreen *screen, *screen2;
3758 IDispatchEx *dispex;
3764 hres = IHTMLWindow2_get_screen(window, &screen);
3765 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3766 ok(screen != NULL, "screen == NULL\n");
3769 hres = IHTMLWindow2_get_screen(window, &screen2);
3770 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3771 ok(screen2 != NULL, "screen == NULL\n");
3772 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3773 IHTMLScreen_Release(screen2);
3775 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3776 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3777 if(SUCCEEDED(hres)) {
3778 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3779 IDispatchEx_Release(dispex);
3782 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3784 exl = GetDeviceCaps(hdc, HORZRES);
3786 hres = IHTMLScreen_get_width(screen, &l);
3787 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3788 ok(l == exl, "width = %d, expected %d\n", l, exl);
3790 exl = GetDeviceCaps(hdc, VERTRES);
3792 hres = IHTMLScreen_get_height(screen, &l);
3793 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3794 ok(l == exl, "height = %d, expected %d\n", l, exl);
3796 exl = GetDeviceCaps(hdc, BITSPIXEL);
3798 hres = IHTMLScreen_get_colorDepth(screen, &l);
3799 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3800 ok(l == exl, "height = %d, expected %d\n", l, exl);
3804 IHTMLScreen_Release(screen);
3807 static void test_current_style(IHTMLCurrentStyle *current_style)
3813 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3814 test_ifaces((IUnknown*)current_style, cstyle_iids);
3816 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3817 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3818 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3821 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3822 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3823 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3826 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3827 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3830 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3831 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3832 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3835 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3836 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3837 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3840 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3841 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3842 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3845 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3846 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3847 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3850 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3851 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3852 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3855 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3856 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3857 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3860 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3861 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3862 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3865 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3866 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3867 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3870 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3871 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3872 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3875 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3876 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3877 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3880 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3881 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3882 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3885 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3886 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3889 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3890 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3893 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3894 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3897 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3898 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3901 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3902 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3905 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3906 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3909 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3910 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3911 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3912 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3915 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3916 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3917 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3920 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3921 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3922 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3925 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3926 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3927 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3930 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3931 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3932 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3935 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3936 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3937 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3940 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3941 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3942 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3945 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3946 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3947 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3948 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3951 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3952 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3953 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3954 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3957 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3958 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3959 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3962 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3963 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3964 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3967 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3968 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3969 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3973 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3974 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3975 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3978 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3979 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3980 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3983 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3984 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3985 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3988 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3989 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3990 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3993 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3994 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3995 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3998 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3999 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4000 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4003 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
4004 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4005 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4008 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
4009 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4010 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4013 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
4014 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4015 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4018 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
4019 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
4020 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4023 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
4024 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4025 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4028 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
4029 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4030 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4033 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
4034 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
4035 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4038 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
4039 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4040 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4043 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
4044 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
4045 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4048 hres = IHTMLCurrentStyle_get_right(current_style, &v);
4049 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
4050 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4053 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
4054 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
4055 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4058 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
4059 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
4060 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4063 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
4064 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
4065 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4069 static void test_style2(IHTMLStyle2 *style2)
4075 str = (void*)0xdeadbeef;
4076 hres = IHTMLStyle2_get_position(style2, &str);
4077 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4078 ok(!str, "str != NULL\n");
4080 str = a2bstr("absolute");
4081 hres = IHTMLStyle2_put_position(style2, str);
4082 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4086 hres = IHTMLStyle2_get_position(style2, &str);
4087 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4088 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4092 V_VT(&v) = VT_EMPTY;
4093 hres = IHTMLStyle2_get_right(style2, &v);
4094 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4095 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4096 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4100 V_BSTR(&v) = a2bstr("3px");
4101 hres = IHTMLStyle2_put_right(style2, v);
4102 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4105 V_VT(&v) = VT_EMPTY;
4106 hres = IHTMLStyle2_get_right(style2, &v);
4107 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4108 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4109 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4113 static void test_style3(IHTMLStyle3 *style3)
4118 str = (void*)0xdeadbeef;
4119 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4120 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4121 ok(!str, "str != NULL\n");
4123 str = a2bstr("break-word");
4124 hres = IHTMLStyle3_put_wordWrap(style3, str);
4125 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4129 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4130 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4131 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4135 static void test_style4(IHTMLStyle4 *style4)
4141 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4142 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4145 V_BSTR(&v) = a2bstr("10px");
4146 hres = IHTMLStyle4_put_minHeight(style4, v);
4147 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4150 hres = IHTMLStyle4_get_minHeight(style4, &v);
4151 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4152 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4153 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4156 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4157 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4158 VariantClear(&vdefault);
4161 static void test_default_style(IHTMLStyle *style)
4163 IHTMLStyle2 *style2;
4164 IHTMLStyle3 *style3;
4165 IHTMLStyle4 *style4;
4171 BSTR sOverflowDefault;
4175 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4176 test_ifaces((IUnknown*)style, style_iids);
4178 test_style_csstext(style, NULL);
4180 hres = IHTMLStyle_get_position(style, &str);
4181 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4182 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4185 hres = IHTMLStyle_get_marginRight(style, &v);
4186 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4187 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4188 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4191 hres = IHTMLStyle_get_marginLeft(style, &v);
4192 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4193 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4194 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4196 str = (void*)0xdeadbeef;
4197 hres = IHTMLStyle_get_fontFamily(style, &str);
4198 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4199 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4201 str = (void*)0xdeadbeef;
4202 hres = IHTMLStyle_get_fontWeight(style, &str);
4203 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4204 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4206 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4207 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4209 str = a2bstr("test");
4210 hres = IHTMLStyle_put_fontWeight(style, str);
4211 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4214 str = a2bstr("bold");
4215 hres = IHTMLStyle_put_fontWeight(style, str);
4216 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4219 str = a2bstr("bolder");
4220 hres = IHTMLStyle_put_fontWeight(style, str);
4221 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4224 str = a2bstr("lighter");
4225 hres = IHTMLStyle_put_fontWeight(style, str);
4226 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4229 str = a2bstr("100");
4230 hres = IHTMLStyle_put_fontWeight(style, str);
4231 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4234 str = a2bstr("200");
4235 hres = IHTMLStyle_put_fontWeight(style, str);
4236 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4239 str = a2bstr("300");
4240 hres = IHTMLStyle_put_fontWeight(style, str);
4241 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4244 str = a2bstr("400");
4245 hres = IHTMLStyle_put_fontWeight(style, str);
4246 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4249 str = a2bstr("500");
4250 hres = IHTMLStyle_put_fontWeight(style, str);
4251 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4254 str = a2bstr("600");
4255 hres = IHTMLStyle_put_fontWeight(style, str);
4256 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4259 str = a2bstr("700");
4260 hres = IHTMLStyle_put_fontWeight(style, str);
4261 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4264 str = a2bstr("800");
4265 hres = IHTMLStyle_put_fontWeight(style, str);
4266 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4269 str = a2bstr("900");
4270 hres = IHTMLStyle_put_fontWeight(style, str);
4271 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4274 hres = IHTMLStyle_get_fontWeight(style, &str);
4275 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4276 ok(!strcmp_wa(str, "900"), "str != style900\n");
4279 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4280 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4281 SysFreeString(sDefault);
4284 hres = IHTMLStyle_get_fontVariant(style, NULL);
4285 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4287 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4288 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4290 str = a2bstr("test");
4291 hres = IHTMLStyle_put_fontVariant(style, str);
4292 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4295 str = a2bstr("small-caps");
4296 hres = IHTMLStyle_put_fontVariant(style, str);
4297 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4300 str = a2bstr("normal");
4301 hres = IHTMLStyle_put_fontVariant(style, str);
4302 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4305 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4306 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4307 SysFreeString(sDefault);
4309 str = (void*)0xdeadbeef;
4310 hres = IHTMLStyle_get_display(style, &str);
4311 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4312 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4314 str = (void*)0xdeadbeef;
4315 hres = IHTMLStyle_get_visibility(style, &str);
4316 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4317 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4320 hres = IHTMLStyle_get_fontSize(style, &v);
4321 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4322 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4323 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4326 hres = IHTMLStyle_get_color(style, &v);
4327 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4328 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4329 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4332 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4333 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4334 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4336 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4337 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4338 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4340 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4341 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4342 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4344 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4345 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4348 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4349 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4350 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4352 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4353 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4354 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4356 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4357 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4358 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4360 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4361 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4364 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4365 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4366 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4368 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4369 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4370 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4372 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4373 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4374 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4376 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4377 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4380 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4381 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4382 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4384 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4385 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4386 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4388 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4389 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4390 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4392 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4393 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4396 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4397 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4398 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4400 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4401 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4402 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4404 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4405 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4406 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4408 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4409 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4411 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4412 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4414 str = a2bstr("invalid");
4415 hres = IHTMLStyle_put_textDecoration(style, str);
4416 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4419 str = a2bstr("none");
4420 hres = IHTMLStyle_put_textDecoration(style, str);
4421 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4424 str = a2bstr("underline");
4425 hres = IHTMLStyle_put_textDecoration(style, str);
4426 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4429 str = a2bstr("overline");
4430 hres = IHTMLStyle_put_textDecoration(style, str);
4431 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4434 str = a2bstr("line-through");
4435 hres = IHTMLStyle_put_textDecoration(style, str);
4436 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4439 str = a2bstr("blink");
4440 hres = IHTMLStyle_put_textDecoration(style, str);
4441 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4444 hres = IHTMLStyle_get_textDecoration(style, &str);
4445 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4446 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4449 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4450 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4451 SysFreeString(sDefault);
4453 hres = IHTMLStyle_get_posWidth(style, NULL);
4454 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4456 hres = IHTMLStyle_get_posWidth(style, &f);
4457 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4458 ok(f == 0.0f, "f = %f\n", f);
4460 V_VT(&v) = VT_EMPTY;
4461 hres = IHTMLStyle_get_width(style, &v);
4462 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4463 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4464 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4466 hres = IHTMLStyle_put_posWidth(style, 2.2);
4467 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4469 hres = IHTMLStyle_get_posWidth(style, &f);
4470 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4472 f == 2.2f, /* IE8 */
4476 V_BSTR(&v) = a2bstr("auto");
4477 hres = IHTMLStyle_put_width(style, v);
4478 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4481 V_VT(&v) = VT_EMPTY;
4482 hres = IHTMLStyle_get_width(style, &v);
4483 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4484 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4485 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4490 hres = IHTMLStyle_put_width(style, v);
4491 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4493 V_VT(&v) = VT_EMPTY;
4494 hres = IHTMLStyle_get_width(style, &v);
4495 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4496 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4497 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4501 str = (void*)0xdeadbeef;
4502 hres = IHTMLStyle_get_margin(style, &str);
4503 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4504 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4507 hres = IHTMLStyle_put_margin(style, str);
4508 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4511 hres = IHTMLStyle_get_margin(style, &str);
4512 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4513 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4516 hres = IHTMLStyle_put_margin(style, NULL);
4517 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4519 str = (void*)0xdeadbeef;
4520 hres = IHTMLStyle_get_marginTop(style, &v);
4521 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4522 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4523 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4526 V_BSTR(&v) = a2bstr("6px");
4527 hres = IHTMLStyle_put_marginTop(style, v);
4528 SysFreeString(V_BSTR(&v));
4529 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4531 str = (void*)0xdeadbeef;
4532 hres = IHTMLStyle_get_marginTop(style, &v);
4533 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4534 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4535 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4539 hres = IHTMLStyle_get_border(style, &str);
4540 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4541 ok(!str || !*str, "str is not empty\n");
4544 str = a2bstr("1px");
4545 hres = IHTMLStyle_put_border(style, str);
4546 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4549 V_VT(&v) = VT_EMPTY;
4550 hres = IHTMLStyle_get_left(style, &v);
4551 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4552 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4553 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4557 hres = IHTMLStyle_get_posLeft(style, NULL);
4558 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4561 hres = IHTMLStyle_get_posLeft(style, &f);
4562 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4563 ok(f == 0.0, "expected 0.0 got %f\n", f);
4565 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4566 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4568 hres = IHTMLStyle_get_posLeft(style, &f);
4569 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4571 f == 4.9f, /* IE8 */
4572 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4574 /* Ensure left is updated correctly. */
4575 V_VT(&v) = VT_EMPTY;
4576 hres = IHTMLStyle_get_left(style, &v);
4577 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4578 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4579 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4580 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4581 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4586 V_BSTR(&v) = a2bstr("3px");
4587 hres = IHTMLStyle_put_left(style, v);
4588 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4591 hres = IHTMLStyle_get_posLeft(style, &f);
4592 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4593 ok(f == 3.0, "expected 3.0 got %f\n", f);
4595 V_VT(&v) = VT_EMPTY;
4596 hres = IHTMLStyle_get_left(style, &v);
4597 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4598 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4599 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4603 hres = IHTMLStyle_put_left(style, v);
4604 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4606 V_VT(&v) = VT_EMPTY;
4607 hres = IHTMLStyle_get_left(style, &v);
4608 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4609 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4610 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4613 V_VT(&v) = VT_EMPTY;
4614 hres = IHTMLStyle_get_top(style, &v);
4615 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4616 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4617 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4621 hres = IHTMLStyle_get_posTop(style, NULL);
4622 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4625 hres = IHTMLStyle_get_posTop(style, &f);
4626 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4627 ok(f == 0.0, "expected 0.0 got %f\n", f);
4629 hres = IHTMLStyle_put_posTop(style, 4.9f);
4630 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4632 hres = IHTMLStyle_get_posTop(style, &f);
4633 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4635 f == 4.9f, /* IE8 */
4636 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4639 V_BSTR(&v) = a2bstr("3px");
4640 hres = IHTMLStyle_put_top(style, v);
4641 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4644 V_VT(&v) = VT_EMPTY;
4645 hres = IHTMLStyle_get_top(style, &v);
4646 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4647 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4648 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4651 hres = IHTMLStyle_get_posTop(style, &f);
4652 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4653 ok(f == 3.0, "expected 3.0 got %f\n", f);
4656 hres = IHTMLStyle_put_top(style, v);
4657 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4659 V_VT(&v) = VT_EMPTY;
4660 hres = IHTMLStyle_get_top(style, &v);
4661 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4662 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4663 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4666 /* Test posHeight */
4667 hres = IHTMLStyle_get_posHeight(style, NULL);
4668 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4670 V_VT(&v) = VT_EMPTY;
4671 hres = IHTMLStyle_get_height(style, &v);
4672 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4673 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4674 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4678 hres = IHTMLStyle_get_posHeight(style, &f);
4679 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4680 ok(f == 0.0, "expected 0.0 got %f\n", f);
4682 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4683 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4685 hres = IHTMLStyle_get_posHeight(style, &f);
4686 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4688 f == 4.9f, /* IE8 */
4689 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4692 V_BSTR(&v) = a2bstr("64px");
4693 hres = IHTMLStyle_put_height(style, v);
4694 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4697 V_VT(&v) = VT_EMPTY;
4698 hres = IHTMLStyle_get_height(style, &v);
4699 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4700 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4701 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4704 hres = IHTMLStyle_get_posHeight(style, &f);
4705 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4706 ok(f == 64.0, "expected 64.0 got %f\n", f);
4708 str = (void*)0xdeadbeef;
4709 hres = IHTMLStyle_get_cursor(style, &str);
4710 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4711 ok(!str, "get_cursor != NULL\n");
4714 str = a2bstr("default");
4715 hres = IHTMLStyle_put_cursor(style, str);
4716 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4720 hres = IHTMLStyle_get_cursor(style, &str);
4721 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4722 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4725 V_VT(&v) = VT_EMPTY;
4726 hres = IHTMLStyle_get_verticalAlign(style, &v);
4727 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4728 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4729 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4733 V_BSTR(&v) = a2bstr("middle");
4734 hres = IHTMLStyle_put_verticalAlign(style, v);
4735 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4738 V_VT(&v) = VT_EMPTY;
4739 hres = IHTMLStyle_get_verticalAlign(style, &v);
4740 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4741 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4742 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4745 str = (void*)0xdeadbeef;
4746 hres = IHTMLStyle_get_textAlign(style, &str);
4747 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4748 ok(!str, "textAlign != NULL\n");
4750 str = a2bstr("center");
4751 hres = IHTMLStyle_put_textAlign(style, str);
4752 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4756 hres = IHTMLStyle_get_textAlign(style, &str);
4757 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4758 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4761 str = (void*)0xdeadbeef;
4762 hres = IHTMLStyle_get_filter(style, &str);
4763 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4764 ok(!str, "filter != NULL\n");
4766 str = a2bstr("alpha(opacity=100)");
4767 hres = IHTMLStyle_put_filter(style, str);
4768 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4771 V_VT(&v) = VT_EMPTY;
4772 hres = IHTMLStyle_get_zIndex(style, &v);
4773 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4774 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4775 ok(!V_I4(&v), "V_I4(v) != 0\n");
4779 V_BSTR(&v) = a2bstr("1");
4780 hres = IHTMLStyle_put_zIndex(style, v);
4781 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4784 V_VT(&v) = VT_EMPTY;
4785 hres = IHTMLStyle_get_zIndex(style, &v);
4786 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4787 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4788 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4792 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4793 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4795 str = a2bstr("test");
4796 hres = IHTMLStyle_put_fontStyle(style, str);
4797 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4800 str = a2bstr("italic");
4801 hres = IHTMLStyle_put_fontStyle(style, str);
4802 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4805 str = a2bstr("oblique");
4806 hres = IHTMLStyle_put_fontStyle(style, str);
4807 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4810 str = a2bstr("normal");
4811 hres = IHTMLStyle_put_fontStyle(style, str);
4812 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4815 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4816 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4817 SysFreeString(sDefault);
4820 hres = IHTMLStyle_get_overflow(style, NULL);
4821 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4823 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4824 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4826 str = a2bstr("test");
4827 hres = IHTMLStyle_put_overflow(style, str);
4828 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4831 str = a2bstr("visible");
4832 hres = IHTMLStyle_put_overflow(style, str);
4833 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4836 str = a2bstr("scroll");
4837 hres = IHTMLStyle_put_overflow(style, str);
4838 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4841 str = a2bstr("hidden");
4842 hres = IHTMLStyle_put_overflow(style, str);
4843 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4846 str = a2bstr("auto");
4847 hres = IHTMLStyle_put_overflow(style, str);
4848 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4851 hres = IHTMLStyle_get_overflow(style, &str);
4852 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4853 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4857 hres = IHTMLStyle_put_overflow(style, str);
4858 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4861 hres = IHTMLStyle_get_overflow(style, &str);
4862 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4863 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4866 /* restore overflow default */
4867 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4868 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4869 SysFreeString(sOverflowDefault);
4871 /* Attribute Tests*/
4872 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4873 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4875 str = a2bstr("position");
4876 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4877 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4879 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4880 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4881 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4884 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4885 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4888 V_BSTR(&v) = a2bstr("absolute");
4889 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4890 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4893 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4894 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4895 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4896 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4901 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4902 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4907 str = a2bstr("borderLeftStyle");
4908 test_border_styles(style, str);
4911 str = a2bstr("borderbottomstyle");
4912 test_border_styles(style, str);
4915 str = a2bstr("borderrightstyle");
4916 test_border_styles(style, str);
4919 str = a2bstr("bordertopstyle");
4920 test_border_styles(style, str);
4923 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4924 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4926 str = a2bstr("none dotted dashed solid");
4927 hres = IHTMLStyle_put_borderStyle(style, str);
4928 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4931 str = a2bstr("none dotted dashed solid");
4932 hres = IHTMLStyle_get_borderStyle(style, &str);
4933 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4934 ok(!strcmp_wa(str, "none dotted dashed solid"),
4935 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4938 str = a2bstr("double groove ridge inset");
4939 hres = IHTMLStyle_put_borderStyle(style, str);
4940 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4943 str = a2bstr("window-inset outset ridge inset");
4944 hres = IHTMLStyle_put_borderStyle(style, str);
4945 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4948 str = a2bstr("window-inset");
4949 hres = IHTMLStyle_put_borderStyle(style, str);
4950 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4953 str = a2bstr("none none none none none");
4954 hres = IHTMLStyle_put_borderStyle(style, str);
4955 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4958 str = a2bstr("invalid none none none");
4959 hres = IHTMLStyle_put_borderStyle(style, str);
4960 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4963 str = a2bstr("none invalid none none");
4964 hres = IHTMLStyle_put_borderStyle(style, str);
4965 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4968 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4969 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4970 SysFreeString(sDefault);
4972 /* backgoundColor */
4973 hres = IHTMLStyle_get_backgroundColor(style, &v);
4974 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4975 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4976 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4980 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4981 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4984 V_BSTR(&v) = a2bstr("10");
4985 hres = IHTMLStyle_put_paddingLeft(style, v);
4986 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4989 hres = IHTMLStyle_get_paddingLeft(style, &v);
4990 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4991 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4994 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4995 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4997 /* BackgroundRepeat */
4998 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4999 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5001 str = a2bstr("invalid");
5002 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5003 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
5006 str = a2bstr("repeat");
5007 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5008 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5011 str = a2bstr("no-repeat");
5012 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5013 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5016 str = a2bstr("repeat-x");
5017 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5018 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5021 str = a2bstr("repeat-y");
5022 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5023 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5026 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
5027 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5028 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
5031 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
5032 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5033 SysFreeString(sDefault);
5036 hres = IHTMLStyle_get_borderColor(style, &sDefault);
5037 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5039 str = a2bstr("red green red blue");
5040 hres = IHTMLStyle_put_borderColor(style, str);
5041 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5044 hres = IHTMLStyle_get_borderColor(style, &str);
5045 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5046 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
5049 hres = IHTMLStyle_put_borderColor(style, sDefault);
5050 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5051 SysFreeString(sDefault);
5054 hres = IHTMLStyle_get_borderRight(style, &sDefault);
5055 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
5057 str = a2bstr("thick dotted red");
5058 hres = IHTMLStyle_put_borderRight(style, str);
5059 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5062 /* IHTMLStyle_get_borderRight appears to have a bug where
5063 it returns the first letter of the color. So we check
5064 each style individually.
5067 hres = IHTMLStyle_get_borderRightColor(style, &v);
5068 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
5069 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5073 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5074 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5075 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5078 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5079 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5080 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5083 hres = IHTMLStyle_put_borderRight(style, sDefault);
5084 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5085 SysFreeString(sDefault);
5088 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5089 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5091 str = a2bstr("thick dotted red");
5092 hres = IHTMLStyle_put_borderTop(style, str);
5093 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5096 /* IHTMLStyle_get_borderTop appears to have a bug where
5097 it returns the first letter of the color. So we check
5098 each style individually.
5101 hres = IHTMLStyle_get_borderTopColor(style, &v);
5102 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5103 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5107 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5108 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5109 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5112 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5113 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5114 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5117 hres = IHTMLStyle_put_borderTop(style, sDefault);
5118 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5119 SysFreeString(sDefault);
5122 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5123 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5125 str = a2bstr("thick dotted red");
5126 hres = IHTMLStyle_put_borderBottom(style, str);
5127 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5130 /* IHTMLStyle_get_borderBottom appears to have a bug where
5131 it returns the first letter of the color. So we check
5132 each style individually.
5135 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5136 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5137 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5141 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5142 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5143 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5146 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5147 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5148 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5151 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5152 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5153 SysFreeString(sDefault);
5156 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5157 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5159 str = a2bstr("thick dotted red");
5160 hres = IHTMLStyle_put_borderLeft(style, str);
5161 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5164 /* IHTMLStyle_get_borderLeft appears to have a bug where
5165 it returns the first letter of the color. So we check
5166 each style individually.
5169 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5170 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5171 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5175 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5176 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5177 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5180 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5181 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5182 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5185 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5186 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5187 SysFreeString(sDefault);
5189 /* backgroundPositionX */
5190 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
5191 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5194 V_BSTR(&v) = a2bstr("10px");
5195 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5196 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5199 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5200 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5201 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5204 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
5205 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5206 VariantClear(&vDefault);
5208 /* backgroundPositionY */
5209 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
5210 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5213 V_BSTR(&v) = a2bstr("10px");
5214 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5215 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5218 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5219 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5220 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5223 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
5224 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5225 VariantClear(&vDefault);
5227 /* borderTopWidth */
5228 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5229 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5232 V_BSTR(&v) = a2bstr("10px");
5233 hres = IHTMLStyle_put_borderTopWidth(style, v);
5234 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5237 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5238 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5239 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5242 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5243 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5244 VariantClear(&vDefault);
5246 /* borderRightWidth */
5247 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5248 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5251 V_BSTR(&v) = a2bstr("10");
5252 hres = IHTMLStyle_put_borderRightWidth(style, v);
5253 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5256 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5257 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5258 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5261 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5262 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5263 VariantClear(&vDefault);
5265 /* borderBottomWidth */
5266 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5267 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5270 V_BSTR(&v) = a2bstr("10");
5271 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5272 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5275 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5276 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5277 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5280 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5281 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5282 VariantClear(&vDefault);
5284 /* borderLeftWidth */
5285 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5286 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5289 V_BSTR(&v) = a2bstr("10");
5290 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5291 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5294 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5295 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5296 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5299 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5300 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5301 VariantClear(&vDefault);
5304 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5305 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5308 V_BSTR(&v) = a2bstr("10");
5309 hres = IHTMLStyle_put_wordSpacing(style, v);
5310 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5313 hres = IHTMLStyle_get_wordSpacing(style, &v);
5314 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5315 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5316 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5319 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5320 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5321 VariantClear(&vDefault);
5324 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5325 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5328 V_BSTR(&v) = a2bstr("11");
5329 hres = IHTMLStyle_put_letterSpacing(style, v);
5330 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5333 hres = IHTMLStyle_get_letterSpacing(style, &v);
5334 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5335 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5336 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5339 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5340 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5341 VariantClear(&vDefault);
5343 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5344 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5345 if(SUCCEEDED(hres)) {
5346 test_style2(style2);
5347 IHTMLStyle2_Release(style2);
5350 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5351 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5352 if(SUCCEEDED(hres)) {
5353 test_style3(style3);
5354 IHTMLStyle3_Release(style3);
5357 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5358 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5359 if(SUCCEEDED(hres)) {
5360 test_style4(style4);
5361 IHTMLStyle4_Release(style4);
5365 static void test_set_csstext(IHTMLStyle *style)
5370 test_style_set_csstext(style, "background-color: black;");
5372 hres = IHTMLStyle_get_backgroundColor(style, &v);
5373 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5374 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5375 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5379 static void test_default_selection(IHTMLDocument2 *doc)
5381 IHTMLSelectionObject *selection;
5382 IHTMLTxtRange *range;
5387 hres = IHTMLDocument2_get_selection(doc, &selection);
5388 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5390 hres = IHTMLSelectionObject_get_type(selection, &str);
5391 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5392 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5395 hres = IHTMLSelectionObject_createRange(selection, &disp);
5396 IHTMLSelectionObject_Release(selection);
5397 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5399 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5400 IDispatch_Release(disp);
5401 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5403 test_range_text(range, NULL);
5404 IHTMLTxtRange_Release(range);
5407 static void test_doc_elem(IHTMLDocument2 *doc)
5409 IHTMLDocument2 *doc_node, *owner_doc;
5411 IHTMLDocument3 *doc3;
5414 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5415 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5417 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5418 IHTMLDocument3_Release(doc3);
5419 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5421 test_node_name((IUnknown*)elem, "HTML");
5422 test_elem_tag((IUnknown*)elem, "HTML");
5424 doc_node = get_doc_node(doc);
5425 owner_doc = get_owner_doc((IUnknown*)elem);
5426 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5427 IHTMLDocument2_Release(owner_doc);
5429 owner_doc = get_owner_doc((IUnknown*)doc_node);
5430 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5431 IHTMLDocument2_Release(doc_node);
5433 test_elem_client_rect((IUnknown*)elem);
5435 IHTMLElement_Release(elem);
5438 static void test_default_body(IHTMLBodyElement *body)
5445 bstr = (void*)0xdeadbeef;
5446 hres = IHTMLBodyElement_get_background(body, &bstr);
5447 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5448 ok(bstr == NULL, "bstr != NULL\n");
5450 l = elem_get_scroll_height((IUnknown*)body);
5451 ok(l != -1, "scrollHeight == -1\n");
5452 l = elem_get_scroll_width((IUnknown*)body);
5453 ok(l != -1, "scrollWidth == -1\n");
5454 l = elem_get_scroll_top((IUnknown*)body);
5455 ok(!l, "scrollTop = %d\n", l);
5456 elem_get_scroll_left((IUnknown*)body);
5458 /* get_text tests */
5459 hres = IHTMLBodyElement_get_text(body, &v);
5460 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5461 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5462 ok(bstr == NULL, "bstr != NULL\n");
5464 /* get_text - Invalid Text */
5466 V_BSTR(&v) = a2bstr("Invalid");
5467 hres = IHTMLBodyElement_put_text(body, v);
5468 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5472 hres = IHTMLBodyElement_get_text(body, &v);
5473 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5474 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5475 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5478 /* get_text - Valid Text */
5480 V_BSTR(&v) = a2bstr("#FF0000");
5481 hres = IHTMLBodyElement_put_text(body, v);
5482 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5486 hres = IHTMLBodyElement_get_text(body, &v);
5487 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5488 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5489 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5493 static void test_body_funs(IHTMLBodyElement *body)
5495 VARIANT vbg, vDefaultbg;
5498 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5499 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5500 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5501 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5503 V_VT(&vbg) = VT_BSTR;
5504 V_BSTR(&vbg) = a2bstr("red");
5505 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5506 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5509 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5510 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5511 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5512 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5515 /* Restore Originial */
5516 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5517 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5518 VariantClear(&vDefaultbg);
5521 static void test_window(IHTMLDocument2 *doc)
5523 IHTMLWindow2 *window, *window2, *self;
5524 IHTMLDocument2 *doc2 = NULL;
5530 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5531 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5532 test_ifaces((IUnknown*)window, window_iids);
5533 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5535 hres = IHTMLWindow2_get_document(window, &doc2);
5536 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5537 ok(doc2 != NULL, "doc2 == NULL\n");
5539 test_ifaces((IUnknown*)doc2, doc_node_iids);
5540 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5542 test_ifaces((IUnknown*)doc, doc_obj_iids);
5543 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5545 unk = (void*)0xdeadbeef;
5546 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5547 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5548 ok(!unk, "unk = %p\n", unk);
5550 IHTMLDocument_Release(doc2);
5552 hres = IHTMLWindow2_get_window(window, &window2);
5553 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5554 ok(window2 != NULL, "window2 == NULL\n");
5556 hres = IHTMLWindow2_get_self(window, &self);
5557 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5558 ok(window2 != NULL, "self == NULL\n");
5560 ok(self == window2, "self != window2\n");
5562 IHTMLWindow2_Release(window2);
5563 IHTMLWindow2_Release(self);
5566 hres = IHTMLDocument2_get_Script(doc, &disp);
5567 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5568 ok(disp == (void*)window, "disp != window\n");
5569 IDispatch_Release(disp);
5571 hres = IHTMLWindow2_toString(window, NULL);
5572 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5575 hres = IHTMLWindow2_toString(window, &str);
5576 ok(hres == S_OK, "toString failed: %08x\n", hres);
5577 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5580 test_window_name(window, NULL);
5581 set_window_name(window, "test");
5582 test_window_length(window, 0);
5583 test_screen(window);
5585 IHTMLWindow2_Release(window);
5588 static void test_defaults(IHTMLDocument2 *doc)
5590 IHTMLStyleSheetsCollection *stylesheetcol;
5591 IHTMLCurrentStyle *cstyle;
5592 IHTMLBodyElement *body;
5593 IHTMLElement2 *elem2;
5598 IHTMLElementCollection *collection;
5600 elem = doc_get_body(doc);
5602 hres = IHTMLDocument2_get_images(doc, NULL);
5603 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5605 hres = IHTMLDocument2_get_images(doc, &collection);
5606 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5609 test_elem_collection((IUnknown*)collection, NULL, 0);
5610 IHTMLElementCollection_Release(collection);
5613 hres = IHTMLDocument2_get_applets(doc, NULL);
5614 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5616 hres = IHTMLDocument2_get_applets(doc, &collection);
5617 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5620 test_elem_collection((IUnknown*)collection, NULL, 0);
5621 IHTMLElementCollection_Release(collection);
5624 hres = IHTMLDocument2_get_links(doc, NULL);
5625 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5627 hres = IHTMLDocument2_get_links(doc, &collection);
5628 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5631 test_elem_collection((IUnknown*)collection, NULL, 0);
5632 IHTMLElementCollection_Release(collection);
5635 hres = IHTMLDocument2_get_forms(doc, NULL);
5636 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5638 hres = IHTMLDocument2_get_forms(doc, &collection);
5639 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5642 test_elem_collection((IUnknown*)collection, NULL, 0);
5643 IHTMLElementCollection_Release(collection);
5646 hres = IHTMLDocument2_get_anchors(doc, NULL);
5647 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5649 hres = IHTMLDocument2_get_anchors(doc, &collection);
5650 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5653 test_elem_collection((IUnknown*)collection, NULL, 0);
5654 IHTMLElementCollection_Release(collection);
5657 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5658 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5659 test_default_body(body);
5660 test_body_funs(body);
5661 IHTMLBodyElement_Release(body);
5663 hres = IHTMLElement_get_style(elem, &style);
5664 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5666 test_default_style(style);
5668 test_compatmode(doc);
5670 test_navigator(doc);
5672 elem2 = get_elem2_iface((IUnknown*)elem);
5673 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5674 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5675 if(SUCCEEDED(hres)) {
5676 test_current_style(cstyle);
5677 IHTMLCurrentStyle_Release(cstyle);
5679 IHTMLElement2_Release(elem2);
5681 IHTMLElement_Release(elem);
5683 test_set_csstext(style);
5684 IHTMLStyle_Release(style);
5686 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5687 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5690 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5691 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5692 ok(l == 0, "length = %d\n", l);
5694 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5696 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5697 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5699 test_default_selection(doc);
5700 test_doc_title(doc, "");
5703 static void test_tr_elem(IHTMLElement *elem)
5705 IHTMLElementCollection *col;
5709 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5711 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5712 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5717 hres = IHTMLTableRow_get_cells(row, &col);
5718 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5719 ok(col != NULL, "get_cells returned NULL\n");
5721 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5722 IHTMLElementCollection_Release(col);
5724 IHTMLTable_Release(row);
5727 static void test_table_elem(IHTMLElement *elem)
5729 IHTMLElementCollection *col;
5734 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5735 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5737 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5738 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5743 hres = IHTMLTable_get_rows(table, &col);
5744 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5745 ok(col != NULL, "get_ros returned NULL\n");
5747 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5748 IHTMLElementCollection_Release(col);
5750 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5752 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5753 test_elem_tag((IUnknown*)node, "TABLE");
5754 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5755 IHTMLDOMNode_Release(node);
5757 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5758 test_elem_tag((IUnknown*)node, "TABLE");
5759 test_elem_all((IUnknown*)node, NULL, 0);
5760 IHTMLDOMNode_Release(node);
5762 IHTMLTable_Release(table);
5765 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5774 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5775 SafeArrayAccessData(sa, (void**)&var);
5776 V_VT(var) = VT_BSTR;
5777 V_BSTR(var) = a2bstr(text);
5778 SafeArrayUnaccessData(sa);
5781 hres = IHTMLDocument2_writeln(doc, sa);
5783 hres = IHTMLDocument2_write(doc, sa);
5784 ok(hres == S_OK, "write failed: %08x\n", hres);
5786 SafeArrayDestroy(sa);
5789 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5791 IHTMLDocument2 *window_doc, *elem_doc;
5792 IHTMLFrameElement3 *frame_elem3;
5793 IHTMLWindow2 *content_window;
5796 content_window = get_frame_content_window(frame_elem);
5797 window_doc = get_window_doc(content_window);
5798 IHTMLWindow2_Release(content_window);
5800 elem_doc = get_elem_doc(frame_elem);
5801 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5804 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5805 if(SUCCEEDED(hres)) {
5806 IDispatch *disp = NULL;
5808 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5809 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5810 ok(disp != NULL, "contentDocument == NULL\n");
5811 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5813 IDispatch_Release(disp);
5814 IHTMLFrameElement3_Release(frame_elem3);
5816 win_skip("IHTMLFrameElement3 not supported\n");
5820 IHTMLDocument2_Release(elem_doc);
5821 IHTMLDocument2_Release(window_doc);
5824 static void test_iframe_elem(IHTMLElement *elem)
5826 IHTMLDocument2 *content_doc, *owner_doc;
5827 IHTMLElementCollection *col;
5828 IHTMLWindow2 *content_window;
5834 static const elem_type_t all_types[] = {
5842 test_frame_doc((IUnknown*)elem, TRUE);
5844 content_window = get_frame_content_window((IUnknown*)elem);
5845 test_window_length(content_window, 0);
5847 content_doc = get_window_doc(content_window);
5848 IHTMLWindow2_Release(content_window);
5850 str = a2bstr("text/html");
5851 V_VT(&errv) = VT_ERROR;
5853 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5855 ok(hres == S_OK, "open failed: %08x\n", hres);
5856 ok(disp != NULL, "disp == NULL\n");
5857 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5858 IDispatch_Release(disp);
5860 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5861 doc_write(content_doc, TRUE, "</html>");
5863 hres = IHTMLDocument2_get_all(content_doc, &col);
5864 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5865 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5866 IHTMLElementCollection_Release(col);
5868 hres = IHTMLDocument2_close(content_doc);
5869 ok(hres == S_OK, "close failed: %08x\n", hres);
5871 owner_doc = get_owner_doc((IUnknown*)content_doc);
5872 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5874 IHTMLDocument2_Release(content_doc);
5877 static void test_stylesheet(IDispatch *disp)
5879 IHTMLStyleSheetRulesCollection *col = NULL;
5880 IHTMLStyleSheet *stylesheet;
5883 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5884 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5886 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5887 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5888 ok(col != NULL, "col == NULL\n");
5890 IHTMLStyleSheetRulesCollection_Release(col);
5891 IHTMLStyleSheet_Release(stylesheet);
5894 static void test_stylesheets(IHTMLDocument2 *doc)
5896 IHTMLStyleSheetsCollection *col = NULL;
5901 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5902 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5903 ok(col != NULL, "col == NULL\n");
5905 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
5907 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5908 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5909 ok(len == 1, "len=%d\n", len);
5915 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5916 ok(hres == S_OK, "item failed: %08x\n", hres);
5917 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5918 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5919 test_stylesheet(V_DISPATCH(&res));
5926 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5927 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5928 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5929 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5932 IHTMLStyleSheetsCollection_Release(col);
5935 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5937 IDispatchEx *dispex;
5939 DISPPARAMS dp = {NULL, NULL, 0, 0};
5947 static const WCHAR w0[] = {'0',0};
5948 static const WCHAR w100[] = {'1','0','0',0};
5950 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5951 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5953 bstr = SysAllocString(w0);
5954 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5955 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5956 SysFreeString(bstr);
5959 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5960 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5961 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5962 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5963 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5964 type = get_node_type((IUnknown*)node);
5965 ok(type == 3, "type=%d\n", type);
5966 IHTMLDOMNode_Release(node);
5969 bstr = SysAllocString(w100);
5970 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5971 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5972 SysFreeString(bstr);
5974 IDispatchEx_Release(dispex);
5979 static void test_elems(IHTMLDocument2 *doc)
5981 IHTMLElementCollection *col;
5982 IHTMLDOMChildrenCollection *child_col;
5983 IHTMLElement *elem, *elem2, *elem3;
5984 IHTMLDOMNode *node, *node2;
5985 IHTMLWindow2 *window;
5989 IHTMLElementCollection *collection;
5990 IHTMLDocument3 *doc3;
5993 static const elem_type_t all_types[] = {
6021 static const elem_type_t item_types[] = {
6027 hres = IHTMLDocument2_get_all(doc, &col);
6028 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6029 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6030 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
6031 IHTMLElementCollection_Release(col);
6033 hres = IHTMLDocument2_get_images(doc, &collection);
6034 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6037 static const elem_type_t images_types[] = {ET_IMG};
6038 test_elem_collection((IUnknown*)collection, images_types, 1);
6040 IHTMLElementCollection_Release(collection);
6043 hres = IHTMLDocument2_get_links(doc, &collection);
6044 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6047 static const elem_type_t images_types[] = {ET_A};
6048 test_elem_collection((IUnknown*)collection, images_types, 1);
6050 IHTMLElementCollection_Release(collection);
6053 hres = IHTMLDocument2_get_anchors(doc, &collection);
6054 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6057 static const elem_type_t anchor_types[] = {ET_A};
6058 test_elem_collection((IUnknown*)collection, anchor_types, 1);
6060 IHTMLElementCollection_Release(collection);
6063 elem = get_doc_elem(doc);
6064 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
6065 IHTMLElement_Release(elem);
6067 get_elem_by_id(doc, "xxx", FALSE);
6068 elem = get_doc_elem_by_id(doc, "xxx");
6069 ok(!elem, "elem != NULL\n");
6071 elem = get_doc_elem_by_id(doc, "s");
6072 ok(elem != NULL, "elem == NULL\n");
6074 test_elem_type((IUnknown*)elem, ET_SELECT);
6075 test_elem_attr(elem, "xxx", NULL);
6076 test_elem_attr(elem, "id", "s");
6077 test_elem_class((IUnknown*)elem, NULL);
6078 test_elem_set_class((IUnknown*)elem, "cl");
6079 test_elem_set_class((IUnknown*)elem, NULL);
6080 test_elem_tabindex((IUnknown*)elem, 0);
6081 test_elem_set_tabindex((IUnknown*)elem, 1);
6082 test_elem_filters((IUnknown*)elem);
6084 node = test_node_get_parent((IUnknown*)elem);
6085 ok(node != NULL, "node == NULL\n");
6086 test_node_name((IUnknown*)node, "BODY");
6087 node2 = test_node_get_parent((IUnknown*)node);
6088 IHTMLDOMNode_Release(node);
6089 ok(node2 != NULL, "node == NULL\n");
6090 test_node_name((IUnknown*)node2, "HTML");
6091 node = test_node_get_parent((IUnknown*)node2);
6092 IHTMLDOMNode_Release(node2);
6093 ok(node != NULL, "node == NULL\n");
6096 test_node_name((IUnknown*)node, "#document");
6097 type = get_node_type((IUnknown*)node);
6098 ok(type == 9, "type=%d, expected 9\n", type);
6099 node2 = test_node_get_parent((IUnknown*)node);
6100 IHTMLDOMNode_Release(node);
6101 ok(node2 == NULL, "node != NULL\n");
6104 elem2 = test_elem_get_parent((IUnknown*)elem);
6105 ok(elem2 != NULL, "elem2 == NULL\n");
6106 test_node_name((IUnknown*)elem2, "BODY");
6107 elem3 = test_elem_get_parent((IUnknown*)elem2);
6108 IHTMLElement_Release(elem2);
6109 ok(elem3 != NULL, "elem3 == NULL\n");
6110 test_node_name((IUnknown*)elem3, "HTML");
6111 elem2 = test_elem_get_parent((IUnknown*)elem3);
6112 IHTMLElement_Release(elem3);
6113 ok(elem2 == NULL, "elem2 != NULL\n");
6115 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6116 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6117 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6119 test_elem_innertext(elem, "opt1opt2");
6121 IHTMLElement_Release(elem);
6124 elem = get_elem_by_id(doc, "s", TRUE);
6126 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6127 IHTMLDocument2 *doc_node, *elem_doc;
6129 test_select_elem(select);
6131 test_elem_title((IUnknown*)select, NULL);
6132 test_elem_set_title((IUnknown*)select, "Title");
6133 test_elem_title((IUnknown*)select, "Title");
6134 test_elem_offset((IUnknown*)select);
6135 test_elem_bounding_client_rect((IUnknown*)select);
6137 node = get_first_child((IUnknown*)select);
6138 ok(node != NULL, "node == NULL\n");
6140 test_elem_type((IUnknown*)node, ET_OPTION);
6141 IHTMLDOMNode_Release(node);
6144 type = get_node_type((IUnknown*)select);
6145 ok(type == 1, "type=%d\n", type);
6147 IHTMLSelectElement_Release(select);
6149 elem_doc = get_elem_doc((IUnknown*)elem);
6151 doc_node = get_doc_node(doc);
6152 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6153 IHTMLDocument2_Release(doc_node);
6154 IHTMLDocument2_Release(elem_doc);
6156 IHTMLElement_Release(elem);
6159 elem = get_elem_by_id(doc, "sc", TRUE);
6161 IHTMLScriptElement *script;
6164 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6165 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6171 hres = IHTMLScriptElement_put_type (script, NULL);
6172 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6173 hres = IHTMLScriptElement_get_type(script, &type);
6174 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6175 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6177 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6178 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6179 hres = IHTMLScriptElement_get_type(script, &type);
6180 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6181 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6183 SysFreeString(type);
6186 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6187 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6189 hres = IHTMLScriptElement_get_defer(script, &vb);
6190 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6191 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6193 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6194 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6197 IHTMLScriptElement_Release(script);
6200 elem = get_elem_by_id(doc, "in", TRUE);
6202 IHTMLInputElement *input;
6204 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6205 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6207 test_elem_id((IUnknown*)elem, "in");
6208 test_elem_put_id((IUnknown*)elem, "newin");
6209 test_input_get_disabled(input, VARIANT_FALSE);
6210 test_input_set_disabled(input, VARIANT_TRUE);
6211 test_input_set_disabled(input, VARIANT_FALSE);
6212 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6213 test_input_get_disabled(input, VARIANT_TRUE);
6214 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6215 test_input_get_disabled(input, VARIANT_FALSE);
6216 test_elem_client_size((IUnknown*)elem);
6217 test_input_type(input, "text");
6219 test_node_get_value_str((IUnknown*)elem, NULL);
6220 test_node_put_value_str((IUnknown*)elem, "test");
6221 test_node_get_value_str((IUnknown*)elem, NULL);
6222 test_input_value((IUnknown*)elem, NULL);
6223 test_input_put_value((IUnknown*)elem, "test");
6224 test_input_value((IUnknown*)elem, NULL);
6225 test_elem_class((IUnknown*)elem, "testclass");
6226 test_elem_tabindex((IUnknown*)elem, 2);
6227 test_elem_set_tabindex((IUnknown*)elem, 3);
6228 test_elem_title((IUnknown*)elem, "test title");
6230 test_input_get_defaultchecked(input, VARIANT_FALSE);
6231 test_input_set_defaultchecked(input, VARIANT_TRUE);
6232 test_input_set_defaultchecked(input, VARIANT_FALSE);
6234 test_input_get_checked(input, VARIANT_FALSE);
6235 test_input_set_checked(input, VARIANT_TRUE);
6236 test_input_set_checked(input, VARIANT_FALSE);
6238 test_input_name(input, NULL);
6239 test_input_set_name(input, "test");
6241 test_input_src(input, NULL);
6242 test_input_set_src(input, "about:blank");
6244 IHTMLInputElement_Release(input);
6245 IHTMLElement_Release(elem);
6248 elem = get_elem_by_id(doc, "imgid", TRUE);
6250 test_img_src((IUnknown*)elem, "");
6251 test_img_set_src((IUnknown*)elem, "about:blank");
6252 test_img_alt((IUnknown*)elem, NULL);
6253 test_img_set_alt((IUnknown*)elem, "alt test");
6254 test_img_name((IUnknown*)elem, "WineImg");
6255 IHTMLElement_Release(elem);
6258 elem = get_doc_elem_by_id(doc, "tbl");
6259 ok(elem != NULL, "elem == NULL\n");
6261 test_table_elem(elem);
6262 IHTMLElement_Release(elem);
6265 elem = get_doc_elem_by_id(doc, "row2");
6266 ok(elem != NULL, "elem == NULL\n");
6269 IHTMLElement_Release(elem);
6272 elem = get_doc_elem_by_id(doc, "ifr");
6273 ok(elem != NULL, "elem == NULL\n");
6275 test_iframe_elem(elem);
6276 IHTMLElement_Release(elem);
6279 elem = get_doc_elem_by_id(doc, "objid");
6280 ok(elem != NULL, "elem == NULL\n");
6282 test_object_vspace((IUnknown*)elem, 100);
6283 IHTMLElement_Release(elem);
6286 elem = get_elem_by_id(doc, "a", TRUE);
6288 test_anchor_href((IUnknown*)elem, "http://test/");
6289 IHTMLElement_Release(elem);
6292 elem = doc_get_body(doc);
6294 node = get_first_child((IUnknown*)elem);
6295 ok(node != NULL, "node == NULL\n");
6297 test_ifaces((IUnknown*)node, text_iids);
6298 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6300 node2 = get_first_child((IUnknown*)node);
6301 ok(!node2, "node2 != NULL\n");
6303 type = get_node_type((IUnknown*)node);
6304 ok(type == 3, "type=%d\n", type);
6306 test_node_get_value_str((IUnknown*)node, "text test");
6307 test_node_put_value_str((IUnknown*)elem, "test text");
6308 test_node_get_value_str((IUnknown*)node, "text test");
6310 IHTMLDOMNode_Release(node);
6313 child_col = get_child_nodes((IUnknown*)elem);
6314 ok(child_col != NULL, "child_coll == NULL\n");
6318 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6320 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6321 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6322 ok(length, "length=0\n");
6325 node = get_child_item(child_col, 0);
6326 ok(node != NULL, "node == NULL\n");
6328 type = get_node_type((IUnknown*)node);
6329 ok(type == 3, "type=%d\n", type);
6330 node2 = node_get_next((IUnknown*)node);
6331 IHTMLDOMNode_Release(node);
6334 node = get_child_item(child_col, 1);
6335 ok(node != NULL, "node == NULL\n");
6337 type = get_node_type((IUnknown*)node);
6338 ok(type == 8, "type=%d\n", type);
6340 test_elem_id((IUnknown*)node, NULL);
6341 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6342 IHTMLDOMNode_Release(node2);
6343 IHTMLDOMNode_Release(node);
6346 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6347 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6349 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6350 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6352 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6353 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6355 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6356 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6358 test_child_col_disp(child_col);
6360 IHTMLDOMChildrenCollection_Release(child_col);
6363 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6364 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6365 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6367 IHTMLElement_Release(elem);
6369 elem = get_doc_elem_by_id(doc, "frm");
6370 ok(elem != NULL, "elem == NULL\n");
6372 test_form_length((IUnknown*)elem, 0);
6373 IHTMLElement_Release(elem);
6376 test_stylesheets(doc);
6377 test_create_option_elem(doc);
6378 test_create_img_elem(doc);
6380 elem = get_doc_elem_by_id(doc, "tbl");
6381 ok(elem != NULL, "elem = NULL\n");
6382 test_elem_set_innertext(elem, "inner text");
6383 IHTMLElement_Release(elem);
6385 test_doc_title(doc, "test");
6386 test_doc_set_title(doc, "test title");
6387 test_doc_title(doc, "test title");
6390 hres = IHTMLDocument2_get_Script(doc, &disp);
6391 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6394 IDispatchEx *dispex;
6395 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6396 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6400 BSTR str = a2bstr("Testing");
6401 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6402 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6403 ok(pid != -1, "pid == -1\n");
6405 IDispatchEx_Release(dispex);
6408 IDispatch_Release(disp);
6410 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6411 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6413 str = a2bstr("img");
6414 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6415 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6419 static const elem_type_t img_types[] = { ET_IMG };
6421 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6422 IHTMLElementCollection_Release(col);
6425 elem = get_doc_elem_by_id(doc, "y");
6426 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6427 test_elem_innerhtml((IUnknown*)elem, "inner html");
6428 test_elem_set_innerhtml((IUnknown*)elem, "");
6429 test_elem_innerhtml((IUnknown*)elem, NULL);
6430 node = node_get_next((IUnknown*)elem);
6431 ok(!node, "node = %p\n", node);
6433 elem2 = get_doc_elem_by_id(doc, "x");
6434 test_elem_tag((IUnknown*)elem2, "A");
6435 node = node_get_next((IUnknown*)elem2);
6436 IHTMLDOMNode_Release(node);
6437 IHTMLElement_Release(elem2);
6438 IHTMLElement_Release(elem);
6440 IHTMLDocument3_Release(doc3);
6442 elem = get_elem_by_id(doc, "s", TRUE);
6444 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6446 test_select_put_length((IUnknown*)elem, 3);
6447 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6448 test_select_put_length((IUnknown*)elem, 1);
6449 test_elem_all((IUnknown*)elem, select_types, 1);
6450 IHTMLElement_Release(elem);
6453 window = get_doc_window(doc);
6454 test_window_name(window, NULL);
6455 set_window_name(window, "test name");
6456 test_window_length(window, 1);
6457 IHTMLWindow2_Release(window);
6460 static void test_elems2(IHTMLDocument2 *doc)
6462 IHTMLElement *elem, *elem2, *div;
6464 static const elem_type_t outer_types[] = {
6469 div = get_doc_elem_by_id(doc, "divid");
6471 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6472 elem2 = get_doc_elem_by_id(doc, "innerid");
6473 ok(elem2 != NULL, "elem2 == NULL\n");
6474 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6475 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6476 IHTMLElement_Release(elem2);
6478 elem2 = get_doc_elem_by_id(doc, "aid");
6479 ok(elem2 != NULL, "elem2 == NULL\n");
6480 test_elem_set_outerhtml((IUnknown*)elem2, "");
6481 test_elem_all((IUnknown*)div, outer_types, 1);
6482 IHTMLElement_Release(elem2);
6484 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6485 elem = get_elem_by_id(doc, "ta", TRUE);
6487 test_textarea_value((IUnknown*)elem, NULL);
6488 test_textarea_put_value((IUnknown*)elem, "test");
6489 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6490 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6491 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6492 test_textarea_type((IUnknown*)elem);
6493 IHTMLElement_Release(elem);
6496 test_elem_set_innerhtml((IUnknown*)div,
6497 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6498 elem = get_elem_by_id(doc, "form", TRUE);
6500 test_form_length((IUnknown*)elem, 2);
6501 test_form_item(elem);
6502 test_form_action((IUnknown*)elem, NULL);
6503 test_form_put_action((IUnknown*)elem, "about:blank");
6504 test_form_method((IUnknown*)elem, "get");
6505 test_form_put_method((IUnknown*)elem, S_OK, "post");
6506 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
6507 test_form_method((IUnknown*)elem, "post");
6508 test_form_name((IUnknown*)elem, NULL);
6509 test_form_put_name((IUnknown*)elem, "Name");
6510 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
6511 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
6512 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
6513 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
6514 test_form_encoding((IUnknown*)elem, "multipart/form-data");
6515 IHTMLElement_Release(elem);
6518 IHTMLElement_Release(div);
6521 static void test_create_elems(IHTMLDocument2 *doc)
6523 IHTMLElement *elem, *body, *elem2;
6524 IHTMLDOMNode *node, *node2, *node3, *comment;
6525 IHTMLDocument5 *doc5;
6532 static const elem_type_t types1[] = { ET_TESTG };
6534 elem = test_create_elem(doc, "TEST");
6535 test_elem_tag((IUnknown*)elem, "TEST");
6536 type = get_node_type((IUnknown*)elem);
6537 ok(type == 1, "type=%d\n", type);
6538 test_ifaces((IUnknown*)elem, elem_iids);
6539 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6541 body = doc_get_body(doc);
6542 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6544 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6545 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6546 elem2 = get_elem_iface((IUnknown*)node);
6547 IHTMLElement_Release(elem2);
6549 hres = IHTMLElement_get_all(body, &disp);
6550 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6551 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6552 IDispatch_Release(disp);
6554 test_node_remove_child((IUnknown*)body, node);
6556 hres = IHTMLElement_get_all(body, &disp);
6557 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6558 test_elem_collection((IUnknown*)disp, NULL, 0);
6559 IDispatch_Release(disp);
6560 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6562 IHTMLElement_Release(elem);
6563 IHTMLDOMNode_Release(node);
6565 node = test_create_text(doc, "test");
6566 test_ifaces((IUnknown*)node, text_iids);
6567 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6568 test_text_length((IUnknown*)node, 4);
6570 V_VT(&var) = VT_NULL;
6571 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6572 IHTMLDOMNode_Release(node);
6574 node = test_create_text(doc, "insert ");
6576 V_VT(&var) = VT_DISPATCH;
6577 V_DISPATCH(&var) = (IDispatch*)node2;
6578 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6579 IHTMLDOMNode_Release(node);
6580 IHTMLDOMNode_Release(node2);
6581 IHTMLDOMNode_Release(node3);
6583 test_elem_innertext(body, "insert test");
6584 test_elem_innerhtml((IUnknown*)body, "insert test");
6586 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6589 str = a2bstr("testing");
6590 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6592 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6595 type = get_node_type((IUnknown*)comment);
6596 ok(type == 8, "type=%d, expected 8\n", type);
6598 test_node_get_value_str((IUnknown*)comment, "testing");
6599 test_elem_title((IUnknown*)comment, NULL);
6600 test_elem_set_title((IUnknown*)comment, "comment title");
6601 test_elem_title((IUnknown*)comment, "comment title");
6602 test_comment_text((IUnknown*)comment, "<!--testing-->");
6603 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6605 IHTMLDOMNode_Release(comment);
6608 IHTMLDocument5_Release(doc5);
6611 IHTMLElement_Release(body);
6614 static void test_null_write(IHTMLDocument2 *doc)
6618 doc_write(doc, FALSE, NULL);
6619 doc_write(doc, TRUE, NULL);
6621 hres = IHTMLDocument2_write(doc, NULL);
6623 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6625 hres = IHTMLDocument2_writeln(doc, NULL);
6627 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6630 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6632 IOleCommandTarget *cmdtrg;
6635 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6636 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6638 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6639 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6641 IOleCommandTarget_Release(cmdtrg);
6644 static void test_indent(IHTMLDocument2 *doc)
6646 IHTMLElementCollection *col;
6647 IHTMLTxtRange *range;
6650 static const elem_type_t all_types[] = {
6659 static const elem_type_t indent_types[] = {
6670 hres = IHTMLDocument2_get_all(doc, &col);
6671 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6672 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6673 IHTMLElementCollection_Release(col);
6675 range = test_create_body_range(doc);
6676 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6677 IHTMLTxtRange_Release(range);
6679 hres = IHTMLDocument2_get_all(doc, &col);
6680 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6681 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6682 IHTMLElementCollection_Release(col);
6685 static void test_cond_comment(IHTMLDocument2 *doc)
6687 IHTMLElementCollection *col;
6690 static const elem_type_t all_types[] = {
6698 hres = IHTMLDocument2_get_all(doc, &col);
6699 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6700 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6701 IHTMLElementCollection_Release(col);
6704 static void test_frame(IDispatch *disp, const char *exp_id)
6706 IHTMLWindow2 *frame2, *parent, *top;
6707 IHTMLDocument2 *parent_doc, *top_doc;
6708 IHTMLWindow4 *frame;
6709 IHTMLFrameBase *frame_elem;
6712 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6713 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6717 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6718 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6719 IHTMLWindow4_Release(frame);
6723 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6724 test_frame_doc((IUnknown*)frame_elem, FALSE);
6725 test_elem_id((IUnknown*)frame_elem, exp_id);
6726 IHTMLElement_Release(frame_elem);
6728 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6729 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6733 hres = IHTMLWindow2_get_parent(frame2, &parent);
6734 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6736 IHTMLWindow2_Release(frame2);
6740 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6741 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6742 IHTMLWindow2_Release(parent);
6744 IHTMLWindow2_Release(frame2);
6748 test_doc_title(parent_doc, "frameset test");
6749 IHTMLDocument2_Release(parent_doc);
6752 hres = IHTMLWindow2_get_top(frame2, &top);
6753 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6754 IHTMLWindow2_Release(frame2);
6758 hres = IHTMLWindow2_get_document(top, &top_doc);
6759 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6760 IHTMLWindow2_Release(top);
6764 test_doc_title(top_doc, "frameset test");
6765 IHTMLDocument2_Release(top_doc);
6768 static void test_frameset(IHTMLDocument2 *doc)
6770 IHTMLWindow2 *window;
6771 IHTMLFramesCollection2 *frames;
6773 IHTMLFrameBase *fbase;
6775 VARIANT index_var, result_var;
6779 window = get_doc_window(doc);
6781 /* test using IHTMLFramesCollection object */
6783 hres = IHTMLWindow2_get_frames(window, &frames);
6784 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6785 IHTMLWindow2_Release(window);
6789 /* test result length */
6790 hres = IHTMLFramesCollection2_get_length(frames, &length);
6791 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6792 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6794 /* test first frame */
6795 V_VT(&index_var) = VT_I4;
6796 V_I4(&index_var) = 0;
6797 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6798 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6799 if(SUCCEEDED(hres)) {
6800 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6801 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6803 VariantClear(&result_var);
6805 /* test second frame */
6806 V_I4(&index_var) = 1;
6807 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6808 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6809 if(SUCCEEDED(hres)) {
6810 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6811 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6813 VariantClear(&result_var);
6815 /* fail on next frame */
6816 V_I4(&index_var) = 3;
6817 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6818 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6819 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6820 VariantClear(&result_var);
6822 /* string argument (element id lookup) */
6823 V_VT(&index_var) = VT_BSTR;
6824 V_BSTR(&index_var) = a2bstr("fr1");
6825 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6826 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6827 if(SUCCEEDED(hres)) {
6828 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6829 test_frame(V_DISPATCH(&result_var), "fr1");
6831 VariantClear(&result_var);
6832 VariantClear(&index_var);
6834 /* invalid argument */
6835 V_VT(&index_var) = VT_BOOL;
6836 V_BOOL(&index_var) = VARIANT_TRUE;
6837 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6838 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6839 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6840 VariantClear(&result_var);
6842 IHTMLFramesCollection2_Release(frames);
6844 /* test using IHTMLWindow2 inheritance */
6846 /* test result length */
6847 hres = IHTMLWindow2_get_length(window, &length);
6848 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6849 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6851 /* test first frame */
6852 V_VT(&index_var) = VT_I4;
6853 V_I4(&index_var) = 0;
6854 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6855 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6856 if(SUCCEEDED(hres)) {
6857 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6858 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6860 VariantClear(&result_var);
6862 /* test second frame */
6863 V_I4(&index_var) = 1;
6864 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6865 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6866 if(SUCCEEDED(hres)) {
6867 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6868 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6870 VariantClear(&result_var);
6872 /* fail on next frame */
6873 V_I4(&index_var) = 3;
6874 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6875 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6876 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6877 VariantClear(&result_var);
6879 /* string argument (element id lookup) */
6880 V_VT(&index_var) = VT_BSTR;
6881 V_BSTR(&index_var) = a2bstr("fr2");
6882 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6883 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6884 if(SUCCEEDED(hres)) {
6885 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6886 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6888 VariantClear(&result_var);
6889 VariantClear(&index_var);
6891 /* invalid argument */
6892 V_VT(&index_var) = VT_BOOL;
6893 V_BOOL(&index_var) = VARIANT_TRUE;
6894 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6895 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6896 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6897 VariantClear(&result_var);
6899 /* getElementById with node name attributes */
6900 elem = get_doc_elem_by_id(doc, "nm1");
6901 test_elem_id((IUnknown*)elem, "fr1");
6903 /* get/put scrolling */
6904 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6905 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6907 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6908 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6909 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6913 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6914 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6917 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6918 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6919 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6922 str = a2bstr("junk");
6923 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6924 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6925 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6928 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6929 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6930 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6934 hres = IHTMLFrameBase_get_name(fbase, &str);
6935 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6936 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6939 IHTMLFrameBase_Release(fbase);
6940 IHTMLElement_Release(elem);
6942 /* get_name with no name attr */
6943 elem = get_doc_elem_by_id(doc, "fr3");
6944 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6945 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6947 hres = IHTMLFrameBase_get_name(fbase, &str);
6948 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6949 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6952 IHTMLFrameBase_Release(fbase);
6953 IHTMLElement_Release(elem);
6956 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
6958 IHTMLDocument2 *frag;
6959 IHTMLDocument3 *doc3;
6962 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6963 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
6965 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
6966 IHTMLDocument3_Release(doc3);
6967 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
6968 ok(frag != NULL, "frag == NULL\n");
6973 static void test_docfrag(IHTMLDocument2 *doc)
6975 IHTMLElement *div, *body, *br;
6976 IHTMLElementCollection *col;
6977 IHTMLLocation *location;
6978 IHTMLDocument2 *frag;
6981 static const elem_type_t all_types[] = {
6990 frag = create_docfrag(doc);
6992 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
6994 body = (void*)0xdeadbeef;
6995 hres = IHTMLDocument2_get_body(frag, &body);
6996 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6997 ok(!body, "body != NULL\n");
6999 location = (void*)0xdeadbeef;
7000 hres = IHTMLDocument2_get_location(frag, &location);
7001 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
7002 ok(location == (void*)0xdeadbeef, "location changed\n");
7004 br = test_create_elem(doc, "BR");
7005 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
7006 IHTMLElement_Release(br);
7008 div = get_elem_by_id(doc, "divid", TRUE);
7009 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
7010 IHTMLElement_Release(div);
7012 hres = IHTMLDocument2_get_all(doc, &col);
7013 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7014 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7015 IHTMLElementCollection_Release(col);
7017 IHTMLDocument2_Release(frag);
7020 static IHTMLDocument2 *notif_doc;
7021 static BOOL doc_complete;
7023 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
7024 REFIID riid, void**ppv)
7026 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
7031 ok(0, "unexpected call\n");
7032 return E_NOINTERFACE;
7035 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
7040 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
7045 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
7047 if(dispID == DISPID_READYSTATE){
7051 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
7052 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
7054 if(!strcmp_wa(state, "complete"))
7055 doc_complete = TRUE;
7057 SysFreeString(state);
7063 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
7065 ok(0, "unexpected call\n");
7069 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
7070 PropertyNotifySink_QueryInterface,
7071 PropertyNotifySink_AddRef,
7072 PropertyNotifySink_Release,
7073 PropertyNotifySink_OnChanged,
7074 PropertyNotifySink_OnRequestEdit
7077 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
7079 static IHTMLDocument2 *create_doc_with_string(const char *str)
7081 IPersistStreamInit *init;
7083 IHTMLDocument2 *doc;
7087 notif_doc = doc = create_document();
7091 doc_complete = FALSE;
7093 mem = GlobalAlloc(0, len);
7094 memcpy(mem, str, len);
7095 CreateStreamOnHGlobal(mem, TRUE, &stream);
7097 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
7099 IPersistStreamInit_Load(init, stream);
7100 IPersistStreamInit_Release(init);
7101 IStream_Release(stream);
7106 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
7108 IConnectionPointContainer *container;
7109 IConnectionPoint *cp;
7113 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
7114 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
7116 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
7117 IConnectionPointContainer_Release(container);
7118 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
7120 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
7121 IConnectionPoint_Release(cp);
7122 ok(hres == S_OK, "Advise failed: %08x\n", hres);
7125 typedef void (*domtest_t)(IHTMLDocument2*);
7127 static void run_domtest(const char *str, domtest_t test)
7129 IHTMLDocument2 *doc;
7133 doc = create_doc_with_string(str);
7137 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
7139 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
7140 TranslateMessage(&msg);
7141 DispatchMessage(&msg);
7146 ref = IHTMLDocument2_Release(doc);
7147 ok(!ref || broken(ref == 1), /* Vista */
7155 run_domtest(doc_str1, test_doc_elem);
7156 run_domtest(doc_str1, test_get_set_attr);
7157 run_domtest(range_test_str, test_txtrange);
7158 run_domtest(range_test2_str, test_txtrange2);
7159 if (winetest_interactive || ! is_ie_hardened()) {
7160 run_domtest(elem_test_str, test_elems);
7162 skip("IE running in Enhanced Security Configuration\n");
7164 run_domtest(elem_test2_str, test_elems2);
7165 run_domtest(doc_blank, test_create_elems);
7166 run_domtest(doc_blank, test_defaults);
7167 run_domtest(doc_blank, test_null_write);
7168 run_domtest(indent_test_str, test_indent);
7169 run_domtest(cond_comment_str, test_cond_comment);
7170 run_domtest(frameset_str, test_frameset);
7171 run_domtest(emptydiv_str, test_docfrag);