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 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, NULL},
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));
530 _test_disp_value(line, unk, val);
533 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
534 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
538 if(_test_get_dispid(line, unk, &iid))
539 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
540 "unexpected guid %s\n", dbgstr_guid(&iid));
542 _test_disp_value(line, unk, val);
545 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
546 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
551 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
552 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
556 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
557 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
562 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
563 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
567 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
568 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
578 #define get_node_iface(u) _get_node_iface(__LINE__,u)
579 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
584 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
585 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
589 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
590 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
595 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
596 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
600 #define get_img_iface(u) _get_img_iface(__LINE__,u)
601 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
603 IHTMLImgElement *img;
606 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
607 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
611 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
612 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
614 IHTMLDOMNode *node = _get_node_iface(line, unk);
618 hres = IHTMLDOMNode_get_nodeName(node, &name);
619 IHTMLDOMNode_Release(node);
620 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
621 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
626 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
627 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
629 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
630 IDispatch *disp = (void*)0xdeadbeef;
634 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
635 IHTMLDOMNode2_Release(node);
636 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
637 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
639 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
640 IDispatch_Release(disp);
641 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
646 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
647 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
649 IHTMLElement *elem = _get_elem_iface(line, unk);
653 hres = IHTMLElement_get_tagName(elem, &tag);
654 IHTMLElement_Release(elem);
655 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
656 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
661 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
662 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
664 _test_elem_tag(line, unk, elem_type_infos[type].tag);
665 _test_ifaces(line, unk, elem_type_infos[type].iids);
667 if(elem_type_infos[type].dispiid)
668 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
671 #define get_node_type(n) _get_node_type(__LINE__,n)
672 static LONG _get_node_type(unsigned line, IUnknown *unk)
674 IHTMLDOMNode *node = _get_node_iface(line, unk);
678 hres = IHTMLDOMNode_get_nodeType(node, &type);
679 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
681 IHTMLDOMNode_Release(node);
686 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
687 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
689 IHTMLDOMNode *node = _get_node_iface(line, unk);
690 IHTMLDOMChildrenCollection *col = NULL;
694 hres = IHTMLDOMNode_get_childNodes(node, &disp);
695 IHTMLDOMNode_Release(node);
696 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
700 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
701 IDispatch_Release(disp);
702 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
707 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
708 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
710 IHTMLDOMNode *node = NULL;
714 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
715 ok(hres == S_OK, "item failed: %08x\n", hres);
717 node = _get_node_iface(line, (IUnknown*)disp);
718 IDispatch_Release(disp);
723 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
724 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
733 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
735 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
738 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
739 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
741 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
744 VariantClear(&value);
747 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
748 static void _test_elem_offset(unsigned line, IUnknown *unk)
750 IHTMLElement *elem = _get_elem_iface(line, unk);
754 hres = IHTMLElement_get_offsetTop(elem, &l);
755 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
757 hres = IHTMLElement_get_offsetHeight(elem, &l);
758 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
760 hres = IHTMLElement_get_offsetWidth(elem, &l);
761 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
763 IHTMLElement_Release(elem);
766 #define get_doc_node(d) _get_doc_node(__LINE__,d)
767 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
769 IHTMLWindow2 *window;
773 hres = IHTMLDocument2_get_parentWindow(doc, &window);
774 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
776 hres = IHTMLWindow2_get_document(window, &ret);
777 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
778 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
783 static void test_doc_elem(IHTMLDocument2 *doc)
785 IHTMLDocument2 *doc_node, *owner_doc;
787 IHTMLDocument3 *doc3;
790 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
791 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
793 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
794 IHTMLDocument3_Release(doc3);
795 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
797 test_node_name((IUnknown*)elem, "HTML");
798 test_elem_tag((IUnknown*)elem, "HTML");
800 doc_node = get_doc_node(doc);
801 owner_doc = get_owner_doc((IUnknown*)elem);
802 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
803 IHTMLDocument2_Release(doc_node);
804 IHTMLDocument2_Release(owner_doc);
806 IHTMLElement_Release(elem);
809 static void test_get_set_attr(IHTMLDocument2 *doc)
812 IHTMLDocument3 *doc3;
817 /* grab an element to test with */
818 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
819 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
821 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
822 IHTMLDocument3_Release(doc3);
823 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
825 /* get a non-present attribute */
826 bstr = a2bstr("notAnAttribute");
827 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
828 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
829 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
833 /* get a present attribute */
834 bstr = a2bstr("scrollHeight");
835 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
836 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
837 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
841 /* create a new BSTR attribute */
842 bstr = a2bstr("newAttribute");
844 V_VT(&val) = VT_BSTR;
845 V_BSTR(&val) = a2bstr("the value");
846 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
847 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
850 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
851 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
852 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
853 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)));
856 /* overwrite the attribute with a BOOL */
857 V_VT(&val) = VT_BOOL;
858 V_BOOL(&val) = VARIANT_TRUE;
859 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
860 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
863 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
864 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
865 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
866 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
871 /* case-insensitive */
872 bstr = a2bstr("newattribute");
873 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
874 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
875 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));
876 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));
880 IHTMLElement_Release(elem);
883 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
884 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
887 IHTMLDocument3 *doc3;
890 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
891 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
892 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
893 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
894 IHTMLDocument3_Release(doc3);
899 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
900 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
905 hres = IHTMLOptionElement_get_text(option, &bstr);
906 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
907 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
911 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
912 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
918 hres = IHTMLOptionElement_put_text(option, bstr);
920 ok(hres == S_OK, "put_text failed: %08x\n", hres);
922 _test_option_text(line, option, text);
925 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
926 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
931 hres = IHTMLOptionElement_get_value(option, &bstr);
932 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
933 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
937 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
938 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
943 bstr = a2bstr(value);
944 hres = IHTMLOptionElement_put_value(option, bstr);
946 ok(hres == S_OK, "put_value failed: %08x\n", hres);
948 _test_option_value(line, option, value);
951 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
952 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
953 const char *txt, const char *val)
955 IHTMLOptionElementFactory *factory;
956 IHTMLOptionElement *option;
957 IHTMLWindow2 *window;
958 VARIANT text, value, empty;
961 hres = IHTMLDocument2_get_parentWindow(doc, &window);
962 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
964 hres = IHTMLWindow2_get_Option(window, &factory);
965 IHTMLWindow2_Release(window);
966 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
968 V_VT(&text) = VT_BSTR;
969 V_BSTR(&text) = a2bstr(txt);
970 V_VT(&value) = VT_BSTR;
971 V_BSTR(&value) = a2bstr(val);
972 V_VT(&empty) = VT_EMPTY;
974 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
975 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
977 IHTMLOptionElementFactory_Release(factory);
979 VariantClear(&value);
981 _test_option_text(line, option, txt);
982 _test_option_value(line, option, val);
987 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
988 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
990 LONG len = 0xdeadbeef;
993 hres = IHTMLSelectElement_get_length(select, &len);
994 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
995 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
998 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
999 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1001 LONG idx = 0xdeadbeef;
1004 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1005 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1006 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1009 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1010 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1014 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1015 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1016 _test_select_selidx(line, select, index);
1019 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1020 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1025 hres = IHTMLSelectElement_get_value(select, &val);
1026 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1028 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1030 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1033 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1034 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1040 hres = IHTMLSelectElement_put_value(select, bstr);
1041 SysFreeString(bstr);
1042 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1045 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1046 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1051 hres = IHTMLSelectElement_get_type(select, &type);
1052 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1053 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1056 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1057 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1062 hres = IHTMLTxtRange_get_text(range, &text);
1063 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1066 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1067 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1069 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1072 SysFreeString(text);
1076 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1077 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1081 hres = IHTMLTxtRange_collapse(range, b);
1082 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1083 _test_range_text(line, range, NULL);
1086 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1087 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1088 VARIANT_BOOL exb, const char *extext)
1090 VARIANT_BOOL b = 0xe0e0;
1093 hres = IHTMLTxtRange_expand(range, unit, &b);
1094 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1095 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1096 _test_range_text(line, range, extext);
1099 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1100 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1102 LONG c = 0xdeadbeef;
1105 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1106 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1107 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1108 _test_range_text(line, range, NULL);
1111 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1112 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1113 LPWSTR unit, LONG cnt, LONG excnt)
1115 LONG c = 0xdeadbeef;
1118 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1119 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1120 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1123 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1124 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1126 LONG c = 0xdeadbeef;
1129 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1130 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1131 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1134 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1135 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1138 BSTR bstr = a2bstr(text);
1140 hres = IHTMLTxtRange_put_text(range, bstr);
1141 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1142 SysFreeString(bstr);
1143 _test_range_text(line, range, NULL);
1146 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1147 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1153 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1154 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1155 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1158 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1159 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1165 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1166 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1167 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1170 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1171 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1172 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1175 test_range_inrange(range1, range2, VARIANT_TRUE);
1176 test_range_inrange(range2, range1, VARIANT_TRUE);
1180 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1181 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1186 hres = IHTMLTxtRange_parentElement(range, &elem);
1187 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1189 _test_elem_type(line, (IUnknown*)elem, type);
1191 IHTMLElement_Release(elem);
1194 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1195 static void _test_elem_collection(unsigned line, IUnknown *unk,
1196 const elem_type_t *elem_types, LONG exlen)
1198 IHTMLElementCollection *col;
1201 VARIANT name, index;
1202 IDispatch *disp, *disp2;
1205 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1206 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1208 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1210 hres = IHTMLElementCollection_get_length(col, &len);
1211 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1212 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1217 V_VT(&index) = VT_EMPTY;
1219 for(i=0; i<len; i++) {
1220 V_VT(&name) = VT_I4;
1222 disp = (void*)0xdeadbeef;
1223 hres = IHTMLElementCollection_item(col, name, index, &disp);
1224 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1225 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1226 if(FAILED(hres) || !disp)
1229 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1232 V_VT(&name) = VT_UINT;
1234 disp2 = (void*)0xdeadbeef;
1235 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1236 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1237 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1239 IDispatch_Release(disp2);
1242 IDispatch_Release(disp);
1245 V_VT(&name) = VT_I4;
1247 disp = (void*)0xdeadbeef;
1248 hres = IHTMLElementCollection_item(col, name, index, &disp);
1249 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1250 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1252 V_VT(&name) = VT_I4;
1254 disp = (void*)0xdeadbeef;
1255 hres = IHTMLElementCollection_item(col, name, index, &disp);
1256 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1257 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1259 IHTMLElementCollection_Release(col);
1262 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1263 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1265 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1266 IHTMLElementCollection *col = NULL;
1267 elem_type_t *types = NULL;
1272 tmp = a2bstr(elem_type_infos[type].tag);
1273 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1275 IHTMLElement2_Release(elem);
1276 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1277 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1280 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1281 for(i=0; i<exlen; i++)
1285 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1287 HeapFree(GetProcessHeap(), 0, types);
1290 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1291 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1296 hres = IHTMLElement_get_innerText(elem, &text);
1297 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1298 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1299 wine_dbgstr_w(text), extext);
1300 SysFreeString(text);
1303 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1304 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1306 IHTMLDOMChildrenCollection *col;
1311 hres = IHTMLElement_put_innerText(elem, str);
1312 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1315 _test_elem_innertext(line, elem, text);
1318 col = _get_child_nodes(line, (IUnknown*)elem);
1319 ok(col != NULL, "col == NULL\n");
1321 LONG length = 0, type;
1324 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1325 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1326 ok(length == 1, "length = %d\n", length);
1328 node = _get_child_item(line, col, 0);
1329 ok(node != NULL, "node == NULL\n");
1331 type = _get_node_type(line, (IUnknown*)node);
1332 ok(type == 3, "type=%d\n", type);
1333 IHTMLDOMNode_Release(node);
1336 IHTMLDOMChildrenCollection_Release(col);
1341 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1342 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1344 IHTMLElement *elem = _get_elem_iface(line, unk);
1348 hres = IHTMLElement_get_innerHTML(elem, &html);
1349 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1351 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1353 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1355 IHTMLElement_Release(elem);
1356 SysFreeString(html);
1359 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1360 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1362 IHTMLElement *elem = _get_elem_iface(line, unk);
1366 html = a2bstr(inner_html);
1367 hres = IHTMLElement_put_innerHTML(elem, html);
1368 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1370 IHTMLElement_Release(elem);
1371 SysFreeString(html);
1374 #define get_first_child(n) _get_first_child(__LINE__,n)
1375 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1377 IHTMLDOMNode *node = _get_node_iface(line, unk);
1378 IHTMLDOMNode *child = NULL;
1381 hres = IHTMLDOMNode_get_firstChild(node, &child);
1382 IHTMLDOMNode_Release(node);
1383 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1388 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1389 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1391 IHTMLDOMNode *node = _get_node_iface(line, unk);
1392 VARIANT_BOOL b = 0xdead;
1395 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1396 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1397 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1399 IHTMLDOMNode_Release(node);
1402 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1403 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1405 IHTMLDOMNode *node = _get_node_iface(line, unk);
1406 IHTMLDOMNode *parent;
1409 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1410 IHTMLDOMNode_Release(node);
1411 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1416 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1417 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1419 IHTMLElement *elem = _get_elem_iface(line, unk);
1420 IHTMLElement *parent;
1423 hres = IHTMLElement_get_parentElement(elem, &parent);
1424 IHTMLElement_Release(elem);
1425 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1430 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1431 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1433 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1434 VARIANT_BOOL disabled = 100;
1438 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1439 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1440 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1441 IHTMLElement3_Release(elem3);
1444 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1445 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1447 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1451 hres = IHTMLElement3_put_disabled(elem3, b);
1452 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1454 IHTMLElement3_Release(elem3);
1455 _test_elem3_get_disabled(line, unk, b);
1458 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1459 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1461 VARIANT_BOOL disabled = 100;
1464 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1465 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1466 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1468 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1471 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1472 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1476 hres = IHTMLSelectElement_put_disabled(select, b);
1477 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1479 _test_select_get_disabled(line, select, b);
1482 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1483 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1485 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1486 IHTMLTextContainer *txtcont;
1487 LONG l = -1, l2 = -1;
1490 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1491 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1492 IHTMLElement2_Release(elem);
1494 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1495 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1497 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1498 IHTMLTextContainer_Release(txtcont);
1499 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1500 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1505 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1506 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1508 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1509 IHTMLTextContainer *txtcont;
1510 LONG l = -1, l2 = -1;
1513 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1514 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1515 IHTMLElement2_Release(elem);
1517 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1518 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1520 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1521 IHTMLTextContainer_Release(txtcont);
1522 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1523 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1528 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1529 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1531 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1532 IHTMLTextContainer *txtcont;
1533 LONG l = -1, l2 = -1;
1536 hres = IHTMLElement2_get_scrollTop(elem, &l);
1537 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1538 IHTMLElement2_Release(elem);
1540 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1541 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1543 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1544 IHTMLTextContainer_Release(txtcont);
1545 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1546 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1551 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1552 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1554 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1555 IHTMLTextContainer *txtcont;
1556 LONG l = -1, l2 = -1;
1559 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1560 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1562 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1563 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1564 IHTMLElement2_Release(elem);
1566 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1567 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1569 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1570 IHTMLTextContainer_Release(txtcont);
1571 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1572 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1575 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1576 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1578 IHTMLImgElement *img = _get_img_iface(line, unk);
1582 hres = IHTMLImgElement_get_src(img, &src);
1583 IHTMLImgElement_Release(img);
1584 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1585 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1589 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1590 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1592 IHTMLImgElement *img = _get_img_iface(line, unk);
1597 hres = IHTMLImgElement_put_src(img, tmp);
1598 IHTMLImgElement_Release(img);
1600 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1602 _test_img_src(line, unk, src);
1605 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1606 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1608 IHTMLImgElement *img = _get_img_iface(line, unk);
1612 hres = IHTMLImgElement_get_alt(img, &alt);
1613 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1615 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1617 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1621 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1622 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1624 IHTMLImgElement *img = _get_img_iface(line, unk);
1629 hres = IHTMLImgElement_put_alt(img, tmp);
1630 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1633 _test_img_alt(line, unk, alt);
1636 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1637 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1639 VARIANT_BOOL disabled = 100;
1642 hres = IHTMLInputElement_get_disabled(input, &disabled);
1643 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1644 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1646 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1649 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1650 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1654 hres = IHTMLInputElement_put_disabled(input, b);
1655 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1657 _test_input_get_disabled(line, input, b);
1660 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1661 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1663 VARIANT_BOOL checked = 100;
1666 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1667 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1668 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1671 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1672 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1676 hres = IHTMLInputElement_put_defaultChecked(input, b);
1677 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1679 _test_input_get_defaultchecked(line, input, b);
1682 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1683 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1685 VARIANT_BOOL checked = 100;
1688 hres = IHTMLInputElement_get_checked(input, &checked);
1689 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1690 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1693 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1694 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1698 hres = IHTMLInputElement_put_checked(input, b);
1699 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1701 _test_input_get_checked(line, input, b);
1704 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1705 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1707 IHTMLInputElement *input;
1711 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1712 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1716 hres = IHTMLInputElement_get_value(input, &bstr);
1717 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1719 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1721 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1722 SysFreeString(bstr);
1723 IHTMLInputElement_Release(input);
1726 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1727 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1729 IHTMLInputElement *input;
1733 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1734 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1739 hres = IHTMLInputElement_get_value(input, &bstr);
1740 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1741 SysFreeString(bstr);
1742 IHTMLInputElement_Release(input);
1745 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1746 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1751 hres = IHTMLInputElement_get_src(input, &src);
1752 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1754 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1756 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1760 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1761 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1767 hres = IHTMLInputElement_put_src(input, tmp);
1769 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1771 _test_input_src(line, input, src);
1774 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1775 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1777 IHTMLElement *elem = _get_elem_iface(line, unk);
1778 BSTR class = (void*)0xdeadbeef;
1781 hres = IHTMLElement_get_className(elem, &class);
1782 IHTMLElement_Release(elem);
1783 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1785 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1787 ok_(__FILE__,line) (!class, "class != NULL\n");
1788 SysFreeString(class);
1791 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1792 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1794 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1798 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1799 IHTMLElement2_Release(elem2);
1800 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1801 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1804 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1805 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1807 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1810 hres = IHTMLElement2_put_tabIndex(elem2, index);
1811 IHTMLElement2_Release(elem2);
1812 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1814 _test_elem_tabindex(line, unk, index);
1817 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1818 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1820 IHTMLElement *elem = _get_elem_iface(line, unk);
1824 tmp = class ? a2bstr(class) : NULL;
1825 hres = IHTMLElement_put_className(elem, tmp);
1826 IHTMLElement_Release(elem);
1827 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1830 _test_elem_class(line, unk, class);
1833 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1834 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1836 IHTMLElement *elem = _get_elem_iface(line, unk);
1837 BSTR id = (void*)0xdeadbeef;
1840 hres = IHTMLElement_get_id(elem, &id);
1841 IHTMLElement_Release(elem);
1842 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1845 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1847 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1852 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1853 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1855 IHTMLElement *elem = _get_elem_iface(line, unk);
1856 BSTR tmp = a2bstr(new_id);
1859 hres = IHTMLElement_put_id(elem, tmp);
1860 IHTMLElement_Release(elem);
1862 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1864 _test_elem_id(line, unk, new_id);
1867 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1868 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1870 IHTMLElement *elem = _get_elem_iface(line, unk);
1874 hres = IHTMLElement_get_title(elem, &title);
1875 IHTMLElement_Release(elem);
1876 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1878 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1880 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1882 SysFreeString(title);
1885 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1886 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1888 IHTMLElement *elem = _get_elem_iface(line, unk);
1892 tmp = a2bstr(title);
1893 hres = IHTMLElement_put_title(elem, tmp);
1894 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1896 IHTMLElement_Release(elem);
1900 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1901 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1903 IHTMLDOMNode *node = _get_node_iface(line, unk);
1907 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1908 IHTMLDOMNode_Release(node);
1909 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1912 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
1913 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
1915 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
1921 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1922 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
1924 IHTMLDOMNode *node = _get_node_iface(line, unk);
1928 V_VT(&var) = VT_BSTR;
1929 V_BSTR(&var) = a2bstr(val);
1931 hres = IHTMLDOMNode_put_nodeValue(node, var);
1932 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1933 IHTMLDOMNode_Release(node);
1937 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1938 static void _test_elem_client_size(unsigned line, IUnknown *unk)
1940 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1944 hres = IHTMLElement2_get_clientWidth(elem, &l);
1945 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
1946 hres = IHTMLElement2_get_clientHeight(elem, &l);
1947 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
1949 IHTMLElement2_Release(elem);
1952 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1953 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
1955 IHTMLElement *elem = NULL;
1960 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
1961 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1962 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
1967 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1968 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
1970 IHTMLDocument3 *doc3;
1971 IHTMLDOMNode *node = NULL;
1975 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1976 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
1979 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
1980 IHTMLDocument3_Release(doc3);
1981 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
1982 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
1987 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1988 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
1990 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
1991 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
1992 IHTMLDOMNode *new_child = NULL;
1995 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
1996 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
1997 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
1998 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2000 IHTMLDOMNode_Release(node);
2001 IHTMLDOMNode_Release(child);
2006 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2007 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2009 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2010 IHTMLDOMNode *new_child = NULL;
2013 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2014 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2015 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2016 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2018 IHTMLDOMNode_Release(node);
2023 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2024 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2026 IHTMLDOMNode *node = _get_node_iface(line, unk);
2027 IHTMLDOMNode *new_node = NULL;
2030 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2031 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2032 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2033 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2035 IHTMLDOMNode_Release(node);
2036 IHTMLDOMNode_Release(new_node);
2039 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2040 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2045 hres = IHTMLDocument2_get_title(doc, &title);
2046 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2047 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2048 SysFreeString(title);
2051 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2052 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2057 tmp = a2bstr(title);
2058 hres = IHTMLDocument2_put_title(doc, tmp);
2059 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2063 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2064 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2069 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2070 LOCALE_USER_DEFAULT, &dispid);
2071 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2074 DISPPARAMS params = {NULL,NULL,0,0};
2075 DISPID dispidNamed = DISPID_PROPERTYPUT;
2080 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2081 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2082 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2085 params.cNamedArgs = 1;
2086 params.rgdispidNamedArgs = &dispidNamed;
2087 V_VT(&arg) = VT_BSTR;
2088 V_BSTR(&arg) = a2bstr("none");
2089 params.rgvarg = &arg;
2090 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2091 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2092 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2095 V_VT(&arg) = VT_BSTR;
2096 V_BSTR(&arg) = a2bstr("dotted");
2097 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2098 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2099 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2102 V_VT(&arg) = VT_BSTR;
2103 V_BSTR(&arg) = a2bstr("dashed");
2104 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2105 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2106 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2109 V_VT(&arg) = VT_BSTR;
2110 V_BSTR(&arg) = a2bstr("solid");
2111 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2112 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2113 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2116 V_VT(&arg) = VT_BSTR;
2117 V_BSTR(&arg) = a2bstr("double");
2118 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2119 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2120 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2123 V_VT(&arg) = VT_BSTR;
2124 V_BSTR(&arg) = a2bstr("groove");
2125 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2126 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2127 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2130 V_VT(&arg) = VT_BSTR;
2131 V_BSTR(&arg) = a2bstr("ridge");
2132 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2133 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2134 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2137 V_VT(&arg) = VT_BSTR;
2138 V_BSTR(&arg) = a2bstr("inset");
2139 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2140 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2141 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2144 V_VT(&arg) = VT_BSTR;
2145 V_BSTR(&arg) = a2bstr("outset");
2146 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2147 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2148 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2151 V_VT(&arg) = VT_BSTR;
2152 V_BSTR(&arg) = a2bstr("invalid");
2153 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2154 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2155 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2158 params.rgvarg = &vDefault;
2159 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2160 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2161 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2165 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2166 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2168 BSTR text = (void*)0xdeadbeef;
2171 hres = IHTMLStyle_get_cssText(style, &text);
2172 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2174 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2176 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2178 SysFreeString(text);
2181 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2182 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2188 hres = IHTMLStyle_put_cssText(style, tmp);
2189 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2193 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2194 const elem_type_t *elem_types, LONG len)
2197 VARIANT name, index;
2201 V_VT(&index) = VT_EMPTY;
2202 V_VT(&name) = VT_BSTR;
2203 V_BSTR(&name) = a2bstr(n);
2205 hres = IHTMLElementCollection_item(col, name, index, &disp);
2206 ok(hres == S_OK, "item failed: %08x\n", hres);
2208 test_elem_collection((IUnknown*)disp, elem_types, len);
2209 IDispatch_Release(disp);
2210 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2214 V_VT(&index) = VT_I4;
2216 for(i=0; i<len; i++) {
2218 disp = (void*)0xdeadbeef;
2219 hres = IHTMLElementCollection_item(col, name, index, &disp);
2220 ok(hres == S_OK, "item failed: %08x\n", hres);
2221 ok(disp != NULL, "disp == NULL\n");
2222 if(FAILED(hres) || !disp)
2225 test_elem_type((IUnknown*)disp, elem_types[i]);
2227 IDispatch_Release(disp);
2231 disp = (void*)0xdeadbeef;
2232 hres = IHTMLElementCollection_item(col, name, index, &disp);
2233 ok(hres == S_OK, "item failed: %08x\n", hres);
2234 ok(disp == NULL, "disp != NULL\n");
2237 disp = (void*)0xdeadbeef;
2238 hres = IHTMLElementCollection_item(col, name, index, &disp);
2239 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2240 ok(disp == NULL, "disp != NULL\n");
2243 SysFreeString(V_BSTR(&name));
2246 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2248 IHTMLElementCollection *col;
2250 IDispatch *disp = (void*)0xdeadbeef;
2251 VARIANT name, index;
2254 hres = IHTMLDocument2_get_all(doc, &col);
2255 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2256 ok(col != NULL, "col == NULL\n");
2257 if(FAILED(hres) || !col)
2260 V_VT(&index) = VT_EMPTY;
2261 V_VT(&name) = VT_BSTR;
2262 V_BSTR(&name) = a2bstr(id);
2264 hres = IHTMLElementCollection_item(col, name, index, &disp);
2265 IHTMLElementCollection_Release(col);
2266 SysFreeString(V_BSTR(&name));
2267 ok(hres == S_OK, "item failed: %08x\n", hres);
2268 if(!expect_success) {
2269 ok(disp == NULL, "disp != NULL\n");
2273 ok(disp != NULL, "disp == NULL\n");
2277 elem = get_elem_iface((IUnknown*)disp);
2278 IDispatch_Release(disp);
2283 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2285 IHTMLDocument3 *doc3;
2290 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2291 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2294 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2296 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2298 IHTMLDocument3_Release(doc3);
2303 static void test_select_elem(IHTMLSelectElement *select)
2305 test_select_type(select, "select-one");
2306 test_select_length(select, 2);
2307 test_select_selidx(select, 0);
2308 test_select_put_selidx(select, 1);
2310 test_select_set_value(select, "val1");
2311 test_select_value(select, "val1");
2313 test_select_get_disabled(select, VARIANT_FALSE);
2314 test_select_set_disabled(select, VARIANT_TRUE);
2315 test_select_set_disabled(select, VARIANT_FALSE);
2318 static void test_create_option_elem(IHTMLDocument2 *doc)
2320 IHTMLOptionElement *option;
2322 option = create_option_elem(doc, "test text", "test value");
2324 test_option_put_text(option, "new text");
2325 test_option_put_value(option, "new value");
2327 IHTMLOptionElement_Release(option);
2330 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2332 IHTMLBodyElement *body;
2333 IHTMLTxtRange *range;
2337 hres = IHTMLDocument2_get_body(doc, &elem);
2338 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2340 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2341 IHTMLElement_Release(elem);
2343 hres = IHTMLBodyElement_createTextRange(body, &range);
2344 IHTMLBodyElement_Release(body);
2345 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2350 static void test_txtrange(IHTMLDocument2 *doc)
2352 IHTMLTxtRange *body_range, *range, *range2;
2353 IHTMLSelectionObject *selection;
2354 IDispatch *disp_range;
2357 body_range = test_create_body_range(doc);
2359 test_range_text(body_range, "test abc 123\r\nit's text");
2361 hres = IHTMLTxtRange_duplicate(body_range, &range);
2362 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2364 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2365 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2366 test_range_isequal(range, range2, VARIANT_TRUE);
2368 test_range_text(range, "test abc 123\r\nit's text");
2369 test_range_text(body_range, "test abc 123\r\nit's text");
2371 test_range_collapse(range, TRUE);
2372 test_range_isequal(range, range2, VARIANT_FALSE);
2373 test_range_inrange(range, range2, VARIANT_FALSE);
2374 test_range_inrange(range2, range, VARIANT_TRUE);
2375 IHTMLTxtRange_Release(range2);
2377 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2378 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2379 test_range_move(range, characterW, 2, 2);
2380 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2382 test_range_collapse(range, FALSE);
2383 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2385 test_range_collapse(range, FALSE);
2386 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2387 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2388 test_range_move(range, characterW, 2, 2);
2389 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2390 test_range_moveend(range, characterW, -5, -5);
2391 test_range_text(range, NULL);
2392 test_range_moveend(range, characterW, 3, 3);
2393 test_range_text(range, "c 1");
2394 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2395 test_range_collapse(range, TRUE);
2396 test_range_move(range, characterW, 4, 4);
2397 test_range_moveend(range, characterW, 1, 1);
2398 test_range_text(range, " ");
2399 test_range_move(range, wordW, 1, 1);
2400 test_range_moveend(range, characterW, 2, 2);
2401 test_range_text(range, "ab");
2403 IHTMLTxtRange_Release(range);
2405 hres = IHTMLTxtRange_duplicate(body_range, &range);
2406 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2408 test_range_text(range, "test abc 123\r\nit's text");
2409 test_range_move(range, characterW, 3, 3);
2410 test_range_moveend(range, characterW, 1, 1);
2411 test_range_text(range, "t");
2412 test_range_moveend(range, characterW, 3, 3);
2413 test_range_text(range, "t ab");
2414 test_range_moveend(range, characterW, -2, -2);
2415 test_range_text(range, "t ");
2416 test_range_move(range, characterW, 6, 6);
2417 test_range_moveend(range, characterW, 3, 3);
2418 test_range_text(range, "123");
2419 test_range_moveend(range, characterW, 2, 2);
2420 test_range_text(range, "123\r\ni");
2422 IHTMLTxtRange_Release(range);
2424 hres = IHTMLTxtRange_duplicate(body_range, &range);
2425 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2427 test_range_move(range, wordW, 1, 1);
2428 test_range_moveend(range, characterW, 2, 2);
2429 test_range_text(range, "ab");
2431 test_range_move(range, characterW, -2, -2);
2432 test_range_moveend(range, characterW, 2, 2);
2433 test_range_text(range, "t ");
2435 test_range_move(range, wordW, 3, 3);
2436 test_range_move(range, wordW, -2, -2);
2437 test_range_moveend(range, characterW, 2, 2);
2438 test_range_text(range, "ab");
2440 test_range_move(range, characterW, -6, -5);
2441 test_range_moveend(range, characterW, -1, 0);
2442 test_range_moveend(range, characterW, -6, 0);
2443 test_range_move(range, characterW, 2, 2);
2444 test_range_moveend(range, characterW, 2, 2);
2445 test_range_text(range, "st");
2446 test_range_moveend(range, characterW, -6, -4);
2447 test_range_moveend(range, characterW, 2, 2);
2449 IHTMLTxtRange_Release(range);
2451 hres = IHTMLTxtRange_duplicate(body_range, &range);
2452 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2454 test_range_move(range, wordW, 2, 2);
2455 test_range_moveend(range, characterW, 2, 2);
2456 test_range_text(range, "12");
2458 test_range_move(range, characterW, 15, 14);
2459 test_range_move(range, characterW, -2, -2);
2460 test_range_moveend(range, characterW, 3, 2);
2461 test_range_text(range, "t");
2462 test_range_moveend(range, characterW, -1, -1);
2463 test_range_text(range, "t");
2464 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2465 test_range_move(range, characterW, -2, -2);
2466 test_range_moveend(range, characterW, 2, 2);
2467 test_range_text(range, "s ");
2468 test_range_move(range, characterW, 100, 7);
2469 test_range_move(range, wordW, 1, 0);
2470 test_range_move(range, characterW, -2, -2);
2471 test_range_moveend(range, characterW, 3, 2);
2472 test_range_text(range, "t");
2474 IHTMLTxtRange_Release(range);
2476 hres = IHTMLTxtRange_duplicate(body_range, &range);
2477 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2479 test_range_collapse(range, TRUE);
2480 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2481 test_range_put_text(range, "word");
2482 test_range_text(body_range, "wordabc 123\r\nit's text");
2483 test_range_text(range, NULL);
2484 test_range_moveend(range, characterW, 3, 3);
2485 test_range_text(range, "abc");
2486 test_range_movestart(range, characterW, -2, -2);
2487 test_range_text(range, "rdabc");
2488 test_range_movestart(range, characterW, 3, 3);
2489 test_range_text(range, "bc");
2490 test_range_movestart(range, characterW, 4, 4);
2491 test_range_text(range, NULL);
2492 test_range_movestart(range, characterW, -3, -3);
2493 test_range_text(range, "c 1");
2494 test_range_movestart(range, characterW, -7, -6);
2495 test_range_text(range, "wordabc 1");
2496 test_range_movestart(range, characterW, 100, 22);
2497 test_range_text(range, NULL);
2499 IHTMLTxtRange_Release(range);
2500 IHTMLTxtRange_Release(body_range);
2502 hres = IHTMLDocument2_get_selection(doc, &selection);
2503 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2505 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2506 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2507 IHTMLSelectionObject_Release(selection);
2509 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2510 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2511 IDispatch_Release(disp_range);
2513 test_range_text(range, NULL);
2514 test_range_moveend(range, characterW, 3, 3);
2515 test_range_text(range, "wor");
2516 test_range_parent(range, ET_BODY);
2517 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2518 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2519 test_range_move(range, characterW, 3, 3);
2520 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2521 test_range_moveend(range, characterW, -4, -4);
2522 test_range_put_text(range, "abc def ");
2523 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2524 test_range_move(range, wordW, 1, 1);
2525 test_range_movestart(range, characterW, -1, -1);
2526 test_range_text(range, " ");
2527 test_range_move(range, wordW, 1, 1);
2528 test_range_moveend(range, characterW, 3, 3);
2529 test_range_text(range, "def");
2530 test_range_put_text(range, "xyz");
2531 test_range_moveend(range, characterW, 1, 1);
2532 test_range_move(range, wordW, 1, 1);
2533 test_range_moveend(range, characterW, 2, 2);
2534 test_range_text(range, "ab");
2536 IHTMLTxtRange_Release(range);
2539 static void test_txtrange2(IHTMLDocument2 *doc)
2541 IHTMLTxtRange *range;
2543 range = test_create_body_range(doc);
2545 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2546 test_range_move(range, characterW, 5, 5);
2547 test_range_moveend(range, characterW, 1, 1);
2548 test_range_text(range, "2");
2549 test_range_move(range, characterW, -3, -3);
2550 test_range_moveend(range, characterW, 3, 3);
2551 test_range_text(range, "c\r\n\r\n1");
2552 test_range_collapse(range, VARIANT_FALSE);
2553 test_range_moveend(range, characterW, 4, 4);
2554 test_range_text(range, "23");
2555 test_range_moveend(range, characterW, 1, 1);
2556 test_range_text(range, "23\r\n\r\n\r\nd");
2557 test_range_moveend(range, characterW, -1, -1);
2558 test_range_text(range, "23");
2559 test_range_moveend(range, characterW, -1, -1);
2560 test_range_text(range, "23");
2561 test_range_moveend(range, characterW, -2, -2);
2562 test_range_text(range, "2");
2564 IHTMLTxtRange_Release(range);
2567 static void test_compatmode(IHTMLDocument2 *doc)
2569 IHTMLDocument5 *doc5;
2573 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2574 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2578 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2579 IHTMLDocument5_Release(doc5);
2580 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2581 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2582 SysFreeString(mode);
2585 static void test_location(IHTMLDocument2 *doc)
2587 IHTMLLocation *location, *location2;
2588 IHTMLWindow2 *window;
2593 hres = IHTMLDocument2_get_location(doc, &location);
2594 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2596 hres = IHTMLDocument2_get_location(doc, &location2);
2597 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2599 ok(location == location2, "location != location2\n");
2600 IHTMLLocation_Release(location2);
2602 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2603 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2605 hres = IHTMLWindow2_get_location(window, &location2);
2606 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2607 ok(location == location2, "location != location2\n");
2608 IHTMLLocation_Release(location2);
2610 test_ifaces((IUnknown*)location, location_iids);
2611 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2613 hres = IHTMLLocation_get_pathname(location, &str);
2614 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2615 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2617 hres = IHTMLLocation_get_href(location, NULL);
2618 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2620 hres = IHTMLLocation_get_href(location, &str);
2621 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2622 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2624 ref = IHTMLLocation_Release(location);
2625 ok(!ref, "location chould be destroyed here\n");
2628 static void test_navigator(IHTMLDocument2 *doc)
2630 IHTMLWindow2 *window;
2631 IOmNavigator *navigator, *navigator2;
2638 static const WCHAR v40[] = {'4','.','0'};
2640 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2641 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2643 hres = IHTMLWindow2_get_navigator(window, &navigator);
2644 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2645 ok(navigator != NULL, "navigator == NULL\n");
2646 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2648 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2649 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2650 ok(navigator != navigator2, "navigator2 != navihgator\n");
2652 IHTMLWindow2_Release(window);
2653 IOmNavigator_Release(navigator2);
2655 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2656 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2657 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2658 SysFreeString(bstr);
2661 hres = IOmNavigator_get_appName(navigator, &bstr);
2662 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2663 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2664 SysFreeString(bstr);
2667 hres = IOmNavigator_get_platform(navigator, &bstr);
2668 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2670 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2672 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2674 SysFreeString(bstr);
2677 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2678 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2679 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2680 SysFreeString(bstr);
2682 hres = IOmNavigator_toString(navigator, NULL);
2683 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2686 hres = IOmNavigator_toString(navigator, &bstr);
2687 ok(hres == S_OK, "toString failed: %08x\n", hres);
2688 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2689 SysFreeString(bstr);
2692 hres = ObtainUserAgentString(0, buf, &size);
2693 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2696 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2697 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2698 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2699 SysFreeString(bstr);
2701 ref = IOmNavigator_Release(navigator);
2702 ok(!ref, "navigator should be destroyed here\n");
2705 static void test_current_style(IHTMLCurrentStyle *current_style)
2711 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2712 test_ifaces((IUnknown*)current_style, cstyle_iids);
2714 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2715 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2716 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2719 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2720 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2721 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2724 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2725 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2728 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2729 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2730 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2733 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2734 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2735 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2738 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2739 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2740 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2743 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2744 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2745 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2748 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2749 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2750 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2753 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2754 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2755 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2758 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2759 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2760 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2763 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2764 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2765 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2768 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2769 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2770 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2773 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2774 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2775 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2778 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2779 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2780 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2783 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2784 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2787 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2788 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2791 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2792 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2795 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2796 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2799 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2800 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2803 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2804 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2807 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2808 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2809 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2810 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2813 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2814 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2815 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2818 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2819 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2820 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2823 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2824 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2825 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2828 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2829 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2830 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2833 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2834 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2835 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2838 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2839 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2840 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2843 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2844 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2845 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2846 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2849 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2850 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2851 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2852 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2855 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2856 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2857 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2860 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2861 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2862 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2865 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2866 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2867 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2871 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2872 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2873 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2876 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2877 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2878 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2881 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2882 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2883 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2886 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2887 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2888 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2891 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2892 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2893 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2896 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
2897 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
2898 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2901 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
2902 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
2903 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2906 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
2907 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
2908 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2911 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
2912 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
2913 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2916 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
2917 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
2918 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2921 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
2922 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2923 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2926 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
2927 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
2928 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2931 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
2932 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
2933 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2936 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
2937 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
2938 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2941 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
2942 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
2943 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2946 hres = IHTMLCurrentStyle_get_right(current_style, &v);
2947 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
2948 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2951 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
2952 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
2953 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2956 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
2957 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
2958 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2961 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
2962 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
2963 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2967 static void test_style2(IHTMLStyle2 *style2)
2972 str = (void*)0xdeadbeef;
2973 hres = IHTMLStyle2_get_position(style2, &str);
2974 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2975 ok(!str, "str != NULL\n");
2977 str = a2bstr("absolute");
2978 hres = IHTMLStyle2_put_position(style2, str);
2979 ok(hres == S_OK, "put_position failed: %08x\n", hres);
2983 hres = IHTMLStyle2_get_position(style2, &str);
2984 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2985 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2989 static void test_style3(IHTMLStyle3 *style3)
2994 str = (void*)0xdeadbeef;
2995 hres = IHTMLStyle3_get_wordWrap(style3, &str);
2996 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
2997 ok(!str, "str != NULL\n");
2999 str = a2bstr("break-word");
3000 hres = IHTMLStyle3_put_wordWrap(style3, str);
3001 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3005 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3006 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3007 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3011 static void test_style4(IHTMLStyle4 *style4)
3017 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3018 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3021 V_BSTR(&v) = a2bstr("10px");
3022 hres = IHTMLStyle4_put_minHeight(style4, v);
3023 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3026 hres = IHTMLStyle4_get_minHeight(style4, &v);
3027 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3028 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3029 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3031 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3032 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3033 VariantClear(&vdefault);
3036 static void test_default_style(IHTMLStyle *style)
3038 IHTMLStyle2 *style2;
3039 IHTMLStyle3 *style3;
3040 IHTMLStyle4 *style4;
3046 BSTR sOverflowDefault;
3050 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3051 test_ifaces((IUnknown*)style, style_iids);
3053 test_style_csstext(style, NULL);
3055 hres = IHTMLStyle_get_position(style, &str);
3056 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3057 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3060 hres = IHTMLStyle_get_marginRight(style, &v);
3061 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3062 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3063 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3066 hres = IHTMLStyle_get_marginLeft(style, &v);
3067 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3068 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3069 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3071 str = (void*)0xdeadbeef;
3072 hres = IHTMLStyle_get_fontFamily(style, &str);
3073 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3074 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3076 str = (void*)0xdeadbeef;
3077 hres = IHTMLStyle_get_fontWeight(style, &str);
3078 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3079 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3081 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3082 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3084 str = a2bstr("test");
3085 hres = IHTMLStyle_put_fontWeight(style, str);
3086 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3089 str = a2bstr("bold");
3090 hres = IHTMLStyle_put_fontWeight(style, str);
3091 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3094 str = a2bstr("bolder");
3095 hres = IHTMLStyle_put_fontWeight(style, str);
3096 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3099 str = a2bstr("lighter");
3100 hres = IHTMLStyle_put_fontWeight(style, str);
3101 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3104 str = a2bstr("100");
3105 hres = IHTMLStyle_put_fontWeight(style, str);
3106 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3109 str = a2bstr("200");
3110 hres = IHTMLStyle_put_fontWeight(style, str);
3111 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3114 str = a2bstr("300");
3115 hres = IHTMLStyle_put_fontWeight(style, str);
3116 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3119 str = a2bstr("400");
3120 hres = IHTMLStyle_put_fontWeight(style, str);
3121 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3124 str = a2bstr("500");
3125 hres = IHTMLStyle_put_fontWeight(style, str);
3126 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3129 str = a2bstr("600");
3130 hres = IHTMLStyle_put_fontWeight(style, str);
3131 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3134 str = a2bstr("700");
3135 hres = IHTMLStyle_put_fontWeight(style, str);
3136 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3139 str = a2bstr("800");
3140 hres = IHTMLStyle_put_fontWeight(style, str);
3141 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3144 str = a2bstr("900");
3145 hres = IHTMLStyle_put_fontWeight(style, str);
3146 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3149 hres = IHTMLStyle_get_fontWeight(style, &str);
3150 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3151 ok(!strcmp_wa(str, "900"), "str != style900\n");
3154 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3155 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3156 SysFreeString(sDefault);
3159 hres = IHTMLStyle_get_fontVariant(style, NULL);
3160 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3162 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3163 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3165 str = a2bstr("test");
3166 hres = IHTMLStyle_put_fontVariant(style, str);
3167 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3170 str = a2bstr("small-caps");
3171 hres = IHTMLStyle_put_fontVariant(style, str);
3172 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3175 str = a2bstr("normal");
3176 hres = IHTMLStyle_put_fontVariant(style, str);
3177 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3180 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3181 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3182 SysFreeString(sDefault);
3184 str = (void*)0xdeadbeef;
3185 hres = IHTMLStyle_get_display(style, &str);
3186 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3187 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3189 str = (void*)0xdeadbeef;
3190 hres = IHTMLStyle_get_visibility(style, &str);
3191 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3192 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3195 hres = IHTMLStyle_get_fontSize(style, &v);
3196 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3197 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3198 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3201 hres = IHTMLStyle_get_color(style, &v);
3202 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3203 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3204 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3207 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3208 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3209 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3211 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3212 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3213 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3215 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3216 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3217 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3219 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3220 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3223 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3224 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3225 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3227 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3228 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3229 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3231 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3232 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3233 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3235 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3236 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3239 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3240 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3241 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3243 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3244 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3245 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3247 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3248 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3249 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3251 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3252 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3255 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3256 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3257 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3259 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3260 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3261 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3263 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3264 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3265 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3267 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3268 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3271 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3272 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3273 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3275 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3276 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3277 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3279 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3280 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3281 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3283 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3284 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3286 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3287 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3289 str = a2bstr("invalid");
3290 hres = IHTMLStyle_put_textDecoration(style, str);
3291 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3294 str = a2bstr("none");
3295 hres = IHTMLStyle_put_textDecoration(style, str);
3296 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3299 str = a2bstr("underline");
3300 hres = IHTMLStyle_put_textDecoration(style, str);
3301 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3304 str = a2bstr("overline");
3305 hres = IHTMLStyle_put_textDecoration(style, str);
3306 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3309 str = a2bstr("line-through");
3310 hres = IHTMLStyle_put_textDecoration(style, str);
3311 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3314 str = a2bstr("blink");
3315 hres = IHTMLStyle_put_textDecoration(style, str);
3316 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3319 hres = IHTMLStyle_get_textDecoration(style, &str);
3320 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3321 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3324 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3325 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3326 SysFreeString(sDefault);
3328 hres = IHTMLStyle_get_posWidth(style, NULL);
3329 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3331 hres = IHTMLStyle_get_posWidth(style, &f);
3332 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3333 ok(f == 0.0f, "f = %f\n", f);
3335 V_VT(&v) = VT_EMPTY;
3336 hres = IHTMLStyle_get_width(style, &v);
3337 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3338 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3339 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3341 hres = IHTMLStyle_put_posWidth(style, 2.2);
3342 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3344 hres = IHTMLStyle_get_posWidth(style, &f);
3345 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3347 f == 2.2f, /* IE8 */
3351 V_BSTR(&v) = a2bstr("auto");
3352 hres = IHTMLStyle_put_width(style, v);
3353 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3356 V_VT(&v) = VT_EMPTY;
3357 hres = IHTMLStyle_get_width(style, &v);
3358 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3359 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3360 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3364 str = (void*)0xdeadbeef;
3365 hres = IHTMLStyle_get_margin(style, &str);
3366 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3367 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3370 hres = IHTMLStyle_put_margin(style, str);
3371 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3374 hres = IHTMLStyle_get_margin(style, &str);
3375 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3376 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3378 hres = IHTMLStyle_put_margin(style, NULL);
3379 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3382 hres = IHTMLStyle_get_border(style, &str);
3383 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3384 ok(!str || !*str, "str is not empty\n");
3387 str = a2bstr("1px");
3388 hres = IHTMLStyle_put_border(style, str);
3389 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3392 V_VT(&v) = VT_EMPTY;
3393 hres = IHTMLStyle_get_left(style, &v);
3394 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3395 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3396 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3400 hres = IHTMLStyle_get_posLeft(style, NULL);
3401 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3404 hres = IHTMLStyle_get_posLeft(style, &f);
3405 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3406 ok(f == 0.0, "expected 0.0 got %f\n", f);
3408 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3409 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3411 hres = IHTMLStyle_get_posLeft(style, &f);
3412 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3414 f == 4.9f, /* IE8 */
3415 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3417 /* Ensure left is updated correctly. */
3418 V_VT(&v) = VT_EMPTY;
3419 hres = IHTMLStyle_get_left(style, &v);
3420 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3421 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3422 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3423 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3424 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3429 V_BSTR(&v) = a2bstr("3px");
3430 hres = IHTMLStyle_put_left(style, v);
3431 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3434 hres = IHTMLStyle_get_posLeft(style, &f);
3435 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3436 ok(f == 3.0, "expected 3.0 got %f\n", f);
3438 V_VT(&v) = VT_EMPTY;
3439 hres = IHTMLStyle_get_left(style, &v);
3440 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3441 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3442 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3446 hres = IHTMLStyle_put_left(style, v);
3447 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3449 V_VT(&v) = VT_EMPTY;
3450 hres = IHTMLStyle_get_left(style, &v);
3451 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3452 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3453 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3456 V_VT(&v) = VT_EMPTY;
3457 hres = IHTMLStyle_get_top(style, &v);
3458 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3459 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3460 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3464 hres = IHTMLStyle_get_posTop(style, NULL);
3465 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3468 hres = IHTMLStyle_get_posTop(style, &f);
3469 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3470 ok(f == 0.0, "expected 0.0 got %f\n", f);
3472 hres = IHTMLStyle_put_posTop(style, 4.9f);
3473 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3475 hres = IHTMLStyle_get_posTop(style, &f);
3476 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3478 f == 4.9f, /* IE8 */
3479 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3482 V_BSTR(&v) = a2bstr("3px");
3483 hres = IHTMLStyle_put_top(style, v);
3484 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3487 V_VT(&v) = VT_EMPTY;
3488 hres = IHTMLStyle_get_top(style, &v);
3489 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3490 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3491 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3494 hres = IHTMLStyle_get_posTop(style, &f);
3495 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3496 ok(f == 3.0, "expected 3.0 got %f\n", f);
3499 hres = IHTMLStyle_put_top(style, v);
3500 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3502 V_VT(&v) = VT_EMPTY;
3503 hres = IHTMLStyle_get_top(style, &v);
3504 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3505 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3506 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3509 /* Test posHeight */
3510 hres = IHTMLStyle_get_posHeight(style, NULL);
3511 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3513 V_VT(&v) = VT_EMPTY;
3514 hres = IHTMLStyle_get_height(style, &v);
3515 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3516 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3517 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3521 hres = IHTMLStyle_get_posHeight(style, &f);
3522 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3523 ok(f == 0.0, "expected 0.0 got %f\n", f);
3525 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3526 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3528 hres = IHTMLStyle_get_posHeight(style, &f);
3529 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3531 f == 4.9f, /* IE8 */
3532 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3535 V_BSTR(&v) = a2bstr("64px");
3536 hres = IHTMLStyle_put_height(style, v);
3537 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3540 V_VT(&v) = VT_EMPTY;
3541 hres = IHTMLStyle_get_height(style, &v);
3542 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3543 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3544 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3547 hres = IHTMLStyle_get_posHeight(style, &f);
3548 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3549 ok(f == 64.0, "expected 64.0 got %f\n", f);
3551 str = (void*)0xdeadbeef;
3552 hres = IHTMLStyle_get_cursor(style, &str);
3553 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3554 ok(!str, "get_cursor != NULL\n");
3557 str = a2bstr("default");
3558 hres = IHTMLStyle_put_cursor(style, str);
3559 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3563 hres = IHTMLStyle_get_cursor(style, &str);
3564 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3565 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3568 V_VT(&v) = VT_EMPTY;
3569 hres = IHTMLStyle_get_verticalAlign(style, &v);
3570 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3571 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3572 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3576 V_BSTR(&v) = a2bstr("middle");
3577 hres = IHTMLStyle_put_verticalAlign(style, v);
3578 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3581 V_VT(&v) = VT_EMPTY;
3582 hres = IHTMLStyle_get_verticalAlign(style, &v);
3583 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3584 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3585 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3588 str = (void*)0xdeadbeef;
3589 hres = IHTMLStyle_get_textAlign(style, &str);
3590 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3591 ok(!str, "textAlign != NULL\n");
3593 str = a2bstr("center");
3594 hres = IHTMLStyle_put_textAlign(style, str);
3595 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3599 hres = IHTMLStyle_get_textAlign(style, &str);
3600 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3601 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3604 str = (void*)0xdeadbeef;
3605 hres = IHTMLStyle_get_filter(style, &str);
3606 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3607 ok(!str, "filter != NULL\n");
3609 str = a2bstr("alpha(opacity=100)");
3610 hres = IHTMLStyle_put_filter(style, str);
3611 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3614 V_VT(&v) = VT_EMPTY;
3615 hres = IHTMLStyle_get_zIndex(style, &v);
3616 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3617 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3618 ok(!V_I4(&v), "V_I4(v) != 0\n");
3622 V_BSTR(&v) = a2bstr("1");
3623 hres = IHTMLStyle_put_zIndex(style, v);
3624 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3627 V_VT(&v) = VT_EMPTY;
3628 hres = IHTMLStyle_get_zIndex(style, &v);
3629 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3630 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3631 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3635 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3636 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3638 str = a2bstr("test");
3639 hres = IHTMLStyle_put_fontStyle(style, str);
3640 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3643 str = a2bstr("italic");
3644 hres = IHTMLStyle_put_fontStyle(style, str);
3645 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3648 str = a2bstr("oblique");
3649 hres = IHTMLStyle_put_fontStyle(style, str);
3650 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3653 str = a2bstr("normal");
3654 hres = IHTMLStyle_put_fontStyle(style, str);
3655 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3658 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3659 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3660 SysFreeString(sDefault);
3663 hres = IHTMLStyle_get_overflow(style, NULL);
3664 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3666 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3667 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3669 str = a2bstr("test");
3670 hres = IHTMLStyle_put_overflow(style, str);
3671 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3674 str = a2bstr("visible");
3675 hres = IHTMLStyle_put_overflow(style, str);
3676 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3679 str = a2bstr("scroll");
3680 hres = IHTMLStyle_put_overflow(style, str);
3681 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3684 str = a2bstr("hidden");
3685 hres = IHTMLStyle_put_overflow(style, str);
3686 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3689 str = a2bstr("auto");
3690 hres = IHTMLStyle_put_overflow(style, str);
3691 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3694 hres = IHTMLStyle_get_overflow(style, &str);
3695 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3696 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3700 hres = IHTMLStyle_put_overflow(style, str);
3701 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3704 hres = IHTMLStyle_get_overflow(style, &str);
3705 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3706 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3709 /* restore overflow default */
3710 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3711 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3712 SysFreeString(sOverflowDefault);
3714 /* Attribute Tests*/
3715 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3716 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3718 str = a2bstr("position");
3719 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3720 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3722 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3723 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3724 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3727 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3728 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3731 V_BSTR(&v) = a2bstr("absolute");
3732 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3733 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3736 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3737 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3738 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3739 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3744 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3745 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3750 str = a2bstr("borderLeftStyle");
3751 test_border_styles(style, str);
3754 str = a2bstr("borderbottomstyle");
3755 test_border_styles(style, str);
3758 str = a2bstr("borderrightstyle");
3759 test_border_styles(style, str);
3762 str = a2bstr("bordertopstyle");
3763 test_border_styles(style, str);
3766 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3767 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3769 str = a2bstr("none dotted dashed solid");
3770 hres = IHTMLStyle_put_borderStyle(style, str);
3771 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3774 str = a2bstr("none dotted dashed solid");
3775 hres = IHTMLStyle_get_borderStyle(style, &str);
3776 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3777 ok(!strcmp_wa(str, "none dotted dashed solid"),
3778 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3781 str = a2bstr("double groove ridge inset");
3782 hres = IHTMLStyle_put_borderStyle(style, str);
3783 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3786 str = a2bstr("window-inset outset ridge inset");
3787 hres = IHTMLStyle_put_borderStyle(style, str);
3788 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3791 str = a2bstr("window-inset");
3792 hres = IHTMLStyle_put_borderStyle(style, str);
3793 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3796 str = a2bstr("none none none none none");
3797 hres = IHTMLStyle_put_borderStyle(style, str);
3798 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3801 str = a2bstr("invalid none none none");
3802 hres = IHTMLStyle_put_borderStyle(style, str);
3803 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3806 str = a2bstr("none invalid none none");
3807 hres = IHTMLStyle_put_borderStyle(style, str);
3808 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3811 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3812 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3813 SysFreeString(sDefault);
3815 /* backgoundColor */
3816 hres = IHTMLStyle_get_backgroundColor(style, &v);
3817 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3818 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3819 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3823 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3824 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3827 V_BSTR(&v) = a2bstr("10");
3828 hres = IHTMLStyle_put_paddingLeft(style, v);
3829 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3832 hres = IHTMLStyle_get_paddingLeft(style, &v);
3833 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3834 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3836 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3837 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3839 /* BackgroundRepeat */
3840 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3841 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3843 str = a2bstr("invalid");
3844 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3845 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3848 str = a2bstr("repeat");
3849 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3850 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3853 str = a2bstr("no-repeat");
3854 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3855 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3858 str = a2bstr("repeat-x");
3859 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3860 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3863 str = a2bstr("repeat-y");
3864 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3865 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3868 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3869 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3870 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
3873 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3874 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3875 SysFreeString(sDefault);
3878 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3879 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3881 str = a2bstr("red green red blue");
3882 hres = IHTMLStyle_put_borderColor(style, str);
3883 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3886 hres = IHTMLStyle_get_borderColor(style, &str);
3887 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3888 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
3891 hres = IHTMLStyle_put_borderColor(style, sDefault);
3892 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3893 SysFreeString(sDefault);
3896 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
3897 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
3899 str = a2bstr("thick dotted red");
3900 hres = IHTMLStyle_put_borderLeft(style, str);
3901 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3904 /* IHTMLStyle_get_borderLeft appears to have a bug where
3905 it returns the first letter of the color. So we check
3906 each style individually.
3909 hres = IHTMLStyle_get_borderLeftColor(style, &v);
3910 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3911 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3915 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
3916 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3917 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3920 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
3921 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3922 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
3925 hres = IHTMLStyle_put_borderLeft(style, sDefault);
3926 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
3927 SysFreeString(sDefault);
3929 /* backgroundPositionX */
3930 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
3931 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3934 V_BSTR(&v) = a2bstr("10px");
3935 hres = IHTMLStyle_put_backgroundPositionX(style, v);
3936 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3939 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
3940 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
3941 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3944 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
3945 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
3946 VariantClear(&vDefault);
3948 /* backgroundPositionY */
3949 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
3950 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3953 V_BSTR(&v) = a2bstr("10px");
3954 hres = IHTMLStyle_put_backgroundPositionY(style, v);
3955 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3958 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
3959 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
3960 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3963 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
3964 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
3965 VariantClear(&vDefault);
3967 /* borderTopWidth */
3968 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
3969 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3972 V_BSTR(&v) = a2bstr("10px");
3973 hres = IHTMLStyle_put_borderTopWidth(style, v);
3974 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3977 hres = IHTMLStyle_get_borderTopWidth(style, &v);
3978 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
3979 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3982 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
3983 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
3984 VariantClear(&vDefault);
3986 /* borderRightWidth */
3987 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
3988 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3991 V_BSTR(&v) = a2bstr("10");
3992 hres = IHTMLStyle_put_borderRightWidth(style, v);
3993 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
3996 hres = IHTMLStyle_get_borderRightWidth(style, &v);
3997 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
3998 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4001 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4002 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4003 VariantClear(&vDefault);
4005 /* borderBottomWidth */
4006 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4007 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4010 V_BSTR(&v) = a2bstr("10");
4011 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4012 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4015 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4016 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4017 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4020 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4021 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4022 VariantClear(&vDefault);
4024 /* borderLeftWidth */
4025 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4026 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4029 V_BSTR(&v) = a2bstr("10");
4030 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4031 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4034 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4035 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4036 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4039 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4040 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4041 VariantClear(&vDefault);
4044 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4045 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4048 V_BSTR(&v) = a2bstr("10");
4049 hres = IHTMLStyle_put_wordSpacing(style, v);
4050 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4053 hres = IHTMLStyle_get_wordSpacing(style, &v);
4054 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4055 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4056 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4059 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4060 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4061 VariantClear(&vDefault);
4064 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4065 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4068 V_BSTR(&v) = a2bstr("11");
4069 hres = IHTMLStyle_put_letterSpacing(style, v);
4070 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4073 hres = IHTMLStyle_get_letterSpacing(style, &v);
4074 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4075 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4076 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4079 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4080 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4081 VariantClear(&vDefault);
4083 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4084 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4085 if(SUCCEEDED(hres)) {
4086 test_style2(style2);
4087 IHTMLStyle2_Release(style2);
4090 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4091 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4092 if(SUCCEEDED(hres)) {
4093 test_style3(style3);
4094 IHTMLStyle3_Release(style3);
4097 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4098 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4099 if(SUCCEEDED(hres)) {
4100 test_style4(style4);
4101 IHTMLStyle4_Release(style4);
4105 static void test_set_csstext(IHTMLStyle *style)
4110 test_style_set_csstext(style, "background-color: black;");
4112 hres = IHTMLStyle_get_backgroundColor(style, &v);
4113 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4114 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4115 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4119 static void test_default_selection(IHTMLDocument2 *doc)
4121 IHTMLSelectionObject *selection;
4122 IHTMLTxtRange *range;
4127 hres = IHTMLDocument2_get_selection(doc, &selection);
4128 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4130 hres = IHTMLSelectionObject_get_type(selection, &str);
4131 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4132 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4135 hres = IHTMLSelectionObject_createRange(selection, &disp);
4136 IHTMLSelectionObject_Release(selection);
4137 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4139 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4140 IDispatch_Release(disp);
4141 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4143 test_range_text(range, NULL);
4144 IHTMLTxtRange_Release(range);
4147 static void test_default_body(IHTMLBodyElement *body)
4153 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4154 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4156 bstr = (void*)0xdeadbeef;
4157 hres = IHTMLBodyElement_get_background(body, &bstr);
4158 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4159 ok(bstr == NULL, "bstr != NULL\n");
4161 l = elem_get_scroll_height((IUnknown*)body);
4162 ok(l != -1, "scrollHeight == -1\n");
4163 l = elem_get_scroll_width((IUnknown*)body);
4164 ok(l != -1, "scrollWidth == -1\n");
4165 l = elem_get_scroll_top((IUnknown*)body);
4166 ok(!l, "scrollTop = %d\n", l);
4167 elem_get_scroll_left((IUnknown*)body);
4169 /* get_text tests */
4170 hres = IHTMLBodyElement_get_text(body, &v);
4171 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4172 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4173 ok(bstr == NULL, "bstr != NULL\n");
4176 /* get_text - Invalid Text */
4178 V_BSTR(&v) = SysAllocString(sTextInvalid);
4179 hres = IHTMLBodyElement_put_text(body, v);
4180 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4184 hres = IHTMLBodyElement_get_text(body, &v);
4185 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4186 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4187 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4190 /* get_text - Valid Text */
4192 V_BSTR(&v) = SysAllocString(sBodyText);
4193 hres = IHTMLBodyElement_put_text(body, v);
4194 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4198 hres = IHTMLBodyElement_get_text(body, &v);
4199 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4200 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4201 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4205 static void test_body_funs(IHTMLBodyElement *body)
4207 static WCHAR sRed[] = {'r','e','d',0};
4212 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4213 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4214 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4216 V_VT(&vbg) = VT_BSTR;
4217 V_BSTR(&vbg) = SysAllocString(sRed);
4218 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4219 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4222 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4223 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4224 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4225 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4228 /* Restore Originial */
4229 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4230 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4231 VariantClear(&vDefaultbg);
4234 static void test_window(IHTMLDocument2 *doc)
4236 IHTMLWindow2 *window, *window2, *self;
4237 IHTMLDocument2 *doc2 = NULL;
4243 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4244 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4245 test_ifaces((IUnknown*)window, window_iids);
4246 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4248 hres = IHTMLWindow2_get_document(window, &doc2);
4249 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4250 ok(doc2 != NULL, "doc2 == NULL\n");
4252 test_ifaces((IUnknown*)doc2, doc_node_iids);
4253 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4255 test_ifaces((IUnknown*)doc, doc_obj_iids);
4256 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4258 unk = (void*)0xdeadbeef;
4259 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4260 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4261 ok(!unk, "unk = %p\n", unk);
4263 IHTMLDocument_Release(doc2);
4265 hres = IHTMLWindow2_get_window(window, &window2);
4266 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4267 ok(window2 != NULL, "window2 == NULL\n");
4269 hres = IHTMLWindow2_get_self(window, &self);
4270 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4271 ok(window2 != NULL, "self == NULL\n");
4273 ok(self == window2, "self != window2\n");
4275 IHTMLWindow2_Release(window2);
4276 IHTMLWindow2_Release(self);
4279 hres = IHTMLDocument2_get_Script(doc, &disp);
4280 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4281 ok(disp == (void*)window, "disp != window\n");
4282 IDispatch_Release(disp);
4284 hres = IHTMLWindow2_toString(window, NULL);
4285 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4288 hres = IHTMLWindow2_toString(window, &str);
4289 ok(hres == S_OK, "toString failed: %08x\n", hres);
4290 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4293 IHTMLWindow2_Release(window);
4296 static void test_defaults(IHTMLDocument2 *doc)
4298 IHTMLStyleSheetsCollection *stylesheetcol;
4299 IHTMLCurrentStyle *cstyle;
4300 IHTMLBodyElement *body;
4301 IHTMLElement2 *elem2;
4306 IHTMLElementCollection *collection;
4308 hres = IHTMLDocument2_get_body(doc, &elem);
4309 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4311 hres = IHTMLDocument2_get_images(doc, NULL);
4312 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4314 hres = IHTMLDocument2_get_images(doc, &collection);
4315 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4318 test_elem_collection((IUnknown*)collection, NULL, 0);
4319 IHTMLElementCollection_Release(collection);
4322 hres = IHTMLDocument2_get_applets(doc, NULL);
4323 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4325 hres = IHTMLDocument2_get_applets(doc, &collection);
4326 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4329 test_elem_collection((IUnknown*)collection, NULL, 0);
4330 IHTMLElementCollection_Release(collection);
4333 hres = IHTMLDocument2_get_links(doc, NULL);
4334 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4336 hres = IHTMLDocument2_get_links(doc, &collection);
4337 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4340 test_elem_collection((IUnknown*)collection, NULL, 0);
4341 IHTMLElementCollection_Release(collection);
4344 hres = IHTMLDocument2_get_forms(doc, NULL);
4345 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4347 hres = IHTMLDocument2_get_forms(doc, &collection);
4348 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4351 test_elem_collection((IUnknown*)collection, NULL, 0);
4352 IHTMLElementCollection_Release(collection);
4355 hres = IHTMLDocument2_get_anchors(doc, NULL);
4356 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4358 hres = IHTMLDocument2_get_anchors(doc, &collection);
4359 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4362 test_elem_collection((IUnknown*)collection, NULL, 0);
4363 IHTMLElementCollection_Release(collection);
4366 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4367 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4368 test_default_body(body);
4369 test_body_funs(body);
4370 IHTMLBodyElement_Release(body);
4372 hres = IHTMLElement_get_style(elem, &style);
4373 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4375 test_default_style(style);
4377 test_compatmode(doc);
4379 test_navigator(doc);
4381 elem2 = get_elem2_iface((IUnknown*)elem);
4382 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4383 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4384 if(SUCCEEDED(hres)) {
4385 test_current_style(cstyle);
4386 IHTMLCurrentStyle_Release(cstyle);
4388 IHTMLElement2_Release(elem2);
4390 IHTMLElement_Release(elem);
4392 test_set_csstext(style);
4393 IHTMLStyle_Release(style);
4395 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4396 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4399 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4400 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4401 ok(l == 0, "length = %d\n", l);
4403 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4405 test_default_selection(doc);
4406 test_doc_title(doc, "");
4409 static void test_tr_elem(IHTMLElement *elem)
4411 IHTMLElementCollection *col;
4415 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4417 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4418 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4423 hres = IHTMLTableRow_get_cells(row, &col);
4424 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4425 ok(col != NULL, "get_cells returned NULL\n");
4427 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4428 IHTMLElementCollection_Release(col);
4430 IHTMLTable_Release(row);
4433 static void test_table_elem(IHTMLElement *elem)
4435 IHTMLElementCollection *col;
4439 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4441 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4442 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4447 hres = IHTMLTable_get_rows(table, &col);
4448 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4449 ok(col != NULL, "get_ros returned NULL\n");
4451 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4452 IHTMLElementCollection_Release(col);
4454 IHTMLTable_Release(table);
4457 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4467 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4468 SafeArrayAccessData(sa, (void**)&var);
4469 V_VT(var) = VT_BSTR;
4470 V_BSTR(var) = str = a2bstr(text);
4471 SafeArrayUnaccessData(sa);
4474 hres = IHTMLDocument2_writeln(doc, sa);
4476 hres = IHTMLDocument2_write(doc, sa);
4477 ok(hres == S_OK, "write failed: %08x\n", hres);
4480 SafeArrayDestroy(sa);
4483 static void test_iframe_elem(IHTMLElement *elem)
4485 IHTMLElementCollection *col;
4486 IHTMLDocument2 *content_doc;
4487 IHTMLWindow2 *content_window;
4488 IHTMLFrameBase2 *base2;
4494 static const elem_type_t all_types[] = {
4502 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4503 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4506 content_window = NULL;
4507 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4508 IHTMLFrameBase2_Release(base2);
4509 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4510 ok(content_window != NULL, "contentWindow = NULL\n");
4513 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4514 IHTMLWindow2_Release(content_window);
4515 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4516 ok(content_doc != NULL, "content_doc = NULL\n");
4518 str = a2bstr("text/html");
4519 V_VT(&errv) = VT_ERROR;
4521 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4523 ok(hres == S_OK, "open failed: %08x\n", hres);
4524 ok(disp != NULL, "disp == NULL\n");
4525 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4526 IDispatch_Release(disp);
4528 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4529 doc_write(content_doc, TRUE, "</html>");
4531 hres = IHTMLDocument2_get_all(content_doc, &col);
4532 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4533 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4534 IHTMLElementCollection_Release(col);
4536 hres = IHTMLDocument2_close(content_doc);
4537 ok(hres == S_OK, "close failed: %08x\n", hres);
4539 IHTMLDocument2_Release(content_doc);
4542 static void test_stylesheet(IDispatch *disp)
4544 IHTMLStyleSheetRulesCollection *col = NULL;
4545 IHTMLStyleSheet *stylesheet;
4548 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4549 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4551 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4552 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4553 ok(col != NULL, "col == NULL\n");
4555 IHTMLStyleSheetRulesCollection_Release(col);
4556 IHTMLStyleSheet_Release(stylesheet);
4559 static void test_stylesheets(IHTMLDocument2 *doc)
4561 IHTMLStyleSheetsCollection *col = NULL;
4566 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4567 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4568 ok(col != NULL, "col == NULL\n");
4570 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4571 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4572 ok(len == 1, "len=%d\n", len);
4578 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4579 ok(hres == S_OK, "item failed: %08x\n", hres);
4580 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4581 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4582 test_stylesheet(V_DISPATCH(&res));
4589 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4590 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4591 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4592 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4595 IHTMLStyleSheetsCollection_Release(col);
4598 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4600 IDispatchEx *dispex;
4602 DISPPARAMS dp = {NULL, NULL, 0, 0};
4610 static const WCHAR w0[] = {'0',0};
4611 static const WCHAR w100[] = {'1','0','0',0};
4613 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4614 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4616 bstr = SysAllocString(w0);
4617 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4618 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4619 SysFreeString(bstr);
4622 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4623 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4624 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4625 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4626 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4627 type = get_node_type((IUnknown*)node);
4628 ok(type == 3, "type=%d\n", type);
4629 IHTMLDOMNode_Release(node);
4632 bstr = SysAllocString(w100);
4633 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4634 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4635 SysFreeString(bstr);
4637 IDispatchEx_Release(dispex);
4642 static void test_elems(IHTMLDocument2 *doc)
4644 IHTMLElementCollection *col;
4645 IHTMLDOMChildrenCollection *child_col;
4646 IHTMLElement *elem, *elem2, *elem3;
4647 IHTMLDOMNode *node, *node2;
4651 IHTMLElementCollection *collection;
4652 IHTMLDocument3 *doc3;
4655 static const elem_type_t all_types[] = {
4680 static const elem_type_t item_types[] = {
4686 hres = IHTMLDocument2_get_all(doc, &col);
4687 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4688 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4689 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4690 IHTMLElementCollection_Release(col);
4692 hres = IHTMLDocument2_get_images(doc, &collection);
4693 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4696 static const elem_type_t images_types[] = {ET_IMG};
4697 test_elem_collection((IUnknown*)collection, images_types, 1);
4699 IHTMLElementCollection_Release(collection);
4702 hres = IHTMLDocument2_get_links(doc, &collection);
4703 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4706 static const elem_type_t images_types[] = {ET_A};
4707 test_elem_collection((IUnknown*)collection, images_types, 1);
4709 IHTMLElementCollection_Release(collection);
4712 hres = IHTMLDocument2_get_anchors(doc, &collection);
4713 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4716 static const elem_type_t anchor_types[] = {ET_A};
4717 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4719 IHTMLElementCollection_Release(collection);
4722 elem = get_doc_elem(doc);
4723 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4724 hres = IHTMLElement_get_all(elem, &disp);
4725 IHTMLElement_Release(elem);
4726 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4728 hres = IDispatch_QueryInterface(disp, &IID_IHTMLElementCollection, (void**)&col);
4729 IDispatch_Release(disp);
4730 ok(hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
4731 test_elem_collection((IUnknown*)col, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4732 IHTMLElementCollection_Release(col);
4734 get_elem_by_id(doc, "xxx", FALSE);
4735 elem = get_doc_elem_by_id(doc, "xxx");
4736 ok(!elem, "elem != NULL\n");
4738 elem = get_doc_elem_by_id(doc, "s");
4739 ok(elem != NULL, "elem == NULL\n");
4741 test_elem_type((IUnknown*)elem, ET_SELECT);
4742 test_elem_attr(elem, "xxx", NULL);
4743 test_elem_attr(elem, "id", "s");
4744 test_elem_class((IUnknown*)elem, NULL);
4745 test_elem_set_class((IUnknown*)elem, "cl");
4746 test_elem_set_class((IUnknown*)elem, NULL);
4747 test_elem_tabindex((IUnknown*)elem, 0);
4748 test_elem_set_tabindex((IUnknown*)elem, 1);
4750 node = test_node_get_parent((IUnknown*)elem);
4751 ok(node != NULL, "node == NULL\n");
4752 test_node_name((IUnknown*)node, "BODY");
4753 node2 = test_node_get_parent((IUnknown*)node);
4754 IHTMLDOMNode_Release(node);
4755 ok(node2 != NULL, "node == NULL\n");
4756 test_node_name((IUnknown*)node2, "HTML");
4757 node = test_node_get_parent((IUnknown*)node2);
4758 IHTMLDOMNode_Release(node2);
4759 ok(node != NULL, "node == NULL\n");
4762 test_node_name((IUnknown*)node, "#document");
4763 type = get_node_type((IUnknown*)node);
4764 ok(type == 9, "type=%d, expected 9\n", type);
4765 node2 = test_node_get_parent((IUnknown*)node);
4766 IHTMLDOMNode_Release(node);
4767 ok(node2 == NULL, "node != NULL\n");
4770 elem2 = test_elem_get_parent((IUnknown*)elem);
4771 ok(elem2 != NULL, "elem2 == NULL\n");
4772 test_node_name((IUnknown*)elem2, "BODY");
4773 elem3 = test_elem_get_parent((IUnknown*)elem2);
4774 IHTMLElement_Release(elem2);
4775 ok(elem3 != NULL, "elem3 == NULL\n");
4776 test_node_name((IUnknown*)elem3, "HTML");
4777 elem2 = test_elem_get_parent((IUnknown*)elem3);
4778 IHTMLElement_Release(elem3);
4779 ok(elem2 == NULL, "elem2 != NULL\n");
4781 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4782 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4783 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4785 test_elem_innertext(elem, "opt1opt2");
4787 IHTMLElement_Release(elem);
4790 elem = get_elem_by_id(doc, "s", TRUE);
4792 IHTMLSelectElement *select;
4793 IHTMLDocument2 *doc_node;
4795 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4796 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4798 test_select_elem(select);
4800 test_elem_title((IUnknown*)select, NULL);
4801 test_elem_set_title((IUnknown*)select, "Title");
4802 test_elem_title((IUnknown*)select, "Title");
4803 test_elem_offset((IUnknown*)select);
4805 node = get_first_child((IUnknown*)select);
4806 ok(node != NULL, "node == NULL\n");
4808 test_elem_type((IUnknown*)node, ET_OPTION);
4809 IHTMLDOMNode_Release(node);
4812 type = get_node_type((IUnknown*)select);
4813 ok(type == 1, "type=%d\n", type);
4815 IHTMLSelectElement_Release(select);
4817 hres = IHTMLElement_get_document(elem, &disp);
4818 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4820 doc_node = get_doc_node(doc);
4821 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
4822 IHTMLDocument2_Release(doc_node);
4824 IHTMLElement_Release(elem);
4827 elem = get_elem_by_id(doc, "sc", TRUE);
4829 IHTMLScriptElement *script;
4832 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4833 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4839 hres = IHTMLScriptElement_get_type(script, &type);
4840 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4841 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4842 SysFreeString(type);
4845 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4846 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4848 hres = IHTMLScriptElement_get_defer(script, &vb);
4849 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4850 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4852 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4853 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4856 IHTMLScriptElement_Release(script);
4859 elem = get_elem_by_id(doc, "in", TRUE);
4861 IHTMLInputElement *input;
4863 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
4864 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
4866 test_elem_id((IUnknown*)elem, "in");
4867 test_elem_put_id((IUnknown*)elem, "newin");
4868 test_input_get_disabled(input, VARIANT_FALSE);
4869 test_input_set_disabled(input, VARIANT_TRUE);
4870 test_input_set_disabled(input, VARIANT_FALSE);
4871 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
4872 test_input_get_disabled(input, VARIANT_TRUE);
4873 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
4874 test_input_get_disabled(input, VARIANT_FALSE);
4875 test_elem_client_size((IUnknown*)elem);
4877 test_node_get_value_str((IUnknown*)elem, NULL);
4878 test_node_put_value_str((IUnknown*)elem, "test");
4879 test_node_get_value_str((IUnknown*)elem, NULL);
4880 test_input_value((IUnknown*)elem, NULL);
4881 test_input_put_value((IUnknown*)elem, "test");
4882 test_input_value((IUnknown*)elem, NULL);
4883 test_elem_class((IUnknown*)elem, "testclass");
4884 test_elem_tabindex((IUnknown*)elem, 2);
4885 test_elem_set_tabindex((IUnknown*)elem, 3);
4886 test_elem_title((IUnknown*)elem, "test title");
4888 test_input_get_defaultchecked(input, VARIANT_FALSE);
4889 test_input_set_defaultchecked(input, VARIANT_TRUE);
4890 test_input_set_defaultchecked(input, VARIANT_FALSE);
4892 test_input_get_checked(input, VARIANT_FALSE);
4893 test_input_set_checked(input, VARIANT_TRUE);
4894 test_input_set_checked(input, VARIANT_FALSE);
4896 test_input_src(input, NULL);
4897 test_input_set_src(input, "about:blank");
4899 IHTMLInputElement_Release(input);
4900 IHTMLElement_Release(elem);
4903 elem = get_elem_by_id(doc, "imgid", TRUE);
4905 test_img_src((IUnknown*)elem, "");
4906 test_img_set_src((IUnknown*)elem, "about:blank");
4907 test_img_alt((IUnknown*)elem, NULL);
4908 test_img_set_alt((IUnknown*)elem, "alt test");
4909 IHTMLElement_Release(elem);
4912 elem = get_doc_elem_by_id(doc, "tbl");
4913 ok(elem != NULL, "elem == NULL\n");
4915 test_table_elem(elem);
4916 IHTMLElement_Release(elem);
4919 elem = get_doc_elem_by_id(doc, "row2");
4920 ok(elem != NULL, "elem == NULL\n");
4923 IHTMLElement_Release(elem);
4926 elem = get_doc_elem_by_id(doc, "ifr");
4927 ok(elem != NULL, "elem == NULL\n");
4929 test_iframe_elem(elem);
4930 IHTMLElement_Release(elem);
4933 hres = IHTMLDocument2_get_body(doc, &elem);
4934 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4936 node = get_first_child((IUnknown*)elem);
4937 ok(node != NULL, "node == NULL\n");
4939 test_ifaces((IUnknown*)node, text_iids);
4940 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
4942 node2 = get_first_child((IUnknown*)node);
4943 ok(!node2, "node2 != NULL\n");
4945 type = get_node_type((IUnknown*)node);
4946 ok(type == 3, "type=%d\n", type);
4948 test_node_get_value_str((IUnknown*)node, "text test");
4949 test_node_put_value_str((IUnknown*)elem, "test text");
4950 test_node_get_value_str((IUnknown*)node, "text test");
4952 IHTMLDOMNode_Release(node);
4955 child_col = get_child_nodes((IUnknown*)elem);
4956 ok(child_col != NULL, "child_coll == NULL\n");
4960 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
4962 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
4963 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4964 ok(length, "length=0\n");
4966 node = get_child_item(child_col, 0);
4967 ok(node != NULL, "node == NULL\n");
4969 type = get_node_type((IUnknown*)node);
4970 ok(type == 3, "type=%d\n", type);
4971 IHTMLDOMNode_Release(node);
4974 node = get_child_item(child_col, 1);
4975 ok(node != NULL, "node == NULL\n");
4977 type = get_node_type((IUnknown*)node);
4978 ok(type == 8, "type=%d\n", type);
4980 test_elem_id((IUnknown*)node, NULL);
4981 IHTMLDOMNode_Release(node);
4984 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
4985 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4987 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
4988 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
4990 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
4991 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4993 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
4994 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4996 test_child_col_disp(child_col);
4998 IHTMLDOMChildrenCollection_Release(child_col);
5001 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5002 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5003 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5005 IHTMLElement_Release(elem);
5007 test_stylesheets(doc);
5008 test_create_option_elem(doc);
5010 elem = get_doc_elem_by_id(doc, "tbl");
5011 ok(elem != NULL, "elem = NULL\n");
5012 test_elem_set_innertext(elem, "inner text");
5013 IHTMLElement_Release(elem);
5015 test_doc_title(doc, "test");
5016 test_doc_set_title(doc, "test title");
5017 test_doc_title(doc, "test title");
5020 hres = IHTMLDocument2_get_Script(doc, &disp);
5021 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5024 IDispatchEx *dispex;
5025 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5026 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5030 BSTR str = a2bstr("Testing");
5031 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5032 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5033 ok(pid != -1, "pid == -1\n");
5035 IDispatchEx_Release(dispex);
5038 IDispatch_Release(disp);
5040 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5041 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5043 str = a2bstr("img");
5044 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5045 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5049 static const elem_type_t img_types[] = { ET_IMG };
5051 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5052 IHTMLElementCollection_Release(col);
5055 elem = get_doc_elem_by_id(doc, "y");
5056 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5057 test_elem_innerhtml((IUnknown*)elem, "inner html");
5058 test_elem_set_innerhtml((IUnknown*)elem, "");
5059 test_elem_innerhtml((IUnknown*)elem, NULL);
5060 IHTMLElement_Release(elem);
5062 IHTMLDocument3_Release(doc3);
5065 static void test_create_elems(IHTMLDocument2 *doc)
5067 IHTMLElement *elem, *body, *elem2;
5068 IHTMLDOMNode *node, *node2, *node3, *comment;
5069 IHTMLDocument5 *doc5;
5076 static const elem_type_t types1[] = { ET_TESTG };
5078 elem = test_create_elem(doc, "TEST");
5079 test_elem_tag((IUnknown*)elem, "TEST");
5080 type = get_node_type((IUnknown*)elem);
5081 ok(type == 1, "type=%d\n", type);
5082 test_ifaces((IUnknown*)elem, elem_iids);
5083 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5085 hres = IHTMLDocument2_get_body(doc, &body);
5086 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5087 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5089 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5090 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5091 elem2 = get_elem_iface((IUnknown*)node);
5092 IHTMLElement_Release(elem2);
5094 hres = IHTMLElement_get_all(body, &disp);
5095 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5096 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5097 IDispatch_Release(disp);
5099 test_node_remove_child((IUnknown*)body, node);
5101 hres = IHTMLElement_get_all(body, &disp);
5102 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5103 test_elem_collection((IUnknown*)disp, NULL, 0);
5104 IDispatch_Release(disp);
5105 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5107 IHTMLElement_Release(elem);
5108 IHTMLDOMNode_Release(node);
5110 node = test_create_text(doc, "test");
5111 test_ifaces((IUnknown*)node, text_iids);
5112 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5114 V_VT(&var) = VT_NULL;
5115 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5116 IHTMLDOMNode_Release(node);
5118 node = test_create_text(doc, "insert ");
5120 V_VT(&var) = VT_DISPATCH;
5121 V_DISPATCH(&var) = (IDispatch*)node2;
5122 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5123 IHTMLDOMNode_Release(node);
5124 IHTMLDOMNode_Release(node2);
5125 IHTMLDOMNode_Release(node3);
5127 test_elem_innertext(body, "insert test");
5128 test_elem_innerhtml((IUnknown*)body, "insert test");
5130 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5133 str = a2bstr("testing");
5134 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5136 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5139 type = get_node_type((IUnknown*)comment);
5140 ok(type == 8, "type=%d, expected 8\n", type);
5142 test_node_get_value_str((IUnknown*)comment, "testing");
5144 IHTMLDOMNode_Release(comment);
5147 IHTMLDocument5_Release(doc5);
5150 IHTMLElement_Release(body);
5153 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5155 IOleCommandTarget *cmdtrg;
5158 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5159 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5161 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5162 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5164 IOleCommandTarget_Release(cmdtrg);
5167 static void test_indent(IHTMLDocument2 *doc)
5169 IHTMLElementCollection *col;
5170 IHTMLTxtRange *range;
5173 static const elem_type_t all_types[] = {
5182 static const elem_type_t indent_types[] = {
5193 hres = IHTMLDocument2_get_all(doc, &col);
5194 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5195 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5196 IHTMLElementCollection_Release(col);
5198 range = test_create_body_range(doc);
5199 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5200 IHTMLTxtRange_Release(range);
5202 hres = IHTMLDocument2_get_all(doc, &col);
5203 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5204 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5205 IHTMLElementCollection_Release(col);
5208 static void test_cond_comment(IHTMLDocument2 *doc)
5210 IHTMLElementCollection *col;
5213 static const elem_type_t all_types[] = {
5221 hres = IHTMLDocument2_get_all(doc, &col);
5222 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5223 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5224 IHTMLElementCollection_Release(col);
5227 static IHTMLDocument2 *notif_doc;
5228 static BOOL doc_complete;
5230 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5231 REFIID riid, void**ppv)
5233 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5238 ok(0, "unexpected call\n");
5239 return E_NOINTERFACE;
5242 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5247 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5252 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5254 if(dispID == DISPID_READYSTATE){
5258 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5259 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5261 if(!strcmp_wa(state, "complete"))
5262 doc_complete = TRUE;
5264 SysFreeString(state);
5270 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5272 ok(0, "unexpected call\n");
5276 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5277 PropertyNotifySink_QueryInterface,
5278 PropertyNotifySink_AddRef,
5279 PropertyNotifySink_Release,
5280 PropertyNotifySink_OnChanged,
5281 PropertyNotifySink_OnRequestEdit
5284 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5286 static IHTMLDocument2 *create_doc_with_string(const char *str)
5288 IPersistStreamInit *init;
5290 IHTMLDocument2 *doc;
5294 notif_doc = doc = create_document();
5298 doc_complete = FALSE;
5300 mem = GlobalAlloc(0, len);
5301 memcpy(mem, str, len);
5302 CreateStreamOnHGlobal(mem, TRUE, &stream);
5304 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5306 IPersistStreamInit_Load(init, stream);
5307 IPersistStreamInit_Release(init);
5308 IStream_Release(stream);
5313 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5315 IConnectionPointContainer *container;
5316 IConnectionPoint *cp;
5320 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5321 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5323 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5324 IConnectionPointContainer_Release(container);
5325 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5327 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5328 IConnectionPoint_Release(cp);
5329 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5332 typedef void (*domtest_t)(IHTMLDocument2*);
5334 static void run_domtest(const char *str, domtest_t test)
5336 IHTMLDocument2 *doc;
5337 IHTMLElement *body = NULL;
5342 doc = create_doc_with_string(str);
5346 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5348 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5349 TranslateMessage(&msg);
5350 DispatchMessage(&msg);
5353 hres = IHTMLDocument2_get_body(doc, &body);
5354 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5357 IHTMLElement_Release(body);
5360 skip("Could not get document body. Assuming no Gecko installed.\n");
5363 ref = IHTMLDocument2_Release(doc);
5365 ref == 1, /* Vista */
5369 static void gecko_installer_workaround(BOOL disable)
5374 static BOOL has_url = FALSE;
5375 static char url[2048];
5377 if(!disable && !has_url)
5380 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5381 if(res != ERROR_SUCCESS)
5385 DWORD type, size = sizeof(url);
5387 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5388 if(res == ERROR_SUCCESS && type == REG_SZ)
5391 RegDeleteValue(hkey, "GeckoUrl");
5393 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5401 gecko_installer_workaround(TRUE);
5404 run_domtest(doc_str1, test_doc_elem);
5405 run_domtest(doc_str1, test_get_set_attr);
5406 run_domtest(range_test_str, test_txtrange);
5407 run_domtest(range_test2_str, test_txtrange2);
5408 if (winetest_interactive || ! is_ie_hardened()) {
5409 run_domtest(elem_test_str, test_elems);
5411 skip("IE running in Enhanced Security Configuration\n");
5413 run_domtest(doc_blank, test_create_elems);
5414 run_domtest(doc_blank, test_defaults);
5415 run_domtest(indent_test_str, test_indent);
5416 run_domtest(cond_comment_str, test_cond_comment);
5419 gecko_installer_workaround(FALSE);