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></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\">"
73 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
74 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
75 static WCHAR wordW[] = {'w','o','r','d',0};
108 static const IID * const none_iids[] = {
113 static const IID * const doc_node_iids[] = {
122 &IID_IConnectionPointContainer,
123 &IID_IInternetHostSecurityManager,
127 static const IID * const doc_obj_iids[] = {
134 &IID_IConnectionPointContainer,
139 static const IID * const elem_iids[] = {
146 &IID_IConnectionPointContainer,
150 static const IID * const body_iids[] = {
156 &IID_IHTMLTextContainer,
157 &IID_IHTMLBodyElement,
159 &IID_IConnectionPointContainer,
163 static const IID * const anchor_iids[] = {
169 &IID_IHTMLAnchorElement,
171 &IID_IConnectionPointContainer,
175 static const IID * const input_iids[] = {
181 &IID_IHTMLInputElement,
182 &IID_IHTMLInputTextElement,
184 &IID_IConnectionPointContainer,
188 static const IID * const select_iids[] = {
194 &IID_IHTMLSelectElement,
196 &IID_IConnectionPointContainer,
200 static const IID * const textarea_iids[] = {
206 &IID_IHTMLTextAreaElement,
208 &IID_IConnectionPointContainer,
212 static const IID * const option_iids[] = {
218 &IID_IHTMLOptionElement,
220 &IID_IConnectionPointContainer,
224 static const IID * const table_iids[] = {
232 &IID_IConnectionPointContainer,
236 static const IID * const script_iids[] = {
242 &IID_IHTMLScriptElement,
244 &IID_IConnectionPointContainer,
248 static const IID * const text_iids[] = {
251 &IID_IHTMLDOMTextNode,
255 static const IID * const location_iids[] = {
261 static const IID * const window_iids[] = {
269 static const IID * const comment_iids[] = {
275 &IID_IHTMLCommentElement,
277 &IID_IConnectionPointContainer,
281 static const IID * const img_iids[] = {
288 &IID_IHTMLImgElement,
289 &IID_IConnectionPointContainer,
293 static const IID * const tr_iids[] = {
301 &IID_IConnectionPointContainer,
305 static const IID * const td_iids[] = {
312 &IID_IConnectionPointContainer,
316 static const IID * const frame_iids[] = {
323 &IID_IHTMLFrameBase2,
325 &IID_IConnectionPointContainer,
329 static const IID * const object_iids[] = {
335 &IID_IHTMLObjectElement,
337 /* FIXME: No IConnectionPointContainer */
341 static const IID * const embed_iids[] = {
347 &IID_IHTMLEmbedElement,
349 /* FIXME: No IConnectionPointContainer */
353 static const IID * const iframe_iids[] = {
360 &IID_IHTMLFrameBase2,
361 &IID_IHTMLIFrameElement,
363 &IID_IConnectionPointContainer,
367 static const IID * const form_iids[] = {
373 &IID_IHTMLFormElement,
375 &IID_IConnectionPointContainer,
379 static const IID * const generic_iids[] = {
385 &IID_IHTMLGenericElement,
387 &IID_IConnectionPointContainer,
391 static const IID * const style_iids[] = {
402 static const IID * const cstyle_iids[] = {
406 &IID_IHTMLCurrentStyle,
410 static const IID * const img_factory_iids[] = {
414 &IID_IHTMLImageElementFactory,
424 static const elem_type_info_t elem_type_infos[] = {
425 {"", none_iids, NULL},
426 {"HTML", elem_iids, NULL},
427 {"HEAD", elem_iids, NULL},
428 {"TITLE", elem_iids, NULL},
429 {"BODY", body_iids, &DIID_DispHTMLBody},
430 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
431 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
432 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
433 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
434 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
435 {"STYLE", elem_iids, NULL},
436 {"BLOCKQUOTE",elem_iids, NULL},
437 {"P", elem_iids, NULL},
438 {"BR", elem_iids, NULL},
439 {"TABLE", table_iids, &DIID_DispHTMLTable},
440 {"TBODY", elem_iids, NULL},
441 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
442 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
443 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
444 {"!", comment_iids, &DIID_DispHTMLCommentElement},
445 {"IMG", img_iids, &DIID_DispHTMLImg},
446 {"TR", tr_iids, &DIID_DispHTMLTableRow},
447 {"TD", td_iids, NULL},
448 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
449 {"FORM", form_iids, &DIID_DispHTMLFormElement},
450 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
451 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
452 {"EMBED", embed_iids, &DIID_DispHTMLEmbed}
455 static const char *dbgstr_guid(REFIID riid)
459 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
460 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
461 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
462 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
467 static int strcmp_wa(LPCWSTR strw, const char *stra)
470 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
471 return lstrcmpA(stra, buf);
474 static BSTR a2bstr(const char *str)
479 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
480 ret = SysAllocStringLen(NULL, len);
481 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
486 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
488 IUnknown *unk1, *unk2;
493 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
494 IUnknown_Release(unk1);
495 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
496 IUnknown_Release(unk2);
501 static IHTMLDocument2 *create_document(void)
504 IHTMLDocument5 *doc5;
507 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
508 &IID_IHTMLDocument2, (void**)&doc);
509 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
513 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
515 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
516 IHTMLDocument2_Release(doc);
520 IHTMLDocument5_Release(doc5);
524 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
525 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
527 const IID * const *piid;
531 for(piid = iids; *piid; piid++) {
532 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
533 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
535 IUnknown_Release(unk);
539 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
540 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
548 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
549 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
554 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
555 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
556 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
558 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
559 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
561 if(SUCCEEDED(hres)) {
564 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
565 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
567 *iid = type_attr->guid;
571 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
572 ITypeInfo_Release(typeinfo);
575 IDispatchEx_Release(dispex);
579 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
580 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
582 DISPPARAMS dp = {NULL,NULL,0,0};
588 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
589 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
593 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
594 IDispatchEx_Release(dispex);
595 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
597 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
598 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
602 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
603 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
607 if(_test_get_dispid(line, unk, &iid))
608 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
611 _test_disp_value(line, unk, val);
614 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
615 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
619 if(_test_get_dispid(line, unk, &iid))
620 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
621 "unexpected guid %s\n", dbgstr_guid(&iid));
624 _test_disp_value(line, unk, val);
627 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
628 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
633 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
634 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
638 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
639 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
644 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
645 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
649 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
650 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
655 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
656 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
660 #define get_node_iface(u) _get_node_iface(__LINE__,u)
661 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
666 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
667 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
671 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
672 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
677 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
678 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
682 #define get_img_iface(u) _get_img_iface(__LINE__,u)
683 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
685 IHTMLImgElement *img;
688 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
689 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
693 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
694 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
696 IHTMLAnchorElement *anchor;
699 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
700 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
704 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
705 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
707 IHTMLTextAreaElement *textarea;
710 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
711 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
715 #define get_select_iface(u) _get_select_iface(__LINE__,u)
716 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
718 IHTMLSelectElement *select;
721 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
722 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
726 #define get_form_iface(u) _get_form_iface(__LINE__,u)
727 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
729 IHTMLFormElement *form;
732 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
733 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
737 #define get_text_iface(u) _get_text_iface(__LINE__,u)
738 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
740 IHTMLDOMTextNode *text;
743 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
744 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
748 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
749 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
751 IHTMLCommentElement *comment;
754 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
755 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
759 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
760 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
762 IHTMLDOMNode *node = _get_node_iface(line, unk);
766 hres = IHTMLDOMNode_get_nodeName(node, &name);
767 IHTMLDOMNode_Release(node);
768 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
769 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
774 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
775 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
777 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
778 IDispatch *disp = (void*)0xdeadbeef;
779 IHTMLDocument2 *doc = NULL;
782 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
783 IHTMLDOMNode2_Release(node);
784 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
787 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
788 IDispatch_Release(disp);
789 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
795 #define get_doc_window(d) _get_doc_window(__LINE__,d)
796 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
798 IHTMLWindow2 *window;
802 hres = IHTMLDocument2_get_parentWindow(doc, &window);
803 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
804 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
809 #define clone_node(n,d) _clone_node(__LINE__,n,d)
810 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
812 IHTMLDOMNode *node = _get_node_iface(line, unk);
813 IHTMLDOMNode *ret = NULL;
816 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
817 IHTMLDOMNode_Release(node);
818 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
819 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
825 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
826 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
828 IHTMLElement *elem = _get_elem_iface(line, unk);
832 hres = IHTMLElement_get_tagName(elem, &tag);
833 IHTMLElement_Release(elem);
834 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
835 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
840 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
841 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
843 _test_elem_tag(line, unk, elem_type_infos[type].tag);
844 _test_ifaces(line, unk, elem_type_infos[type].iids);
846 if(elem_type_infos[type].dispiid && type != ET_A)
847 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
850 #define get_node_type(n) _get_node_type(__LINE__,n)
851 static LONG _get_node_type(unsigned line, IUnknown *unk)
853 IHTMLDOMNode *node = _get_node_iface(line, unk);
857 hres = IHTMLDOMNode_get_nodeType(node, &type);
858 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
860 IHTMLDOMNode_Release(node);
865 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
866 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
868 IHTMLDOMNode *node = _get_node_iface(line, unk);
869 IHTMLDOMChildrenCollection *col = NULL;
873 hres = IHTMLDOMNode_get_childNodes(node, &disp);
874 IHTMLDOMNode_Release(node);
875 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
879 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
880 IDispatch_Release(disp);
881 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
886 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
887 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
889 IHTMLDOMNode *node = NULL;
893 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
894 ok(hres == S_OK, "item failed: %08x\n", hres);
896 node = _get_node_iface(line, (IUnknown*)disp);
897 IDispatch_Release(disp);
902 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
903 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
912 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
914 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
917 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
918 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
920 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
923 VariantClear(&value);
926 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
927 static void _test_elem_offset(unsigned line, IUnknown *unk)
929 IHTMLElement *elem = _get_elem_iface(line, unk);
933 hres = IHTMLElement_get_offsetTop(elem, &l);
934 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
936 hres = IHTMLElement_get_offsetHeight(elem, &l);
937 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
939 hres = IHTMLElement_get_offsetWidth(elem, &l);
940 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
942 IHTMLElement_Release(elem);
945 #define get_doc_node(d) _get_doc_node(__LINE__,d)
946 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
948 IHTMLWindow2 *window;
952 hres = IHTMLDocument2_get_parentWindow(doc, &window);
953 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
955 hres = IHTMLWindow2_get_document(window, &ret);
956 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
957 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
962 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
963 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
968 hres = IHTMLWindow2_get_name(window, &name);
969 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
971 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
973 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
977 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
978 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
984 hres = IHTMLWindow2_put_name(window, str);
986 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
988 _test_window_name(line, window, name);
991 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
992 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
997 hres = IHTMLWindow2_get_length(window, &length);
998 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
999 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
1002 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1003 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
1005 IHTMLFrameBase2 *base2;
1006 IHTMLWindow2 *window;
1009 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
1010 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
1013 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1014 IHTMLFrameBase2_Release(base2);
1015 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1016 ok(window != NULL, "contentWindow = NULL\n");
1021 static void test_get_set_attr(IHTMLDocument2 *doc)
1024 IHTMLDocument3 *doc3;
1029 /* grab an element to test with */
1030 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1031 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1033 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1034 IHTMLDocument3_Release(doc3);
1035 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1037 /* get a non-present attribute */
1038 bstr = a2bstr("notAnAttribute");
1039 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1040 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1041 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1043 SysFreeString(bstr);
1045 /* get a present attribute */
1046 bstr = a2bstr("scrollHeight");
1047 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1048 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1049 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1051 SysFreeString(bstr);
1053 /* create a new BSTR attribute */
1054 bstr = a2bstr("newAttribute");
1056 V_VT(&val) = VT_BSTR;
1057 V_BSTR(&val) = a2bstr("the value");
1058 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1059 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1062 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1063 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1064 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1065 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)));
1068 /* overwrite the attribute with a BOOL */
1069 V_VT(&val) = VT_BOOL;
1070 V_BOOL(&val) = VARIANT_TRUE;
1071 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1072 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1075 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1076 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1077 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1078 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1081 SysFreeString(bstr);
1083 /* case-insensitive */
1084 bstr = a2bstr("newattribute");
1085 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1086 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1087 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1088 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1090 SysFreeString(bstr);
1092 IHTMLElement_Release(elem);
1095 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1096 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1099 IHTMLDocument3 *doc3;
1102 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1103 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1104 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1105 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1106 IHTMLDocument3_Release(doc3);
1111 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1112 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1114 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1118 hres = IHTMLAnchorElement_get_href(anchor, &str);
1119 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1120 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1123 _test_disp_value(line, unk, exhref);
1126 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1127 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1132 hres = IHTMLOptionElement_get_text(option, &bstr);
1133 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1134 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1135 SysFreeString(bstr);
1138 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1139 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1144 bstr = a2bstr(text);
1145 hres = IHTMLOptionElement_put_text(option, bstr);
1146 SysFreeString(bstr);
1147 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1149 _test_option_text(line, option, text);
1152 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1153 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1158 hres = IHTMLOptionElement_get_value(option, &bstr);
1159 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1160 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1161 SysFreeString(bstr);
1164 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1165 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1170 bstr = a2bstr(value);
1171 hres = IHTMLOptionElement_put_value(option, bstr);
1172 SysFreeString(bstr);
1173 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1175 _test_option_value(line, option, value);
1178 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1179 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1181 VARIANT_BOOL b = 0x100;
1184 hres = IHTMLOptionElement_get_selected(option, &b);
1185 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1186 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1189 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1190 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1194 hres = IHTMLOptionElement_put_selected(option, b);
1195 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1196 _test_option_selected(line, option, b);
1199 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1200 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1202 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1203 BSTR value = (void*)0xdeadbeef;
1206 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1207 IHTMLTextAreaElement_Release(textarea);
1208 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1210 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1212 ok_(__FILE__,line)(!value, "value = %p\n", value);
1213 SysFreeString(value);
1216 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1217 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1219 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1220 BSTR tmp = a2bstr(value);
1223 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1224 IHTMLTextAreaElement_Release(textarea);
1225 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1228 _test_textarea_value(line, unk, value);
1231 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1232 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1234 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1235 VARIANT_BOOL b = 0x100;
1238 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1239 IHTMLTextAreaElement_Release(textarea);
1240 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1241 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1244 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1245 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1247 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1250 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1251 IHTMLTextAreaElement_Release(textarea);
1252 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1254 _test_textarea_readonly(line, unk, b);
1257 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1258 static void _test_textarea_type(unsigned line, IUnknown *unk)
1260 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1261 BSTR type = (void*)0xdeadbeef;
1264 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1265 IHTMLTextAreaElement_Release(textarea);
1266 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1267 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1268 SysFreeString(type);
1271 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1272 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1274 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1278 text = a2bstr(extext);
1279 hres = IHTMLCommentElement_get_text(comment, &text);
1280 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1281 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1283 IHTMLCommentElement_Release(comment);
1284 SysFreeString(text);
1287 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1288 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1289 const char *txt, const char *val)
1291 IHTMLOptionElementFactory *factory;
1292 IHTMLOptionElement *option;
1293 IHTMLWindow2 *window;
1294 VARIANT text, value, empty;
1297 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1298 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1300 hres = IHTMLWindow2_get_Option(window, &factory);
1301 IHTMLWindow2_Release(window);
1302 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1304 V_VT(&text) = VT_BSTR;
1305 V_BSTR(&text) = a2bstr(txt);
1306 V_VT(&value) = VT_BSTR;
1307 V_BSTR(&value) = a2bstr(val);
1308 V_VT(&empty) = VT_EMPTY;
1310 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1311 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1313 IHTMLOptionElementFactory_Release(factory);
1314 VariantClear(&text);
1315 VariantClear(&value);
1317 _test_option_text(line, option, txt);
1318 _test_option_value(line, option, val);
1319 _test_option_selected(line, option, VARIANT_FALSE);
1324 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1325 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1330 hres = IHTMLImgElement_get_width(img, &found);
1331 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1332 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1335 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1336 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1340 hres = IHTMLImgElement_put_width(img, width);
1341 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1343 _test_img_width(line, img, width);
1346 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1347 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1352 hres = IHTMLImgElement_get_height(img, &found);
1353 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1354 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1357 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1358 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1362 hres = IHTMLImgElement_put_height(img, height);
1363 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1365 _test_img_height(line, img, height);
1368 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1369 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1370 LONG wdth, LONG hght)
1372 IHTMLImageElementFactory *factory;
1373 IHTMLImgElement *img;
1374 IHTMLWindow2 *window;
1375 VARIANT width, height;
1379 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1380 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1382 hres = IHTMLWindow2_get_Image(window, &factory);
1383 IHTMLWindow2_Release(window);
1384 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1386 test_ifaces((IUnknown*)factory, img_factory_iids);
1387 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1390 snprintf(buf, 16, "%d", wdth);
1391 V_VT(&width) = VT_BSTR;
1392 V_BSTR(&width) = a2bstr(buf);
1394 V_VT(&width) = VT_EMPTY;
1399 snprintf(buf, 16, "%d", hght);
1400 V_VT(&height) = VT_BSTR;
1401 V_BSTR(&height) = a2bstr(buf);
1403 V_VT(&height) = VT_EMPTY;
1407 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1408 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1410 IHTMLImageElementFactory_Release(factory);
1411 VariantClear(&width);
1412 VariantClear(&height);
1414 if(SUCCEEDED(hres)) {
1415 _test_img_width(line, img, wdth);
1416 _test_img_height(line, img, hght);
1423 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1424 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1426 LONG len = 0xdeadbeef;
1429 hres = IHTMLSelectElement_get_length(select, &len);
1430 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1431 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1434 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1435 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1437 IHTMLSelectElement *select = _get_select_iface(line, unk);
1440 hres = IHTMLSelectElement_put_length(select, length);
1441 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1442 _test_select_length(line, select, length);
1443 IHTMLSelectElement_Release(select);
1446 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1447 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1449 LONG idx = 0xdeadbeef;
1452 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1453 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1454 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1457 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1458 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1462 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1463 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1464 _test_select_selidx(line, select, index);
1467 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1468 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1473 hres = IHTMLSelectElement_get_value(select, &val);
1474 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1476 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1478 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1482 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1483 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1489 hres = IHTMLSelectElement_put_value(select, bstr);
1490 SysFreeString(bstr);
1491 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1494 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1495 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1500 hres = IHTMLSelectElement_get_type(select, &type);
1501 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1502 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1503 SysFreeString(type);
1506 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1507 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1512 hres = IHTMLTxtRange_get_text(range, &text);
1513 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1516 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1517 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1519 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1522 SysFreeString(text);
1526 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1527 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1531 hres = IHTMLTxtRange_collapse(range, b);
1532 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1533 _test_range_text(line, range, NULL);
1536 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1537 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1538 VARIANT_BOOL exb, const char *extext)
1540 VARIANT_BOOL b = 0xe0e0;
1543 hres = IHTMLTxtRange_expand(range, unit, &b);
1544 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1545 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1546 _test_range_text(line, range, extext);
1549 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1550 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1552 LONG c = 0xdeadbeef;
1555 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1556 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1557 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1558 _test_range_text(line, range, NULL);
1561 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1562 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1563 LPWSTR unit, LONG cnt, LONG excnt)
1565 LONG c = 0xdeadbeef;
1568 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1569 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1570 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1573 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1574 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1576 LONG c = 0xdeadbeef;
1579 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1580 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1581 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1584 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1585 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1588 BSTR bstr = a2bstr(text);
1590 hres = IHTMLTxtRange_put_text(range, bstr);
1591 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1592 SysFreeString(bstr);
1593 _test_range_text(line, range, NULL);
1596 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1597 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1603 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1604 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1605 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1608 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1609 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1615 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1616 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1617 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1620 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1621 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1622 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1625 test_range_inrange(range1, range2, VARIANT_TRUE);
1626 test_range_inrange(range2, range1, VARIANT_TRUE);
1630 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1631 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1636 hres = IHTMLTxtRange_parentElement(range, &elem);
1637 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1639 _test_elem_type(line, (IUnknown*)elem, type);
1641 IHTMLElement_Release(elem);
1644 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1645 static void _test_elem_collection(unsigned line, IUnknown *unk,
1646 const elem_type_t *elem_types, LONG exlen)
1648 IHTMLElementCollection *col;
1651 VARIANT name, index;
1652 IDispatch *disp, *disp2;
1655 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1656 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1658 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1660 hres = IHTMLElementCollection_get_length(col, &len);
1661 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1662 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1667 V_VT(&index) = VT_EMPTY;
1669 for(i=0; i<len; i++) {
1670 V_VT(&name) = VT_I4;
1672 disp = (void*)0xdeadbeef;
1673 hres = IHTMLElementCollection_item(col, name, index, &disp);
1674 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1675 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1676 if(FAILED(hres) || !disp)
1679 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1682 V_VT(&name) = VT_UINT;
1684 disp2 = (void*)0xdeadbeef;
1685 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1686 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1687 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1689 IDispatch_Release(disp2);
1692 IDispatch_Release(disp);
1695 V_VT(&name) = VT_I4;
1697 disp = (void*)0xdeadbeef;
1698 hres = IHTMLElementCollection_item(col, name, index, &disp);
1699 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1700 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1702 V_VT(&name) = VT_I4;
1704 disp = (void*)0xdeadbeef;
1705 hres = IHTMLElementCollection_item(col, name, index, &disp);
1706 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1707 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1709 IHTMLElementCollection_Release(col);
1712 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1713 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1715 IHTMLElement *elem = _get_elem_iface(line, unk);
1719 hres = IHTMLElement_get_all(elem, &disp);
1720 IHTMLElement_Release(elem);
1721 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1723 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1724 IDispatch_Release(disp);
1727 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1728 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1730 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1731 IHTMLElementCollection *col = NULL;
1732 elem_type_t *types = NULL;
1737 tmp = a2bstr(elem_type_infos[type].tag);
1738 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1740 IHTMLElement2_Release(elem);
1741 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1742 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1745 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1746 for(i=0; i<exlen; i++)
1750 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1752 HeapFree(GetProcessHeap(), 0, types);
1755 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1756 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1761 hres = IHTMLElement_get_innerText(elem, &text);
1762 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1763 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1764 wine_dbgstr_w(text), extext);
1765 SysFreeString(text);
1768 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1769 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1771 IHTMLDOMChildrenCollection *col;
1776 hres = IHTMLElement_put_innerText(elem, str);
1777 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1780 _test_elem_innertext(line, elem, text);
1783 col = _get_child_nodes(line, (IUnknown*)elem);
1784 ok(col != NULL, "col == NULL\n");
1786 LONG length = 0, type;
1789 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1790 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1791 ok(length == 1, "length = %d\n", length);
1793 node = _get_child_item(line, col, 0);
1794 ok(node != NULL, "node == NULL\n");
1796 type = _get_node_type(line, (IUnknown*)node);
1797 ok(type == 3, "type=%d\n", type);
1798 IHTMLDOMNode_Release(node);
1801 IHTMLDOMChildrenCollection_Release(col);
1806 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1807 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1809 IHTMLElement *elem = _get_elem_iface(line, unk);
1813 hres = IHTMLElement_get_innerHTML(elem, &html);
1814 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1816 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1818 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1820 IHTMLElement_Release(elem);
1821 SysFreeString(html);
1824 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1825 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1827 IHTMLElement *elem = _get_elem_iface(line, unk);
1831 html = a2bstr(inner_html);
1832 hres = IHTMLElement_put_innerHTML(elem, html);
1833 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1835 IHTMLElement_Release(elem);
1836 SysFreeString(html);
1839 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1840 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1842 IHTMLElement *elem = _get_elem_iface(line, unk);
1846 html = a2bstr(outer_html);
1847 hres = IHTMLElement_put_outerHTML(elem, html);
1848 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1850 IHTMLElement_Release(elem);
1851 SysFreeString(html);
1854 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1855 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1857 IHTMLElement *elem = _get_elem_iface(line, unk);
1861 hres = IHTMLElement_get_outerHTML(elem, &html);
1862 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1863 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1865 IHTMLElement_Release(elem);
1866 SysFreeString(html);
1869 #define get_first_child(n) _get_first_child(__LINE__,n)
1870 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1872 IHTMLDOMNode *node = _get_node_iface(line, unk);
1873 IHTMLDOMNode *child = NULL;
1876 hres = IHTMLDOMNode_get_firstChild(node, &child);
1877 IHTMLDOMNode_Release(node);
1878 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1883 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1884 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1886 IHTMLDOMNode *node = _get_node_iface(line, unk);
1887 VARIANT_BOOL b = 0xdead;
1890 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1891 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1892 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1894 IHTMLDOMNode_Release(node);
1897 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1898 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1900 IHTMLDOMNode *node = _get_node_iface(line, unk);
1901 IHTMLDOMNode *parent;
1904 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1905 IHTMLDOMNode_Release(node);
1906 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1911 #define node_get_next(u) _node_get_next(__LINE__,u)
1912 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1914 IHTMLDOMNode *node = _get_node_iface(line, unk);
1918 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1919 IHTMLDOMNode_Release(node);
1920 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1925 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1926 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1928 IHTMLElement *elem = _get_elem_iface(line, unk);
1929 IHTMLElement *parent;
1932 hres = IHTMLElement_get_parentElement(elem, &parent);
1933 IHTMLElement_Release(elem);
1934 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1939 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1940 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1942 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1943 VARIANT_BOOL disabled = 100;
1947 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1948 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1949 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1950 IHTMLElement3_Release(elem3);
1953 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1954 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1956 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1960 hres = IHTMLElement3_put_disabled(elem3, b);
1961 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1963 IHTMLElement3_Release(elem3);
1964 _test_elem3_get_disabled(line, unk, b);
1967 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1968 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1970 VARIANT_BOOL disabled = 100;
1973 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1974 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1975 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1977 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1980 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1981 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1983 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
1987 hres = IHTMLDOMTextNode_get_length(text, &length);
1988 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
1989 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
1990 IHTMLDOMTextNode_Release(text);
1993 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1994 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1998 hres = IHTMLSelectElement_put_disabled(select, b);
1999 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2001 _test_select_get_disabled(line, select, b);
2004 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2005 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2007 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2008 IHTMLTextContainer *txtcont;
2009 LONG l = -1, l2 = -1;
2012 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2013 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2014 IHTMLElement2_Release(elem);
2016 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2017 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2019 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2020 IHTMLTextContainer_Release(txtcont);
2021 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2022 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2027 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2028 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2030 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2031 IHTMLTextContainer *txtcont;
2032 LONG l = -1, l2 = -1;
2035 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2036 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2037 IHTMLElement2_Release(elem);
2039 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2040 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2042 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2043 IHTMLTextContainer_Release(txtcont);
2044 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2045 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2050 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2051 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2053 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2054 IHTMLTextContainer *txtcont;
2055 LONG l = -1, l2 = -1;
2058 hres = IHTMLElement2_get_scrollTop(elem, &l);
2059 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2060 IHTMLElement2_Release(elem);
2062 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2063 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2065 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2066 IHTMLTextContainer_Release(txtcont);
2067 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2068 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2073 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2074 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2076 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2077 IHTMLTextContainer *txtcont;
2078 LONG l = -1, l2 = -1;
2081 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2082 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2084 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2085 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2086 IHTMLElement2_Release(elem);
2088 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2089 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2091 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2092 IHTMLTextContainer_Release(txtcont);
2093 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2094 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2097 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2098 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2100 IHTMLImgElement *img = _get_img_iface(line, unk);
2104 hres = IHTMLImgElement_get_src(img, &src);
2105 IHTMLImgElement_Release(img);
2106 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2107 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2111 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2112 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2114 IHTMLImgElement *img = _get_img_iface(line, unk);
2119 hres = IHTMLImgElement_put_src(img, tmp);
2120 IHTMLImgElement_Release(img);
2122 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2124 _test_img_src(line, unk, src);
2127 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2128 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2130 IHTMLImgElement *img = _get_img_iface(line, unk);
2134 hres = IHTMLImgElement_get_alt(img, &alt);
2135 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2137 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2139 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2143 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2144 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2146 IHTMLImgElement *img = _get_img_iface(line, unk);
2151 hres = IHTMLImgElement_put_alt(img, tmp);
2152 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2155 _test_img_alt(line, unk, alt);
2158 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2159 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2161 IHTMLImgElement *img = _get_img_iface(line, unk);
2165 hres = IHTMLImgElement_get_name(img, &sName);
2166 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2167 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2168 IHTMLImgElement_Release(img);
2169 SysFreeString(sName);
2172 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2173 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2178 hres = IHTMLInputElement_get_type(input, &type);
2179 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2180 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2181 SysFreeString(type);
2184 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2185 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2187 BSTR name = (BSTR)0xdeadbeef;
2190 hres = IHTMLInputElement_get_name(input, &name);
2191 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2193 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2195 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2196 SysFreeString(name);
2199 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2200 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2202 BSTR tmp = a2bstr(name);
2205 hres = IHTMLInputElement_put_name(input, tmp);
2206 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2209 _test_input_name(line, input, name);
2212 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2213 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2215 VARIANT_BOOL disabled = 100;
2218 hres = IHTMLInputElement_get_disabled(input, &disabled);
2219 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2220 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2222 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2225 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2226 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2230 hres = IHTMLInputElement_put_disabled(input, b);
2231 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2233 _test_input_get_disabled(line, input, b);
2236 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2237 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2239 VARIANT_BOOL checked = 100;
2242 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2243 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2244 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2247 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2248 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2252 hres = IHTMLInputElement_put_defaultChecked(input, b);
2253 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2255 _test_input_get_defaultchecked(line, input, b);
2258 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2259 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2261 VARIANT_BOOL checked = 100;
2264 hres = IHTMLInputElement_get_checked(input, &checked);
2265 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2266 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2269 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2270 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2274 hres = IHTMLInputElement_put_checked(input, b);
2275 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2277 _test_input_get_checked(line, input, b);
2280 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2281 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2283 IHTMLInputElement *input;
2287 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2288 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2292 hres = IHTMLInputElement_get_value(input, &bstr);
2293 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2295 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2297 ok_(__FILE__,line) (!exval, "exval != NULL\n");
2298 SysFreeString(bstr);
2299 IHTMLInputElement_Release(input);
2302 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2303 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2305 IHTMLInputElement *input;
2309 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2310 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2315 hres = IHTMLInputElement_get_value(input, &bstr);
2316 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2317 SysFreeString(bstr);
2318 IHTMLInputElement_Release(input);
2321 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2322 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2327 hres = IHTMLInputElement_get_src(input, &src);
2328 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2330 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2332 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2336 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2337 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2343 hres = IHTMLInputElement_put_src(input, tmp);
2345 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2347 _test_input_src(line, input, src);
2350 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2351 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2353 IHTMLElement *elem = _get_elem_iface(line, unk);
2354 BSTR class = (void*)0xdeadbeef;
2357 hres = IHTMLElement_get_className(elem, &class);
2358 IHTMLElement_Release(elem);
2359 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2361 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2363 ok_(__FILE__,line) (!class, "class != NULL\n");
2364 SysFreeString(class);
2367 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2368 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2370 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2374 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2375 IHTMLElement2_Release(elem2);
2376 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2377 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2380 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2381 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2383 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2386 hres = IHTMLElement2_put_tabIndex(elem2, index);
2387 IHTMLElement2_Release(elem2);
2388 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2390 _test_elem_tabindex(line, unk, index);
2393 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2394 static void _test_elem_filters(unsigned line, IUnknown *unk)
2396 IHTMLElement *elem = _get_elem_iface(line, unk);
2398 IHTMLFiltersCollection *filters;
2400 hres = IHTMLElement_get_filters(elem, &filters);
2401 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2402 "get_filters failed: %08x\n", hres);
2406 IDispatchEx *dispex;
2408 hres = IHTMLFiltersCollection_get_length(filters, &len);
2409 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2410 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2412 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2413 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2414 "Could not get IDispatchEx interface: %08x\n", hres);
2415 if(SUCCEEDED(hres)) {
2416 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2417 IDispatchEx_Release(dispex);
2420 IHTMLFiltersCollection_Release(filters);
2423 IHTMLElement_Release(elem);
2426 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2427 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2429 IHTMLElement *elem = _get_elem_iface(line, unk);
2433 tmp = class ? a2bstr(class) : NULL;
2434 hres = IHTMLElement_put_className(elem, tmp);
2435 IHTMLElement_Release(elem);
2436 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2439 _test_elem_class(line, unk, class);
2442 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2443 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2445 IHTMLElement *elem = _get_elem_iface(line, unk);
2446 BSTR id = (void*)0xdeadbeef;
2449 hres = IHTMLElement_get_id(elem, &id);
2450 IHTMLElement_Release(elem);
2451 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2454 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2456 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2461 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2462 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2464 IHTMLElement *elem = _get_elem_iface(line, unk);
2465 BSTR tmp = a2bstr(new_id);
2468 hres = IHTMLElement_put_id(elem, tmp);
2469 IHTMLElement_Release(elem);
2471 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2473 _test_elem_id(line, unk, new_id);
2476 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2477 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2479 IHTMLElement *elem = _get_elem_iface(line, unk);
2483 hres = IHTMLElement_get_title(elem, &title);
2484 IHTMLElement_Release(elem);
2485 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2487 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2489 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2491 SysFreeString(title);
2494 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2495 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2497 IHTMLElement *elem = _get_elem_iface(line, unk);
2501 tmp = a2bstr(title);
2502 hres = IHTMLElement_put_title(elem, tmp);
2503 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2505 IHTMLElement_Release(elem);
2509 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2510 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2512 IHTMLDOMNode *node = _get_node_iface(line, unk);
2516 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2517 IHTMLDOMNode_Release(node);
2518 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2521 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2522 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2524 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2530 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2531 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2533 IHTMLDOMNode *node = _get_node_iface(line, unk);
2537 V_VT(&var) = VT_BSTR;
2538 V_BSTR(&var) = a2bstr(val);
2540 hres = IHTMLDOMNode_put_nodeValue(node, var);
2541 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2542 IHTMLDOMNode_Release(node);
2546 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2547 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2549 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2553 hres = IHTMLElement2_get_clientWidth(elem, &l);
2554 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2555 hres = IHTMLElement2_get_clientHeight(elem, &l);
2556 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2558 IHTMLElement2_Release(elem);
2561 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2562 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2564 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2568 hres = IHTMLElement2_get_clientLeft(elem, &l);
2569 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2570 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2572 hres = IHTMLElement2_get_clientTop(elem, &l);
2573 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2574 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2576 IHTMLElement2_Release(elem);
2579 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2580 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2582 IHTMLFormElement *form = _get_form_iface(line, unk);
2583 LONG len = 0xdeadbeef;
2586 hres = IHTMLFormElement_get_length(form, &len);
2587 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2588 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2590 IHTMLFormElement_Release(form);
2593 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2594 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2596 IHTMLFormElement *form = _get_form_iface(line, unk);
2597 BSTR action = (void*)0xdeadbeef;
2600 hres = IHTMLFormElement_get_action(form, &action);
2601 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2603 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2605 ok_(__FILE__,line)(!action, "action=%p\n", action);
2607 SysFreeString(action);
2608 IHTMLFormElement_Release(form);
2611 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2612 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2614 IHTMLFormElement *form = _get_form_iface(line, unk);
2615 BSTR tmp = a2bstr(action);
2618 hres = IHTMLFormElement_put_action(form, tmp);
2619 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2621 IHTMLFormElement_Release(form);
2623 _test_form_action(line, unk, action);
2626 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2627 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2629 IHTMLFormElement *form = _get_form_iface(line, unk);
2630 BSTR method = (void*)0xdeadbeef;
2633 hres = IHTMLFormElement_get_method(form, &method);
2634 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2636 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2638 ok_(__FILE__,line)(!method, "method=%p\n", method);
2640 SysFreeString(method);
2641 IHTMLFormElement_Release(form);
2644 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2645 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2647 IHTMLFormElement *form = _get_form_iface(line, unk);
2648 BSTR tmp = a2bstr(method);
2651 hres = IHTMLFormElement_put_method(form, tmp);
2652 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2654 IHTMLFormElement_Release(form);
2656 if(exp_hres == S_OK)
2657 _test_form_method(line, unk, method);
2660 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2661 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2663 IHTMLFormElement *form = _get_form_iface(line, unk);
2664 BSTR name = (void*)0xdeadbeef;
2667 hres = IHTMLFormElement_get_name(form, &name);
2668 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2670 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2672 ok_(__FILE__,line)(!name, "name=%p\n", name);
2674 SysFreeString(name);
2675 IHTMLFormElement_Release(form);
2678 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2679 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2681 IHTMLFormElement *form = _get_form_iface(line, unk);
2682 BSTR tmp = a2bstr(name);
2685 hres = IHTMLFormElement_put_name(form, tmp);
2686 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2688 IHTMLFormElement_Release(form);
2690 _test_form_name(line, unk, name);
2693 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2694 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2696 IHTMLFormElement *form = _get_form_iface(line, unk);
2697 BSTR encoding = (void*)0xdeadbeef;
2700 hres = IHTMLFormElement_get_encoding(form, &encoding);
2701 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2703 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2705 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2707 SysFreeString(encoding);
2708 IHTMLFormElement_Release(form);
2711 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2712 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2714 IHTMLFormElement *form = _get_form_iface(line, unk);
2715 BSTR tmp = a2bstr(encoding);
2718 hres = IHTMLFormElement_put_encoding(form, tmp);
2719 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2721 IHTMLFormElement_Release(form);
2723 if(exp_hres == S_OK)
2724 _test_form_encoding(line, unk, encoding);
2727 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2728 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2730 IHTMLElement *elem = _get_elem_iface(line, unk);
2731 IHTMLDocument2 *doc;
2736 hres = IHTMLElement_get_document(elem, &disp);
2737 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2738 ok(disp != NULL, "disp == NULL\n");
2740 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2741 IDispatch_Release(disp);
2742 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2747 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2748 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2750 IHTMLDocument2 *doc;
2754 hres = IHTMLWindow2_get_document(window, &doc);
2755 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2756 ok(doc != NULL, "disp == NULL\n");
2761 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2762 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2764 IHTMLElement *elem = NULL;
2769 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2770 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2771 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2776 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2777 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2779 IHTMLDocument3 *doc3;
2780 IHTMLDOMNode *node = NULL;
2784 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2785 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2788 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2789 IHTMLDocument3_Release(doc3);
2790 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2791 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2796 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2797 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2799 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2800 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2801 IHTMLDOMNode *new_child = NULL;
2804 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2805 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2806 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2807 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2809 IHTMLDOMNode_Release(node);
2810 IHTMLDOMNode_Release(child);
2815 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2816 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2818 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2819 IHTMLDOMNode *new_child = NULL;
2822 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2823 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2824 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2825 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2827 IHTMLDOMNode_Release(node);
2832 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2833 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2835 IHTMLDOMNode *node = _get_node_iface(line, unk);
2836 IHTMLDOMNode *new_node = NULL;
2839 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2840 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2841 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2842 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2844 IHTMLDOMNode_Release(node);
2845 IHTMLDOMNode_Release(new_node);
2848 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2849 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2854 hres = IHTMLDocument2_get_title(doc, &title);
2855 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2856 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2857 SysFreeString(title);
2860 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2861 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2866 tmp = a2bstr(title);
2867 hres = IHTMLDocument2_put_title(doc, tmp);
2868 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2872 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2873 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2878 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2879 LOCALE_USER_DEFAULT, &dispid);
2880 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2883 DISPPARAMS params = {NULL,NULL,0,0};
2884 DISPID dispidNamed = DISPID_PROPERTYPUT;
2889 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2890 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2891 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2894 params.cNamedArgs = 1;
2895 params.rgdispidNamedArgs = &dispidNamed;
2896 V_VT(&arg) = VT_BSTR;
2897 V_BSTR(&arg) = a2bstr("none");
2898 params.rgvarg = &arg;
2899 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2900 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2901 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2904 V_VT(&arg) = VT_BSTR;
2905 V_BSTR(&arg) = a2bstr("dotted");
2906 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2907 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2908 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2911 V_VT(&arg) = VT_BSTR;
2912 V_BSTR(&arg) = a2bstr("dashed");
2913 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2914 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2915 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2918 V_VT(&arg) = VT_BSTR;
2919 V_BSTR(&arg) = a2bstr("solid");
2920 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2921 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2922 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2925 V_VT(&arg) = VT_BSTR;
2926 V_BSTR(&arg) = a2bstr("double");
2927 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2928 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2929 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2932 V_VT(&arg) = VT_BSTR;
2933 V_BSTR(&arg) = a2bstr("groove");
2934 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2935 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2936 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2939 V_VT(&arg) = VT_BSTR;
2940 V_BSTR(&arg) = a2bstr("ridge");
2941 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2942 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2943 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2946 V_VT(&arg) = VT_BSTR;
2947 V_BSTR(&arg) = a2bstr("inset");
2948 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2949 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2950 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2953 V_VT(&arg) = VT_BSTR;
2954 V_BSTR(&arg) = a2bstr("outset");
2955 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2956 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2957 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2960 V_VT(&arg) = VT_BSTR;
2961 V_BSTR(&arg) = a2bstr("invalid");
2962 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2963 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2964 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2967 params.rgvarg = &vDefault;
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, "default. ret: %08x\n", hres);
2974 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2975 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2977 BSTR text = (void*)0xdeadbeef;
2980 hres = IHTMLStyle_get_cssText(style, &text);
2981 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2983 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2985 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2987 SysFreeString(text);
2990 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2991 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2997 hres = IHTMLStyle_put_cssText(style, tmp);
2998 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3002 static void test_elem_bounding_client_rect(IUnknown *unk)
3004 IHTMLRect *rect, *rect2;
3005 IHTMLElement2 *elem2;
3009 elem2 = get_elem2_iface(unk);
3010 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3011 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3012 IHTMLElement2_Release(elem2);
3013 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3014 ok(rect != NULL, "rect == NULL\n");
3015 ok(rect != rect2, "rect == rect2\n");
3016 IHTMLRect_Release(rect2);
3018 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3021 hres = IHTMLRect_get_top(rect, &l);
3022 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3023 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3026 hres = IHTMLRect_get_left(rect, &l);
3027 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3028 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3031 hres = IHTMLRect_get_bottom(rect, &l);
3032 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3033 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3036 hres = IHTMLRect_get_right(rect, &l);
3037 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3038 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3040 IHTMLRect_Release(rect);
3043 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3044 const elem_type_t *elem_types, LONG len)
3047 VARIANT name, index;
3051 V_VT(&index) = VT_EMPTY;
3052 V_VT(&name) = VT_BSTR;
3053 V_BSTR(&name) = a2bstr(n);
3055 hres = IHTMLElementCollection_item(col, name, index, &disp);
3056 ok(hres == S_OK, "item failed: %08x\n", hres);
3058 test_elem_collection((IUnknown*)disp, elem_types, len);
3059 IDispatch_Release(disp);
3060 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3064 V_VT(&index) = VT_I4;
3066 for(i=0; i<len; i++) {
3068 disp = (void*)0xdeadbeef;
3069 hres = IHTMLElementCollection_item(col, name, index, &disp);
3070 ok(hres == S_OK, "item failed: %08x\n", hres);
3071 ok(disp != NULL, "disp == NULL\n");
3072 if(FAILED(hres) || !disp)
3075 test_elem_type((IUnknown*)disp, elem_types[i]);
3077 IDispatch_Release(disp);
3081 disp = (void*)0xdeadbeef;
3082 hres = IHTMLElementCollection_item(col, name, index, &disp);
3083 ok(hres == S_OK, "item failed: %08x\n", hres);
3084 ok(disp == NULL, "disp != NULL\n");
3087 disp = (void*)0xdeadbeef;
3088 hres = IHTMLElementCollection_item(col, name, index, &disp);
3089 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3090 ok(disp == NULL, "disp != NULL\n");
3093 SysFreeString(V_BSTR(&name));
3096 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3098 IHTMLElementCollection *col;
3100 IDispatch *disp = (void*)0xdeadbeef;
3101 VARIANT name, index;
3104 hres = IHTMLDocument2_get_all(doc, &col);
3105 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3106 ok(col != NULL, "col == NULL\n");
3107 if(FAILED(hres) || !col)
3110 V_VT(&index) = VT_EMPTY;
3111 V_VT(&name) = VT_BSTR;
3112 V_BSTR(&name) = a2bstr(id);
3114 hres = IHTMLElementCollection_item(col, name, index, &disp);
3115 IHTMLElementCollection_Release(col);
3116 SysFreeString(V_BSTR(&name));
3117 ok(hres == S_OK, "item failed: %08x\n", hres);
3118 if(!expect_success) {
3119 ok(disp == NULL, "disp != NULL\n");
3123 ok(disp != NULL, "disp == NULL\n");
3127 elem = get_elem_iface((IUnknown*)disp);
3128 IDispatch_Release(disp);
3133 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3135 IHTMLDocument3 *doc3;
3140 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3141 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3144 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3146 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3148 IHTMLDocument3_Release(doc3);
3153 static void test_select_elem(IHTMLSelectElement *select)
3155 IDispatch *disp, *disp2;
3156 VARIANT name, index;
3159 test_select_type(select, "select-one");
3160 test_select_length(select, 2);
3161 test_select_selidx(select, 0);
3162 test_select_put_selidx(select, 1);
3164 test_select_set_value(select, "val1");
3165 test_select_value(select, "val1");
3167 test_select_get_disabled(select, VARIANT_FALSE);
3168 test_select_set_disabled(select, VARIANT_TRUE);
3169 test_select_set_disabled(select, VARIANT_FALSE);
3172 hres = IHTMLSelectElement_get_options(select, &disp);
3173 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3174 ok(disp != NULL, "options == NULL\n");
3175 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3176 IDispatch_Release(disp);
3178 V_VT(&index) = VT_EMPTY;
3179 V_VT(&name) = VT_I4;
3181 disp = (void*)0xdeadbeef;
3182 hres = IHTMLSelectElement_item(select, name, index, &disp);
3183 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3184 ok(!disp, "disp = %p\n", disp);
3187 disp = (void*)0xdeadbeef;
3188 hres = IHTMLSelectElement_item(select, name, index, &disp);
3189 ok(hres == S_OK, "item failed: %08x\n", hres);
3190 ok(!disp, "disp = %p\n", disp);
3193 hres = IHTMLSelectElement_item(select, name, index, NULL);
3194 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3197 hres = IHTMLSelectElement_item(select, name, index, &disp);
3198 ok(hres == S_OK, "item failed: %08x\n", hres);
3199 ok(disp != NULL, "disp = NULL\n");
3200 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3202 V_VT(&index) = VT_I4;
3205 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3206 ok(hres == S_OK, "item failed: %08x\n", hres);
3207 ok(disp2 != NULL, "disp = NULL\n");
3208 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3209 IDispatch_Release(disp2);
3210 IDispatch_Release(disp);
3213 static void test_form_item(IHTMLElement *elem)
3215 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3216 IDispatch *disp, *disp2;
3217 VARIANT name, index;
3220 V_VT(&index) = VT_EMPTY;
3221 V_VT(&name) = VT_I4;
3223 disp = (void*)0xdeadbeef;
3224 hres = IHTMLFormElement_item(form, name, index, &disp);
3225 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3226 ok(!disp, "disp = %p\n", disp);
3229 disp = (void*)0xdeadbeef;
3230 hres = IHTMLFormElement_item(form, name, index, &disp);
3231 ok(hres == S_OK, "item failed: %08x\n", hres);
3232 ok(!disp, "disp = %p\n", disp);
3235 hres = IHTMLFormElement_item(form, name, index, NULL);
3236 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3239 hres = IHTMLFormElement_item(form, name, index, &disp);
3240 ok(hres == S_OK, "item failed: %08x\n", hres);
3241 ok(disp != NULL, "disp = NULL\n");
3242 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3244 V_VT(&index) = VT_I4;
3247 hres = IHTMLFormElement_item(form, name, index, &disp2);
3248 ok(hres == S_OK, "item failed: %08x\n", hres);
3249 ok(disp2 != NULL, "disp = NULL\n");
3250 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3251 IDispatch_Release(disp2);
3252 IDispatch_Release(disp);
3255 static void test_create_option_elem(IHTMLDocument2 *doc)
3257 IHTMLOptionElement *option;
3259 option = create_option_elem(doc, "test text", "test value");
3261 test_option_put_text(option, "new text");
3262 test_option_put_value(option, "new value");
3263 test_option_put_selected(option, VARIANT_TRUE);
3264 test_option_put_selected(option, VARIANT_FALSE);
3266 IHTMLOptionElement_Release(option);
3269 static void test_create_img_elem(IHTMLDocument2 *doc)
3271 IHTMLImgElement *img;
3273 img = create_img_elem(doc, 10, 15);
3276 test_img_put_width(img, 5);
3277 test_img_put_height(img, 20);
3279 IHTMLImgElement_Release(img);
3283 img = create_img_elem(doc, -1, -1);
3286 test_img_put_width(img, 5);
3287 test_img_put_height(img, 20);
3289 IHTMLImgElement_Release(img);
3293 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3295 IHTMLBodyElement *body;
3296 IHTMLTxtRange *range;
3300 hres = IHTMLDocument2_get_body(doc, &elem);
3301 ok(hres == S_OK, "get_body failed: %08x\n", hres);
3303 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3304 IHTMLElement_Release(elem);
3306 hres = IHTMLBodyElement_createTextRange(body, &range);
3307 IHTMLBodyElement_Release(body);
3308 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3313 static void test_txtrange(IHTMLDocument2 *doc)
3315 IHTMLTxtRange *body_range, *range, *range2;
3316 IHTMLSelectionObject *selection;
3317 IDispatch *disp_range;
3320 body_range = test_create_body_range(doc);
3322 test_range_text(body_range, "test abc 123\r\nit's text");
3324 hres = IHTMLTxtRange_duplicate(body_range, &range);
3325 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3327 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3328 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3329 test_range_isequal(range, range2, VARIANT_TRUE);
3331 test_range_text(range, "test abc 123\r\nit's text");
3332 test_range_text(body_range, "test abc 123\r\nit's text");
3334 test_range_collapse(range, TRUE);
3335 test_range_isequal(range, range2, VARIANT_FALSE);
3336 test_range_inrange(range, range2, VARIANT_FALSE);
3337 test_range_inrange(range2, range, VARIANT_TRUE);
3338 IHTMLTxtRange_Release(range2);
3340 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3341 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3342 test_range_move(range, characterW, 2, 2);
3343 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3345 test_range_collapse(range, FALSE);
3346 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3348 test_range_collapse(range, FALSE);
3349 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3350 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3351 test_range_move(range, characterW, 2, 2);
3352 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3353 test_range_moveend(range, characterW, -5, -5);
3354 test_range_text(range, NULL);
3355 test_range_moveend(range, characterW, 3, 3);
3356 test_range_text(range, "c 1");
3357 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3358 test_range_collapse(range, TRUE);
3359 test_range_move(range, characterW, 4, 4);
3360 test_range_moveend(range, characterW, 1, 1);
3361 test_range_text(range, " ");
3362 test_range_move(range, wordW, 1, 1);
3363 test_range_moveend(range, characterW, 2, 2);
3364 test_range_text(range, "ab");
3366 IHTMLTxtRange_Release(range);
3368 hres = IHTMLTxtRange_duplicate(body_range, &range);
3369 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3371 test_range_text(range, "test abc 123\r\nit's text");
3372 test_range_move(range, characterW, 3, 3);
3373 test_range_moveend(range, characterW, 1, 1);
3374 test_range_text(range, "t");
3375 test_range_moveend(range, characterW, 3, 3);
3376 test_range_text(range, "t ab");
3377 test_range_moveend(range, characterW, -2, -2);
3378 test_range_text(range, "t ");
3379 test_range_move(range, characterW, 6, 6);
3380 test_range_moveend(range, characterW, 3, 3);
3381 test_range_text(range, "123");
3382 test_range_moveend(range, characterW, 2, 2);
3383 test_range_text(range, "123\r\ni");
3385 IHTMLTxtRange_Release(range);
3387 hres = IHTMLTxtRange_duplicate(body_range, &range);
3388 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3390 test_range_move(range, wordW, 1, 1);
3391 test_range_moveend(range, characterW, 2, 2);
3392 test_range_text(range, "ab");
3394 test_range_move(range, characterW, -2, -2);
3395 test_range_moveend(range, characterW, 2, 2);
3396 test_range_text(range, "t ");
3398 test_range_move(range, wordW, 3, 3);
3399 test_range_move(range, wordW, -2, -2);
3400 test_range_moveend(range, characterW, 2, 2);
3401 test_range_text(range, "ab");
3403 test_range_move(range, characterW, -6, -5);
3404 test_range_moveend(range, characterW, -1, 0);
3405 test_range_moveend(range, characterW, -6, 0);
3406 test_range_move(range, characterW, 2, 2);
3407 test_range_moveend(range, characterW, 2, 2);
3408 test_range_text(range, "st");
3409 test_range_moveend(range, characterW, -6, -4);
3410 test_range_moveend(range, characterW, 2, 2);
3412 IHTMLTxtRange_Release(range);
3414 hres = IHTMLTxtRange_duplicate(body_range, &range);
3415 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3417 test_range_move(range, wordW, 2, 2);
3418 test_range_moveend(range, characterW, 2, 2);
3419 test_range_text(range, "12");
3421 test_range_move(range, characterW, 15, 14);
3422 test_range_move(range, characterW, -2, -2);
3423 test_range_moveend(range, characterW, 3, 2);
3424 test_range_text(range, "t");
3425 test_range_moveend(range, characterW, -1, -1);
3426 test_range_text(range, "t");
3427 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3428 test_range_move(range, characterW, -2, -2);
3429 test_range_moveend(range, characterW, 2, 2);
3430 test_range_text(range, "s ");
3431 test_range_move(range, characterW, 100, 7);
3432 test_range_move(range, wordW, 1, 0);
3433 test_range_move(range, characterW, -2, -2);
3434 test_range_moveend(range, characterW, 3, 2);
3435 test_range_text(range, "t");
3437 IHTMLTxtRange_Release(range);
3439 hres = IHTMLTxtRange_duplicate(body_range, &range);
3440 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3442 test_range_collapse(range, TRUE);
3443 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3444 test_range_put_text(range, "word");
3445 test_range_text(body_range, "wordabc 123\r\nit's text");
3446 test_range_text(range, NULL);
3447 test_range_moveend(range, characterW, 3, 3);
3448 test_range_text(range, "abc");
3449 test_range_movestart(range, characterW, -2, -2);
3450 test_range_text(range, "rdabc");
3451 test_range_movestart(range, characterW, 3, 3);
3452 test_range_text(range, "bc");
3453 test_range_movestart(range, characterW, 4, 4);
3454 test_range_text(range, NULL);
3455 test_range_movestart(range, characterW, -3, -3);
3456 test_range_text(range, "c 1");
3457 test_range_movestart(range, characterW, -7, -6);
3458 test_range_text(range, "wordabc 1");
3459 test_range_movestart(range, characterW, 100, 22);
3460 test_range_text(range, NULL);
3462 IHTMLTxtRange_Release(range);
3463 IHTMLTxtRange_Release(body_range);
3465 hres = IHTMLDocument2_get_selection(doc, &selection);
3466 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3468 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3469 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3470 IHTMLSelectionObject_Release(selection);
3472 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3473 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3474 IDispatch_Release(disp_range);
3476 test_range_text(range, NULL);
3477 test_range_moveend(range, characterW, 3, 3);
3478 test_range_text(range, "wor");
3479 test_range_parent(range, ET_BODY);
3480 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3481 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3482 test_range_move(range, characterW, 3, 3);
3483 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3484 test_range_moveend(range, characterW, -4, -4);
3485 test_range_put_text(range, "abc def ");
3486 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3487 test_range_move(range, wordW, 1, 1);
3488 test_range_movestart(range, characterW, -1, -1);
3489 test_range_text(range, " ");
3490 test_range_move(range, wordW, 1, 1);
3491 test_range_moveend(range, characterW, 3, 3);
3492 test_range_text(range, "def");
3493 test_range_put_text(range, "xyz");
3494 test_range_moveend(range, characterW, 1, 1);
3495 test_range_move(range, wordW, 1, 1);
3496 test_range_moveend(range, characterW, 2, 2);
3497 test_range_text(range, "ab");
3499 IHTMLTxtRange_Release(range);
3502 static void test_txtrange2(IHTMLDocument2 *doc)
3504 IHTMLTxtRange *range;
3506 range = test_create_body_range(doc);
3508 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3509 test_range_move(range, characterW, 5, 5);
3510 test_range_moveend(range, characterW, 1, 1);
3511 test_range_text(range, "2");
3512 test_range_move(range, characterW, -3, -3);
3513 test_range_moveend(range, characterW, 3, 3);
3514 test_range_text(range, "c\r\n\r\n1");
3515 test_range_collapse(range, VARIANT_FALSE);
3516 test_range_moveend(range, characterW, 4, 4);
3517 test_range_text(range, "23");
3518 test_range_moveend(range, characterW, 1, 1);
3519 test_range_text(range, "23\r\n\r\n\r\nd");
3520 test_range_moveend(range, characterW, -1, -1);
3521 test_range_text(range, "23");
3522 test_range_moveend(range, characterW, -1, -1);
3523 test_range_text(range, "23");
3524 test_range_moveend(range, characterW, -2, -2);
3525 test_range_text(range, "2");
3527 IHTMLTxtRange_Release(range);
3530 static void test_compatmode(IHTMLDocument2 *doc)
3532 IHTMLDocument5 *doc5;
3536 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3537 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3541 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3542 IHTMLDocument5_Release(doc5);
3543 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3544 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3545 SysFreeString(mode);
3548 static void test_location(IHTMLDocument2 *doc)
3550 IHTMLLocation *location, *location2;
3551 IHTMLWindow2 *window;
3556 hres = IHTMLDocument2_get_location(doc, &location);
3557 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3559 hres = IHTMLDocument2_get_location(doc, &location2);
3560 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3562 ok(location == location2, "location != location2\n");
3563 IHTMLLocation_Release(location2);
3565 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3566 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3568 hres = IHTMLWindow2_get_location(window, &location2);
3569 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3570 ok(location == location2, "location != location2\n");
3571 IHTMLLocation_Release(location2);
3573 test_ifaces((IUnknown*)location, location_iids);
3574 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3576 hres = IHTMLLocation_get_pathname(location, &str);
3577 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3578 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3581 hres = IHTMLLocation_get_href(location, NULL);
3582 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3584 hres = IHTMLLocation_get_href(location, &str);
3585 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3586 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3589 ref = IHTMLLocation_Release(location);
3590 ok(!ref, "location chould be destroyed here\n");
3593 static void test_navigator(IHTMLDocument2 *doc)
3595 IHTMLWindow2 *window;
3596 IOmNavigator *navigator, *navigator2;
3603 static const WCHAR v40[] = {'4','.','0'};
3605 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3606 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3608 hres = IHTMLWindow2_get_navigator(window, &navigator);
3609 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3610 ok(navigator != NULL, "navigator == NULL\n");
3611 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3613 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3614 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3615 ok(navigator != navigator2, "navigator2 != navihgator\n");
3617 IHTMLWindow2_Release(window);
3618 IOmNavigator_Release(navigator2);
3620 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3621 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3622 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3623 SysFreeString(bstr);
3626 hres = IOmNavigator_get_appName(navigator, &bstr);
3627 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3628 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3629 SysFreeString(bstr);
3632 hres = IOmNavigator_get_platform(navigator, &bstr);
3633 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3635 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3637 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3639 SysFreeString(bstr);
3642 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3643 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3644 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3645 SysFreeString(bstr);
3647 hres = IOmNavigator_toString(navigator, NULL);
3648 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3651 hres = IOmNavigator_toString(navigator, &bstr);
3652 ok(hres == S_OK, "toString failed: %08x\n", hres);
3653 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3654 SysFreeString(bstr);
3657 hres = ObtainUserAgentString(0, buf, &size);
3658 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3661 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3662 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3663 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3664 SysFreeString(bstr);
3666 if(!strncmp(buf, "Mozilla/", 8)) {
3668 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3669 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3670 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3671 SysFreeString(bstr);
3673 skip("nonstandard user agent\n");
3676 ref = IOmNavigator_Release(navigator);
3677 ok(!ref, "navigator should be destroyed here\n");
3680 static void test_screen(IHTMLWindow2 *window)
3682 IHTMLScreen *screen, *screen2;
3683 IDispatchEx *dispex;
3689 hres = IHTMLWindow2_get_screen(window, &screen);
3690 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3691 ok(screen != NULL, "screen == NULL\n");
3694 hres = IHTMLWindow2_get_screen(window, &screen2);
3695 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3696 ok(screen2 != NULL, "screen == NULL\n");
3697 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3698 IHTMLScreen_Release(screen2);
3700 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3701 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3702 if(SUCCEEDED(hres)) {
3703 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3704 IDispatchEx_Release(dispex);
3707 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3709 exl = GetDeviceCaps(hdc, HORZRES);
3711 hres = IHTMLScreen_get_width(screen, &l);
3712 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3713 ok(l == exl, "width = %d, expected %d\n", l, exl);
3715 exl = GetDeviceCaps(hdc, VERTRES);
3717 hres = IHTMLScreen_get_height(screen, &l);
3718 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3719 ok(l == exl, "height = %d, expected %d\n", l, exl);
3721 exl = GetDeviceCaps(hdc, BITSPIXEL);
3723 hres = IHTMLScreen_get_colorDepth(screen, &l);
3724 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3725 ok(l == exl, "height = %d, expected %d\n", l, exl);
3729 IHTMLScreen_Release(screen);
3732 static void test_current_style(IHTMLCurrentStyle *current_style)
3738 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3739 test_ifaces((IUnknown*)current_style, cstyle_iids);
3741 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3742 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3743 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3746 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3747 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3748 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3751 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3752 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3755 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3756 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3757 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3760 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3761 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3762 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3765 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3766 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3767 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3770 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3771 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3772 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3775 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3776 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3777 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3780 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3781 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3782 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3785 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3786 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3787 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3790 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3791 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3792 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3795 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3796 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3797 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3800 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3801 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3802 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3805 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3806 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3807 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3810 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3811 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3814 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3815 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3818 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3819 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3822 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3823 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3826 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3827 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3830 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3831 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3834 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3835 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3836 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3837 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3840 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3841 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3842 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3845 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3846 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3847 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3850 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3851 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3852 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3855 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3856 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3857 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3860 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3861 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3862 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3865 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3866 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3867 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3870 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3871 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3872 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3873 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3876 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3877 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3878 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3879 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3882 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3883 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3884 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3887 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3888 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3889 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3892 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3893 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3894 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3898 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3899 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3900 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3903 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3904 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3905 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3908 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3909 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3910 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3913 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3914 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3915 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3918 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3919 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3920 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3923 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3924 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3925 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3928 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3929 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3930 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3933 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3934 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3935 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3938 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3939 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3940 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3943 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3944 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3945 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3948 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3949 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3950 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3953 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3954 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3955 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3958 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3959 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3960 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3963 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3964 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3965 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3968 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3969 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3970 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3973 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3974 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3975 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3978 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3979 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3980 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3983 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3984 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3985 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3988 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3989 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3990 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3994 static void test_style2(IHTMLStyle2 *style2)
4000 str = (void*)0xdeadbeef;
4001 hres = IHTMLStyle2_get_position(style2, &str);
4002 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4003 ok(!str, "str != NULL\n");
4005 str = a2bstr("absolute");
4006 hres = IHTMLStyle2_put_position(style2, str);
4007 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4011 hres = IHTMLStyle2_get_position(style2, &str);
4012 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4013 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4017 V_VT(&v) = VT_EMPTY;
4018 hres = IHTMLStyle2_get_right(style2, &v);
4019 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4020 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4021 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4025 V_BSTR(&v) = a2bstr("3px");
4026 hres = IHTMLStyle2_put_right(style2, v);
4027 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4030 V_VT(&v) = VT_EMPTY;
4031 hres = IHTMLStyle2_get_right(style2, &v);
4032 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4033 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4034 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4038 static void test_style3(IHTMLStyle3 *style3)
4043 str = (void*)0xdeadbeef;
4044 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4045 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4046 ok(!str, "str != NULL\n");
4048 str = a2bstr("break-word");
4049 hres = IHTMLStyle3_put_wordWrap(style3, str);
4050 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4054 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4055 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4056 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4060 static void test_style4(IHTMLStyle4 *style4)
4066 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4067 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4070 V_BSTR(&v) = a2bstr("10px");
4071 hres = IHTMLStyle4_put_minHeight(style4, v);
4072 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4075 hres = IHTMLStyle4_get_minHeight(style4, &v);
4076 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4077 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4078 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4081 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4082 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4083 VariantClear(&vdefault);
4086 static void test_default_style(IHTMLStyle *style)
4088 IHTMLStyle2 *style2;
4089 IHTMLStyle3 *style3;
4090 IHTMLStyle4 *style4;
4096 BSTR sOverflowDefault;
4100 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4101 test_ifaces((IUnknown*)style, style_iids);
4103 test_style_csstext(style, NULL);
4105 hres = IHTMLStyle_get_position(style, &str);
4106 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4107 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4110 hres = IHTMLStyle_get_marginRight(style, &v);
4111 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4112 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4113 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4116 hres = IHTMLStyle_get_marginLeft(style, &v);
4117 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4118 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4119 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4121 str = (void*)0xdeadbeef;
4122 hres = IHTMLStyle_get_fontFamily(style, &str);
4123 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4124 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4126 str = (void*)0xdeadbeef;
4127 hres = IHTMLStyle_get_fontWeight(style, &str);
4128 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4129 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4131 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4132 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4134 str = a2bstr("test");
4135 hres = IHTMLStyle_put_fontWeight(style, str);
4136 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4139 str = a2bstr("bold");
4140 hres = IHTMLStyle_put_fontWeight(style, str);
4141 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4144 str = a2bstr("bolder");
4145 hres = IHTMLStyle_put_fontWeight(style, str);
4146 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4149 str = a2bstr("lighter");
4150 hres = IHTMLStyle_put_fontWeight(style, str);
4151 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4154 str = a2bstr("100");
4155 hres = IHTMLStyle_put_fontWeight(style, str);
4156 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4159 str = a2bstr("200");
4160 hres = IHTMLStyle_put_fontWeight(style, str);
4161 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4164 str = a2bstr("300");
4165 hres = IHTMLStyle_put_fontWeight(style, str);
4166 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4169 str = a2bstr("400");
4170 hres = IHTMLStyle_put_fontWeight(style, str);
4171 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4174 str = a2bstr("500");
4175 hres = IHTMLStyle_put_fontWeight(style, str);
4176 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4179 str = a2bstr("600");
4180 hres = IHTMLStyle_put_fontWeight(style, str);
4181 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4184 str = a2bstr("700");
4185 hres = IHTMLStyle_put_fontWeight(style, str);
4186 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4189 str = a2bstr("800");
4190 hres = IHTMLStyle_put_fontWeight(style, str);
4191 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4194 str = a2bstr("900");
4195 hres = IHTMLStyle_put_fontWeight(style, str);
4196 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4199 hres = IHTMLStyle_get_fontWeight(style, &str);
4200 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4201 ok(!strcmp_wa(str, "900"), "str != style900\n");
4204 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4205 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4206 SysFreeString(sDefault);
4209 hres = IHTMLStyle_get_fontVariant(style, NULL);
4210 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4212 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4213 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4215 str = a2bstr("test");
4216 hres = IHTMLStyle_put_fontVariant(style, str);
4217 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4220 str = a2bstr("small-caps");
4221 hres = IHTMLStyle_put_fontVariant(style, str);
4222 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4225 str = a2bstr("normal");
4226 hres = IHTMLStyle_put_fontVariant(style, str);
4227 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4230 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4231 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4232 SysFreeString(sDefault);
4234 str = (void*)0xdeadbeef;
4235 hres = IHTMLStyle_get_display(style, &str);
4236 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4237 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4239 str = (void*)0xdeadbeef;
4240 hres = IHTMLStyle_get_visibility(style, &str);
4241 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4242 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4245 hres = IHTMLStyle_get_fontSize(style, &v);
4246 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4247 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4248 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4251 hres = IHTMLStyle_get_color(style, &v);
4252 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4253 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4254 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4257 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4258 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4259 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4261 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4262 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4263 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4265 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4266 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4267 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4269 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4270 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4273 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4274 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4275 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4277 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4278 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4279 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4281 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4282 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4283 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4285 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4286 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4289 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4290 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4291 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4293 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4294 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4295 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4297 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4298 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4299 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4301 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4302 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4305 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4306 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4307 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4309 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4310 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4311 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4313 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4314 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4315 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4317 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4318 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4321 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4322 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4323 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4325 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4326 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4327 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4329 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4330 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4331 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4333 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4334 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4336 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4337 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4339 str = a2bstr("invalid");
4340 hres = IHTMLStyle_put_textDecoration(style, str);
4341 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4344 str = a2bstr("none");
4345 hres = IHTMLStyle_put_textDecoration(style, str);
4346 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4349 str = a2bstr("underline");
4350 hres = IHTMLStyle_put_textDecoration(style, str);
4351 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4354 str = a2bstr("overline");
4355 hres = IHTMLStyle_put_textDecoration(style, str);
4356 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4359 str = a2bstr("line-through");
4360 hres = IHTMLStyle_put_textDecoration(style, str);
4361 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4364 str = a2bstr("blink");
4365 hres = IHTMLStyle_put_textDecoration(style, str);
4366 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4369 hres = IHTMLStyle_get_textDecoration(style, &str);
4370 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4371 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4374 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4375 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4376 SysFreeString(sDefault);
4378 hres = IHTMLStyle_get_posWidth(style, NULL);
4379 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4381 hres = IHTMLStyle_get_posWidth(style, &f);
4382 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4383 ok(f == 0.0f, "f = %f\n", f);
4385 V_VT(&v) = VT_EMPTY;
4386 hres = IHTMLStyle_get_width(style, &v);
4387 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4388 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4389 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4391 hres = IHTMLStyle_put_posWidth(style, 2.2);
4392 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4394 hres = IHTMLStyle_get_posWidth(style, &f);
4395 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4397 f == 2.2f, /* IE8 */
4401 V_BSTR(&v) = a2bstr("auto");
4402 hres = IHTMLStyle_put_width(style, v);
4403 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4406 V_VT(&v) = VT_EMPTY;
4407 hres = IHTMLStyle_get_width(style, &v);
4408 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4409 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4410 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4415 hres = IHTMLStyle_put_width(style, v);
4416 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4418 V_VT(&v) = VT_EMPTY;
4419 hres = IHTMLStyle_get_width(style, &v);
4420 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4421 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4422 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4426 str = (void*)0xdeadbeef;
4427 hres = IHTMLStyle_get_margin(style, &str);
4428 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4429 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4432 hres = IHTMLStyle_put_margin(style, str);
4433 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4436 hres = IHTMLStyle_get_margin(style, &str);
4437 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4438 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4441 hres = IHTMLStyle_put_margin(style, NULL);
4442 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4444 str = (void*)0xdeadbeef;
4445 hres = IHTMLStyle_get_marginTop(style, &v);
4446 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4447 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4448 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4451 V_BSTR(&v) = a2bstr("6px");
4452 hres = IHTMLStyle_put_marginTop(style, v);
4453 SysFreeString(V_BSTR(&v));
4454 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4456 str = (void*)0xdeadbeef;
4457 hres = IHTMLStyle_get_marginTop(style, &v);
4458 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4459 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4460 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4464 hres = IHTMLStyle_get_border(style, &str);
4465 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4466 ok(!str || !*str, "str is not empty\n");
4469 str = a2bstr("1px");
4470 hres = IHTMLStyle_put_border(style, str);
4471 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4474 V_VT(&v) = VT_EMPTY;
4475 hres = IHTMLStyle_get_left(style, &v);
4476 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4477 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4478 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4482 hres = IHTMLStyle_get_posLeft(style, NULL);
4483 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4486 hres = IHTMLStyle_get_posLeft(style, &f);
4487 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4488 ok(f == 0.0, "expected 0.0 got %f\n", f);
4490 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4491 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4493 hres = IHTMLStyle_get_posLeft(style, &f);
4494 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4496 f == 4.9f, /* IE8 */
4497 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4499 /* Ensure left is updated correctly. */
4500 V_VT(&v) = VT_EMPTY;
4501 hres = IHTMLStyle_get_left(style, &v);
4502 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4503 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4504 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4505 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4506 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4511 V_BSTR(&v) = a2bstr("3px");
4512 hres = IHTMLStyle_put_left(style, v);
4513 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4516 hres = IHTMLStyle_get_posLeft(style, &f);
4517 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4518 ok(f == 3.0, "expected 3.0 got %f\n", f);
4520 V_VT(&v) = VT_EMPTY;
4521 hres = IHTMLStyle_get_left(style, &v);
4522 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4523 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4524 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4528 hres = IHTMLStyle_put_left(style, v);
4529 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4531 V_VT(&v) = VT_EMPTY;
4532 hres = IHTMLStyle_get_left(style, &v);
4533 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4534 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4535 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4538 V_VT(&v) = VT_EMPTY;
4539 hres = IHTMLStyle_get_top(style, &v);
4540 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4541 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4542 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4546 hres = IHTMLStyle_get_posTop(style, NULL);
4547 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4550 hres = IHTMLStyle_get_posTop(style, &f);
4551 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4552 ok(f == 0.0, "expected 0.0 got %f\n", f);
4554 hres = IHTMLStyle_put_posTop(style, 4.9f);
4555 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4557 hres = IHTMLStyle_get_posTop(style, &f);
4558 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4560 f == 4.9f, /* IE8 */
4561 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4564 V_BSTR(&v) = a2bstr("3px");
4565 hres = IHTMLStyle_put_top(style, v);
4566 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4569 V_VT(&v) = VT_EMPTY;
4570 hres = IHTMLStyle_get_top(style, &v);
4571 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4572 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4573 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4576 hres = IHTMLStyle_get_posTop(style, &f);
4577 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4578 ok(f == 3.0, "expected 3.0 got %f\n", f);
4581 hres = IHTMLStyle_put_top(style, v);
4582 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4584 V_VT(&v) = VT_EMPTY;
4585 hres = IHTMLStyle_get_top(style, &v);
4586 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4587 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4588 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4591 /* Test posHeight */
4592 hres = IHTMLStyle_get_posHeight(style, NULL);
4593 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4595 V_VT(&v) = VT_EMPTY;
4596 hres = IHTMLStyle_get_height(style, &v);
4597 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4598 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4599 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4603 hres = IHTMLStyle_get_posHeight(style, &f);
4604 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4605 ok(f == 0.0, "expected 0.0 got %f\n", f);
4607 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4608 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4610 hres = IHTMLStyle_get_posHeight(style, &f);
4611 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4613 f == 4.9f, /* IE8 */
4614 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4617 V_BSTR(&v) = a2bstr("64px");
4618 hres = IHTMLStyle_put_height(style, v);
4619 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4622 V_VT(&v) = VT_EMPTY;
4623 hres = IHTMLStyle_get_height(style, &v);
4624 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4625 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4626 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4629 hres = IHTMLStyle_get_posHeight(style, &f);
4630 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4631 ok(f == 64.0, "expected 64.0 got %f\n", f);
4633 str = (void*)0xdeadbeef;
4634 hres = IHTMLStyle_get_cursor(style, &str);
4635 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4636 ok(!str, "get_cursor != NULL\n");
4639 str = a2bstr("default");
4640 hres = IHTMLStyle_put_cursor(style, str);
4641 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4645 hres = IHTMLStyle_get_cursor(style, &str);
4646 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4647 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4650 V_VT(&v) = VT_EMPTY;
4651 hres = IHTMLStyle_get_verticalAlign(style, &v);
4652 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4653 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4654 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4658 V_BSTR(&v) = a2bstr("middle");
4659 hres = IHTMLStyle_put_verticalAlign(style, v);
4660 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4663 V_VT(&v) = VT_EMPTY;
4664 hres = IHTMLStyle_get_verticalAlign(style, &v);
4665 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4666 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4667 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4670 str = (void*)0xdeadbeef;
4671 hres = IHTMLStyle_get_textAlign(style, &str);
4672 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4673 ok(!str, "textAlign != NULL\n");
4675 str = a2bstr("center");
4676 hres = IHTMLStyle_put_textAlign(style, str);
4677 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4681 hres = IHTMLStyle_get_textAlign(style, &str);
4682 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4683 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4686 str = (void*)0xdeadbeef;
4687 hres = IHTMLStyle_get_filter(style, &str);
4688 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4689 ok(!str, "filter != NULL\n");
4691 str = a2bstr("alpha(opacity=100)");
4692 hres = IHTMLStyle_put_filter(style, str);
4693 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4696 V_VT(&v) = VT_EMPTY;
4697 hres = IHTMLStyle_get_zIndex(style, &v);
4698 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4699 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4700 ok(!V_I4(&v), "V_I4(v) != 0\n");
4704 V_BSTR(&v) = a2bstr("1");
4705 hres = IHTMLStyle_put_zIndex(style, v);
4706 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4709 V_VT(&v) = VT_EMPTY;
4710 hres = IHTMLStyle_get_zIndex(style, &v);
4711 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4712 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4713 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4717 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4718 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4720 str = a2bstr("test");
4721 hres = IHTMLStyle_put_fontStyle(style, str);
4722 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4725 str = a2bstr("italic");
4726 hres = IHTMLStyle_put_fontStyle(style, str);
4727 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4730 str = a2bstr("oblique");
4731 hres = IHTMLStyle_put_fontStyle(style, str);
4732 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4735 str = a2bstr("normal");
4736 hres = IHTMLStyle_put_fontStyle(style, str);
4737 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4740 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4741 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4742 SysFreeString(sDefault);
4745 hres = IHTMLStyle_get_overflow(style, NULL);
4746 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4748 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4749 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4751 str = a2bstr("test");
4752 hres = IHTMLStyle_put_overflow(style, str);
4753 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4756 str = a2bstr("visible");
4757 hres = IHTMLStyle_put_overflow(style, str);
4758 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4761 str = a2bstr("scroll");
4762 hres = IHTMLStyle_put_overflow(style, str);
4763 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4766 str = a2bstr("hidden");
4767 hres = IHTMLStyle_put_overflow(style, str);
4768 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4771 str = a2bstr("auto");
4772 hres = IHTMLStyle_put_overflow(style, str);
4773 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4776 hres = IHTMLStyle_get_overflow(style, &str);
4777 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4778 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4782 hres = IHTMLStyle_put_overflow(style, str);
4783 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4786 hres = IHTMLStyle_get_overflow(style, &str);
4787 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4788 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4791 /* restore overflow default */
4792 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4793 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4794 SysFreeString(sOverflowDefault);
4796 /* Attribute Tests*/
4797 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4798 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4800 str = a2bstr("position");
4801 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4802 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4804 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4805 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4806 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4809 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4810 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4813 V_BSTR(&v) = a2bstr("absolute");
4814 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4815 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4818 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4819 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4820 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4821 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4826 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4827 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4832 str = a2bstr("borderLeftStyle");
4833 test_border_styles(style, str);
4836 str = a2bstr("borderbottomstyle");
4837 test_border_styles(style, str);
4840 str = a2bstr("borderrightstyle");
4841 test_border_styles(style, str);
4844 str = a2bstr("bordertopstyle");
4845 test_border_styles(style, str);
4848 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4849 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4851 str = a2bstr("none dotted dashed solid");
4852 hres = IHTMLStyle_put_borderStyle(style, str);
4853 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4856 str = a2bstr("none dotted dashed solid");
4857 hres = IHTMLStyle_get_borderStyle(style, &str);
4858 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4859 ok(!strcmp_wa(str, "none dotted dashed solid"),
4860 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4863 str = a2bstr("double groove ridge inset");
4864 hres = IHTMLStyle_put_borderStyle(style, str);
4865 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4868 str = a2bstr("window-inset outset ridge inset");
4869 hres = IHTMLStyle_put_borderStyle(style, str);
4870 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4873 str = a2bstr("window-inset");
4874 hres = IHTMLStyle_put_borderStyle(style, str);
4875 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4878 str = a2bstr("none none none none none");
4879 hres = IHTMLStyle_put_borderStyle(style, str);
4880 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4883 str = a2bstr("invalid none none none");
4884 hres = IHTMLStyle_put_borderStyle(style, str);
4885 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4888 str = a2bstr("none invalid none none");
4889 hres = IHTMLStyle_put_borderStyle(style, str);
4890 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4893 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4894 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4895 SysFreeString(sDefault);
4897 /* backgoundColor */
4898 hres = IHTMLStyle_get_backgroundColor(style, &v);
4899 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4900 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4901 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4905 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4906 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4909 V_BSTR(&v) = a2bstr("10");
4910 hres = IHTMLStyle_put_paddingLeft(style, v);
4911 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4914 hres = IHTMLStyle_get_paddingLeft(style, &v);
4915 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4916 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4919 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4920 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4922 /* BackgroundRepeat */
4923 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4924 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4926 str = a2bstr("invalid");
4927 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4928 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4931 str = a2bstr("repeat");
4932 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4933 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4936 str = a2bstr("no-repeat");
4937 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4938 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4941 str = a2bstr("repeat-x");
4942 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4943 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4946 str = a2bstr("repeat-y");
4947 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4948 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4951 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4952 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4953 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4956 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4957 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4958 SysFreeString(sDefault);
4961 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4962 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4964 str = a2bstr("red green red blue");
4965 hres = IHTMLStyle_put_borderColor(style, str);
4966 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4969 hres = IHTMLStyle_get_borderColor(style, &str);
4970 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4971 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4974 hres = IHTMLStyle_put_borderColor(style, sDefault);
4975 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4976 SysFreeString(sDefault);
4979 hres = IHTMLStyle_get_borderRight(style, &sDefault);
4980 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
4982 str = a2bstr("thick dotted red");
4983 hres = IHTMLStyle_put_borderRight(style, str);
4984 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
4987 /* IHTMLStyle_get_borderRight appears to have a bug where
4988 it returns the first letter of the color. So we check
4989 each style individually.
4992 hres = IHTMLStyle_get_borderRightColor(style, &v);
4993 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4994 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4998 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4999 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5000 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5003 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5004 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5005 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5008 hres = IHTMLStyle_put_borderRight(style, sDefault);
5009 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5010 SysFreeString(sDefault);
5013 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5014 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5016 str = a2bstr("thick dotted red");
5017 hres = IHTMLStyle_put_borderTop(style, str);
5018 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5021 /* IHTMLStyle_get_borderTop appears to have a bug where
5022 it returns the first letter of the color. So we check
5023 each style individually.
5026 hres = IHTMLStyle_get_borderTopColor(style, &v);
5027 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5028 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5032 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5033 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5034 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5037 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5038 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5039 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5042 hres = IHTMLStyle_put_borderTop(style, sDefault);
5043 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5044 SysFreeString(sDefault);
5047 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5048 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5050 str = a2bstr("thick dotted red");
5051 hres = IHTMLStyle_put_borderBottom(style, str);
5052 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5055 /* IHTMLStyle_get_borderBottom appears to have a bug where
5056 it returns the first letter of the color. So we check
5057 each style individually.
5060 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5061 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5062 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5066 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5067 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5068 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5071 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5072 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5073 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5076 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5077 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5078 SysFreeString(sDefault);
5081 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5082 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5084 str = a2bstr("thick dotted red");
5085 hres = IHTMLStyle_put_borderLeft(style, str);
5086 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5089 /* IHTMLStyle_get_borderLeft appears to have a bug where
5090 it returns the first letter of the color. So we check
5091 each style individually.
5094 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5095 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5096 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5100 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5101 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5102 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5105 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5106 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5107 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5110 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5111 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5112 SysFreeString(sDefault);
5114 /* backgroundPositionX */
5115 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
5116 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5119 V_BSTR(&v) = a2bstr("10px");
5120 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5121 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5124 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5125 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5126 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5129 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
5130 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5131 VariantClear(&vDefault);
5133 /* backgroundPositionY */
5134 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
5135 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5138 V_BSTR(&v) = a2bstr("10px");
5139 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5140 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5143 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5144 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5145 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5148 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
5149 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5150 VariantClear(&vDefault);
5152 /* borderTopWidth */
5153 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5154 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5157 V_BSTR(&v) = a2bstr("10px");
5158 hres = IHTMLStyle_put_borderTopWidth(style, v);
5159 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5162 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5163 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5164 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5167 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5168 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5169 VariantClear(&vDefault);
5171 /* borderRightWidth */
5172 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5173 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5176 V_BSTR(&v) = a2bstr("10");
5177 hres = IHTMLStyle_put_borderRightWidth(style, v);
5178 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5181 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5182 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5183 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5186 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5187 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5188 VariantClear(&vDefault);
5190 /* borderBottomWidth */
5191 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5192 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5195 V_BSTR(&v) = a2bstr("10");
5196 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5197 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5200 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5201 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5202 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5205 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5206 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5207 VariantClear(&vDefault);
5209 /* borderLeftWidth */
5210 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5211 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5214 V_BSTR(&v) = a2bstr("10");
5215 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5216 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5219 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5220 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5221 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5224 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5225 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5226 VariantClear(&vDefault);
5229 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5230 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5233 V_BSTR(&v) = a2bstr("10");
5234 hres = IHTMLStyle_put_wordSpacing(style, v);
5235 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5238 hres = IHTMLStyle_get_wordSpacing(style, &v);
5239 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5240 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5241 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5244 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5245 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5246 VariantClear(&vDefault);
5249 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5250 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5253 V_BSTR(&v) = a2bstr("11");
5254 hres = IHTMLStyle_put_letterSpacing(style, v);
5255 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5258 hres = IHTMLStyle_get_letterSpacing(style, &v);
5259 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5260 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5261 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5264 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5265 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5266 VariantClear(&vDefault);
5268 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5269 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5270 if(SUCCEEDED(hres)) {
5271 test_style2(style2);
5272 IHTMLStyle2_Release(style2);
5275 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5276 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5277 if(SUCCEEDED(hres)) {
5278 test_style3(style3);
5279 IHTMLStyle3_Release(style3);
5282 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5283 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5284 if(SUCCEEDED(hres)) {
5285 test_style4(style4);
5286 IHTMLStyle4_Release(style4);
5290 static void test_set_csstext(IHTMLStyle *style)
5295 test_style_set_csstext(style, "background-color: black;");
5297 hres = IHTMLStyle_get_backgroundColor(style, &v);
5298 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5299 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5300 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5304 static void test_default_selection(IHTMLDocument2 *doc)
5306 IHTMLSelectionObject *selection;
5307 IHTMLTxtRange *range;
5312 hres = IHTMLDocument2_get_selection(doc, &selection);
5313 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5315 hres = IHTMLSelectionObject_get_type(selection, &str);
5316 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5317 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5320 hres = IHTMLSelectionObject_createRange(selection, &disp);
5321 IHTMLSelectionObject_Release(selection);
5322 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5324 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5325 IDispatch_Release(disp);
5326 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5328 test_range_text(range, NULL);
5329 IHTMLTxtRange_Release(range);
5332 static void test_doc_elem(IHTMLDocument2 *doc)
5334 IHTMLDocument2 *doc_node, *owner_doc;
5336 IHTMLDocument3 *doc3;
5339 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5340 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5342 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5343 IHTMLDocument3_Release(doc3);
5344 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5346 test_node_name((IUnknown*)elem, "HTML");
5347 test_elem_tag((IUnknown*)elem, "HTML");
5349 doc_node = get_doc_node(doc);
5350 owner_doc = get_owner_doc((IUnknown*)elem);
5351 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5352 IHTMLDocument2_Release(owner_doc);
5354 owner_doc = get_owner_doc((IUnknown*)doc_node);
5355 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5356 IHTMLDocument2_Release(doc_node);
5358 test_elem_client_rect((IUnknown*)elem);
5360 IHTMLElement_Release(elem);
5363 static void test_default_body(IHTMLBodyElement *body)
5370 bstr = (void*)0xdeadbeef;
5371 hres = IHTMLBodyElement_get_background(body, &bstr);
5372 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5373 ok(bstr == NULL, "bstr != NULL\n");
5375 l = elem_get_scroll_height((IUnknown*)body);
5376 ok(l != -1, "scrollHeight == -1\n");
5377 l = elem_get_scroll_width((IUnknown*)body);
5378 ok(l != -1, "scrollWidth == -1\n");
5379 l = elem_get_scroll_top((IUnknown*)body);
5380 ok(!l, "scrollTop = %d\n", l);
5381 elem_get_scroll_left((IUnknown*)body);
5383 /* get_text tests */
5384 hres = IHTMLBodyElement_get_text(body, &v);
5385 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5386 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5387 ok(bstr == NULL, "bstr != NULL\n");
5389 /* get_text - Invalid Text */
5391 V_BSTR(&v) = a2bstr("Invalid");
5392 hres = IHTMLBodyElement_put_text(body, v);
5393 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5397 hres = IHTMLBodyElement_get_text(body, &v);
5398 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5399 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5400 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5403 /* get_text - Valid Text */
5405 V_BSTR(&v) = a2bstr("#FF0000");
5406 hres = IHTMLBodyElement_put_text(body, v);
5407 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5411 hres = IHTMLBodyElement_get_text(body, &v);
5412 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5413 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5414 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5418 static void test_body_funs(IHTMLBodyElement *body)
5420 VARIANT vbg, vDefaultbg;
5423 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5424 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5425 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5426 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5428 V_VT(&vbg) = VT_BSTR;
5429 V_BSTR(&vbg) = a2bstr("red");
5430 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5431 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5434 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5435 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5436 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5437 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5440 /* Restore Originial */
5441 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5442 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5443 VariantClear(&vDefaultbg);
5446 static void test_window(IHTMLDocument2 *doc)
5448 IHTMLWindow2 *window, *window2, *self;
5449 IHTMLDocument2 *doc2 = NULL;
5455 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5456 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5457 test_ifaces((IUnknown*)window, window_iids);
5458 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5460 hres = IHTMLWindow2_get_document(window, &doc2);
5461 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5462 ok(doc2 != NULL, "doc2 == NULL\n");
5464 test_ifaces((IUnknown*)doc2, doc_node_iids);
5465 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5467 test_ifaces((IUnknown*)doc, doc_obj_iids);
5468 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5470 unk = (void*)0xdeadbeef;
5471 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5472 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5473 ok(!unk, "unk = %p\n", unk);
5475 IHTMLDocument_Release(doc2);
5477 hres = IHTMLWindow2_get_window(window, &window2);
5478 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5479 ok(window2 != NULL, "window2 == NULL\n");
5481 hres = IHTMLWindow2_get_self(window, &self);
5482 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5483 ok(window2 != NULL, "self == NULL\n");
5485 ok(self == window2, "self != window2\n");
5487 IHTMLWindow2_Release(window2);
5488 IHTMLWindow2_Release(self);
5491 hres = IHTMLDocument2_get_Script(doc, &disp);
5492 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5493 ok(disp == (void*)window, "disp != window\n");
5494 IDispatch_Release(disp);
5496 hres = IHTMLWindow2_toString(window, NULL);
5497 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5500 hres = IHTMLWindow2_toString(window, &str);
5501 ok(hres == S_OK, "toString failed: %08x\n", hres);
5502 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5505 test_window_name(window, NULL);
5506 set_window_name(window, "test");
5507 test_window_length(window, 0);
5508 test_screen(window);
5510 IHTMLWindow2_Release(window);
5513 static void test_defaults(IHTMLDocument2 *doc)
5515 IHTMLStyleSheetsCollection *stylesheetcol;
5516 IHTMLCurrentStyle *cstyle;
5517 IHTMLBodyElement *body;
5518 IHTMLElement2 *elem2;
5523 IHTMLElementCollection *collection;
5525 hres = IHTMLDocument2_get_body(doc, &elem);
5526 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5528 hres = IHTMLDocument2_get_images(doc, NULL);
5529 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5531 hres = IHTMLDocument2_get_images(doc, &collection);
5532 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5535 test_elem_collection((IUnknown*)collection, NULL, 0);
5536 IHTMLElementCollection_Release(collection);
5539 hres = IHTMLDocument2_get_applets(doc, NULL);
5540 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5542 hres = IHTMLDocument2_get_applets(doc, &collection);
5543 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5546 test_elem_collection((IUnknown*)collection, NULL, 0);
5547 IHTMLElementCollection_Release(collection);
5550 hres = IHTMLDocument2_get_links(doc, NULL);
5551 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5553 hres = IHTMLDocument2_get_links(doc, &collection);
5554 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5557 test_elem_collection((IUnknown*)collection, NULL, 0);
5558 IHTMLElementCollection_Release(collection);
5561 hres = IHTMLDocument2_get_forms(doc, NULL);
5562 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5564 hres = IHTMLDocument2_get_forms(doc, &collection);
5565 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5568 test_elem_collection((IUnknown*)collection, NULL, 0);
5569 IHTMLElementCollection_Release(collection);
5572 hres = IHTMLDocument2_get_anchors(doc, NULL);
5573 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5575 hres = IHTMLDocument2_get_anchors(doc, &collection);
5576 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5579 test_elem_collection((IUnknown*)collection, NULL, 0);
5580 IHTMLElementCollection_Release(collection);
5583 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5584 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5585 test_default_body(body);
5586 test_body_funs(body);
5587 IHTMLBodyElement_Release(body);
5589 hres = IHTMLElement_get_style(elem, &style);
5590 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5592 test_default_style(style);
5594 test_compatmode(doc);
5596 test_navigator(doc);
5598 elem2 = get_elem2_iface((IUnknown*)elem);
5599 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5600 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5601 if(SUCCEEDED(hres)) {
5602 test_current_style(cstyle);
5603 IHTMLCurrentStyle_Release(cstyle);
5605 IHTMLElement2_Release(elem2);
5607 IHTMLElement_Release(elem);
5609 test_set_csstext(style);
5610 IHTMLStyle_Release(style);
5612 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5613 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5616 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5617 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5618 ok(l == 0, "length = %d\n", l);
5620 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5622 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5623 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5625 test_default_selection(doc);
5626 test_doc_title(doc, "");
5629 static void test_tr_elem(IHTMLElement *elem)
5631 IHTMLElementCollection *col;
5635 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5637 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5638 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5643 hres = IHTMLTableRow_get_cells(row, &col);
5644 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5645 ok(col != NULL, "get_cells returned NULL\n");
5647 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5648 IHTMLElementCollection_Release(col);
5650 IHTMLTable_Release(row);
5653 static void test_table_elem(IHTMLElement *elem)
5655 IHTMLElementCollection *col;
5660 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5661 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5663 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5664 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
5669 hres = IHTMLTable_get_rows(table, &col);
5670 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
5671 ok(col != NULL, "get_ros returned NULL\n");
5673 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
5674 IHTMLElementCollection_Release(col);
5676 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
5678 node = clone_node((IUnknown*)table, VARIANT_TRUE);
5679 test_elem_tag((IUnknown*)node, "TABLE");
5680 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
5681 IHTMLDOMNode_Release(node);
5683 node = clone_node((IUnknown*)table, VARIANT_FALSE);
5684 test_elem_tag((IUnknown*)node, "TABLE");
5685 test_elem_all((IUnknown*)node, NULL, 0);
5686 IHTMLDOMNode_Release(node);
5688 IHTMLTable_Release(table);
5691 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
5701 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
5702 SafeArrayAccessData(sa, (void**)&var);
5703 V_VT(var) = VT_BSTR;
5704 V_BSTR(var) = str = a2bstr(text);
5705 SafeArrayUnaccessData(sa);
5708 hres = IHTMLDocument2_writeln(doc, sa);
5710 hres = IHTMLDocument2_write(doc, sa);
5711 ok(hres == S_OK, "write failed: %08x\n", hres);
5714 SafeArrayDestroy(sa);
5717 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
5719 IHTMLDocument2 *window_doc, *elem_doc;
5720 IHTMLFrameElement3 *frame_elem3;
5721 IHTMLWindow2 *content_window;
5724 content_window = get_frame_content_window(frame_elem);
5725 window_doc = get_window_doc(content_window);
5726 IHTMLWindow2_Release(content_window);
5728 elem_doc = get_elem_doc(frame_elem);
5729 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
5732 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
5733 if(SUCCEEDED(hres)) {
5734 IDispatch *disp = NULL;
5736 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
5737 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
5738 ok(disp != NULL, "contentDocument == NULL\n");
5739 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
5741 IDispatch_Release(disp);
5742 IHTMLFrameElement3_Release(frame_elem3);
5744 win_skip("IHTMLFrameElement3 not supported\n");
5748 IHTMLDocument2_Release(elem_doc);
5749 IHTMLDocument2_Release(window_doc);
5752 static void test_iframe_elem(IHTMLElement *elem)
5754 IHTMLDocument2 *content_doc, *owner_doc;
5755 IHTMLElementCollection *col;
5756 IHTMLWindow2 *content_window;
5762 static const elem_type_t all_types[] = {
5770 test_frame_doc((IUnknown*)elem, TRUE);
5772 content_window = get_frame_content_window((IUnknown*)elem);
5773 test_window_length(content_window, 0);
5775 content_doc = get_window_doc(content_window);
5776 IHTMLWindow2_Release(content_window);
5778 str = a2bstr("text/html");
5779 V_VT(&errv) = VT_ERROR;
5781 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
5783 ok(hres == S_OK, "open failed: %08x\n", hres);
5784 ok(disp != NULL, "disp == NULL\n");
5785 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
5786 IDispatch_Release(disp);
5788 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
5789 doc_write(content_doc, TRUE, "</html>");
5791 hres = IHTMLDocument2_get_all(content_doc, &col);
5792 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5793 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5794 IHTMLElementCollection_Release(col);
5796 hres = IHTMLDocument2_close(content_doc);
5797 ok(hres == S_OK, "close failed: %08x\n", hres);
5799 owner_doc = get_owner_doc((IUnknown*)content_doc);
5800 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5802 IHTMLDocument2_Release(content_doc);
5805 static void test_stylesheet(IDispatch *disp)
5807 IHTMLStyleSheetRulesCollection *col = NULL;
5808 IHTMLStyleSheet *stylesheet;
5811 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5812 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5814 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5815 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5816 ok(col != NULL, "col == NULL\n");
5818 IHTMLStyleSheetRulesCollection_Release(col);
5819 IHTMLStyleSheet_Release(stylesheet);
5822 static void test_stylesheets(IHTMLDocument2 *doc)
5824 IHTMLStyleSheetsCollection *col = NULL;
5829 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5830 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5831 ok(col != NULL, "col == NULL\n");
5833 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5834 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5835 ok(len == 1, "len=%d\n", len);
5841 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5842 ok(hres == S_OK, "item failed: %08x\n", hres);
5843 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5844 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5845 test_stylesheet(V_DISPATCH(&res));
5852 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5853 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5854 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5855 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5858 IHTMLStyleSheetsCollection_Release(col);
5861 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5863 IDispatchEx *dispex;
5865 DISPPARAMS dp = {NULL, NULL, 0, 0};
5873 static const WCHAR w0[] = {'0',0};
5874 static const WCHAR w100[] = {'1','0','0',0};
5876 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5877 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5879 bstr = SysAllocString(w0);
5880 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5881 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5882 SysFreeString(bstr);
5885 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5886 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5887 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5888 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5889 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5890 type = get_node_type((IUnknown*)node);
5891 ok(type == 3, "type=%d\n", type);
5892 IHTMLDOMNode_Release(node);
5895 bstr = SysAllocString(w100);
5896 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5897 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5898 SysFreeString(bstr);
5900 IDispatchEx_Release(dispex);
5905 static void test_elems(IHTMLDocument2 *doc)
5907 IHTMLElementCollection *col;
5908 IHTMLDOMChildrenCollection *child_col;
5909 IHTMLElement *elem, *elem2, *elem3;
5910 IHTMLDOMNode *node, *node2;
5911 IHTMLWindow2 *window;
5915 IHTMLElementCollection *collection;
5916 IHTMLDocument3 *doc3;
5919 static const elem_type_t all_types[] = {
5947 static const elem_type_t item_types[] = {
5953 hres = IHTMLDocument2_get_all(doc, &col);
5954 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5955 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5956 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5957 IHTMLElementCollection_Release(col);
5959 hres = IHTMLDocument2_get_images(doc, &collection);
5960 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5963 static const elem_type_t images_types[] = {ET_IMG};
5964 test_elem_collection((IUnknown*)collection, images_types, 1);
5966 IHTMLElementCollection_Release(collection);
5969 hres = IHTMLDocument2_get_links(doc, &collection);
5970 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5973 static const elem_type_t images_types[] = {ET_A};
5974 test_elem_collection((IUnknown*)collection, images_types, 1);
5976 IHTMLElementCollection_Release(collection);
5979 hres = IHTMLDocument2_get_anchors(doc, &collection);
5980 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5983 static const elem_type_t anchor_types[] = {ET_A};
5984 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5986 IHTMLElementCollection_Release(collection);
5989 elem = get_doc_elem(doc);
5990 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5991 IHTMLElement_Release(elem);
5993 get_elem_by_id(doc, "xxx", FALSE);
5994 elem = get_doc_elem_by_id(doc, "xxx");
5995 ok(!elem, "elem != NULL\n");
5997 elem = get_doc_elem_by_id(doc, "s");
5998 ok(elem != NULL, "elem == NULL\n");
6000 test_elem_type((IUnknown*)elem, ET_SELECT);
6001 test_elem_attr(elem, "xxx", NULL);
6002 test_elem_attr(elem, "id", "s");
6003 test_elem_class((IUnknown*)elem, NULL);
6004 test_elem_set_class((IUnknown*)elem, "cl");
6005 test_elem_set_class((IUnknown*)elem, NULL);
6006 test_elem_tabindex((IUnknown*)elem, 0);
6007 test_elem_set_tabindex((IUnknown*)elem, 1);
6008 test_elem_filters((IUnknown*)elem);
6010 node = test_node_get_parent((IUnknown*)elem);
6011 ok(node != NULL, "node == NULL\n");
6012 test_node_name((IUnknown*)node, "BODY");
6013 node2 = test_node_get_parent((IUnknown*)node);
6014 IHTMLDOMNode_Release(node);
6015 ok(node2 != NULL, "node == NULL\n");
6016 test_node_name((IUnknown*)node2, "HTML");
6017 node = test_node_get_parent((IUnknown*)node2);
6018 IHTMLDOMNode_Release(node2);
6019 ok(node != NULL, "node == NULL\n");
6022 test_node_name((IUnknown*)node, "#document");
6023 type = get_node_type((IUnknown*)node);
6024 ok(type == 9, "type=%d, expected 9\n", type);
6025 node2 = test_node_get_parent((IUnknown*)node);
6026 IHTMLDOMNode_Release(node);
6027 ok(node2 == NULL, "node != NULL\n");
6030 elem2 = test_elem_get_parent((IUnknown*)elem);
6031 ok(elem2 != NULL, "elem2 == NULL\n");
6032 test_node_name((IUnknown*)elem2, "BODY");
6033 elem3 = test_elem_get_parent((IUnknown*)elem2);
6034 IHTMLElement_Release(elem2);
6035 ok(elem3 != NULL, "elem3 == NULL\n");
6036 test_node_name((IUnknown*)elem3, "HTML");
6037 elem2 = test_elem_get_parent((IUnknown*)elem3);
6038 IHTMLElement_Release(elem3);
6039 ok(elem2 == NULL, "elem2 != NULL\n");
6041 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6042 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6043 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6045 test_elem_innertext(elem, "opt1opt2");
6047 IHTMLElement_Release(elem);
6050 elem = get_elem_by_id(doc, "s", TRUE);
6052 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6053 IHTMLDocument2 *doc_node, *elem_doc;
6055 test_select_elem(select);
6057 test_elem_title((IUnknown*)select, NULL);
6058 test_elem_set_title((IUnknown*)select, "Title");
6059 test_elem_title((IUnknown*)select, "Title");
6060 test_elem_offset((IUnknown*)select);
6061 test_elem_bounding_client_rect((IUnknown*)select);
6063 node = get_first_child((IUnknown*)select);
6064 ok(node != NULL, "node == NULL\n");
6066 test_elem_type((IUnknown*)node, ET_OPTION);
6067 IHTMLDOMNode_Release(node);
6070 type = get_node_type((IUnknown*)select);
6071 ok(type == 1, "type=%d\n", type);
6073 IHTMLSelectElement_Release(select);
6075 elem_doc = get_elem_doc((IUnknown*)elem);
6077 doc_node = get_doc_node(doc);
6078 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6079 IHTMLDocument2_Release(doc_node);
6080 IHTMLDocument2_Release(elem_doc);
6082 IHTMLElement_Release(elem);
6085 elem = get_elem_by_id(doc, "sc", TRUE);
6087 IHTMLScriptElement *script;
6090 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6091 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6097 hres = IHTMLScriptElement_put_type (script, NULL);
6098 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6099 hres = IHTMLScriptElement_get_type(script, &type);
6100 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6101 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6103 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6104 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6105 hres = IHTMLScriptElement_get_type(script, &type);
6106 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6107 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6109 SysFreeString(type);
6112 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6113 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6115 hres = IHTMLScriptElement_get_defer(script, &vb);
6116 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6117 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6119 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6120 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6123 IHTMLScriptElement_Release(script);
6126 elem = get_elem_by_id(doc, "in", TRUE);
6128 IHTMLInputElement *input;
6130 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6131 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6133 test_elem_id((IUnknown*)elem, "in");
6134 test_elem_put_id((IUnknown*)elem, "newin");
6135 test_input_get_disabled(input, VARIANT_FALSE);
6136 test_input_set_disabled(input, VARIANT_TRUE);
6137 test_input_set_disabled(input, VARIANT_FALSE);
6138 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6139 test_input_get_disabled(input, VARIANT_TRUE);
6140 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6141 test_input_get_disabled(input, VARIANT_FALSE);
6142 test_elem_client_size((IUnknown*)elem);
6143 test_input_type(input, "text");
6145 test_node_get_value_str((IUnknown*)elem, NULL);
6146 test_node_put_value_str((IUnknown*)elem, "test");
6147 test_node_get_value_str((IUnknown*)elem, NULL);
6148 test_input_value((IUnknown*)elem, NULL);
6149 test_input_put_value((IUnknown*)elem, "test");
6150 test_input_value((IUnknown*)elem, NULL);
6151 test_elem_class((IUnknown*)elem, "testclass");
6152 test_elem_tabindex((IUnknown*)elem, 2);
6153 test_elem_set_tabindex((IUnknown*)elem, 3);
6154 test_elem_title((IUnknown*)elem, "test title");
6156 test_input_get_defaultchecked(input, VARIANT_FALSE);
6157 test_input_set_defaultchecked(input, VARIANT_TRUE);
6158 test_input_set_defaultchecked(input, VARIANT_FALSE);
6160 test_input_get_checked(input, VARIANT_FALSE);
6161 test_input_set_checked(input, VARIANT_TRUE);
6162 test_input_set_checked(input, VARIANT_FALSE);
6164 test_input_name(input, NULL);
6165 test_input_set_name(input, "test");
6167 test_input_src(input, NULL);
6168 test_input_set_src(input, "about:blank");
6170 IHTMLInputElement_Release(input);
6171 IHTMLElement_Release(elem);
6174 elem = get_elem_by_id(doc, "imgid", TRUE);
6176 test_img_src((IUnknown*)elem, "");
6177 test_img_set_src((IUnknown*)elem, "about:blank");
6178 test_img_alt((IUnknown*)elem, NULL);
6179 test_img_set_alt((IUnknown*)elem, "alt test");
6180 test_img_name((IUnknown*)elem, "WineImg");
6181 IHTMLElement_Release(elem);
6184 elem = get_doc_elem_by_id(doc, "tbl");
6185 ok(elem != NULL, "elem == NULL\n");
6187 test_table_elem(elem);
6188 IHTMLElement_Release(elem);
6191 elem = get_doc_elem_by_id(doc, "row2");
6192 ok(elem != NULL, "elem == NULL\n");
6195 IHTMLElement_Release(elem);
6198 elem = get_doc_elem_by_id(doc, "ifr");
6199 ok(elem != NULL, "elem == NULL\n");
6201 test_iframe_elem(elem);
6202 IHTMLElement_Release(elem);
6205 elem = get_elem_by_id(doc, "a", TRUE);
6207 test_anchor_href((IUnknown*)elem, "http://test/");
6208 IHTMLElement_Release(elem);
6211 hres = IHTMLDocument2_get_body(doc, &elem);
6212 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6214 node = get_first_child((IUnknown*)elem);
6215 ok(node != NULL, "node == NULL\n");
6217 test_ifaces((IUnknown*)node, text_iids);
6218 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6220 node2 = get_first_child((IUnknown*)node);
6221 ok(!node2, "node2 != NULL\n");
6223 type = get_node_type((IUnknown*)node);
6224 ok(type == 3, "type=%d\n", type);
6226 test_node_get_value_str((IUnknown*)node, "text test");
6227 test_node_put_value_str((IUnknown*)elem, "test text");
6228 test_node_get_value_str((IUnknown*)node, "text test");
6230 IHTMLDOMNode_Release(node);
6233 child_col = get_child_nodes((IUnknown*)elem);
6234 ok(child_col != NULL, "child_coll == NULL\n");
6238 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6240 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6241 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6242 ok(length, "length=0\n");
6245 node = get_child_item(child_col, 0);
6246 ok(node != NULL, "node == NULL\n");
6248 type = get_node_type((IUnknown*)node);
6249 ok(type == 3, "type=%d\n", type);
6250 node2 = node_get_next((IUnknown*)node);
6251 IHTMLDOMNode_Release(node);
6254 node = get_child_item(child_col, 1);
6255 ok(node != NULL, "node == NULL\n");
6257 type = get_node_type((IUnknown*)node);
6258 ok(type == 8, "type=%d\n", type);
6260 test_elem_id((IUnknown*)node, NULL);
6261 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6262 IHTMLDOMNode_Release(node2);
6263 IHTMLDOMNode_Release(node);
6266 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6267 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6269 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6270 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6272 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6273 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6275 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6276 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6278 test_child_col_disp(child_col);
6280 IHTMLDOMChildrenCollection_Release(child_col);
6283 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6284 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6285 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6287 IHTMLElement_Release(elem);
6289 elem = get_doc_elem_by_id(doc, "frm");
6290 ok(elem != NULL, "elem == NULL\n");
6292 test_form_length((IUnknown*)elem, 0);
6293 IHTMLElement_Release(elem);
6296 test_stylesheets(doc);
6297 test_create_option_elem(doc);
6298 test_create_img_elem(doc);
6300 elem = get_doc_elem_by_id(doc, "tbl");
6301 ok(elem != NULL, "elem = NULL\n");
6302 test_elem_set_innertext(elem, "inner text");
6303 IHTMLElement_Release(elem);
6305 test_doc_title(doc, "test");
6306 test_doc_set_title(doc, "test title");
6307 test_doc_title(doc, "test title");
6310 hres = IHTMLDocument2_get_Script(doc, &disp);
6311 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6314 IDispatchEx *dispex;
6315 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6316 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6320 BSTR str = a2bstr("Testing");
6321 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6322 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6323 ok(pid != -1, "pid == -1\n");
6325 IDispatchEx_Release(dispex);
6328 IDispatch_Release(disp);
6330 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6331 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6333 str = a2bstr("img");
6334 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6335 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6339 static const elem_type_t img_types[] = { ET_IMG };
6341 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6342 IHTMLElementCollection_Release(col);
6345 elem = get_doc_elem_by_id(doc, "y");
6346 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6347 test_elem_innerhtml((IUnknown*)elem, "inner html");
6348 test_elem_set_innerhtml((IUnknown*)elem, "");
6349 test_elem_innerhtml((IUnknown*)elem, NULL);
6350 node = node_get_next((IUnknown*)elem);
6351 ok(!node, "node = %p\n", node);
6353 elem2 = get_doc_elem_by_id(doc, "x");
6354 test_elem_tag((IUnknown*)elem2, "A");
6355 node = node_get_next((IUnknown*)elem2);
6356 IHTMLDOMNode_Release(node);
6357 IHTMLElement_Release(elem2);
6358 IHTMLElement_Release(elem);
6360 IHTMLDocument3_Release(doc3);
6362 elem = get_elem_by_id(doc, "s", TRUE);
6364 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6366 test_select_put_length((IUnknown*)elem, 3);
6367 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6368 test_select_put_length((IUnknown*)elem, 1);
6369 test_elem_all((IUnknown*)elem, select_types, 1);
6370 IHTMLElement_Release(elem);
6373 window = get_doc_window(doc);
6374 test_window_name(window, NULL);
6375 set_window_name(window, "test name");
6376 test_window_length(window, 1);
6377 IHTMLWindow2_Release(window);
6380 static void test_elems2(IHTMLDocument2 *doc)
6382 IHTMLElement *elem, *elem2, *div;
6384 static const elem_type_t outer_types[] = {
6389 div = get_doc_elem_by_id(doc, "divid");
6391 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6392 elem2 = get_doc_elem_by_id(doc, "innerid");
6393 ok(elem2 != NULL, "elem2 == NULL\n");
6394 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6395 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6396 IHTMLElement_Release(elem2);
6398 elem2 = get_doc_elem_by_id(doc, "aid");
6399 ok(elem2 != NULL, "elem2 == NULL\n");
6400 test_elem_set_outerhtml((IUnknown*)elem2, "");
6401 test_elem_all((IUnknown*)div, outer_types, 1);
6402 IHTMLElement_Release(elem2);
6404 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6405 elem = get_elem_by_id(doc, "ta", TRUE);
6407 test_textarea_value((IUnknown*)elem, NULL);
6408 test_textarea_put_value((IUnknown*)elem, "test");
6409 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6410 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6411 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6412 test_textarea_type((IUnknown*)elem);
6413 IHTMLElement_Release(elem);
6416 test_elem_set_innerhtml((IUnknown*)div,
6417 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6418 elem = get_elem_by_id(doc, "form", TRUE);
6420 test_form_length((IUnknown*)elem, 2);
6421 test_form_item(elem);
6422 test_form_action((IUnknown*)elem, NULL);
6423 test_form_put_action((IUnknown*)elem, "about:blank");
6424 test_form_method((IUnknown*)elem, "get");
6425 test_form_put_method((IUnknown*)elem, S_OK, "post");
6426 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
6427 test_form_method((IUnknown*)elem, "post");
6428 test_form_name((IUnknown*)elem, NULL);
6429 test_form_put_name((IUnknown*)elem, "Name");
6430 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
6431 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
6432 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
6433 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
6434 test_form_encoding((IUnknown*)elem, "multipart/form-data");
6435 IHTMLElement_Release(elem);
6438 IHTMLElement_Release(div);
6441 static void test_create_elems(IHTMLDocument2 *doc)
6443 IHTMLElement *elem, *body, *elem2;
6444 IHTMLDOMNode *node, *node2, *node3, *comment;
6445 IHTMLDocument5 *doc5;
6452 static const elem_type_t types1[] = { ET_TESTG };
6454 elem = test_create_elem(doc, "TEST");
6455 test_elem_tag((IUnknown*)elem, "TEST");
6456 type = get_node_type((IUnknown*)elem);
6457 ok(type == 1, "type=%d\n", type);
6458 test_ifaces((IUnknown*)elem, elem_iids);
6459 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6461 hres = IHTMLDocument2_get_body(doc, &body);
6462 ok(hres == S_OK, "get_body failed: %08x\n", hres);
6463 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6465 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6466 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6467 elem2 = get_elem_iface((IUnknown*)node);
6468 IHTMLElement_Release(elem2);
6470 hres = IHTMLElement_get_all(body, &disp);
6471 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6472 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6473 IDispatch_Release(disp);
6475 test_node_remove_child((IUnknown*)body, node);
6477 hres = IHTMLElement_get_all(body, &disp);
6478 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6479 test_elem_collection((IUnknown*)disp, NULL, 0);
6480 IDispatch_Release(disp);
6481 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6483 IHTMLElement_Release(elem);
6484 IHTMLDOMNode_Release(node);
6486 node = test_create_text(doc, "test");
6487 test_ifaces((IUnknown*)node, text_iids);
6488 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6489 test_text_length((IUnknown*)node, 4);
6491 V_VT(&var) = VT_NULL;
6492 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6493 IHTMLDOMNode_Release(node);
6495 node = test_create_text(doc, "insert ");
6497 V_VT(&var) = VT_DISPATCH;
6498 V_DISPATCH(&var) = (IDispatch*)node2;
6499 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6500 IHTMLDOMNode_Release(node);
6501 IHTMLDOMNode_Release(node2);
6502 IHTMLDOMNode_Release(node3);
6504 test_elem_innertext(body, "insert test");
6505 test_elem_innerhtml((IUnknown*)body, "insert test");
6507 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6510 str = a2bstr("testing");
6511 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6513 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6516 type = get_node_type((IUnknown*)comment);
6517 ok(type == 8, "type=%d, expected 8\n", type);
6519 test_node_get_value_str((IUnknown*)comment, "testing");
6520 test_elem_title((IUnknown*)comment, NULL);
6521 test_elem_set_title((IUnknown*)comment, "comment title");
6522 test_elem_title((IUnknown*)comment, "comment title");
6523 test_comment_text((IUnknown*)comment, "<!--testing-->");
6524 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6526 IHTMLDOMNode_Release(comment);
6529 IHTMLDocument5_Release(doc5);
6532 IHTMLElement_Release(body);
6535 static void test_null_write(IHTMLDocument2 *doc)
6539 doc_write(doc, FALSE, NULL);
6540 doc_write(doc, TRUE, NULL);
6542 hres = IHTMLDocument2_write(doc, NULL);
6544 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6546 hres = IHTMLDocument2_writeln(doc, NULL);
6548 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6551 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6553 IOleCommandTarget *cmdtrg;
6556 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6557 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6559 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6560 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6562 IOleCommandTarget_Release(cmdtrg);
6565 static void test_indent(IHTMLDocument2 *doc)
6567 IHTMLElementCollection *col;
6568 IHTMLTxtRange *range;
6571 static const elem_type_t all_types[] = {
6580 static const elem_type_t indent_types[] = {
6591 hres = IHTMLDocument2_get_all(doc, &col);
6592 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6593 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6594 IHTMLElementCollection_Release(col);
6596 range = test_create_body_range(doc);
6597 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6598 IHTMLTxtRange_Release(range);
6600 hres = IHTMLDocument2_get_all(doc, &col);
6601 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6602 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6603 IHTMLElementCollection_Release(col);
6606 static void test_cond_comment(IHTMLDocument2 *doc)
6608 IHTMLElementCollection *col;
6611 static const elem_type_t all_types[] = {
6619 hres = IHTMLDocument2_get_all(doc, &col);
6620 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6621 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6622 IHTMLElementCollection_Release(col);
6625 static void test_frame(IDispatch *disp, const char *exp_id)
6627 IHTMLWindow2 *frame2, *parent, *top;
6628 IHTMLDocument2 *parent_doc, *top_doc;
6629 IHTMLWindow4 *frame;
6630 IHTMLFrameBase *frame_elem;
6633 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
6634 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
6638 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
6639 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
6640 IHTMLWindow4_Release(frame);
6644 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
6645 test_frame_doc((IUnknown*)frame_elem, FALSE);
6646 test_elem_id((IUnknown*)frame_elem, exp_id);
6647 IHTMLElement_Release(frame_elem);
6649 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
6650 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
6654 hres = IHTMLWindow2_get_parent(frame2, &parent);
6655 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
6657 IHTMLWindow2_Release(frame2);
6661 hres = IHTMLWindow2_get_document(parent, &parent_doc);
6662 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6663 IHTMLWindow2_Release(parent);
6665 IHTMLWindow2_Release(frame2);
6669 test_doc_title(parent_doc, "frameset test");
6670 IHTMLDocument2_Release(parent_doc);
6673 hres = IHTMLWindow2_get_top(frame2, &top);
6674 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
6675 IHTMLWindow2_Release(frame2);
6679 hres = IHTMLWindow2_get_document(top, &top_doc);
6680 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
6681 IHTMLWindow2_Release(top);
6685 test_doc_title(top_doc, "frameset test");
6686 IHTMLDocument2_Release(top_doc);
6689 static void test_frameset(IHTMLDocument2 *doc)
6691 IHTMLWindow2 *window;
6692 IHTMLFramesCollection2 *frames;
6694 IHTMLFrameBase *fbase;
6696 VARIANT index_var, result_var;
6700 window = get_doc_window(doc);
6702 /* test using IHTMLFramesCollection object */
6704 hres = IHTMLWindow2_get_frames(window, &frames);
6705 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
6706 IHTMLWindow2_Release(window);
6710 /* test result length */
6711 hres = IHTMLFramesCollection2_get_length(frames, &length);
6712 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
6713 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
6715 /* test first frame */
6716 V_VT(&index_var) = VT_I4;
6717 V_I4(&index_var) = 0;
6718 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6719 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6720 if(SUCCEEDED(hres)) {
6721 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6722 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6724 VariantClear(&result_var);
6726 /* test second frame */
6727 V_I4(&index_var) = 1;
6728 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6729 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6730 if(SUCCEEDED(hres)) {
6731 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6732 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6734 VariantClear(&result_var);
6736 /* fail on next frame */
6737 V_I4(&index_var) = 3;
6738 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6739 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
6740 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6741 VariantClear(&result_var);
6743 /* string argument (element id lookup) */
6744 V_VT(&index_var) = VT_BSTR;
6745 V_BSTR(&index_var) = a2bstr("fr1");
6746 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6747 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
6748 if(SUCCEEDED(hres)) {
6749 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6750 test_frame(V_DISPATCH(&result_var), "fr1");
6752 VariantClear(&result_var);
6753 VariantClear(&index_var);
6755 /* invalid argument */
6756 V_VT(&index_var) = VT_BOOL;
6757 V_BOOL(&index_var) = VARIANT_TRUE;
6758 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
6759 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
6760 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6761 VariantClear(&result_var);
6763 IHTMLFramesCollection2_Release(frames);
6765 /* test using IHTMLWindow2 inheritance */
6767 /* test result length */
6768 hres = IHTMLWindow2_get_length(window, &length);
6769 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
6770 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
6772 /* test first frame */
6773 V_VT(&index_var) = VT_I4;
6774 V_I4(&index_var) = 0;
6775 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6776 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6777 if(SUCCEEDED(hres)) {
6778 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6779 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
6781 VariantClear(&result_var);
6783 /* test second frame */
6784 V_I4(&index_var) = 1;
6785 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6786 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6787 if(SUCCEEDED(hres)) {
6788 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6789 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6791 VariantClear(&result_var);
6793 /* fail on next frame */
6794 V_I4(&index_var) = 3;
6795 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6796 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
6797 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
6798 VariantClear(&result_var);
6800 /* string argument (element id lookup) */
6801 V_VT(&index_var) = VT_BSTR;
6802 V_BSTR(&index_var) = a2bstr("fr2");
6803 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6804 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
6805 if(SUCCEEDED(hres)) {
6806 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
6807 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
6809 VariantClear(&result_var);
6810 VariantClear(&index_var);
6812 /* invalid argument */
6813 V_VT(&index_var) = VT_BOOL;
6814 V_BOOL(&index_var) = VARIANT_TRUE;
6815 hres = IHTMLWindow2_item(window, &index_var, &result_var);
6816 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
6817 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
6818 VariantClear(&result_var);
6820 /* getElementById with node name attributes */
6821 elem = get_doc_elem_by_id(doc, "nm1");
6822 test_elem_id((IUnknown*)elem, "fr1");
6824 /* get/put scrolling */
6825 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6826 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6828 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6829 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6830 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
6834 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6835 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
6838 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6839 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6840 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6843 str = a2bstr("junk");
6844 hres = IHTMLFrameBase_put_scrolling(fbase, str);
6845 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
6846 "with E_INVALIDARG, instead: 0x%08x\n", hres);
6849 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
6850 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
6851 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
6855 hres = IHTMLFrameBase_get_name(fbase, &str);
6856 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6857 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
6860 IHTMLFrameBase_Release(fbase);
6861 IHTMLElement_Release(elem);
6863 /* get_name with no name attr */
6864 elem = get_doc_elem_by_id(doc, "fr3");
6865 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
6866 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
6868 hres = IHTMLFrameBase_get_name(fbase, &str);
6869 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
6870 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
6873 IHTMLFrameBase_Release(fbase);
6874 IHTMLElement_Release(elem);
6877 static IHTMLDocument2 *notif_doc;
6878 static BOOL doc_complete;
6880 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
6881 REFIID riid, void**ppv)
6883 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
6888 ok(0, "unexpected call\n");
6889 return E_NOINTERFACE;
6892 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
6897 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
6902 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
6904 if(dispID == DISPID_READYSTATE){
6908 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
6909 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
6911 if(!strcmp_wa(state, "complete"))
6912 doc_complete = TRUE;
6914 SysFreeString(state);
6920 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
6922 ok(0, "unexpected call\n");
6926 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
6927 PropertyNotifySink_QueryInterface,
6928 PropertyNotifySink_AddRef,
6929 PropertyNotifySink_Release,
6930 PropertyNotifySink_OnChanged,
6931 PropertyNotifySink_OnRequestEdit
6934 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
6936 static IHTMLDocument2 *create_doc_with_string(const char *str)
6938 IPersistStreamInit *init;
6940 IHTMLDocument2 *doc;
6944 notif_doc = doc = create_document();
6948 doc_complete = FALSE;
6950 mem = GlobalAlloc(0, len);
6951 memcpy(mem, str, len);
6952 CreateStreamOnHGlobal(mem, TRUE, &stream);
6954 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6956 IPersistStreamInit_Load(init, stream);
6957 IPersistStreamInit_Release(init);
6958 IStream_Release(stream);
6963 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6965 IConnectionPointContainer *container;
6966 IConnectionPoint *cp;
6970 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6971 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6973 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6974 IConnectionPointContainer_Release(container);
6975 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6977 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6978 IConnectionPoint_Release(cp);
6979 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6982 typedef void (*domtest_t)(IHTMLDocument2*);
6984 static void run_domtest(const char *str, domtest_t test)
6986 IHTMLDocument2 *doc;
6990 doc = create_doc_with_string(str);
6994 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6996 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6997 TranslateMessage(&msg);
6998 DispatchMessage(&msg);
7003 ref = IHTMLDocument2_Release(doc);
7004 ok(!ref || broken(ref == 1), /* Vista */
7012 run_domtest(doc_str1, test_doc_elem);
7013 run_domtest(doc_str1, test_get_set_attr);
7014 run_domtest(range_test_str, test_txtrange);
7015 run_domtest(range_test2_str, test_txtrange2);
7016 if (winetest_interactive || ! is_ie_hardened()) {
7017 run_domtest(elem_test_str, test_elems);
7019 skip("IE running in Enhanced Security Configuration\n");
7021 run_domtest(elem_test2_str, test_elems2);
7022 run_domtest(doc_blank, test_create_elems);
7023 run_domtest(doc_blank, test_defaults);
7024 run_domtest(doc_blank, test_null_write);
7025 run_domtest(indent_test_str, test_indent);
7026 run_domtest(cond_comment_str, test_cond_comment);
7027 run_domtest(frameset_str, test_frameset);