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>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
93 static const IID * const none_iids[] = {
98 static const IID * const doc_node_iids[] = {
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
112 static const IID * const doc_obj_iids[] = {
119 &IID_IConnectionPointContainer,
124 static const IID * const elem_iids[] = {
131 &IID_IConnectionPointContainer,
135 static const IID * const body_iids[] = {
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
144 &IID_IConnectionPointContainer,
148 static const IID * const anchor_iids[] = {
154 &IID_IHTMLAnchorElement,
156 &IID_IConnectionPointContainer,
160 static const IID * const input_iids[] = {
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
169 &IID_IConnectionPointContainer,
173 static const IID * const select_iids[] = {
179 &IID_IHTMLSelectElement,
181 &IID_IConnectionPointContainer,
185 static const IID * const textarea_iids[] = {
191 &IID_IHTMLTextAreaElement,
193 &IID_IConnectionPointContainer,
197 static const IID * const option_iids[] = {
203 &IID_IHTMLOptionElement,
205 &IID_IConnectionPointContainer,
209 static const IID * const table_iids[] = {
217 &IID_IConnectionPointContainer,
221 static const IID * const script_iids[] = {
227 &IID_IHTMLScriptElement,
229 &IID_IConnectionPointContainer,
233 static const IID * const text_iids[] = {
236 &IID_IHTMLDOMTextNode,
240 static const IID * const location_iids[] = {
246 static const IID * const window_iids[] = {
254 static const IID * const comment_iids[] = {
260 &IID_IHTMLCommentElement,
262 &IID_IConnectionPointContainer,
266 static const IID * const img_iids[] = {
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
278 static const IID * const tr_iids[] = {
286 &IID_IConnectionPointContainer,
290 static const IID * const td_iids[] = {
297 &IID_IConnectionPointContainer,
301 static const IID * const iframe_iids[] = {
307 &IID_IHTMLFrameBase2,
309 &IID_IConnectionPointContainer,
313 static const IID * const generic_iids[] = {
319 &IID_IHTMLGenericElement,
321 &IID_IConnectionPointContainer,
325 static const IID * const style_iids[] = {
336 static const IID * const cstyle_iids[] = {
340 &IID_IHTMLCurrentStyle,
350 static const elem_type_info_t elem_type_infos[] = {
351 {"", none_iids, NULL},
352 {"HTML", elem_iids, NULL},
353 {"HEAD", elem_iids, NULL},
354 {"TITLE", elem_iids, NULL},
355 {"BODY", body_iids, &DIID_DispHTMLBody},
356 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
357 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
358 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
359 {"TEXTAREA", textarea_iids, NULL},
360 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
361 {"STYLE", elem_iids, NULL},
362 {"BLOCKQUOTE",elem_iids, NULL},
363 {"P", elem_iids, NULL},
364 {"BR", elem_iids, NULL},
365 {"TABLE", table_iids, &DIID_DispHTMLTable},
366 {"TBODY", elem_iids, NULL},
367 {"SCRIPT", script_iids, NULL},
368 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
369 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
370 {"!", comment_iids, &DIID_DispHTMLCommentElement},
371 {"IMG", img_iids, &DIID_DispHTMLImg},
372 {"TR", tr_iids, &DIID_DispHTMLTableRow},
373 {"TD", td_iids, NULL},
374 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
377 static const char *dbgstr_guid(REFIID riid)
381 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
382 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
383 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
384 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
389 static int strcmp_wa(LPCWSTR strw, const char *stra)
392 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
393 return lstrcmpA(stra, buf);
396 static BSTR a2bstr(const char *str)
401 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
402 ret = SysAllocStringLen(NULL, len);
403 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
408 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
410 IUnknown *unk1, *unk2;
415 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
416 IUnknown_Release(unk1);
417 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
418 IUnknown_Release(unk2);
423 static IHTMLDocument2 *create_document(void)
426 IHTMLDocument5 *doc5;
429 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
430 &IID_IHTMLDocument2, (void**)&doc);
431 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
433 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
435 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
436 IHTMLDocument2_Release(doc);
440 IHTMLDocument5_Release(doc5);
444 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
445 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
447 const IID * const *piid;
451 for(piid = iids; *piid; piid++) {
452 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
453 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
455 IUnknown_Release(unk);
459 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
460 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
468 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
469 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
474 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
475 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
476 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
478 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
479 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
481 if(SUCCEEDED(hres)) {
484 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
485 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
487 *iid = type_attr->guid;
491 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
492 ITypeInfo_Release(typeinfo);
495 IDispatchEx_Release(dispex);
499 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
500 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
502 DISPPARAMS dp = {NULL,NULL,0,0};
508 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
509 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
513 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
514 IDispatchEx_Release(dispex);
515 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
517 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
518 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
522 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
523 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
527 if(_test_get_dispid(line, unk, &iid))
528 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
531 _test_disp_value(line, unk, val);
534 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
535 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
539 if(_test_get_dispid(line, unk, &iid))
540 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
541 "unexpected guid %s\n", dbgstr_guid(&iid));
544 _test_disp_value(line, unk, val);
547 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
548 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
553 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
554 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
558 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
559 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
564 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
565 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
569 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
570 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
575 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
576 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
580 #define get_node_iface(u) _get_node_iface(__LINE__,u)
581 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
586 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
587 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
591 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
592 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
597 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
598 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
602 #define get_img_iface(u) _get_img_iface(__LINE__,u)
603 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
605 IHTMLImgElement *img;
608 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
609 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
613 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
614 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
616 IHTMLAnchorElement *anchor;
619 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
620 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
624 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
625 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
627 IHTMLDOMNode *node = _get_node_iface(line, unk);
631 hres = IHTMLDOMNode_get_nodeName(node, &name);
632 IHTMLDOMNode_Release(node);
633 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
634 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
639 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
640 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
642 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
643 IDispatch *disp = (void*)0xdeadbeef;
647 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
648 IHTMLDOMNode2_Release(node);
649 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
650 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
652 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
653 IDispatch_Release(disp);
654 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
659 #define clone_node(n,d) _clone_node(__LINE__,n,d)
660 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
662 IHTMLDOMNode *node = _get_node_iface(line, unk);
663 IHTMLDOMNode *ret = NULL;
666 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
667 IHTMLDOMNode_Release(node);
668 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
669 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
675 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
676 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
678 IHTMLElement *elem = _get_elem_iface(line, unk);
682 hres = IHTMLElement_get_tagName(elem, &tag);
683 IHTMLElement_Release(elem);
684 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
685 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
690 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
691 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
693 _test_elem_tag(line, unk, elem_type_infos[type].tag);
694 _test_ifaces(line, unk, elem_type_infos[type].iids);
696 if(elem_type_infos[type].dispiid && type != ET_A)
697 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
700 #define get_node_type(n) _get_node_type(__LINE__,n)
701 static LONG _get_node_type(unsigned line, IUnknown *unk)
703 IHTMLDOMNode *node = _get_node_iface(line, unk);
707 hres = IHTMLDOMNode_get_nodeType(node, &type);
708 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
710 IHTMLDOMNode_Release(node);
715 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
716 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
718 IHTMLDOMNode *node = _get_node_iface(line, unk);
719 IHTMLDOMChildrenCollection *col = NULL;
723 hres = IHTMLDOMNode_get_childNodes(node, &disp);
724 IHTMLDOMNode_Release(node);
725 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
729 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
730 IDispatch_Release(disp);
731 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
736 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
737 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
739 IHTMLDOMNode *node = NULL;
743 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
744 ok(hres == S_OK, "item failed: %08x\n", hres);
746 node = _get_node_iface(line, (IUnknown*)disp);
747 IDispatch_Release(disp);
752 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
753 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
762 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
764 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
767 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
768 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
770 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
773 VariantClear(&value);
776 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
777 static void _test_elem_offset(unsigned line, IUnknown *unk)
779 IHTMLElement *elem = _get_elem_iface(line, unk);
783 hres = IHTMLElement_get_offsetTop(elem, &l);
784 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
786 hres = IHTMLElement_get_offsetHeight(elem, &l);
787 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
789 hres = IHTMLElement_get_offsetWidth(elem, &l);
790 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
792 IHTMLElement_Release(elem);
795 #define get_doc_node(d) _get_doc_node(__LINE__,d)
796 static IHTMLDocument2 *_get_doc_node(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);
805 hres = IHTMLWindow2_get_document(window, &ret);
806 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
807 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
812 static void test_get_set_attr(IHTMLDocument2 *doc)
815 IHTMLDocument3 *doc3;
820 /* grab an element to test with */
821 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
822 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
824 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
825 IHTMLDocument3_Release(doc3);
826 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
828 /* get a non-present attribute */
829 bstr = a2bstr("notAnAttribute");
830 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
831 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
832 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
836 /* get a present attribute */
837 bstr = a2bstr("scrollHeight");
838 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
839 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
840 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
844 /* create a new BSTR attribute */
845 bstr = a2bstr("newAttribute");
847 V_VT(&val) = VT_BSTR;
848 V_BSTR(&val) = a2bstr("the value");
849 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
850 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
853 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
854 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
855 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
856 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)));
859 /* overwrite the attribute with a BOOL */
860 V_VT(&val) = VT_BOOL;
861 V_BOOL(&val) = VARIANT_TRUE;
862 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
863 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
866 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
867 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
868 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
869 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
874 /* case-insensitive */
875 bstr = a2bstr("newattribute");
876 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
877 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
878 todo_wine ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
879 todo_wine ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
883 IHTMLElement_Release(elem);
886 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
887 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
890 IHTMLDocument3 *doc3;
893 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
894 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
895 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
896 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
897 IHTMLDocument3_Release(doc3);
902 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
903 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
905 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
909 hres = IHTMLAnchorElement_get_href(anchor, &str);
910 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
911 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
914 _test_disp_value(line, unk, exhref);
917 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
918 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
923 hres = IHTMLOptionElement_get_text(option, &bstr);
924 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
925 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
929 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
930 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
936 hres = IHTMLOptionElement_put_text(option, bstr);
938 ok(hres == S_OK, "put_text failed: %08x\n", hres);
940 _test_option_text(line, option, text);
943 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
944 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
949 hres = IHTMLOptionElement_get_value(option, &bstr);
950 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
951 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
955 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
956 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
961 bstr = a2bstr(value);
962 hres = IHTMLOptionElement_put_value(option, bstr);
964 ok(hres == S_OK, "put_value failed: %08x\n", hres);
966 _test_option_value(line, option, value);
969 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
970 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
971 const char *txt, const char *val)
973 IHTMLOptionElementFactory *factory;
974 IHTMLOptionElement *option;
975 IHTMLWindow2 *window;
976 VARIANT text, value, empty;
979 hres = IHTMLDocument2_get_parentWindow(doc, &window);
980 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
982 hres = IHTMLWindow2_get_Option(window, &factory);
983 IHTMLWindow2_Release(window);
984 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
986 V_VT(&text) = VT_BSTR;
987 V_BSTR(&text) = a2bstr(txt);
988 V_VT(&value) = VT_BSTR;
989 V_BSTR(&value) = a2bstr(val);
990 V_VT(&empty) = VT_EMPTY;
992 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
993 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
995 IHTMLOptionElementFactory_Release(factory);
997 VariantClear(&value);
999 _test_option_text(line, option, txt);
1000 _test_option_value(line, option, val);
1005 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1006 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1008 LONG len = 0xdeadbeef;
1011 hres = IHTMLSelectElement_get_length(select, &len);
1012 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1013 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1016 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1017 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1019 LONG idx = 0xdeadbeef;
1022 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1023 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1024 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1027 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1028 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1032 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1033 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1034 _test_select_selidx(line, select, index);
1037 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1038 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1043 hres = IHTMLSelectElement_get_value(select, &val);
1044 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1046 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1048 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1051 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1052 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1058 hres = IHTMLSelectElement_put_value(select, bstr);
1059 SysFreeString(bstr);
1060 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1063 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1064 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1069 hres = IHTMLSelectElement_get_type(select, &type);
1070 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1071 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1074 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1075 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1080 hres = IHTMLTxtRange_get_text(range, &text);
1081 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1084 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1085 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1087 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1090 SysFreeString(text);
1094 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1095 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1099 hres = IHTMLTxtRange_collapse(range, b);
1100 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1101 _test_range_text(line, range, NULL);
1104 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1105 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1106 VARIANT_BOOL exb, const char *extext)
1108 VARIANT_BOOL b = 0xe0e0;
1111 hres = IHTMLTxtRange_expand(range, unit, &b);
1112 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1113 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1114 _test_range_text(line, range, extext);
1117 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1118 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1120 LONG c = 0xdeadbeef;
1123 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1124 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1125 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1126 _test_range_text(line, range, NULL);
1129 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1130 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1131 LPWSTR unit, LONG cnt, LONG excnt)
1133 LONG c = 0xdeadbeef;
1136 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1137 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1138 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1141 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1142 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1144 LONG c = 0xdeadbeef;
1147 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1148 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1149 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1152 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1153 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1156 BSTR bstr = a2bstr(text);
1158 hres = IHTMLTxtRange_put_text(range, bstr);
1159 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1160 SysFreeString(bstr);
1161 _test_range_text(line, range, NULL);
1164 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1165 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1171 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1172 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1173 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1176 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1177 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1183 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1184 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1185 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1188 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1189 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1190 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1193 test_range_inrange(range1, range2, VARIANT_TRUE);
1194 test_range_inrange(range2, range1, VARIANT_TRUE);
1198 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1199 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1204 hres = IHTMLTxtRange_parentElement(range, &elem);
1205 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1207 _test_elem_type(line, (IUnknown*)elem, type);
1209 IHTMLElement_Release(elem);
1212 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1213 static void _test_elem_collection(unsigned line, IUnknown *unk,
1214 const elem_type_t *elem_types, LONG exlen)
1216 IHTMLElementCollection *col;
1219 VARIANT name, index;
1220 IDispatch *disp, *disp2;
1223 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1224 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1226 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1228 hres = IHTMLElementCollection_get_length(col, &len);
1229 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1230 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1235 V_VT(&index) = VT_EMPTY;
1237 for(i=0; i<len; i++) {
1238 V_VT(&name) = VT_I4;
1240 disp = (void*)0xdeadbeef;
1241 hres = IHTMLElementCollection_item(col, name, index, &disp);
1242 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1243 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1244 if(FAILED(hres) || !disp)
1247 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1250 V_VT(&name) = VT_UINT;
1252 disp2 = (void*)0xdeadbeef;
1253 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1254 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1255 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1257 IDispatch_Release(disp2);
1260 IDispatch_Release(disp);
1263 V_VT(&name) = VT_I4;
1265 disp = (void*)0xdeadbeef;
1266 hres = IHTMLElementCollection_item(col, name, index, &disp);
1267 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1268 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1270 V_VT(&name) = VT_I4;
1272 disp = (void*)0xdeadbeef;
1273 hres = IHTMLElementCollection_item(col, name, index, &disp);
1274 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1275 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1277 IHTMLElementCollection_Release(col);
1280 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1281 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1283 IHTMLElement *elem = _get_elem_iface(line, unk);
1287 hres = IHTMLElement_get_all(elem, &disp);
1288 IHTMLElement_Release(elem);
1289 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1291 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1292 IDispatch_Release(disp);
1295 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1296 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1298 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1299 IHTMLElementCollection *col = NULL;
1300 elem_type_t *types = NULL;
1305 tmp = a2bstr(elem_type_infos[type].tag);
1306 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1308 IHTMLElement2_Release(elem);
1309 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1310 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1313 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1314 for(i=0; i<exlen; i++)
1318 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1320 HeapFree(GetProcessHeap(), 0, types);
1323 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1324 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1329 hres = IHTMLElement_get_innerText(elem, &text);
1330 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1331 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1332 wine_dbgstr_w(text), extext);
1333 SysFreeString(text);
1336 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1337 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1339 IHTMLDOMChildrenCollection *col;
1344 hres = IHTMLElement_put_innerText(elem, str);
1345 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1348 _test_elem_innertext(line, elem, text);
1351 col = _get_child_nodes(line, (IUnknown*)elem);
1352 ok(col != NULL, "col == NULL\n");
1354 LONG length = 0, type;
1357 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1358 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1359 ok(length == 1, "length = %d\n", length);
1361 node = _get_child_item(line, col, 0);
1362 ok(node != NULL, "node == NULL\n");
1364 type = _get_node_type(line, (IUnknown*)node);
1365 ok(type == 3, "type=%d\n", type);
1366 IHTMLDOMNode_Release(node);
1369 IHTMLDOMChildrenCollection_Release(col);
1374 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1375 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1377 IHTMLElement *elem = _get_elem_iface(line, unk);
1381 hres = IHTMLElement_get_innerHTML(elem, &html);
1382 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1384 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1386 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1388 IHTMLElement_Release(elem);
1389 SysFreeString(html);
1392 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1393 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1395 IHTMLElement *elem = _get_elem_iface(line, unk);
1399 html = a2bstr(inner_html);
1400 hres = IHTMLElement_put_innerHTML(elem, html);
1401 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1403 IHTMLElement_Release(elem);
1404 SysFreeString(html);
1407 #define get_first_child(n) _get_first_child(__LINE__,n)
1408 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1410 IHTMLDOMNode *node = _get_node_iface(line, unk);
1411 IHTMLDOMNode *child = NULL;
1414 hres = IHTMLDOMNode_get_firstChild(node, &child);
1415 IHTMLDOMNode_Release(node);
1416 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1421 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1422 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1424 IHTMLDOMNode *node = _get_node_iface(line, unk);
1425 VARIANT_BOOL b = 0xdead;
1428 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1429 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1430 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1432 IHTMLDOMNode_Release(node);
1435 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1436 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1438 IHTMLDOMNode *node = _get_node_iface(line, unk);
1439 IHTMLDOMNode *parent;
1442 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1443 IHTMLDOMNode_Release(node);
1444 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1449 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1450 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1452 IHTMLElement *elem = _get_elem_iface(line, unk);
1453 IHTMLElement *parent;
1456 hres = IHTMLElement_get_parentElement(elem, &parent);
1457 IHTMLElement_Release(elem);
1458 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1463 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1464 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1466 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1467 VARIANT_BOOL disabled = 100;
1471 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1472 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1473 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1474 IHTMLElement3_Release(elem3);
1477 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1478 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1480 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1484 hres = IHTMLElement3_put_disabled(elem3, b);
1485 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1487 IHTMLElement3_Release(elem3);
1488 _test_elem3_get_disabled(line, unk, b);
1491 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1492 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1494 VARIANT_BOOL disabled = 100;
1497 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1498 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1499 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1501 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1504 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1505 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1509 hres = IHTMLSelectElement_put_disabled(select, b);
1510 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1512 _test_select_get_disabled(line, select, b);
1515 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1516 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1518 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1519 IHTMLTextContainer *txtcont;
1520 LONG l = -1, l2 = -1;
1523 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1524 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1525 IHTMLElement2_Release(elem);
1527 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1528 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1530 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1531 IHTMLTextContainer_Release(txtcont);
1532 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1533 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1538 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1539 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1541 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1542 IHTMLTextContainer *txtcont;
1543 LONG l = -1, l2 = -1;
1546 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1547 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1548 IHTMLElement2_Release(elem);
1550 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1551 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1553 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1554 IHTMLTextContainer_Release(txtcont);
1555 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1556 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1561 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1562 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1564 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1565 IHTMLTextContainer *txtcont;
1566 LONG l = -1, l2 = -1;
1569 hres = IHTMLElement2_get_scrollTop(elem, &l);
1570 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1571 IHTMLElement2_Release(elem);
1573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1576 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1577 IHTMLTextContainer_Release(txtcont);
1578 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1579 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1584 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1585 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1587 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1588 IHTMLTextContainer *txtcont;
1589 LONG l = -1, l2 = -1;
1592 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1593 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1595 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1596 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1597 IHTMLElement2_Release(elem);
1599 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1600 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1602 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1603 IHTMLTextContainer_Release(txtcont);
1604 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1605 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1608 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1609 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1611 IHTMLImgElement *img = _get_img_iface(line, unk);
1615 hres = IHTMLImgElement_get_src(img, &src);
1616 IHTMLImgElement_Release(img);
1617 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1618 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1622 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1623 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1625 IHTMLImgElement *img = _get_img_iface(line, unk);
1630 hres = IHTMLImgElement_put_src(img, tmp);
1631 IHTMLImgElement_Release(img);
1633 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1635 _test_img_src(line, unk, src);
1638 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1639 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1641 IHTMLImgElement *img = _get_img_iface(line, unk);
1645 hres = IHTMLImgElement_get_alt(img, &alt);
1646 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1648 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1650 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1654 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1655 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1657 IHTMLImgElement *img = _get_img_iface(line, unk);
1662 hres = IHTMLImgElement_put_alt(img, tmp);
1663 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1666 _test_img_alt(line, unk, alt);
1669 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1670 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1672 VARIANT_BOOL disabled = 100;
1675 hres = IHTMLInputElement_get_disabled(input, &disabled);
1676 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1677 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1679 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1682 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1683 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1687 hres = IHTMLInputElement_put_disabled(input, b);
1688 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1690 _test_input_get_disabled(line, input, b);
1693 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1694 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1696 VARIANT_BOOL checked = 100;
1699 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1700 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1701 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1704 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1705 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1709 hres = IHTMLInputElement_put_defaultChecked(input, b);
1710 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1712 _test_input_get_defaultchecked(line, input, b);
1715 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1716 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1718 VARIANT_BOOL checked = 100;
1721 hres = IHTMLInputElement_get_checked(input, &checked);
1722 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1723 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1726 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1727 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1731 hres = IHTMLInputElement_put_checked(input, b);
1732 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1734 _test_input_get_checked(line, input, b);
1737 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1738 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1740 IHTMLInputElement *input;
1744 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1745 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1749 hres = IHTMLInputElement_get_value(input, &bstr);
1750 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1752 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1754 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1755 SysFreeString(bstr);
1756 IHTMLInputElement_Release(input);
1759 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1760 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1762 IHTMLInputElement *input;
1766 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1767 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1772 hres = IHTMLInputElement_get_value(input, &bstr);
1773 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1774 SysFreeString(bstr);
1775 IHTMLInputElement_Release(input);
1778 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1779 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1784 hres = IHTMLInputElement_get_src(input, &src);
1785 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1787 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1789 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1793 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1794 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1800 hres = IHTMLInputElement_put_src(input, tmp);
1802 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1804 _test_input_src(line, input, src);
1807 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1808 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1810 IHTMLElement *elem = _get_elem_iface(line, unk);
1811 BSTR class = (void*)0xdeadbeef;
1814 hres = IHTMLElement_get_className(elem, &class);
1815 IHTMLElement_Release(elem);
1816 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1818 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1820 ok_(__FILE__,line) (!class, "class != NULL\n");
1821 SysFreeString(class);
1824 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1825 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1827 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1831 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1832 IHTMLElement2_Release(elem2);
1833 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1834 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1837 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1838 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1840 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1843 hres = IHTMLElement2_put_tabIndex(elem2, index);
1844 IHTMLElement2_Release(elem2);
1845 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1847 _test_elem_tabindex(line, unk, index);
1850 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1851 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1853 IHTMLElement *elem = _get_elem_iface(line, unk);
1857 tmp = class ? a2bstr(class) : NULL;
1858 hres = IHTMLElement_put_className(elem, tmp);
1859 IHTMLElement_Release(elem);
1860 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1863 _test_elem_class(line, unk, class);
1866 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1867 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1869 IHTMLElement *elem = _get_elem_iface(line, unk);
1870 BSTR id = (void*)0xdeadbeef;
1873 hres = IHTMLElement_get_id(elem, &id);
1874 IHTMLElement_Release(elem);
1875 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1878 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1880 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1885 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1886 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1888 IHTMLElement *elem = _get_elem_iface(line, unk);
1889 BSTR tmp = a2bstr(new_id);
1892 hres = IHTMLElement_put_id(elem, tmp);
1893 IHTMLElement_Release(elem);
1895 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1897 _test_elem_id(line, unk, new_id);
1900 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1901 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1903 IHTMLElement *elem = _get_elem_iface(line, unk);
1907 hres = IHTMLElement_get_title(elem, &title);
1908 IHTMLElement_Release(elem);
1909 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1911 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1913 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1915 SysFreeString(title);
1918 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1919 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1921 IHTMLElement *elem = _get_elem_iface(line, unk);
1925 tmp = a2bstr(title);
1926 hres = IHTMLElement_put_title(elem, tmp);
1927 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1929 IHTMLElement_Release(elem);
1933 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1934 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1936 IHTMLDOMNode *node = _get_node_iface(line, unk);
1940 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1941 IHTMLDOMNode_Release(node);
1942 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1945 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1946 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
1948 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1954 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1955 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1957 IHTMLDOMNode *node = _get_node_iface(line, unk);
1961 V_VT(&var) = VT_BSTR;
1962 V_BSTR(&var) = a2bstr(val);
1964 hres = IHTMLDOMNode_put_nodeValue(node, var);
1965 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1966 IHTMLDOMNode_Release(node);
1970 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1971 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1973 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1977 hres = IHTMLElement2_get_clientWidth(elem, &l);
1978 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1979 hres = IHTMLElement2_get_clientHeight(elem, &l);
1980 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1982 IHTMLElement2_Release(elem);
1985 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
1986 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
1988 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1992 hres = IHTMLElement2_get_clientLeft(elem, &l);
1993 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
1994 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
1996 hres = IHTMLElement2_get_clientTop(elem, &l);
1997 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
1998 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2000 IHTMLElement2_Release(elem);
2003 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2004 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2006 IHTMLElement *elem = NULL;
2011 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2012 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2013 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2018 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2019 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2021 IHTMLDocument3 *doc3;
2022 IHTMLDOMNode *node = NULL;
2026 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2027 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2030 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2031 IHTMLDocument3_Release(doc3);
2032 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2033 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2038 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2039 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2041 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2042 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2043 IHTMLDOMNode *new_child = NULL;
2046 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2047 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2048 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2049 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2051 IHTMLDOMNode_Release(node);
2052 IHTMLDOMNode_Release(child);
2057 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2058 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2060 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2061 IHTMLDOMNode *new_child = NULL;
2064 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2065 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2066 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2067 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2069 IHTMLDOMNode_Release(node);
2074 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2075 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2077 IHTMLDOMNode *node = _get_node_iface(line, unk);
2078 IHTMLDOMNode *new_node = NULL;
2081 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2082 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2083 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2084 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2086 IHTMLDOMNode_Release(node);
2087 IHTMLDOMNode_Release(new_node);
2090 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2091 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2096 hres = IHTMLDocument2_get_title(doc, &title);
2097 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2098 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2099 SysFreeString(title);
2102 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2103 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2108 tmp = a2bstr(title);
2109 hres = IHTMLDocument2_put_title(doc, tmp);
2110 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2114 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2115 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2120 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2121 LOCALE_USER_DEFAULT, &dispid);
2122 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2125 DISPPARAMS params = {NULL,NULL,0,0};
2126 DISPID dispidNamed = DISPID_PROPERTYPUT;
2131 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2132 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2133 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2136 params.cNamedArgs = 1;
2137 params.rgdispidNamedArgs = &dispidNamed;
2138 V_VT(&arg) = VT_BSTR;
2139 V_BSTR(&arg) = a2bstr("none");
2140 params.rgvarg = &arg;
2141 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2142 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2143 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2146 V_VT(&arg) = VT_BSTR;
2147 V_BSTR(&arg) = a2bstr("dotted");
2148 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2149 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2150 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2153 V_VT(&arg) = VT_BSTR;
2154 V_BSTR(&arg) = a2bstr("dashed");
2155 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2156 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2157 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2160 V_VT(&arg) = VT_BSTR;
2161 V_BSTR(&arg) = a2bstr("solid");
2162 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2163 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2164 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2167 V_VT(&arg) = VT_BSTR;
2168 V_BSTR(&arg) = a2bstr("double");
2169 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2170 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2171 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2174 V_VT(&arg) = VT_BSTR;
2175 V_BSTR(&arg) = a2bstr("groove");
2176 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2177 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2178 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2181 V_VT(&arg) = VT_BSTR;
2182 V_BSTR(&arg) = a2bstr("ridge");
2183 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2184 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2185 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2188 V_VT(&arg) = VT_BSTR;
2189 V_BSTR(&arg) = a2bstr("inset");
2190 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2191 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2192 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2195 V_VT(&arg) = VT_BSTR;
2196 V_BSTR(&arg) = a2bstr("outset");
2197 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2198 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2199 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2202 V_VT(&arg) = VT_BSTR;
2203 V_BSTR(&arg) = a2bstr("invalid");
2204 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2205 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2206 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2209 params.rgvarg = &vDefault;
2210 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2211 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2212 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2216 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2217 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2219 BSTR text = (void*)0xdeadbeef;
2222 hres = IHTMLStyle_get_cssText(style, &text);
2223 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2225 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2227 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2229 SysFreeString(text);
2232 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2233 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2239 hres = IHTMLStyle_put_cssText(style, tmp);
2240 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2244 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2245 const elem_type_t *elem_types, LONG len)
2248 VARIANT name, index;
2252 V_VT(&index) = VT_EMPTY;
2253 V_VT(&name) = VT_BSTR;
2254 V_BSTR(&name) = a2bstr(n);
2256 hres = IHTMLElementCollection_item(col, name, index, &disp);
2257 ok(hres == S_OK, "item failed: %08x\n", hres);
2259 test_elem_collection((IUnknown*)disp, elem_types, len);
2260 IDispatch_Release(disp);
2261 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2265 V_VT(&index) = VT_I4;
2267 for(i=0; i<len; i++) {
2269 disp = (void*)0xdeadbeef;
2270 hres = IHTMLElementCollection_item(col, name, index, &disp);
2271 ok(hres == S_OK, "item failed: %08x\n", hres);
2272 ok(disp != NULL, "disp == NULL\n");
2273 if(FAILED(hres) || !disp)
2276 test_elem_type((IUnknown*)disp, elem_types[i]);
2278 IDispatch_Release(disp);
2282 disp = (void*)0xdeadbeef;
2283 hres = IHTMLElementCollection_item(col, name, index, &disp);
2284 ok(hres == S_OK, "item failed: %08x\n", hres);
2285 ok(disp == NULL, "disp != NULL\n");
2288 disp = (void*)0xdeadbeef;
2289 hres = IHTMLElementCollection_item(col, name, index, &disp);
2290 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2291 ok(disp == NULL, "disp != NULL\n");
2294 SysFreeString(V_BSTR(&name));
2297 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2299 IHTMLElementCollection *col;
2301 IDispatch *disp = (void*)0xdeadbeef;
2302 VARIANT name, index;
2305 hres = IHTMLDocument2_get_all(doc, &col);
2306 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2307 ok(col != NULL, "col == NULL\n");
2308 if(FAILED(hres) || !col)
2311 V_VT(&index) = VT_EMPTY;
2312 V_VT(&name) = VT_BSTR;
2313 V_BSTR(&name) = a2bstr(id);
2315 hres = IHTMLElementCollection_item(col, name, index, &disp);
2316 IHTMLElementCollection_Release(col);
2317 SysFreeString(V_BSTR(&name));
2318 ok(hres == S_OK, "item failed: %08x\n", hres);
2319 if(!expect_success) {
2320 ok(disp == NULL, "disp != NULL\n");
2324 ok(disp != NULL, "disp == NULL\n");
2328 elem = get_elem_iface((IUnknown*)disp);
2329 IDispatch_Release(disp);
2334 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2336 IHTMLDocument3 *doc3;
2341 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2342 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2345 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2347 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2349 IHTMLDocument3_Release(doc3);
2354 static void test_select_elem(IHTMLSelectElement *select)
2356 test_select_type(select, "select-one");
2357 test_select_length(select, 2);
2358 test_select_selidx(select, 0);
2359 test_select_put_selidx(select, 1);
2361 test_select_set_value(select, "val1");
2362 test_select_value(select, "val1");
2364 test_select_get_disabled(select, VARIANT_FALSE);
2365 test_select_set_disabled(select, VARIANT_TRUE);
2366 test_select_set_disabled(select, VARIANT_FALSE);
2369 static void test_create_option_elem(IHTMLDocument2 *doc)
2371 IHTMLOptionElement *option;
2373 option = create_option_elem(doc, "test text", "test value");
2375 test_option_put_text(option, "new text");
2376 test_option_put_value(option, "new value");
2378 IHTMLOptionElement_Release(option);
2381 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2383 IHTMLBodyElement *body;
2384 IHTMLTxtRange *range;
2388 hres = IHTMLDocument2_get_body(doc, &elem);
2389 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2391 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2392 IHTMLElement_Release(elem);
2394 hres = IHTMLBodyElement_createTextRange(body, &range);
2395 IHTMLBodyElement_Release(body);
2396 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2401 static void test_txtrange(IHTMLDocument2 *doc)
2403 IHTMLTxtRange *body_range, *range, *range2;
2404 IHTMLSelectionObject *selection;
2405 IDispatch *disp_range;
2408 body_range = test_create_body_range(doc);
2410 test_range_text(body_range, "test abc 123\r\nit's text");
2412 hres = IHTMLTxtRange_duplicate(body_range, &range);
2413 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2415 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2416 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2417 test_range_isequal(range, range2, VARIANT_TRUE);
2419 test_range_text(range, "test abc 123\r\nit's text");
2420 test_range_text(body_range, "test abc 123\r\nit's text");
2422 test_range_collapse(range, TRUE);
2423 test_range_isequal(range, range2, VARIANT_FALSE);
2424 test_range_inrange(range, range2, VARIANT_FALSE);
2425 test_range_inrange(range2, range, VARIANT_TRUE);
2426 IHTMLTxtRange_Release(range2);
2428 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2429 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2430 test_range_move(range, characterW, 2, 2);
2431 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2433 test_range_collapse(range, FALSE);
2434 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2436 test_range_collapse(range, FALSE);
2437 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2438 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2439 test_range_move(range, characterW, 2, 2);
2440 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2441 test_range_moveend(range, characterW, -5, -5);
2442 test_range_text(range, NULL);
2443 test_range_moveend(range, characterW, 3, 3);
2444 test_range_text(range, "c 1");
2445 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2446 test_range_collapse(range, TRUE);
2447 test_range_move(range, characterW, 4, 4);
2448 test_range_moveend(range, characterW, 1, 1);
2449 test_range_text(range, " ");
2450 test_range_move(range, wordW, 1, 1);
2451 test_range_moveend(range, characterW, 2, 2);
2452 test_range_text(range, "ab");
2454 IHTMLTxtRange_Release(range);
2456 hres = IHTMLTxtRange_duplicate(body_range, &range);
2457 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2459 test_range_text(range, "test abc 123\r\nit's text");
2460 test_range_move(range, characterW, 3, 3);
2461 test_range_moveend(range, characterW, 1, 1);
2462 test_range_text(range, "t");
2463 test_range_moveend(range, characterW, 3, 3);
2464 test_range_text(range, "t ab");
2465 test_range_moveend(range, characterW, -2, -2);
2466 test_range_text(range, "t ");
2467 test_range_move(range, characterW, 6, 6);
2468 test_range_moveend(range, characterW, 3, 3);
2469 test_range_text(range, "123");
2470 test_range_moveend(range, characterW, 2, 2);
2471 test_range_text(range, "123\r\ni");
2473 IHTMLTxtRange_Release(range);
2475 hres = IHTMLTxtRange_duplicate(body_range, &range);
2476 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2478 test_range_move(range, wordW, 1, 1);
2479 test_range_moveend(range, characterW, 2, 2);
2480 test_range_text(range, "ab");
2482 test_range_move(range, characterW, -2, -2);
2483 test_range_moveend(range, characterW, 2, 2);
2484 test_range_text(range, "t ");
2486 test_range_move(range, wordW, 3, 3);
2487 test_range_move(range, wordW, -2, -2);
2488 test_range_moveend(range, characterW, 2, 2);
2489 test_range_text(range, "ab");
2491 test_range_move(range, characterW, -6, -5);
2492 test_range_moveend(range, characterW, -1, 0);
2493 test_range_moveend(range, characterW, -6, 0);
2494 test_range_move(range, characterW, 2, 2);
2495 test_range_moveend(range, characterW, 2, 2);
2496 test_range_text(range, "st");
2497 test_range_moveend(range, characterW, -6, -4);
2498 test_range_moveend(range, characterW, 2, 2);
2500 IHTMLTxtRange_Release(range);
2502 hres = IHTMLTxtRange_duplicate(body_range, &range);
2503 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2505 test_range_move(range, wordW, 2, 2);
2506 test_range_moveend(range, characterW, 2, 2);
2507 test_range_text(range, "12");
2509 test_range_move(range, characterW, 15, 14);
2510 test_range_move(range, characterW, -2, -2);
2511 test_range_moveend(range, characterW, 3, 2);
2512 test_range_text(range, "t");
2513 test_range_moveend(range, characterW, -1, -1);
2514 test_range_text(range, "t");
2515 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2516 test_range_move(range, characterW, -2, -2);
2517 test_range_moveend(range, characterW, 2, 2);
2518 test_range_text(range, "s ");
2519 test_range_move(range, characterW, 100, 7);
2520 test_range_move(range, wordW, 1, 0);
2521 test_range_move(range, characterW, -2, -2);
2522 test_range_moveend(range, characterW, 3, 2);
2523 test_range_text(range, "t");
2525 IHTMLTxtRange_Release(range);
2527 hres = IHTMLTxtRange_duplicate(body_range, &range);
2528 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2530 test_range_collapse(range, TRUE);
2531 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2532 test_range_put_text(range, "word");
2533 test_range_text(body_range, "wordabc 123\r\nit's text");
2534 test_range_text(range, NULL);
2535 test_range_moveend(range, characterW, 3, 3);
2536 test_range_text(range, "abc");
2537 test_range_movestart(range, characterW, -2, -2);
2538 test_range_text(range, "rdabc");
2539 test_range_movestart(range, characterW, 3, 3);
2540 test_range_text(range, "bc");
2541 test_range_movestart(range, characterW, 4, 4);
2542 test_range_text(range, NULL);
2543 test_range_movestart(range, characterW, -3, -3);
2544 test_range_text(range, "c 1");
2545 test_range_movestart(range, characterW, -7, -6);
2546 test_range_text(range, "wordabc 1");
2547 test_range_movestart(range, characterW, 100, 22);
2548 test_range_text(range, NULL);
2550 IHTMLTxtRange_Release(range);
2551 IHTMLTxtRange_Release(body_range);
2553 hres = IHTMLDocument2_get_selection(doc, &selection);
2554 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2556 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2557 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2558 IHTMLSelectionObject_Release(selection);
2560 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2561 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2562 IDispatch_Release(disp_range);
2564 test_range_text(range, NULL);
2565 test_range_moveend(range, characterW, 3, 3);
2566 test_range_text(range, "wor");
2567 test_range_parent(range, ET_BODY);
2568 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2569 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2570 test_range_move(range, characterW, 3, 3);
2571 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2572 test_range_moveend(range, characterW, -4, -4);
2573 test_range_put_text(range, "abc def ");
2574 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2575 test_range_move(range, wordW, 1, 1);
2576 test_range_movestart(range, characterW, -1, -1);
2577 test_range_text(range, " ");
2578 test_range_move(range, wordW, 1, 1);
2579 test_range_moveend(range, characterW, 3, 3);
2580 test_range_text(range, "def");
2581 test_range_put_text(range, "xyz");
2582 test_range_moveend(range, characterW, 1, 1);
2583 test_range_move(range, wordW, 1, 1);
2584 test_range_moveend(range, characterW, 2, 2);
2585 test_range_text(range, "ab");
2587 IHTMLTxtRange_Release(range);
2590 static void test_txtrange2(IHTMLDocument2 *doc)
2592 IHTMLTxtRange *range;
2594 range = test_create_body_range(doc);
2596 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2597 test_range_move(range, characterW, 5, 5);
2598 test_range_moveend(range, characterW, 1, 1);
2599 test_range_text(range, "2");
2600 test_range_move(range, characterW, -3, -3);
2601 test_range_moveend(range, characterW, 3, 3);
2602 test_range_text(range, "c\r\n\r\n1");
2603 test_range_collapse(range, VARIANT_FALSE);
2604 test_range_moveend(range, characterW, 4, 4);
2605 test_range_text(range, "23");
2606 test_range_moveend(range, characterW, 1, 1);
2607 test_range_text(range, "23\r\n\r\n\r\nd");
2608 test_range_moveend(range, characterW, -1, -1);
2609 test_range_text(range, "23");
2610 test_range_moveend(range, characterW, -1, -1);
2611 test_range_text(range, "23");
2612 test_range_moveend(range, characterW, -2, -2);
2613 test_range_text(range, "2");
2615 IHTMLTxtRange_Release(range);
2618 static void test_compatmode(IHTMLDocument2 *doc)
2620 IHTMLDocument5 *doc5;
2624 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2625 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2629 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2630 IHTMLDocument5_Release(doc5);
2631 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2632 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2633 SysFreeString(mode);
2636 static void test_location(IHTMLDocument2 *doc)
2638 IHTMLLocation *location, *location2;
2639 IHTMLWindow2 *window;
2644 hres = IHTMLDocument2_get_location(doc, &location);
2645 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2647 hres = IHTMLDocument2_get_location(doc, &location2);
2648 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2650 ok(location == location2, "location != location2\n");
2651 IHTMLLocation_Release(location2);
2653 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2654 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2656 hres = IHTMLWindow2_get_location(window, &location2);
2657 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2658 ok(location == location2, "location != location2\n");
2659 IHTMLLocation_Release(location2);
2661 test_ifaces((IUnknown*)location, location_iids);
2662 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2664 hres = IHTMLLocation_get_pathname(location, &str);
2665 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2666 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2668 hres = IHTMLLocation_get_href(location, NULL);
2669 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2671 hres = IHTMLLocation_get_href(location, &str);
2672 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2673 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2675 ref = IHTMLLocation_Release(location);
2676 ok(!ref, "location chould be destroyed here\n");
2679 static void test_navigator(IHTMLDocument2 *doc)
2681 IHTMLWindow2 *window;
2682 IOmNavigator *navigator, *navigator2;
2689 static const WCHAR v40[] = {'4','.','0'};
2691 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2692 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2694 hres = IHTMLWindow2_get_navigator(window, &navigator);
2695 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2696 ok(navigator != NULL, "navigator == NULL\n");
2697 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2699 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2700 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2701 ok(navigator != navigator2, "navigator2 != navihgator\n");
2703 IHTMLWindow2_Release(window);
2704 IOmNavigator_Release(navigator2);
2706 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2707 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2708 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2709 SysFreeString(bstr);
2712 hres = IOmNavigator_get_appName(navigator, &bstr);
2713 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2714 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2715 SysFreeString(bstr);
2718 hres = IOmNavigator_get_platform(navigator, &bstr);
2719 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2721 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2723 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2725 SysFreeString(bstr);
2728 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2729 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2730 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2731 SysFreeString(bstr);
2733 hres = IOmNavigator_toString(navigator, NULL);
2734 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2737 hres = IOmNavigator_toString(navigator, &bstr);
2738 ok(hres == S_OK, "toString failed: %08x\n", hres);
2739 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2740 SysFreeString(bstr);
2743 hres = ObtainUserAgentString(0, buf, &size);
2744 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2747 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2748 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2749 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2750 SysFreeString(bstr);
2752 ref = IOmNavigator_Release(navigator);
2753 ok(!ref, "navigator should be destroyed here\n");
2756 static void test_current_style(IHTMLCurrentStyle *current_style)
2762 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2763 test_ifaces((IUnknown*)current_style, cstyle_iids);
2765 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2766 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2767 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2770 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2771 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2772 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2775 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2776 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2779 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2780 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2781 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2784 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2785 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2786 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2789 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2790 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2791 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2794 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2795 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2796 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2799 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2800 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2801 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2804 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2805 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2806 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2809 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2810 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2811 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2814 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2815 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2816 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2819 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2820 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2821 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2824 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2825 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2826 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2829 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2830 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2831 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2834 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2835 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2838 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2839 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2842 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2843 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2846 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2847 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2850 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2851 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2854 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2855 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2858 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2859 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2860 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2861 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2864 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2865 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2866 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2869 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2870 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2871 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2874 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2875 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2876 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2879 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2880 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2881 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2884 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2885 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2886 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2889 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2890 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2891 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2894 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2895 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2896 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2897 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2900 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2901 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2902 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2903 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2906 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2907 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2908 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2911 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2912 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2913 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2916 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2917 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2918 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2922 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2923 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2924 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2927 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2928 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2929 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2932 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2933 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2934 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2937 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2938 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2939 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2942 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2943 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2944 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2947 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
2948 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
2949 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2952 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
2953 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
2954 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2957 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
2958 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
2959 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2962 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
2963 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
2964 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2967 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
2968 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
2969 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2972 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
2973 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2974 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2977 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
2978 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2979 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2982 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
2983 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
2984 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2987 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
2988 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
2989 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2992 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
2993 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
2994 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2997 hres = IHTMLCurrentStyle_get_right(current_style, &v);
2998 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
2999 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3002 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3003 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3004 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3007 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3008 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3009 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3012 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3013 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3014 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3018 static void test_style2(IHTMLStyle2 *style2)
3023 str = (void*)0xdeadbeef;
3024 hres = IHTMLStyle2_get_position(style2, &str);
3025 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3026 ok(!str, "str != NULL\n");
3028 str = a2bstr("absolute");
3029 hres = IHTMLStyle2_put_position(style2, str);
3030 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3034 hres = IHTMLStyle2_get_position(style2, &str);
3035 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3036 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3040 static void test_style3(IHTMLStyle3 *style3)
3045 str = (void*)0xdeadbeef;
3046 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3047 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3048 ok(!str, "str != NULL\n");
3050 str = a2bstr("break-word");
3051 hres = IHTMLStyle3_put_wordWrap(style3, str);
3052 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3056 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3057 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3058 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3062 static void test_style4(IHTMLStyle4 *style4)
3068 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3069 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3072 V_BSTR(&v) = a2bstr("10px");
3073 hres = IHTMLStyle4_put_minHeight(style4, v);
3074 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3077 hres = IHTMLStyle4_get_minHeight(style4, &v);
3078 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3079 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3080 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3082 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3083 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3084 VariantClear(&vdefault);
3087 static void test_default_style(IHTMLStyle *style)
3089 IHTMLStyle2 *style2;
3090 IHTMLStyle3 *style3;
3091 IHTMLStyle4 *style4;
3097 BSTR sOverflowDefault;
3101 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3102 test_ifaces((IUnknown*)style, style_iids);
3104 test_style_csstext(style, NULL);
3106 hres = IHTMLStyle_get_position(style, &str);
3107 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3108 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3111 hres = IHTMLStyle_get_marginRight(style, &v);
3112 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3113 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3114 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3117 hres = IHTMLStyle_get_marginLeft(style, &v);
3118 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3119 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3120 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3122 str = (void*)0xdeadbeef;
3123 hres = IHTMLStyle_get_fontFamily(style, &str);
3124 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3125 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3127 str = (void*)0xdeadbeef;
3128 hres = IHTMLStyle_get_fontWeight(style, &str);
3129 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3130 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3132 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3133 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3135 str = a2bstr("test");
3136 hres = IHTMLStyle_put_fontWeight(style, str);
3137 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3140 str = a2bstr("bold");
3141 hres = IHTMLStyle_put_fontWeight(style, str);
3142 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3145 str = a2bstr("bolder");
3146 hres = IHTMLStyle_put_fontWeight(style, str);
3147 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3150 str = a2bstr("lighter");
3151 hres = IHTMLStyle_put_fontWeight(style, str);
3152 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3155 str = a2bstr("100");
3156 hres = IHTMLStyle_put_fontWeight(style, str);
3157 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3160 str = a2bstr("200");
3161 hres = IHTMLStyle_put_fontWeight(style, str);
3162 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3165 str = a2bstr("300");
3166 hres = IHTMLStyle_put_fontWeight(style, str);
3167 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3170 str = a2bstr("400");
3171 hres = IHTMLStyle_put_fontWeight(style, str);
3172 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3175 str = a2bstr("500");
3176 hres = IHTMLStyle_put_fontWeight(style, str);
3177 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3180 str = a2bstr("600");
3181 hres = IHTMLStyle_put_fontWeight(style, str);
3182 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3185 str = a2bstr("700");
3186 hres = IHTMLStyle_put_fontWeight(style, str);
3187 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3190 str = a2bstr("800");
3191 hres = IHTMLStyle_put_fontWeight(style, str);
3192 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3195 str = a2bstr("900");
3196 hres = IHTMLStyle_put_fontWeight(style, str);
3197 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3200 hres = IHTMLStyle_get_fontWeight(style, &str);
3201 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3202 ok(!strcmp_wa(str, "900"), "str != style900\n");
3205 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3206 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3207 SysFreeString(sDefault);
3210 hres = IHTMLStyle_get_fontVariant(style, NULL);
3211 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3213 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3214 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3216 str = a2bstr("test");
3217 hres = IHTMLStyle_put_fontVariant(style, str);
3218 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3221 str = a2bstr("small-caps");
3222 hres = IHTMLStyle_put_fontVariant(style, str);
3223 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3226 str = a2bstr("normal");
3227 hres = IHTMLStyle_put_fontVariant(style, str);
3228 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3231 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3232 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3233 SysFreeString(sDefault);
3235 str = (void*)0xdeadbeef;
3236 hres = IHTMLStyle_get_display(style, &str);
3237 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3238 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3240 str = (void*)0xdeadbeef;
3241 hres = IHTMLStyle_get_visibility(style, &str);
3242 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3243 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3246 hres = IHTMLStyle_get_fontSize(style, &v);
3247 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3248 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3249 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3252 hres = IHTMLStyle_get_color(style, &v);
3253 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3254 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3255 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3258 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3259 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3260 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3262 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3263 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3264 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3266 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3267 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3268 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3270 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3271 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3274 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3275 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3276 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3278 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3279 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3280 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3282 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3283 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3284 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3286 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3287 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3290 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3291 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3292 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3294 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3295 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3296 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3298 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3299 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3300 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3302 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3303 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3306 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3307 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3308 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3310 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3311 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3312 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3314 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3315 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3316 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3318 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3319 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3322 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3323 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3324 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3326 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3327 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3328 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3330 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3331 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3332 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3334 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3335 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3337 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3338 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3340 str = a2bstr("invalid");
3341 hres = IHTMLStyle_put_textDecoration(style, str);
3342 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3345 str = a2bstr("none");
3346 hres = IHTMLStyle_put_textDecoration(style, str);
3347 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3350 str = a2bstr("underline");
3351 hres = IHTMLStyle_put_textDecoration(style, str);
3352 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3355 str = a2bstr("overline");
3356 hres = IHTMLStyle_put_textDecoration(style, str);
3357 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3360 str = a2bstr("line-through");
3361 hres = IHTMLStyle_put_textDecoration(style, str);
3362 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3365 str = a2bstr("blink");
3366 hres = IHTMLStyle_put_textDecoration(style, str);
3367 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3370 hres = IHTMLStyle_get_textDecoration(style, &str);
3371 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3372 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3375 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3376 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3377 SysFreeString(sDefault);
3379 hres = IHTMLStyle_get_posWidth(style, NULL);
3380 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3382 hres = IHTMLStyle_get_posWidth(style, &f);
3383 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3384 ok(f == 0.0f, "f = %f\n", f);
3386 V_VT(&v) = VT_EMPTY;
3387 hres = IHTMLStyle_get_width(style, &v);
3388 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3389 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3390 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3392 hres = IHTMLStyle_put_posWidth(style, 2.2);
3393 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3395 hres = IHTMLStyle_get_posWidth(style, &f);
3396 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3398 f == 2.2f, /* IE8 */
3402 V_BSTR(&v) = a2bstr("auto");
3403 hres = IHTMLStyle_put_width(style, v);
3404 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3407 V_VT(&v) = VT_EMPTY;
3408 hres = IHTMLStyle_get_width(style, &v);
3409 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3410 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3411 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3415 str = (void*)0xdeadbeef;
3416 hres = IHTMLStyle_get_margin(style, &str);
3417 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3418 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3421 hres = IHTMLStyle_put_margin(style, str);
3422 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3425 hres = IHTMLStyle_get_margin(style, &str);
3426 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3427 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3429 hres = IHTMLStyle_put_margin(style, NULL);
3430 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3433 hres = IHTMLStyle_get_border(style, &str);
3434 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3435 ok(!str || !*str, "str is not empty\n");
3438 str = a2bstr("1px");
3439 hres = IHTMLStyle_put_border(style, str);
3440 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3443 V_VT(&v) = VT_EMPTY;
3444 hres = IHTMLStyle_get_left(style, &v);
3445 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3446 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3447 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3451 hres = IHTMLStyle_get_posLeft(style, NULL);
3452 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3455 hres = IHTMLStyle_get_posLeft(style, &f);
3456 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3457 ok(f == 0.0, "expected 0.0 got %f\n", f);
3459 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3460 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3462 hres = IHTMLStyle_get_posLeft(style, &f);
3463 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3465 f == 4.9f, /* IE8 */
3466 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3468 /* Ensure left is updated correctly. */
3469 V_VT(&v) = VT_EMPTY;
3470 hres = IHTMLStyle_get_left(style, &v);
3471 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3472 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3473 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3474 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3475 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3480 V_BSTR(&v) = a2bstr("3px");
3481 hres = IHTMLStyle_put_left(style, v);
3482 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3485 hres = IHTMLStyle_get_posLeft(style, &f);
3486 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3487 ok(f == 3.0, "expected 3.0 got %f\n", f);
3489 V_VT(&v) = VT_EMPTY;
3490 hres = IHTMLStyle_get_left(style, &v);
3491 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3492 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3493 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3497 hres = IHTMLStyle_put_left(style, v);
3498 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3500 V_VT(&v) = VT_EMPTY;
3501 hres = IHTMLStyle_get_left(style, &v);
3502 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3503 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3504 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3507 V_VT(&v) = VT_EMPTY;
3508 hres = IHTMLStyle_get_top(style, &v);
3509 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3510 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3511 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3515 hres = IHTMLStyle_get_posTop(style, NULL);
3516 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3519 hres = IHTMLStyle_get_posTop(style, &f);
3520 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3521 ok(f == 0.0, "expected 0.0 got %f\n", f);
3523 hres = IHTMLStyle_put_posTop(style, 4.9f);
3524 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3526 hres = IHTMLStyle_get_posTop(style, &f);
3527 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3529 f == 4.9f, /* IE8 */
3530 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3533 V_BSTR(&v) = a2bstr("3px");
3534 hres = IHTMLStyle_put_top(style, v);
3535 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3538 V_VT(&v) = VT_EMPTY;
3539 hres = IHTMLStyle_get_top(style, &v);
3540 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3541 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3542 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3545 hres = IHTMLStyle_get_posTop(style, &f);
3546 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3547 ok(f == 3.0, "expected 3.0 got %f\n", f);
3550 hres = IHTMLStyle_put_top(style, v);
3551 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3553 V_VT(&v) = VT_EMPTY;
3554 hres = IHTMLStyle_get_top(style, &v);
3555 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3556 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3557 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3560 /* Test posHeight */
3561 hres = IHTMLStyle_get_posHeight(style, NULL);
3562 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3564 V_VT(&v) = VT_EMPTY;
3565 hres = IHTMLStyle_get_height(style, &v);
3566 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3567 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3568 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3572 hres = IHTMLStyle_get_posHeight(style, &f);
3573 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3574 ok(f == 0.0, "expected 0.0 got %f\n", f);
3576 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3577 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3579 hres = IHTMLStyle_get_posHeight(style, &f);
3580 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3582 f == 4.9f, /* IE8 */
3583 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3586 V_BSTR(&v) = a2bstr("64px");
3587 hres = IHTMLStyle_put_height(style, v);
3588 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3591 V_VT(&v) = VT_EMPTY;
3592 hres = IHTMLStyle_get_height(style, &v);
3593 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3594 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3595 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3598 hres = IHTMLStyle_get_posHeight(style, &f);
3599 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3600 ok(f == 64.0, "expected 64.0 got %f\n", f);
3602 str = (void*)0xdeadbeef;
3603 hres = IHTMLStyle_get_cursor(style, &str);
3604 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3605 ok(!str, "get_cursor != NULL\n");
3608 str = a2bstr("default");
3609 hres = IHTMLStyle_put_cursor(style, str);
3610 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3614 hres = IHTMLStyle_get_cursor(style, &str);
3615 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3616 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3619 V_VT(&v) = VT_EMPTY;
3620 hres = IHTMLStyle_get_verticalAlign(style, &v);
3621 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3622 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3623 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3627 V_BSTR(&v) = a2bstr("middle");
3628 hres = IHTMLStyle_put_verticalAlign(style, v);
3629 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3632 V_VT(&v) = VT_EMPTY;
3633 hres = IHTMLStyle_get_verticalAlign(style, &v);
3634 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3635 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3636 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3639 str = (void*)0xdeadbeef;
3640 hres = IHTMLStyle_get_textAlign(style, &str);
3641 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3642 ok(!str, "textAlign != NULL\n");
3644 str = a2bstr("center");
3645 hres = IHTMLStyle_put_textAlign(style, str);
3646 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3650 hres = IHTMLStyle_get_textAlign(style, &str);
3651 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3652 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3655 str = (void*)0xdeadbeef;
3656 hres = IHTMLStyle_get_filter(style, &str);
3657 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3658 ok(!str, "filter != NULL\n");
3660 str = a2bstr("alpha(opacity=100)");
3661 hres = IHTMLStyle_put_filter(style, str);
3662 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3665 V_VT(&v) = VT_EMPTY;
3666 hres = IHTMLStyle_get_zIndex(style, &v);
3667 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3668 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3669 ok(!V_I4(&v), "V_I4(v) != 0\n");
3673 V_BSTR(&v) = a2bstr("1");
3674 hres = IHTMLStyle_put_zIndex(style, v);
3675 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3678 V_VT(&v) = VT_EMPTY;
3679 hres = IHTMLStyle_get_zIndex(style, &v);
3680 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3681 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3682 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3686 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3687 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3689 str = a2bstr("test");
3690 hres = IHTMLStyle_put_fontStyle(style, str);
3691 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3694 str = a2bstr("italic");
3695 hres = IHTMLStyle_put_fontStyle(style, str);
3696 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3699 str = a2bstr("oblique");
3700 hres = IHTMLStyle_put_fontStyle(style, str);
3701 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3704 str = a2bstr("normal");
3705 hres = IHTMLStyle_put_fontStyle(style, str);
3706 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3709 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3710 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3711 SysFreeString(sDefault);
3714 hres = IHTMLStyle_get_overflow(style, NULL);
3715 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3717 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3718 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3720 str = a2bstr("test");
3721 hres = IHTMLStyle_put_overflow(style, str);
3722 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3725 str = a2bstr("visible");
3726 hres = IHTMLStyle_put_overflow(style, str);
3727 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3730 str = a2bstr("scroll");
3731 hres = IHTMLStyle_put_overflow(style, str);
3732 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3735 str = a2bstr("hidden");
3736 hres = IHTMLStyle_put_overflow(style, str);
3737 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3740 str = a2bstr("auto");
3741 hres = IHTMLStyle_put_overflow(style, str);
3742 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3745 hres = IHTMLStyle_get_overflow(style, &str);
3746 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3747 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3751 hres = IHTMLStyle_put_overflow(style, str);
3752 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3755 hres = IHTMLStyle_get_overflow(style, &str);
3756 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3757 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3760 /* restore overflow default */
3761 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3762 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3763 SysFreeString(sOverflowDefault);
3765 /* Attribute Tests*/
3766 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3767 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3769 str = a2bstr("position");
3770 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3771 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3773 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3774 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3775 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3778 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3779 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3782 V_BSTR(&v) = a2bstr("absolute");
3783 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3784 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3787 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3788 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3789 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3790 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3795 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3796 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3801 str = a2bstr("borderLeftStyle");
3802 test_border_styles(style, str);
3805 str = a2bstr("borderbottomstyle");
3806 test_border_styles(style, str);
3809 str = a2bstr("borderrightstyle");
3810 test_border_styles(style, str);
3813 str = a2bstr("bordertopstyle");
3814 test_border_styles(style, str);
3817 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3818 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3820 str = a2bstr("none dotted dashed solid");
3821 hres = IHTMLStyle_put_borderStyle(style, str);
3822 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3825 str = a2bstr("none dotted dashed solid");
3826 hres = IHTMLStyle_get_borderStyle(style, &str);
3827 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3828 ok(!strcmp_wa(str, "none dotted dashed solid"),
3829 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3832 str = a2bstr("double groove ridge inset");
3833 hres = IHTMLStyle_put_borderStyle(style, str);
3834 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3837 str = a2bstr("window-inset outset ridge inset");
3838 hres = IHTMLStyle_put_borderStyle(style, str);
3839 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3842 str = a2bstr("window-inset");
3843 hres = IHTMLStyle_put_borderStyle(style, str);
3844 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3847 str = a2bstr("none none none none none");
3848 hres = IHTMLStyle_put_borderStyle(style, str);
3849 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3852 str = a2bstr("invalid none none none");
3853 hres = IHTMLStyle_put_borderStyle(style, str);
3854 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3857 str = a2bstr("none invalid none none");
3858 hres = IHTMLStyle_put_borderStyle(style, str);
3859 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3862 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3863 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3864 SysFreeString(sDefault);
3866 /* backgoundColor */
3867 hres = IHTMLStyle_get_backgroundColor(style, &v);
3868 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3869 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3870 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3874 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3875 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3878 V_BSTR(&v) = a2bstr("10");
3879 hres = IHTMLStyle_put_paddingLeft(style, v);
3880 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3883 hres = IHTMLStyle_get_paddingLeft(style, &v);
3884 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3885 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3887 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3888 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3890 /* BackgroundRepeat */
3891 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3892 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3894 str = a2bstr("invalid");
3895 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3896 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3899 str = a2bstr("repeat");
3900 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3901 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3904 str = a2bstr("no-repeat");
3905 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3906 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3909 str = a2bstr("repeat-x");
3910 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3911 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3914 str = a2bstr("repeat-y");
3915 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3916 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3919 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3920 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3921 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
3924 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3925 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3926 SysFreeString(sDefault);
3929 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3930 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3932 str = a2bstr("red green red blue");
3933 hres = IHTMLStyle_put_borderColor(style, str);
3934 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3937 hres = IHTMLStyle_get_borderColor(style, &str);
3938 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3939 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
3942 hres = IHTMLStyle_put_borderColor(style, sDefault);
3943 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3944 SysFreeString(sDefault);
3947 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3948 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3950 str = a2bstr("thick dotted red");
3951 hres = IHTMLStyle_put_borderLeft(style, str);
3952 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3955 /* IHTMLStyle_get_borderLeft appears to have a bug where
3956 it returns the first letter of the color. So we check
3957 each style individually.
3960 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3961 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3962 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3966 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3967 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3968 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3971 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3972 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3973 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
3976 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3977 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3978 SysFreeString(sDefault);
3980 /* backgroundPositionX */
3981 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3982 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3985 V_BSTR(&v) = a2bstr("10px");
3986 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3987 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3990 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3991 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3992 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3995 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
3996 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3997 VariantClear(&vDefault);
3999 /* backgroundPositionY */
4000 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4001 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4004 V_BSTR(&v) = a2bstr("10px");
4005 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4006 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4009 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4010 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4011 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4014 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4015 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4016 VariantClear(&vDefault);
4018 /* borderTopWidth */
4019 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4020 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4023 V_BSTR(&v) = a2bstr("10px");
4024 hres = IHTMLStyle_put_borderTopWidth(style, v);
4025 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4028 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4029 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4030 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4033 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4034 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4035 VariantClear(&vDefault);
4037 /* borderRightWidth */
4038 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4039 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4042 V_BSTR(&v) = a2bstr("10");
4043 hres = IHTMLStyle_put_borderRightWidth(style, v);
4044 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4047 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4048 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4049 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4052 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4053 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4054 VariantClear(&vDefault);
4056 /* borderBottomWidth */
4057 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4058 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4061 V_BSTR(&v) = a2bstr("10");
4062 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4063 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4066 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4067 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4068 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4071 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4072 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4073 VariantClear(&vDefault);
4075 /* borderLeftWidth */
4076 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4077 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4080 V_BSTR(&v) = a2bstr("10");
4081 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4082 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4085 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4086 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4087 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4090 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4091 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4092 VariantClear(&vDefault);
4095 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4096 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4099 V_BSTR(&v) = a2bstr("10");
4100 hres = IHTMLStyle_put_wordSpacing(style, v);
4101 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4104 hres = IHTMLStyle_get_wordSpacing(style, &v);
4105 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4106 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4107 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4110 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4111 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4112 VariantClear(&vDefault);
4115 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4116 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4119 V_BSTR(&v) = a2bstr("11");
4120 hres = IHTMLStyle_put_letterSpacing(style, v);
4121 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4124 hres = IHTMLStyle_get_letterSpacing(style, &v);
4125 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4126 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4127 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4130 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4131 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4132 VariantClear(&vDefault);
4134 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4135 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4136 if(SUCCEEDED(hres)) {
4137 test_style2(style2);
4138 IHTMLStyle2_Release(style2);
4141 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4142 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4143 if(SUCCEEDED(hres)) {
4144 test_style3(style3);
4145 IHTMLStyle3_Release(style3);
4148 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4149 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4150 if(SUCCEEDED(hres)) {
4151 test_style4(style4);
4152 IHTMLStyle4_Release(style4);
4156 static void test_set_csstext(IHTMLStyle *style)
4161 test_style_set_csstext(style, "background-color: black;");
4163 hres = IHTMLStyle_get_backgroundColor(style, &v);
4164 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4165 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4166 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4170 static void test_default_selection(IHTMLDocument2 *doc)
4172 IHTMLSelectionObject *selection;
4173 IHTMLTxtRange *range;
4178 hres = IHTMLDocument2_get_selection(doc, &selection);
4179 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4181 hres = IHTMLSelectionObject_get_type(selection, &str);
4182 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4183 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4186 hres = IHTMLSelectionObject_createRange(selection, &disp);
4187 IHTMLSelectionObject_Release(selection);
4188 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4190 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4191 IDispatch_Release(disp);
4192 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4194 test_range_text(range, NULL);
4195 IHTMLTxtRange_Release(range);
4198 static void test_doc_elem(IHTMLDocument2 *doc)
4200 IHTMLDocument2 *doc_node, *owner_doc;
4202 IHTMLDocument3 *doc3;
4205 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4206 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4208 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4209 IHTMLDocument3_Release(doc3);
4210 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4212 test_node_name((IUnknown*)elem, "HTML");
4213 test_elem_tag((IUnknown*)elem, "HTML");
4215 doc_node = get_doc_node(doc);
4216 owner_doc = get_owner_doc((IUnknown*)elem);
4217 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4218 IHTMLDocument2_Release(doc_node);
4219 IHTMLDocument2_Release(owner_doc);
4221 test_elem_client_rect((IUnknown*)elem);
4223 IHTMLElement_Release(elem);
4226 static void test_default_body(IHTMLBodyElement *body)
4232 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4233 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4235 bstr = (void*)0xdeadbeef;
4236 hres = IHTMLBodyElement_get_background(body, &bstr);
4237 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4238 ok(bstr == NULL, "bstr != NULL\n");
4240 l = elem_get_scroll_height((IUnknown*)body);
4241 ok(l != -1, "scrollHeight == -1\n");
4242 l = elem_get_scroll_width((IUnknown*)body);
4243 ok(l != -1, "scrollWidth == -1\n");
4244 l = elem_get_scroll_top((IUnknown*)body);
4245 ok(!l, "scrollTop = %d\n", l);
4246 elem_get_scroll_left((IUnknown*)body);
4248 /* get_text tests */
4249 hres = IHTMLBodyElement_get_text(body, &v);
4250 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4251 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4252 ok(bstr == NULL, "bstr != NULL\n");
4255 /* get_text - Invalid Text */
4257 V_BSTR(&v) = SysAllocString(sTextInvalid);
4258 hres = IHTMLBodyElement_put_text(body, v);
4259 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4263 hres = IHTMLBodyElement_get_text(body, &v);
4264 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4265 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4266 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4269 /* get_text - Valid Text */
4271 V_BSTR(&v) = SysAllocString(sBodyText);
4272 hres = IHTMLBodyElement_put_text(body, v);
4273 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4277 hres = IHTMLBodyElement_get_text(body, &v);
4278 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4279 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4280 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4284 static void test_body_funs(IHTMLBodyElement *body)
4286 static WCHAR sRed[] = {'r','e','d',0};
4291 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4292 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4293 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4295 V_VT(&vbg) = VT_BSTR;
4296 V_BSTR(&vbg) = SysAllocString(sRed);
4297 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4298 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4301 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4302 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4303 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4304 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4307 /* Restore Originial */
4308 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4309 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4310 VariantClear(&vDefaultbg);
4313 static void test_window(IHTMLDocument2 *doc)
4315 IHTMLWindow2 *window, *window2, *self;
4316 IHTMLDocument2 *doc2 = NULL;
4322 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4323 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4324 test_ifaces((IUnknown*)window, window_iids);
4325 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4327 hres = IHTMLWindow2_get_document(window, &doc2);
4328 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4329 ok(doc2 != NULL, "doc2 == NULL\n");
4331 test_ifaces((IUnknown*)doc2, doc_node_iids);
4332 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4334 test_ifaces((IUnknown*)doc, doc_obj_iids);
4335 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4337 unk = (void*)0xdeadbeef;
4338 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4339 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4340 ok(!unk, "unk = %p\n", unk);
4342 IHTMLDocument_Release(doc2);
4344 hres = IHTMLWindow2_get_window(window, &window2);
4345 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4346 ok(window2 != NULL, "window2 == NULL\n");
4348 hres = IHTMLWindow2_get_self(window, &self);
4349 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4350 ok(window2 != NULL, "self == NULL\n");
4352 ok(self == window2, "self != window2\n");
4354 IHTMLWindow2_Release(window2);
4355 IHTMLWindow2_Release(self);
4358 hres = IHTMLDocument2_get_Script(doc, &disp);
4359 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4360 ok(disp == (void*)window, "disp != window\n");
4361 IDispatch_Release(disp);
4363 hres = IHTMLWindow2_toString(window, NULL);
4364 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4367 hres = IHTMLWindow2_toString(window, &str);
4368 ok(hres == S_OK, "toString failed: %08x\n", hres);
4369 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4372 IHTMLWindow2_Release(window);
4375 static void test_defaults(IHTMLDocument2 *doc)
4377 IHTMLStyleSheetsCollection *stylesheetcol;
4378 IHTMLCurrentStyle *cstyle;
4379 IHTMLBodyElement *body;
4380 IHTMLElement2 *elem2;
4385 IHTMLElementCollection *collection;
4387 hres = IHTMLDocument2_get_body(doc, &elem);
4388 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4390 hres = IHTMLDocument2_get_images(doc, NULL);
4391 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4393 hres = IHTMLDocument2_get_images(doc, &collection);
4394 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4397 test_elem_collection((IUnknown*)collection, NULL, 0);
4398 IHTMLElementCollection_Release(collection);
4401 hres = IHTMLDocument2_get_applets(doc, NULL);
4402 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4404 hres = IHTMLDocument2_get_applets(doc, &collection);
4405 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4408 test_elem_collection((IUnknown*)collection, NULL, 0);
4409 IHTMLElementCollection_Release(collection);
4412 hres = IHTMLDocument2_get_links(doc, NULL);
4413 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4415 hres = IHTMLDocument2_get_links(doc, &collection);
4416 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4419 test_elem_collection((IUnknown*)collection, NULL, 0);
4420 IHTMLElementCollection_Release(collection);
4423 hres = IHTMLDocument2_get_forms(doc, NULL);
4424 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4426 hres = IHTMLDocument2_get_forms(doc, &collection);
4427 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4430 test_elem_collection((IUnknown*)collection, NULL, 0);
4431 IHTMLElementCollection_Release(collection);
4434 hres = IHTMLDocument2_get_anchors(doc, NULL);
4435 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4437 hres = IHTMLDocument2_get_anchors(doc, &collection);
4438 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4441 test_elem_collection((IUnknown*)collection, NULL, 0);
4442 IHTMLElementCollection_Release(collection);
4445 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4446 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4447 test_default_body(body);
4448 test_body_funs(body);
4449 IHTMLBodyElement_Release(body);
4451 hres = IHTMLElement_get_style(elem, &style);
4452 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4454 test_default_style(style);
4456 test_compatmode(doc);
4458 test_navigator(doc);
4460 elem2 = get_elem2_iface((IUnknown*)elem);
4461 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4462 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4463 if(SUCCEEDED(hres)) {
4464 test_current_style(cstyle);
4465 IHTMLCurrentStyle_Release(cstyle);
4467 IHTMLElement2_Release(elem2);
4469 IHTMLElement_Release(elem);
4471 test_set_csstext(style);
4472 IHTMLStyle_Release(style);
4474 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4475 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4478 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4479 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4480 ok(l == 0, "length = %d\n", l);
4482 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4484 test_default_selection(doc);
4485 test_doc_title(doc, "");
4488 static void test_tr_elem(IHTMLElement *elem)
4490 IHTMLElementCollection *col;
4494 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4496 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4497 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4502 hres = IHTMLTableRow_get_cells(row, &col);
4503 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4504 ok(col != NULL, "get_cells returned NULL\n");
4506 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4507 IHTMLElementCollection_Release(col);
4509 IHTMLTable_Release(row);
4512 static void test_table_elem(IHTMLElement *elem)
4514 IHTMLElementCollection *col;
4519 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4520 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4522 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4523 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4528 hres = IHTMLTable_get_rows(table, &col);
4529 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4530 ok(col != NULL, "get_ros returned NULL\n");
4532 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4533 IHTMLElementCollection_Release(col);
4535 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4537 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4538 test_elem_tag((IUnknown*)node, "TABLE");
4539 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4540 IHTMLDOMNode_Release(node);
4542 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4543 test_elem_tag((IUnknown*)node, "TABLE");
4544 test_elem_all((IUnknown*)node, NULL, 0);
4545 IHTMLDOMNode_Release(node);
4547 IHTMLTable_Release(table);
4550 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4560 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4561 SafeArrayAccessData(sa, (void**)&var);
4562 V_VT(var) = VT_BSTR;
4563 V_BSTR(var) = str = a2bstr(text);
4564 SafeArrayUnaccessData(sa);
4567 hres = IHTMLDocument2_writeln(doc, sa);
4569 hres = IHTMLDocument2_write(doc, sa);
4570 ok(hres == S_OK, "write failed: %08x\n", hres);
4573 SafeArrayDestroy(sa);
4576 static void test_iframe_elem(IHTMLElement *elem)
4578 IHTMLElementCollection *col;
4579 IHTMLDocument2 *content_doc;
4580 IHTMLWindow2 *content_window;
4581 IHTMLFrameBase2 *base2;
4587 static const elem_type_t all_types[] = {
4595 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4596 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4599 content_window = NULL;
4600 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4601 IHTMLFrameBase2_Release(base2);
4602 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4603 ok(content_window != NULL, "contentWindow = NULL\n");
4606 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4607 IHTMLWindow2_Release(content_window);
4608 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4609 ok(content_doc != NULL, "content_doc = NULL\n");
4611 str = a2bstr("text/html");
4612 V_VT(&errv) = VT_ERROR;
4614 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4616 ok(hres == S_OK, "open failed: %08x\n", hres);
4617 ok(disp != NULL, "disp == NULL\n");
4618 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4619 IDispatch_Release(disp);
4621 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4622 doc_write(content_doc, TRUE, "</html>");
4624 hres = IHTMLDocument2_get_all(content_doc, &col);
4625 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4626 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4627 IHTMLElementCollection_Release(col);
4629 hres = IHTMLDocument2_close(content_doc);
4630 ok(hres == S_OK, "close failed: %08x\n", hres);
4632 IHTMLDocument2_Release(content_doc);
4635 static void test_stylesheet(IDispatch *disp)
4637 IHTMLStyleSheetRulesCollection *col = NULL;
4638 IHTMLStyleSheet *stylesheet;
4641 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4642 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4644 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4645 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4646 ok(col != NULL, "col == NULL\n");
4648 IHTMLStyleSheetRulesCollection_Release(col);
4649 IHTMLStyleSheet_Release(stylesheet);
4652 static void test_stylesheets(IHTMLDocument2 *doc)
4654 IHTMLStyleSheetsCollection *col = NULL;
4659 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4660 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4661 ok(col != NULL, "col == NULL\n");
4663 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4664 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4665 ok(len == 1, "len=%d\n", len);
4671 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4672 ok(hres == S_OK, "item failed: %08x\n", hres);
4673 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4674 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4675 test_stylesheet(V_DISPATCH(&res));
4682 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4683 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4684 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4685 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4688 IHTMLStyleSheetsCollection_Release(col);
4691 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4693 IDispatchEx *dispex;
4695 DISPPARAMS dp = {NULL, NULL, 0, 0};
4703 static const WCHAR w0[] = {'0',0};
4704 static const WCHAR w100[] = {'1','0','0',0};
4706 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4707 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4709 bstr = SysAllocString(w0);
4710 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4711 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4712 SysFreeString(bstr);
4715 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4716 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4717 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4718 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4719 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4720 type = get_node_type((IUnknown*)node);
4721 ok(type == 3, "type=%d\n", type);
4722 IHTMLDOMNode_Release(node);
4725 bstr = SysAllocString(w100);
4726 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4727 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4728 SysFreeString(bstr);
4730 IDispatchEx_Release(dispex);
4735 static void test_elems(IHTMLDocument2 *doc)
4737 IHTMLElementCollection *col;
4738 IHTMLDOMChildrenCollection *child_col;
4739 IHTMLElement *elem, *elem2, *elem3;
4740 IHTMLDOMNode *node, *node2;
4744 IHTMLElementCollection *collection;
4745 IHTMLDocument3 *doc3;
4748 static const elem_type_t all_types[] = {
4773 static const elem_type_t item_types[] = {
4779 hres = IHTMLDocument2_get_all(doc, &col);
4780 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4781 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4782 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4783 IHTMLElementCollection_Release(col);
4785 hres = IHTMLDocument2_get_images(doc, &collection);
4786 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4789 static const elem_type_t images_types[] = {ET_IMG};
4790 test_elem_collection((IUnknown*)collection, images_types, 1);
4792 IHTMLElementCollection_Release(collection);
4795 hres = IHTMLDocument2_get_links(doc, &collection);
4796 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4799 static const elem_type_t images_types[] = {ET_A};
4800 test_elem_collection((IUnknown*)collection, images_types, 1);
4802 IHTMLElementCollection_Release(collection);
4805 hres = IHTMLDocument2_get_anchors(doc, &collection);
4806 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4809 static const elem_type_t anchor_types[] = {ET_A};
4810 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4812 IHTMLElementCollection_Release(collection);
4815 elem = get_doc_elem(doc);
4816 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4817 IHTMLElement_Release(elem);
4819 get_elem_by_id(doc, "xxx", FALSE);
4820 elem = get_doc_elem_by_id(doc, "xxx");
4821 ok(!elem, "elem != NULL\n");
4823 elem = get_doc_elem_by_id(doc, "s");
4824 ok(elem != NULL, "elem == NULL\n");
4826 test_elem_type((IUnknown*)elem, ET_SELECT);
4827 test_elem_attr(elem, "xxx", NULL);
4828 test_elem_attr(elem, "id", "s");
4829 test_elem_class((IUnknown*)elem, NULL);
4830 test_elem_set_class((IUnknown*)elem, "cl");
4831 test_elem_set_class((IUnknown*)elem, NULL);
4832 test_elem_tabindex((IUnknown*)elem, 0);
4833 test_elem_set_tabindex((IUnknown*)elem, 1);
4835 node = test_node_get_parent((IUnknown*)elem);
4836 ok(node != NULL, "node == NULL\n");
4837 test_node_name((IUnknown*)node, "BODY");
4838 node2 = test_node_get_parent((IUnknown*)node);
4839 IHTMLDOMNode_Release(node);
4840 ok(node2 != NULL, "node == NULL\n");
4841 test_node_name((IUnknown*)node2, "HTML");
4842 node = test_node_get_parent((IUnknown*)node2);
4843 IHTMLDOMNode_Release(node2);
4844 ok(node != NULL, "node == NULL\n");
4847 test_node_name((IUnknown*)node, "#document");
4848 type = get_node_type((IUnknown*)node);
4849 ok(type == 9, "type=%d, expected 9\n", type);
4850 node2 = test_node_get_parent((IUnknown*)node);
4851 IHTMLDOMNode_Release(node);
4852 ok(node2 == NULL, "node != NULL\n");
4855 elem2 = test_elem_get_parent((IUnknown*)elem);
4856 ok(elem2 != NULL, "elem2 == NULL\n");
4857 test_node_name((IUnknown*)elem2, "BODY");
4858 elem3 = test_elem_get_parent((IUnknown*)elem2);
4859 IHTMLElement_Release(elem2);
4860 ok(elem3 != NULL, "elem3 == NULL\n");
4861 test_node_name((IUnknown*)elem3, "HTML");
4862 elem2 = test_elem_get_parent((IUnknown*)elem3);
4863 IHTMLElement_Release(elem3);
4864 ok(elem2 == NULL, "elem2 != NULL\n");
4866 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4867 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4868 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4870 test_elem_innertext(elem, "opt1opt2");
4872 IHTMLElement_Release(elem);
4875 elem = get_elem_by_id(doc, "s", TRUE);
4877 IHTMLSelectElement *select;
4878 IHTMLDocument2 *doc_node;
4880 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4881 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4883 test_select_elem(select);
4885 test_elem_title((IUnknown*)select, NULL);
4886 test_elem_set_title((IUnknown*)select, "Title");
4887 test_elem_title((IUnknown*)select, "Title");
4888 test_elem_offset((IUnknown*)select);
4890 node = get_first_child((IUnknown*)select);
4891 ok(node != NULL, "node == NULL\n");
4893 test_elem_type((IUnknown*)node, ET_OPTION);
4894 IHTMLDOMNode_Release(node);
4897 type = get_node_type((IUnknown*)select);
4898 ok(type == 1, "type=%d\n", type);
4900 IHTMLSelectElement_Release(select);
4902 hres = IHTMLElement_get_document(elem, &disp);
4903 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4905 doc_node = get_doc_node(doc);
4906 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
4907 IHTMLDocument2_Release(doc_node);
4909 IHTMLElement_Release(elem);
4912 elem = get_elem_by_id(doc, "sc", TRUE);
4914 IHTMLScriptElement *script;
4917 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4918 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4924 hres = IHTMLScriptElement_get_type(script, &type);
4925 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4926 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4927 SysFreeString(type);
4930 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4931 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4933 hres = IHTMLScriptElement_get_defer(script, &vb);
4934 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4935 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4937 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4938 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4941 IHTMLScriptElement_Release(script);
4944 elem = get_elem_by_id(doc, "in", TRUE);
4946 IHTMLInputElement *input;
4948 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4949 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4951 test_elem_id((IUnknown*)elem, "in");
4952 test_elem_put_id((IUnknown*)elem, "newin");
4953 test_input_get_disabled(input, VARIANT_FALSE);
4954 test_input_set_disabled(input, VARIANT_TRUE);
4955 test_input_set_disabled(input, VARIANT_FALSE);
4956 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4957 test_input_get_disabled(input, VARIANT_TRUE);
4958 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4959 test_input_get_disabled(input, VARIANT_FALSE);
4960 test_elem_client_size((IUnknown*)elem);
4962 test_node_get_value_str((IUnknown*)elem, NULL);
4963 test_node_put_value_str((IUnknown*)elem, "test");
4964 test_node_get_value_str((IUnknown*)elem, NULL);
4965 test_input_value((IUnknown*)elem, NULL);
4966 test_input_put_value((IUnknown*)elem, "test");
4967 test_input_value((IUnknown*)elem, NULL);
4968 test_elem_class((IUnknown*)elem, "testclass");
4969 test_elem_tabindex((IUnknown*)elem, 2);
4970 test_elem_set_tabindex((IUnknown*)elem, 3);
4971 test_elem_title((IUnknown*)elem, "test title");
4973 test_input_get_defaultchecked(input, VARIANT_FALSE);
4974 test_input_set_defaultchecked(input, VARIANT_TRUE);
4975 test_input_set_defaultchecked(input, VARIANT_FALSE);
4977 test_input_get_checked(input, VARIANT_FALSE);
4978 test_input_set_checked(input, VARIANT_TRUE);
4979 test_input_set_checked(input, VARIANT_FALSE);
4981 test_input_src(input, NULL);
4982 test_input_set_src(input, "about:blank");
4984 IHTMLInputElement_Release(input);
4985 IHTMLElement_Release(elem);
4988 elem = get_elem_by_id(doc, "imgid", TRUE);
4990 test_img_src((IUnknown*)elem, "");
4991 test_img_set_src((IUnknown*)elem, "about:blank");
4992 test_img_alt((IUnknown*)elem, NULL);
4993 test_img_set_alt((IUnknown*)elem, "alt test");
4994 IHTMLElement_Release(elem);
4997 elem = get_doc_elem_by_id(doc, "tbl");
4998 ok(elem != NULL, "elem == NULL\n");
5000 test_table_elem(elem);
5001 IHTMLElement_Release(elem);
5004 elem = get_doc_elem_by_id(doc, "row2");
5005 ok(elem != NULL, "elem == NULL\n");
5008 IHTMLElement_Release(elem);
5011 elem = get_doc_elem_by_id(doc, "ifr");
5012 ok(elem != NULL, "elem == NULL\n");
5014 test_iframe_elem(elem);
5015 IHTMLElement_Release(elem);
5018 elem = get_elem_by_id(doc, "a", TRUE);
5020 test_anchor_href((IUnknown*)elem, "http://test/");
5021 IHTMLElement_Release(elem);
5024 hres = IHTMLDocument2_get_body(doc, &elem);
5025 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5027 node = get_first_child((IUnknown*)elem);
5028 ok(node != NULL, "node == NULL\n");
5030 test_ifaces((IUnknown*)node, text_iids);
5031 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5033 node2 = get_first_child((IUnknown*)node);
5034 ok(!node2, "node2 != NULL\n");
5036 type = get_node_type((IUnknown*)node);
5037 ok(type == 3, "type=%d\n", type);
5039 test_node_get_value_str((IUnknown*)node, "text test");
5040 test_node_put_value_str((IUnknown*)elem, "test text");
5041 test_node_get_value_str((IUnknown*)node, "text test");
5043 IHTMLDOMNode_Release(node);
5046 child_col = get_child_nodes((IUnknown*)elem);
5047 ok(child_col != NULL, "child_coll == NULL\n");
5051 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5053 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5054 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5055 ok(length, "length=0\n");
5057 node = get_child_item(child_col, 0);
5058 ok(node != NULL, "node == NULL\n");
5060 type = get_node_type((IUnknown*)node);
5061 ok(type == 3, "type=%d\n", type);
5062 IHTMLDOMNode_Release(node);
5065 node = get_child_item(child_col, 1);
5066 ok(node != NULL, "node == NULL\n");
5068 type = get_node_type((IUnknown*)node);
5069 ok(type == 8, "type=%d\n", type);
5071 test_elem_id((IUnknown*)node, NULL);
5072 IHTMLDOMNode_Release(node);
5075 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5076 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5078 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5079 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5081 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5082 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5084 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5085 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5087 test_child_col_disp(child_col);
5089 IHTMLDOMChildrenCollection_Release(child_col);
5092 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5093 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5094 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5096 IHTMLElement_Release(elem);
5098 test_stylesheets(doc);
5099 test_create_option_elem(doc);
5101 elem = get_doc_elem_by_id(doc, "tbl");
5102 ok(elem != NULL, "elem = NULL\n");
5103 test_elem_set_innertext(elem, "inner text");
5104 IHTMLElement_Release(elem);
5106 test_doc_title(doc, "test");
5107 test_doc_set_title(doc, "test title");
5108 test_doc_title(doc, "test title");
5111 hres = IHTMLDocument2_get_Script(doc, &disp);
5112 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5115 IDispatchEx *dispex;
5116 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5117 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5121 BSTR str = a2bstr("Testing");
5122 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5123 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5124 ok(pid != -1, "pid == -1\n");
5126 IDispatchEx_Release(dispex);
5129 IDispatch_Release(disp);
5131 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5132 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5134 str = a2bstr("img");
5135 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5136 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5140 static const elem_type_t img_types[] = { ET_IMG };
5142 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5143 IHTMLElementCollection_Release(col);
5146 elem = get_doc_elem_by_id(doc, "y");
5147 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5148 test_elem_innerhtml((IUnknown*)elem, "inner html");
5149 test_elem_set_innerhtml((IUnknown*)elem, "");
5150 test_elem_innerhtml((IUnknown*)elem, NULL);
5151 IHTMLElement_Release(elem);
5153 IHTMLDocument3_Release(doc3);
5156 static void test_create_elems(IHTMLDocument2 *doc)
5158 IHTMLElement *elem, *body, *elem2;
5159 IHTMLDOMNode *node, *node2, *node3, *comment;
5160 IHTMLDocument5 *doc5;
5167 static const elem_type_t types1[] = { ET_TESTG };
5169 elem = test_create_elem(doc, "TEST");
5170 test_elem_tag((IUnknown*)elem, "TEST");
5171 type = get_node_type((IUnknown*)elem);
5172 ok(type == 1, "type=%d\n", type);
5173 test_ifaces((IUnknown*)elem, elem_iids);
5174 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5176 hres = IHTMLDocument2_get_body(doc, &body);
5177 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5178 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5180 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5181 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5182 elem2 = get_elem_iface((IUnknown*)node);
5183 IHTMLElement_Release(elem2);
5185 hres = IHTMLElement_get_all(body, &disp);
5186 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5187 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5188 IDispatch_Release(disp);
5190 test_node_remove_child((IUnknown*)body, node);
5192 hres = IHTMLElement_get_all(body, &disp);
5193 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5194 test_elem_collection((IUnknown*)disp, NULL, 0);
5195 IDispatch_Release(disp);
5196 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5198 IHTMLElement_Release(elem);
5199 IHTMLDOMNode_Release(node);
5201 node = test_create_text(doc, "test");
5202 test_ifaces((IUnknown*)node, text_iids);
5203 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5205 V_VT(&var) = VT_NULL;
5206 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5207 IHTMLDOMNode_Release(node);
5209 node = test_create_text(doc, "insert ");
5211 V_VT(&var) = VT_DISPATCH;
5212 V_DISPATCH(&var) = (IDispatch*)node2;
5213 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5214 IHTMLDOMNode_Release(node);
5215 IHTMLDOMNode_Release(node2);
5216 IHTMLDOMNode_Release(node3);
5218 test_elem_innertext(body, "insert test");
5219 test_elem_innerhtml((IUnknown*)body, "insert test");
5221 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5224 str = a2bstr("testing");
5225 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5227 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5230 type = get_node_type((IUnknown*)comment);
5231 ok(type == 8, "type=%d, expected 8\n", type);
5233 test_node_get_value_str((IUnknown*)comment, "testing");
5235 IHTMLDOMNode_Release(comment);
5238 IHTMLDocument5_Release(doc5);
5241 IHTMLElement_Release(body);
5244 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5246 IOleCommandTarget *cmdtrg;
5249 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5250 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5252 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5253 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5255 IOleCommandTarget_Release(cmdtrg);
5258 static void test_indent(IHTMLDocument2 *doc)
5260 IHTMLElementCollection *col;
5261 IHTMLTxtRange *range;
5264 static const elem_type_t all_types[] = {
5273 static const elem_type_t indent_types[] = {
5284 hres = IHTMLDocument2_get_all(doc, &col);
5285 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5286 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5287 IHTMLElementCollection_Release(col);
5289 range = test_create_body_range(doc);
5290 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5291 IHTMLTxtRange_Release(range);
5293 hres = IHTMLDocument2_get_all(doc, &col);
5294 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5295 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5296 IHTMLElementCollection_Release(col);
5299 static void test_cond_comment(IHTMLDocument2 *doc)
5301 IHTMLElementCollection *col;
5304 static const elem_type_t all_types[] = {
5312 hres = IHTMLDocument2_get_all(doc, &col);
5313 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5314 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5315 IHTMLElementCollection_Release(col);
5318 static IHTMLDocument2 *notif_doc;
5319 static BOOL doc_complete;
5321 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5322 REFIID riid, void**ppv)
5324 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5329 ok(0, "unexpected call\n");
5330 return E_NOINTERFACE;
5333 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5338 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5343 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5345 if(dispID == DISPID_READYSTATE){
5349 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5350 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5352 if(!strcmp_wa(state, "complete"))
5353 doc_complete = TRUE;
5355 SysFreeString(state);
5361 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5363 ok(0, "unexpected call\n");
5367 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5368 PropertyNotifySink_QueryInterface,
5369 PropertyNotifySink_AddRef,
5370 PropertyNotifySink_Release,
5371 PropertyNotifySink_OnChanged,
5372 PropertyNotifySink_OnRequestEdit
5375 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5377 static IHTMLDocument2 *create_doc_with_string(const char *str)
5379 IPersistStreamInit *init;
5381 IHTMLDocument2 *doc;
5385 notif_doc = doc = create_document();
5389 doc_complete = FALSE;
5391 mem = GlobalAlloc(0, len);
5392 memcpy(mem, str, len);
5393 CreateStreamOnHGlobal(mem, TRUE, &stream);
5395 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5397 IPersistStreamInit_Load(init, stream);
5398 IPersistStreamInit_Release(init);
5399 IStream_Release(stream);
5404 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5406 IConnectionPointContainer *container;
5407 IConnectionPoint *cp;
5411 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5412 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5414 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5415 IConnectionPointContainer_Release(container);
5416 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5418 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5419 IConnectionPoint_Release(cp);
5420 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5423 typedef void (*domtest_t)(IHTMLDocument2*);
5425 static void run_domtest(const char *str, domtest_t test)
5427 IHTMLDocument2 *doc;
5428 IHTMLElement *body = NULL;
5433 doc = create_doc_with_string(str);
5437 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5439 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5440 TranslateMessage(&msg);
5441 DispatchMessage(&msg);
5444 hres = IHTMLDocument2_get_body(doc, &body);
5445 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5448 IHTMLElement_Release(body);
5451 skip("Could not get document body. Assuming no Gecko installed.\n");
5454 ref = IHTMLDocument2_Release(doc);
5456 ref == 1, /* Vista */
5460 static void gecko_installer_workaround(BOOL disable)
5465 static BOOL has_url = FALSE;
5466 static char url[2048];
5468 if(!disable && !has_url)
5471 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5472 if(res != ERROR_SUCCESS)
5476 DWORD type, size = sizeof(url);
5478 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5479 if(res == ERROR_SUCCESS && type == REG_SZ)
5482 RegDeleteValue(hkey, "GeckoUrl");
5484 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5492 gecko_installer_workaround(TRUE);
5495 run_domtest(doc_str1, test_doc_elem);
5496 run_domtest(doc_str1, test_get_set_attr);
5497 run_domtest(range_test_str, test_txtrange);
5498 run_domtest(range_test2_str, test_txtrange2);
5499 if (winetest_interactive || ! is_ie_hardened()) {
5500 run_domtest(elem_test_str, test_elems);
5502 skip("IE running in Enhanced Security Configuration\n");
5504 run_domtest(doc_blank, test_create_elems);
5505 run_domtest(doc_blank, test_defaults);
5506 run_domtest(indent_test_str, test_indent);
5507 run_domtest(cond_comment_str, test_cond_comment);
5510 gecko_installer_workaround(FALSE);