2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
93 static const IID * const none_iids[] = {
98 static const IID * const doc_node_iids[] = {
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
112 static const IID * const doc_obj_iids[] = {
119 &IID_IConnectionPointContainer,
124 static const IID * const elem_iids[] = {
131 &IID_IConnectionPointContainer,
135 static const IID * const body_iids[] = {
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
144 &IID_IConnectionPointContainer,
148 static const IID * const anchor_iids[] = {
154 &IID_IHTMLAnchorElement,
156 &IID_IConnectionPointContainer,
160 static const IID * const input_iids[] = {
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
169 &IID_IConnectionPointContainer,
173 static const IID * const select_iids[] = {
179 &IID_IHTMLSelectElement,
181 &IID_IConnectionPointContainer,
185 static const IID * const textarea_iids[] = {
191 &IID_IHTMLTextAreaElement,
193 &IID_IConnectionPointContainer,
197 static const IID * const option_iids[] = {
203 &IID_IHTMLOptionElement,
205 &IID_IConnectionPointContainer,
209 static const IID * const table_iids[] = {
217 &IID_IConnectionPointContainer,
221 static const IID * const script_iids[] = {
227 &IID_IHTMLScriptElement,
229 &IID_IConnectionPointContainer,
233 static const IID * const text_iids[] = {
236 &IID_IHTMLDOMTextNode,
240 static const IID * const location_iids[] = {
246 static const IID * const window_iids[] = {
254 static const IID * const comment_iids[] = {
260 &IID_IHTMLCommentElement,
262 &IID_IConnectionPointContainer,
266 static const IID * const img_iids[] = {
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
278 static const IID * const tr_iids[] = {
286 &IID_IConnectionPointContainer,
290 static const IID * const td_iids[] = {
297 &IID_IConnectionPointContainer,
301 static const IID * const iframe_iids[] = {
308 &IID_IHTMLFrameBase2,
310 &IID_IConnectionPointContainer,
314 static const IID * const generic_iids[] = {
320 &IID_IHTMLGenericElement,
322 &IID_IConnectionPointContainer,
326 static const IID * const style_iids[] = {
337 static const IID * const cstyle_iids[] = {
341 &IID_IHTMLCurrentStyle,
345 static const IID * const img_factory_iids[] = {
349 &IID_IHTMLImageElementFactory,
359 static const elem_type_info_t elem_type_infos[] = {
360 {"", none_iids, NULL},
361 {"HTML", elem_iids, NULL},
362 {"HEAD", elem_iids, NULL},
363 {"TITLE", elem_iids, NULL},
364 {"BODY", body_iids, &DIID_DispHTMLBody},
365 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
366 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
367 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
368 {"TEXTAREA", textarea_iids, NULL},
369 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
370 {"STYLE", elem_iids, NULL},
371 {"BLOCKQUOTE",elem_iids, NULL},
372 {"P", elem_iids, NULL},
373 {"BR", elem_iids, NULL},
374 {"TABLE", table_iids, &DIID_DispHTMLTable},
375 {"TBODY", elem_iids, NULL},
376 {"SCRIPT", script_iids, NULL},
377 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
378 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
379 {"!", comment_iids, &DIID_DispHTMLCommentElement},
380 {"IMG", img_iids, &DIID_DispHTMLImg},
381 {"TR", tr_iids, &DIID_DispHTMLTableRow},
382 {"TD", td_iids, NULL},
383 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
386 static const char *dbgstr_guid(REFIID riid)
390 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
391 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
392 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
393 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
398 static int strcmp_wa(LPCWSTR strw, const char *stra)
401 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
402 return lstrcmpA(stra, buf);
405 static BSTR a2bstr(const char *str)
410 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
411 ret = SysAllocStringLen(NULL, len);
412 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
417 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
419 IUnknown *unk1, *unk2;
424 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
425 IUnknown_Release(unk1);
426 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
427 IUnknown_Release(unk2);
432 static IHTMLDocument2 *create_document(void)
435 IHTMLDocument5 *doc5;
438 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
439 &IID_IHTMLDocument2, (void**)&doc);
440 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
442 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
444 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
445 IHTMLDocument2_Release(doc);
449 IHTMLDocument5_Release(doc5);
453 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
454 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
456 const IID * const *piid;
460 for(piid = iids; *piid; piid++) {
461 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
462 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
464 IUnknown_Release(unk);
468 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
469 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
477 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
478 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
483 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
484 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
485 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
487 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
488 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
490 if(SUCCEEDED(hres)) {
493 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
494 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
496 *iid = type_attr->guid;
500 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
501 ITypeInfo_Release(typeinfo);
504 IDispatchEx_Release(dispex);
508 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
509 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
511 DISPPARAMS dp = {NULL,NULL,0,0};
517 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
518 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
522 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
523 IDispatchEx_Release(dispex);
524 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
526 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
527 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
531 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
532 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
536 if(_test_get_dispid(line, unk, &iid))
537 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
540 _test_disp_value(line, unk, val);
543 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
544 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
548 if(_test_get_dispid(line, unk, &iid))
549 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
550 "unexpected guid %s\n", dbgstr_guid(&iid));
553 _test_disp_value(line, unk, val);
556 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
557 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
562 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
563 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
567 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
568 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
578 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
579 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
584 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
585 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
589 #define get_node_iface(u) _get_node_iface(__LINE__,u)
590 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
595 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
596 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
600 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
601 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
606 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
607 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
611 #define get_img_iface(u) _get_img_iface(__LINE__,u)
612 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
614 IHTMLImgElement *img;
617 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
618 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
622 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
623 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
625 IHTMLAnchorElement *anchor;
628 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
629 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
633 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
634 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
636 IHTMLDOMNode *node = _get_node_iface(line, unk);
640 hres = IHTMLDOMNode_get_nodeName(node, &name);
641 IHTMLDOMNode_Release(node);
642 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
643 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
648 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
649 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
651 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
652 IDispatch *disp = (void*)0xdeadbeef;
656 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
657 IHTMLDOMNode2_Release(node);
658 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
659 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
661 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
662 IDispatch_Release(disp);
663 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
668 #define get_doc_window(d) _get_doc_window(__LINE__,d)
669 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
671 IHTMLWindow2 *window;
675 hres = IHTMLDocument2_get_parentWindow(doc, &window);
676 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
677 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
682 #define clone_node(n,d) _clone_node(__LINE__,n,d)
683 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
685 IHTMLDOMNode *node = _get_node_iface(line, unk);
686 IHTMLDOMNode *ret = NULL;
689 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
690 IHTMLDOMNode_Release(node);
691 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
692 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
698 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
699 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
701 IHTMLElement *elem = _get_elem_iface(line, unk);
705 hres = IHTMLElement_get_tagName(elem, &tag);
706 IHTMLElement_Release(elem);
707 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
708 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
713 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
714 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
716 _test_elem_tag(line, unk, elem_type_infos[type].tag);
717 _test_ifaces(line, unk, elem_type_infos[type].iids);
719 if(elem_type_infos[type].dispiid && type != ET_A)
720 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
723 #define get_node_type(n) _get_node_type(__LINE__,n)
724 static LONG _get_node_type(unsigned line, IUnknown *unk)
726 IHTMLDOMNode *node = _get_node_iface(line, unk);
730 hres = IHTMLDOMNode_get_nodeType(node, &type);
731 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
733 IHTMLDOMNode_Release(node);
738 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
739 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
741 IHTMLDOMNode *node = _get_node_iface(line, unk);
742 IHTMLDOMChildrenCollection *col = NULL;
746 hres = IHTMLDOMNode_get_childNodes(node, &disp);
747 IHTMLDOMNode_Release(node);
748 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
752 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
753 IDispatch_Release(disp);
754 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
759 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
760 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
762 IHTMLDOMNode *node = NULL;
766 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
767 ok(hres == S_OK, "item failed: %08x\n", hres);
769 node = _get_node_iface(line, (IUnknown*)disp);
770 IDispatch_Release(disp);
775 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
776 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
785 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
787 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
790 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
791 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
793 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
796 VariantClear(&value);
799 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
800 static void _test_elem_offset(unsigned line, IUnknown *unk)
802 IHTMLElement *elem = _get_elem_iface(line, unk);
806 hres = IHTMLElement_get_offsetTop(elem, &l);
807 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
809 hres = IHTMLElement_get_offsetHeight(elem, &l);
810 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
812 hres = IHTMLElement_get_offsetWidth(elem, &l);
813 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
815 IHTMLElement_Release(elem);
818 #define get_doc_node(d) _get_doc_node(__LINE__,d)
819 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
821 IHTMLWindow2 *window;
825 hres = IHTMLDocument2_get_parentWindow(doc, &window);
826 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
828 hres = IHTMLWindow2_get_document(window, &ret);
829 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
830 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
835 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
836 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
841 hres = IHTMLWindow2_get_name(window, &name);
842 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
844 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
846 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
849 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
850 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
856 hres = IHTMLWindow2_put_name(window, str);
858 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
860 _test_window_name(line, window, name);
863 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
864 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
869 hres = IHTMLWindow2_get_length(window, &length);
870 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
871 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
874 static void test_get_set_attr(IHTMLDocument2 *doc)
877 IHTMLDocument3 *doc3;
882 /* grab an element to test with */
883 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
884 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
886 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
887 IHTMLDocument3_Release(doc3);
888 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
890 /* get a non-present attribute */
891 bstr = a2bstr("notAnAttribute");
892 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
893 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
894 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
898 /* get a present attribute */
899 bstr = a2bstr("scrollHeight");
900 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
901 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
902 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
906 /* create a new BSTR attribute */
907 bstr = a2bstr("newAttribute");
909 V_VT(&val) = VT_BSTR;
910 V_BSTR(&val) = a2bstr("the value");
911 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
912 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
915 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
916 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
917 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
918 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)));
921 /* overwrite the attribute with a BOOL */
922 V_VT(&val) = VT_BOOL;
923 V_BOOL(&val) = VARIANT_TRUE;
924 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
925 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
928 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
929 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
930 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
931 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
936 /* case-insensitive */
937 bstr = a2bstr("newattribute");
938 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
939 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
940 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));
941 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));
945 IHTMLElement_Release(elem);
948 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
949 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
952 IHTMLDocument3 *doc3;
955 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
956 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
957 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
958 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
959 IHTMLDocument3_Release(doc3);
964 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
965 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
967 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
971 hres = IHTMLAnchorElement_get_href(anchor, &str);
972 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
973 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
976 _test_disp_value(line, unk, exhref);
979 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
980 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
985 hres = IHTMLOptionElement_get_text(option, &bstr);
986 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
987 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
991 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
992 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
998 hres = IHTMLOptionElement_put_text(option, bstr);
1000 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1002 _test_option_text(line, option, text);
1005 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1006 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1011 hres = IHTMLOptionElement_get_value(option, &bstr);
1012 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1013 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1014 SysFreeString(bstr);
1017 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1018 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1023 bstr = a2bstr(value);
1024 hres = IHTMLOptionElement_put_value(option, bstr);
1025 SysFreeString(bstr);
1026 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1028 _test_option_value(line, option, value);
1031 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1032 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1033 const char *txt, const char *val)
1035 IHTMLOptionElementFactory *factory;
1036 IHTMLOptionElement *option;
1037 IHTMLWindow2 *window;
1038 VARIANT text, value, empty;
1041 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1042 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1044 hres = IHTMLWindow2_get_Option(window, &factory);
1045 IHTMLWindow2_Release(window);
1046 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1048 V_VT(&text) = VT_BSTR;
1049 V_BSTR(&text) = a2bstr(txt);
1050 V_VT(&value) = VT_BSTR;
1051 V_BSTR(&value) = a2bstr(val);
1052 V_VT(&empty) = VT_EMPTY;
1054 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1055 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1057 IHTMLOptionElementFactory_Release(factory);
1058 VariantClear(&text);
1059 VariantClear(&value);
1061 _test_option_text(line, option, txt);
1062 _test_option_value(line, option, val);
1067 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1068 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1073 hres = IHTMLImgElement_get_width(img, &found);
1074 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1075 todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1078 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1079 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1083 hres = IHTMLImgElement_put_width(img, width);
1084 todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres);
1086 _test_img_width(line, img, width);
1089 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1090 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1095 hres = IHTMLImgElement_get_height(img, &found);
1096 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1097 todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1100 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1101 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1105 hres = IHTMLImgElement_put_height(img, height);
1106 todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres);
1108 _test_img_height(line, img, height);
1111 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1112 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1113 LONG wdth, LONG hght)
1115 IHTMLImageElementFactory *factory;
1116 IHTMLImgElement *img;
1117 IHTMLWindow2 *window;
1118 VARIANT width, height;
1122 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1123 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1125 hres = IHTMLWindow2_get_Image(window, &factory);
1126 IHTMLWindow2_Release(window);
1127 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1129 test_ifaces((IUnknown*)factory, img_factory_iids);
1130 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1133 snprintf(buf, 16, "%d", wdth);
1134 V_VT(&width) = VT_BSTR;
1135 V_BSTR(&width) = a2bstr(buf);
1137 V_VT(&width) = VT_EMPTY;
1142 snprintf(buf, 16, "%d", hght);
1143 V_VT(&height) = VT_BSTR;
1144 V_BSTR(&height) = a2bstr(buf);
1146 V_VT(&height) = VT_EMPTY;
1150 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1151 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1153 IHTMLImageElementFactory_Release(factory);
1154 VariantClear(&width);
1155 VariantClear(&height);
1157 if(SUCCEEDED(hres)) {
1158 _test_img_width(line, img, wdth);
1159 _test_img_height(line, img, hght);
1166 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1167 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1169 LONG len = 0xdeadbeef;
1172 hres = IHTMLSelectElement_get_length(select, &len);
1173 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1174 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1177 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1178 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1180 LONG idx = 0xdeadbeef;
1183 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1184 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1185 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1188 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1189 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1193 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1194 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1195 _test_select_selidx(line, select, index);
1198 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1199 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1204 hres = IHTMLSelectElement_get_value(select, &val);
1205 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1207 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1209 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1212 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1213 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1219 hres = IHTMLSelectElement_put_value(select, bstr);
1220 SysFreeString(bstr);
1221 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1224 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1225 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1230 hres = IHTMLSelectElement_get_type(select, &type);
1231 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1232 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1235 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1236 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1241 hres = IHTMLTxtRange_get_text(range, &text);
1242 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1245 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1246 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1248 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1251 SysFreeString(text);
1255 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1256 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1260 hres = IHTMLTxtRange_collapse(range, b);
1261 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1262 _test_range_text(line, range, NULL);
1265 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1266 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1267 VARIANT_BOOL exb, const char *extext)
1269 VARIANT_BOOL b = 0xe0e0;
1272 hres = IHTMLTxtRange_expand(range, unit, &b);
1273 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1274 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1275 _test_range_text(line, range, extext);
1278 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1279 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1281 LONG c = 0xdeadbeef;
1284 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1285 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1286 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1287 _test_range_text(line, range, NULL);
1290 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1291 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1292 LPWSTR unit, LONG cnt, LONG excnt)
1294 LONG c = 0xdeadbeef;
1297 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1298 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1299 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1302 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1303 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1305 LONG c = 0xdeadbeef;
1308 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1309 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1310 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1313 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1314 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1317 BSTR bstr = a2bstr(text);
1319 hres = IHTMLTxtRange_put_text(range, bstr);
1320 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1321 SysFreeString(bstr);
1322 _test_range_text(line, range, NULL);
1325 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1326 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1332 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1333 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1334 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1337 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1338 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1344 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1345 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1346 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1349 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1350 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1351 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1354 test_range_inrange(range1, range2, VARIANT_TRUE);
1355 test_range_inrange(range2, range1, VARIANT_TRUE);
1359 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1360 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1365 hres = IHTMLTxtRange_parentElement(range, &elem);
1366 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1368 _test_elem_type(line, (IUnknown*)elem, type);
1370 IHTMLElement_Release(elem);
1373 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1374 static void _test_elem_collection(unsigned line, IUnknown *unk,
1375 const elem_type_t *elem_types, LONG exlen)
1377 IHTMLElementCollection *col;
1380 VARIANT name, index;
1381 IDispatch *disp, *disp2;
1384 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1385 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1387 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1389 hres = IHTMLElementCollection_get_length(col, &len);
1390 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1391 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1396 V_VT(&index) = VT_EMPTY;
1398 for(i=0; i<len; i++) {
1399 V_VT(&name) = VT_I4;
1401 disp = (void*)0xdeadbeef;
1402 hres = IHTMLElementCollection_item(col, name, index, &disp);
1403 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1404 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1405 if(FAILED(hres) || !disp)
1408 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1411 V_VT(&name) = VT_UINT;
1413 disp2 = (void*)0xdeadbeef;
1414 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1415 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1416 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1418 IDispatch_Release(disp2);
1421 IDispatch_Release(disp);
1424 V_VT(&name) = VT_I4;
1426 disp = (void*)0xdeadbeef;
1427 hres = IHTMLElementCollection_item(col, name, index, &disp);
1428 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1429 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1431 V_VT(&name) = VT_I4;
1433 disp = (void*)0xdeadbeef;
1434 hres = IHTMLElementCollection_item(col, name, index, &disp);
1435 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1436 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1438 IHTMLElementCollection_Release(col);
1441 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1442 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1444 IHTMLElement *elem = _get_elem_iface(line, unk);
1448 hres = IHTMLElement_get_all(elem, &disp);
1449 IHTMLElement_Release(elem);
1450 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1452 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1453 IDispatch_Release(disp);
1456 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1457 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1459 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1460 IHTMLElementCollection *col = NULL;
1461 elem_type_t *types = NULL;
1466 tmp = a2bstr(elem_type_infos[type].tag);
1467 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1469 IHTMLElement2_Release(elem);
1470 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1471 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1474 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1475 for(i=0; i<exlen; i++)
1479 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1481 HeapFree(GetProcessHeap(), 0, types);
1484 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1485 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1490 hres = IHTMLElement_get_innerText(elem, &text);
1491 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1492 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1493 wine_dbgstr_w(text), extext);
1494 SysFreeString(text);
1497 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1498 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1500 IHTMLDOMChildrenCollection *col;
1505 hres = IHTMLElement_put_innerText(elem, str);
1506 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1509 _test_elem_innertext(line, elem, text);
1512 col = _get_child_nodes(line, (IUnknown*)elem);
1513 ok(col != NULL, "col == NULL\n");
1515 LONG length = 0, type;
1518 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1519 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1520 ok(length == 1, "length = %d\n", length);
1522 node = _get_child_item(line, col, 0);
1523 ok(node != NULL, "node == NULL\n");
1525 type = _get_node_type(line, (IUnknown*)node);
1526 ok(type == 3, "type=%d\n", type);
1527 IHTMLDOMNode_Release(node);
1530 IHTMLDOMChildrenCollection_Release(col);
1535 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1536 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1538 IHTMLElement *elem = _get_elem_iface(line, unk);
1542 hres = IHTMLElement_get_innerHTML(elem, &html);
1543 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1545 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1547 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1549 IHTMLElement_Release(elem);
1550 SysFreeString(html);
1553 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1554 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1556 IHTMLElement *elem = _get_elem_iface(line, unk);
1560 html = a2bstr(inner_html);
1561 hres = IHTMLElement_put_innerHTML(elem, html);
1562 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1564 IHTMLElement_Release(elem);
1565 SysFreeString(html);
1568 #define get_first_child(n) _get_first_child(__LINE__,n)
1569 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1571 IHTMLDOMNode *node = _get_node_iface(line, unk);
1572 IHTMLDOMNode *child = NULL;
1575 hres = IHTMLDOMNode_get_firstChild(node, &child);
1576 IHTMLDOMNode_Release(node);
1577 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1582 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1583 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1585 IHTMLDOMNode *node = _get_node_iface(line, unk);
1586 VARIANT_BOOL b = 0xdead;
1589 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1590 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1591 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1593 IHTMLDOMNode_Release(node);
1596 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1597 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1599 IHTMLDOMNode *node = _get_node_iface(line, unk);
1600 IHTMLDOMNode *parent;
1603 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1604 IHTMLDOMNode_Release(node);
1605 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1610 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1611 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1613 IHTMLElement *elem = _get_elem_iface(line, unk);
1614 IHTMLElement *parent;
1617 hres = IHTMLElement_get_parentElement(elem, &parent);
1618 IHTMLElement_Release(elem);
1619 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1624 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1625 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1627 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1628 VARIANT_BOOL disabled = 100;
1632 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1633 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1634 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1635 IHTMLElement3_Release(elem3);
1638 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1639 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1641 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1645 hres = IHTMLElement3_put_disabled(elem3, b);
1646 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1648 IHTMLElement3_Release(elem3);
1649 _test_elem3_get_disabled(line, unk, b);
1652 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1653 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1655 VARIANT_BOOL disabled = 100;
1658 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1659 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1660 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1662 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1665 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1666 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1670 hres = IHTMLSelectElement_put_disabled(select, b);
1671 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1673 _test_select_get_disabled(line, select, b);
1676 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1677 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1679 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1680 IHTMLTextContainer *txtcont;
1681 LONG l = -1, l2 = -1;
1684 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1685 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1686 IHTMLElement2_Release(elem);
1688 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1689 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1691 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1692 IHTMLTextContainer_Release(txtcont);
1693 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1694 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1699 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1700 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1702 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1703 IHTMLTextContainer *txtcont;
1704 LONG l = -1, l2 = -1;
1707 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1708 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1709 IHTMLElement2_Release(elem);
1711 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1712 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1714 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1715 IHTMLTextContainer_Release(txtcont);
1716 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1717 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1722 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1723 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1725 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1726 IHTMLTextContainer *txtcont;
1727 LONG l = -1, l2 = -1;
1730 hres = IHTMLElement2_get_scrollTop(elem, &l);
1731 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1732 IHTMLElement2_Release(elem);
1734 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1735 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1737 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1738 IHTMLTextContainer_Release(txtcont);
1739 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1740 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1745 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1746 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1748 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1749 IHTMLTextContainer *txtcont;
1750 LONG l = -1, l2 = -1;
1753 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1754 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1756 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1757 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1758 IHTMLElement2_Release(elem);
1760 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1761 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1763 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1764 IHTMLTextContainer_Release(txtcont);
1765 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1766 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1769 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1770 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1772 IHTMLImgElement *img = _get_img_iface(line, unk);
1776 hres = IHTMLImgElement_get_src(img, &src);
1777 IHTMLImgElement_Release(img);
1778 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1779 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1783 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1784 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1786 IHTMLImgElement *img = _get_img_iface(line, unk);
1791 hres = IHTMLImgElement_put_src(img, tmp);
1792 IHTMLImgElement_Release(img);
1794 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1796 _test_img_src(line, unk, src);
1799 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1800 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1802 IHTMLImgElement *img = _get_img_iface(line, unk);
1806 hres = IHTMLImgElement_get_alt(img, &alt);
1807 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1809 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1811 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1815 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1816 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1818 IHTMLImgElement *img = _get_img_iface(line, unk);
1823 hres = IHTMLImgElement_put_alt(img, tmp);
1824 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1827 _test_img_alt(line, unk, alt);
1830 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1831 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1833 VARIANT_BOOL disabled = 100;
1836 hres = IHTMLInputElement_get_disabled(input, &disabled);
1837 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1838 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1840 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1843 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1844 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1848 hres = IHTMLInputElement_put_disabled(input, b);
1849 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1851 _test_input_get_disabled(line, input, b);
1854 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1855 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1857 VARIANT_BOOL checked = 100;
1860 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1861 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1862 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1865 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1866 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1870 hres = IHTMLInputElement_put_defaultChecked(input, b);
1871 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1873 _test_input_get_defaultchecked(line, input, b);
1876 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1877 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1879 VARIANT_BOOL checked = 100;
1882 hres = IHTMLInputElement_get_checked(input, &checked);
1883 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1884 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1887 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1888 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1892 hres = IHTMLInputElement_put_checked(input, b);
1893 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1895 _test_input_get_checked(line, input, b);
1898 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1899 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1901 IHTMLInputElement *input;
1905 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1906 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1910 hres = IHTMLInputElement_get_value(input, &bstr);
1911 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1913 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1915 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1916 SysFreeString(bstr);
1917 IHTMLInputElement_Release(input);
1920 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1921 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1923 IHTMLInputElement *input;
1927 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1928 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1933 hres = IHTMLInputElement_get_value(input, &bstr);
1934 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1935 SysFreeString(bstr);
1936 IHTMLInputElement_Release(input);
1939 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1940 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1945 hres = IHTMLInputElement_get_src(input, &src);
1946 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1948 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1950 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1954 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1955 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1961 hres = IHTMLInputElement_put_src(input, tmp);
1963 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1965 _test_input_src(line, input, src);
1968 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1969 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1971 IHTMLElement *elem = _get_elem_iface(line, unk);
1972 BSTR class = (void*)0xdeadbeef;
1975 hres = IHTMLElement_get_className(elem, &class);
1976 IHTMLElement_Release(elem);
1977 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1979 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1981 ok_(__FILE__,line) (!class, "class != NULL\n");
1982 SysFreeString(class);
1985 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1986 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1988 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1992 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1993 IHTMLElement2_Release(elem2);
1994 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1995 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1998 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1999 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2001 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2004 hres = IHTMLElement2_put_tabIndex(elem2, index);
2005 IHTMLElement2_Release(elem2);
2006 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2008 _test_elem_tabindex(line, unk, index);
2011 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2012 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2014 IHTMLElement *elem = _get_elem_iface(line, unk);
2018 tmp = class ? a2bstr(class) : NULL;
2019 hres = IHTMLElement_put_className(elem, tmp);
2020 IHTMLElement_Release(elem);
2021 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2024 _test_elem_class(line, unk, class);
2027 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2028 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2030 IHTMLElement *elem = _get_elem_iface(line, unk);
2031 BSTR id = (void*)0xdeadbeef;
2034 hres = IHTMLElement_get_id(elem, &id);
2035 IHTMLElement_Release(elem);
2036 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2039 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2041 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2046 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2047 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2049 IHTMLElement *elem = _get_elem_iface(line, unk);
2050 BSTR tmp = a2bstr(new_id);
2053 hres = IHTMLElement_put_id(elem, tmp);
2054 IHTMLElement_Release(elem);
2056 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2058 _test_elem_id(line, unk, new_id);
2061 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2062 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2064 IHTMLElement *elem = _get_elem_iface(line, unk);
2068 hres = IHTMLElement_get_title(elem, &title);
2069 IHTMLElement_Release(elem);
2070 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2072 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2074 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2076 SysFreeString(title);
2079 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2080 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2082 IHTMLElement *elem = _get_elem_iface(line, unk);
2086 tmp = a2bstr(title);
2087 hres = IHTMLElement_put_title(elem, tmp);
2088 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2090 IHTMLElement_Release(elem);
2094 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2095 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2097 IHTMLDOMNode *node = _get_node_iface(line, unk);
2101 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2102 IHTMLDOMNode_Release(node);
2103 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2106 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2107 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2109 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2115 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2116 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2118 IHTMLDOMNode *node = _get_node_iface(line, unk);
2122 V_VT(&var) = VT_BSTR;
2123 V_BSTR(&var) = a2bstr(val);
2125 hres = IHTMLDOMNode_put_nodeValue(node, var);
2126 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2127 IHTMLDOMNode_Release(node);
2131 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2132 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2134 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2138 hres = IHTMLElement2_get_clientWidth(elem, &l);
2139 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2140 hres = IHTMLElement2_get_clientHeight(elem, &l);
2141 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2143 IHTMLElement2_Release(elem);
2146 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2147 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2149 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2153 hres = IHTMLElement2_get_clientLeft(elem, &l);
2154 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2155 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2157 hres = IHTMLElement2_get_clientTop(elem, &l);
2158 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2159 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2161 IHTMLElement2_Release(elem);
2164 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2165 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2167 IHTMLElement *elem = NULL;
2172 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2173 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2174 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2179 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2180 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2182 IHTMLDocument3 *doc3;
2183 IHTMLDOMNode *node = NULL;
2187 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2188 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2191 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2192 IHTMLDocument3_Release(doc3);
2193 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2194 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2199 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2200 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2202 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2203 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2204 IHTMLDOMNode *new_child = NULL;
2207 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2208 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2209 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2210 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2212 IHTMLDOMNode_Release(node);
2213 IHTMLDOMNode_Release(child);
2218 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2219 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2221 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2222 IHTMLDOMNode *new_child = NULL;
2225 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2226 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2227 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2228 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2230 IHTMLDOMNode_Release(node);
2235 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2236 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2238 IHTMLDOMNode *node = _get_node_iface(line, unk);
2239 IHTMLDOMNode *new_node = NULL;
2242 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2243 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2244 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2245 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2247 IHTMLDOMNode_Release(node);
2248 IHTMLDOMNode_Release(new_node);
2251 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2252 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2257 hres = IHTMLDocument2_get_title(doc, &title);
2258 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2259 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2260 SysFreeString(title);
2263 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2264 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2269 tmp = a2bstr(title);
2270 hres = IHTMLDocument2_put_title(doc, tmp);
2271 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2275 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2276 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2281 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2282 LOCALE_USER_DEFAULT, &dispid);
2283 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2286 DISPPARAMS params = {NULL,NULL,0,0};
2287 DISPID dispidNamed = DISPID_PROPERTYPUT;
2292 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2293 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2294 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2297 params.cNamedArgs = 1;
2298 params.rgdispidNamedArgs = &dispidNamed;
2299 V_VT(&arg) = VT_BSTR;
2300 V_BSTR(&arg) = a2bstr("none");
2301 params.rgvarg = &arg;
2302 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2303 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2304 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2307 V_VT(&arg) = VT_BSTR;
2308 V_BSTR(&arg) = a2bstr("dotted");
2309 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2310 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2311 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2314 V_VT(&arg) = VT_BSTR;
2315 V_BSTR(&arg) = a2bstr("dashed");
2316 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2317 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2318 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2321 V_VT(&arg) = VT_BSTR;
2322 V_BSTR(&arg) = a2bstr("solid");
2323 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2324 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2325 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2328 V_VT(&arg) = VT_BSTR;
2329 V_BSTR(&arg) = a2bstr("double");
2330 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2331 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2332 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2335 V_VT(&arg) = VT_BSTR;
2336 V_BSTR(&arg) = a2bstr("groove");
2337 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2338 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2339 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2342 V_VT(&arg) = VT_BSTR;
2343 V_BSTR(&arg) = a2bstr("ridge");
2344 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2345 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2346 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2349 V_VT(&arg) = VT_BSTR;
2350 V_BSTR(&arg) = a2bstr("inset");
2351 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2352 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2353 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2356 V_VT(&arg) = VT_BSTR;
2357 V_BSTR(&arg) = a2bstr("outset");
2358 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2359 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2360 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2363 V_VT(&arg) = VT_BSTR;
2364 V_BSTR(&arg) = a2bstr("invalid");
2365 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2366 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2367 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2370 params.rgvarg = &vDefault;
2371 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2372 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2373 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2377 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2378 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2380 BSTR text = (void*)0xdeadbeef;
2383 hres = IHTMLStyle_get_cssText(style, &text);
2384 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2386 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2388 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2390 SysFreeString(text);
2393 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2394 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2400 hres = IHTMLStyle_put_cssText(style, tmp);
2401 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2405 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2406 const elem_type_t *elem_types, LONG len)
2409 VARIANT name, index;
2413 V_VT(&index) = VT_EMPTY;
2414 V_VT(&name) = VT_BSTR;
2415 V_BSTR(&name) = a2bstr(n);
2417 hres = IHTMLElementCollection_item(col, name, index, &disp);
2418 ok(hres == S_OK, "item failed: %08x\n", hres);
2420 test_elem_collection((IUnknown*)disp, elem_types, len);
2421 IDispatch_Release(disp);
2422 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2426 V_VT(&index) = VT_I4;
2428 for(i=0; i<len; i++) {
2430 disp = (void*)0xdeadbeef;
2431 hres = IHTMLElementCollection_item(col, name, index, &disp);
2432 ok(hres == S_OK, "item failed: %08x\n", hres);
2433 ok(disp != NULL, "disp == NULL\n");
2434 if(FAILED(hres) || !disp)
2437 test_elem_type((IUnknown*)disp, elem_types[i]);
2439 IDispatch_Release(disp);
2443 disp = (void*)0xdeadbeef;
2444 hres = IHTMLElementCollection_item(col, name, index, &disp);
2445 ok(hres == S_OK, "item failed: %08x\n", hres);
2446 ok(disp == NULL, "disp != NULL\n");
2449 disp = (void*)0xdeadbeef;
2450 hres = IHTMLElementCollection_item(col, name, index, &disp);
2451 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2452 ok(disp == NULL, "disp != NULL\n");
2455 SysFreeString(V_BSTR(&name));
2458 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2460 IHTMLElementCollection *col;
2462 IDispatch *disp = (void*)0xdeadbeef;
2463 VARIANT name, index;
2466 hres = IHTMLDocument2_get_all(doc, &col);
2467 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2468 ok(col != NULL, "col == NULL\n");
2469 if(FAILED(hres) || !col)
2472 V_VT(&index) = VT_EMPTY;
2473 V_VT(&name) = VT_BSTR;
2474 V_BSTR(&name) = a2bstr(id);
2476 hres = IHTMLElementCollection_item(col, name, index, &disp);
2477 IHTMLElementCollection_Release(col);
2478 SysFreeString(V_BSTR(&name));
2479 ok(hres == S_OK, "item failed: %08x\n", hres);
2480 if(!expect_success) {
2481 ok(disp == NULL, "disp != NULL\n");
2485 ok(disp != NULL, "disp == NULL\n");
2489 elem = get_elem_iface((IUnknown*)disp);
2490 IDispatch_Release(disp);
2495 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2497 IHTMLDocument3 *doc3;
2502 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2503 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2506 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2508 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2510 IHTMLDocument3_Release(doc3);
2515 static void test_select_elem(IHTMLSelectElement *select)
2517 test_select_type(select, "select-one");
2518 test_select_length(select, 2);
2519 test_select_selidx(select, 0);
2520 test_select_put_selidx(select, 1);
2522 test_select_set_value(select, "val1");
2523 test_select_value(select, "val1");
2525 test_select_get_disabled(select, VARIANT_FALSE);
2526 test_select_set_disabled(select, VARIANT_TRUE);
2527 test_select_set_disabled(select, VARIANT_FALSE);
2530 static void test_create_option_elem(IHTMLDocument2 *doc)
2532 IHTMLOptionElement *option;
2534 option = create_option_elem(doc, "test text", "test value");
2536 test_option_put_text(option, "new text");
2537 test_option_put_value(option, "new value");
2539 IHTMLOptionElement_Release(option);
2542 static void test_create_img_elem(IHTMLDocument2 *doc)
2544 IHTMLImgElement *img;
2546 img = create_img_elem(doc, 10, 15);
2549 test_img_put_width(img, 5);
2550 test_img_put_height(img, 20);
2552 IHTMLImgElement_Release(img);
2556 img = create_img_elem(doc, -1, -1);
2559 test_img_put_width(img, 5);
2560 test_img_put_height(img, 20);
2562 IHTMLImgElement_Release(img);
2566 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2568 IHTMLBodyElement *body;
2569 IHTMLTxtRange *range;
2573 hres = IHTMLDocument2_get_body(doc, &elem);
2574 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2576 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2577 IHTMLElement_Release(elem);
2579 hres = IHTMLBodyElement_createTextRange(body, &range);
2580 IHTMLBodyElement_Release(body);
2581 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2586 static void test_txtrange(IHTMLDocument2 *doc)
2588 IHTMLTxtRange *body_range, *range, *range2;
2589 IHTMLSelectionObject *selection;
2590 IDispatch *disp_range;
2593 body_range = test_create_body_range(doc);
2595 test_range_text(body_range, "test abc 123\r\nit's text");
2597 hres = IHTMLTxtRange_duplicate(body_range, &range);
2598 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2600 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2601 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2602 test_range_isequal(range, range2, VARIANT_TRUE);
2604 test_range_text(range, "test abc 123\r\nit's text");
2605 test_range_text(body_range, "test abc 123\r\nit's text");
2607 test_range_collapse(range, TRUE);
2608 test_range_isequal(range, range2, VARIANT_FALSE);
2609 test_range_inrange(range, range2, VARIANT_FALSE);
2610 test_range_inrange(range2, range, VARIANT_TRUE);
2611 IHTMLTxtRange_Release(range2);
2613 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2614 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2615 test_range_move(range, characterW, 2, 2);
2616 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2618 test_range_collapse(range, FALSE);
2619 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2621 test_range_collapse(range, FALSE);
2622 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2623 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2624 test_range_move(range, characterW, 2, 2);
2625 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2626 test_range_moveend(range, characterW, -5, -5);
2627 test_range_text(range, NULL);
2628 test_range_moveend(range, characterW, 3, 3);
2629 test_range_text(range, "c 1");
2630 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2631 test_range_collapse(range, TRUE);
2632 test_range_move(range, characterW, 4, 4);
2633 test_range_moveend(range, characterW, 1, 1);
2634 test_range_text(range, " ");
2635 test_range_move(range, wordW, 1, 1);
2636 test_range_moveend(range, characterW, 2, 2);
2637 test_range_text(range, "ab");
2639 IHTMLTxtRange_Release(range);
2641 hres = IHTMLTxtRange_duplicate(body_range, &range);
2642 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2644 test_range_text(range, "test abc 123\r\nit's text");
2645 test_range_move(range, characterW, 3, 3);
2646 test_range_moveend(range, characterW, 1, 1);
2647 test_range_text(range, "t");
2648 test_range_moveend(range, characterW, 3, 3);
2649 test_range_text(range, "t ab");
2650 test_range_moveend(range, characterW, -2, -2);
2651 test_range_text(range, "t ");
2652 test_range_move(range, characterW, 6, 6);
2653 test_range_moveend(range, characterW, 3, 3);
2654 test_range_text(range, "123");
2655 test_range_moveend(range, characterW, 2, 2);
2656 test_range_text(range, "123\r\ni");
2658 IHTMLTxtRange_Release(range);
2660 hres = IHTMLTxtRange_duplicate(body_range, &range);
2661 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2663 test_range_move(range, wordW, 1, 1);
2664 test_range_moveend(range, characterW, 2, 2);
2665 test_range_text(range, "ab");
2667 test_range_move(range, characterW, -2, -2);
2668 test_range_moveend(range, characterW, 2, 2);
2669 test_range_text(range, "t ");
2671 test_range_move(range, wordW, 3, 3);
2672 test_range_move(range, wordW, -2, -2);
2673 test_range_moveend(range, characterW, 2, 2);
2674 test_range_text(range, "ab");
2676 test_range_move(range, characterW, -6, -5);
2677 test_range_moveend(range, characterW, -1, 0);
2678 test_range_moveend(range, characterW, -6, 0);
2679 test_range_move(range, characterW, 2, 2);
2680 test_range_moveend(range, characterW, 2, 2);
2681 test_range_text(range, "st");
2682 test_range_moveend(range, characterW, -6, -4);
2683 test_range_moveend(range, characterW, 2, 2);
2685 IHTMLTxtRange_Release(range);
2687 hres = IHTMLTxtRange_duplicate(body_range, &range);
2688 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2690 test_range_move(range, wordW, 2, 2);
2691 test_range_moveend(range, characterW, 2, 2);
2692 test_range_text(range, "12");
2694 test_range_move(range, characterW, 15, 14);
2695 test_range_move(range, characterW, -2, -2);
2696 test_range_moveend(range, characterW, 3, 2);
2697 test_range_text(range, "t");
2698 test_range_moveend(range, characterW, -1, -1);
2699 test_range_text(range, "t");
2700 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2701 test_range_move(range, characterW, -2, -2);
2702 test_range_moveend(range, characterW, 2, 2);
2703 test_range_text(range, "s ");
2704 test_range_move(range, characterW, 100, 7);
2705 test_range_move(range, wordW, 1, 0);
2706 test_range_move(range, characterW, -2, -2);
2707 test_range_moveend(range, characterW, 3, 2);
2708 test_range_text(range, "t");
2710 IHTMLTxtRange_Release(range);
2712 hres = IHTMLTxtRange_duplicate(body_range, &range);
2713 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2715 test_range_collapse(range, TRUE);
2716 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2717 test_range_put_text(range, "word");
2718 test_range_text(body_range, "wordabc 123\r\nit's text");
2719 test_range_text(range, NULL);
2720 test_range_moveend(range, characterW, 3, 3);
2721 test_range_text(range, "abc");
2722 test_range_movestart(range, characterW, -2, -2);
2723 test_range_text(range, "rdabc");
2724 test_range_movestart(range, characterW, 3, 3);
2725 test_range_text(range, "bc");
2726 test_range_movestart(range, characterW, 4, 4);
2727 test_range_text(range, NULL);
2728 test_range_movestart(range, characterW, -3, -3);
2729 test_range_text(range, "c 1");
2730 test_range_movestart(range, characterW, -7, -6);
2731 test_range_text(range, "wordabc 1");
2732 test_range_movestart(range, characterW, 100, 22);
2733 test_range_text(range, NULL);
2735 IHTMLTxtRange_Release(range);
2736 IHTMLTxtRange_Release(body_range);
2738 hres = IHTMLDocument2_get_selection(doc, &selection);
2739 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2741 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2742 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2743 IHTMLSelectionObject_Release(selection);
2745 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2746 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2747 IDispatch_Release(disp_range);
2749 test_range_text(range, NULL);
2750 test_range_moveend(range, characterW, 3, 3);
2751 test_range_text(range, "wor");
2752 test_range_parent(range, ET_BODY);
2753 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2754 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2755 test_range_move(range, characterW, 3, 3);
2756 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2757 test_range_moveend(range, characterW, -4, -4);
2758 test_range_put_text(range, "abc def ");
2759 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2760 test_range_move(range, wordW, 1, 1);
2761 test_range_movestart(range, characterW, -1, -1);
2762 test_range_text(range, " ");
2763 test_range_move(range, wordW, 1, 1);
2764 test_range_moveend(range, characterW, 3, 3);
2765 test_range_text(range, "def");
2766 test_range_put_text(range, "xyz");
2767 test_range_moveend(range, characterW, 1, 1);
2768 test_range_move(range, wordW, 1, 1);
2769 test_range_moveend(range, characterW, 2, 2);
2770 test_range_text(range, "ab");
2772 IHTMLTxtRange_Release(range);
2775 static void test_txtrange2(IHTMLDocument2 *doc)
2777 IHTMLTxtRange *range;
2779 range = test_create_body_range(doc);
2781 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2782 test_range_move(range, characterW, 5, 5);
2783 test_range_moveend(range, characterW, 1, 1);
2784 test_range_text(range, "2");
2785 test_range_move(range, characterW, -3, -3);
2786 test_range_moveend(range, characterW, 3, 3);
2787 test_range_text(range, "c\r\n\r\n1");
2788 test_range_collapse(range, VARIANT_FALSE);
2789 test_range_moveend(range, characterW, 4, 4);
2790 test_range_text(range, "23");
2791 test_range_moveend(range, characterW, 1, 1);
2792 test_range_text(range, "23\r\n\r\n\r\nd");
2793 test_range_moveend(range, characterW, -1, -1);
2794 test_range_text(range, "23");
2795 test_range_moveend(range, characterW, -1, -1);
2796 test_range_text(range, "23");
2797 test_range_moveend(range, characterW, -2, -2);
2798 test_range_text(range, "2");
2800 IHTMLTxtRange_Release(range);
2803 static void test_compatmode(IHTMLDocument2 *doc)
2805 IHTMLDocument5 *doc5;
2809 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2810 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2814 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2815 IHTMLDocument5_Release(doc5);
2816 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2817 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2818 SysFreeString(mode);
2821 static void test_location(IHTMLDocument2 *doc)
2823 IHTMLLocation *location, *location2;
2824 IHTMLWindow2 *window;
2829 hres = IHTMLDocument2_get_location(doc, &location);
2830 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2832 hres = IHTMLDocument2_get_location(doc, &location2);
2833 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2835 ok(location == location2, "location != location2\n");
2836 IHTMLLocation_Release(location2);
2838 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2839 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2841 hres = IHTMLWindow2_get_location(window, &location2);
2842 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2843 ok(location == location2, "location != location2\n");
2844 IHTMLLocation_Release(location2);
2846 test_ifaces((IUnknown*)location, location_iids);
2847 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2849 hres = IHTMLLocation_get_pathname(location, &str);
2850 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2851 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2853 hres = IHTMLLocation_get_href(location, NULL);
2854 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2856 hres = IHTMLLocation_get_href(location, &str);
2857 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2858 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2860 ref = IHTMLLocation_Release(location);
2861 ok(!ref, "location chould be destroyed here\n");
2864 static void test_navigator(IHTMLDocument2 *doc)
2866 IHTMLWindow2 *window;
2867 IOmNavigator *navigator, *navigator2;
2874 static const WCHAR v40[] = {'4','.','0'};
2876 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2877 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2879 hres = IHTMLWindow2_get_navigator(window, &navigator);
2880 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2881 ok(navigator != NULL, "navigator == NULL\n");
2882 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2884 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2885 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2886 ok(navigator != navigator2, "navigator2 != navihgator\n");
2888 IHTMLWindow2_Release(window);
2889 IOmNavigator_Release(navigator2);
2891 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2892 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2893 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2894 SysFreeString(bstr);
2897 hres = IOmNavigator_get_appName(navigator, &bstr);
2898 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2899 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2900 SysFreeString(bstr);
2903 hres = IOmNavigator_get_platform(navigator, &bstr);
2904 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2906 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2908 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2910 SysFreeString(bstr);
2913 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2914 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2915 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2916 SysFreeString(bstr);
2918 hres = IOmNavigator_toString(navigator, NULL);
2919 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2922 hres = IOmNavigator_toString(navigator, &bstr);
2923 ok(hres == S_OK, "toString failed: %08x\n", hres);
2924 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2925 SysFreeString(bstr);
2928 hres = ObtainUserAgentString(0, buf, &size);
2929 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2932 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2933 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2934 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2935 SysFreeString(bstr);
2937 ref = IOmNavigator_Release(navigator);
2938 ok(!ref, "navigator should be destroyed here\n");
2941 static void test_current_style(IHTMLCurrentStyle *current_style)
2947 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2948 test_ifaces((IUnknown*)current_style, cstyle_iids);
2950 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2951 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2952 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2955 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2956 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2957 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2960 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2961 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2964 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2965 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2966 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2969 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2970 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2971 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2974 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2975 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2976 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2979 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2980 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2981 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2984 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2985 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2986 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2989 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2990 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2991 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2994 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2995 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2996 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2999 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3000 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3001 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3004 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3005 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3006 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3009 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3010 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3011 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3014 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3015 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3016 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3019 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3020 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3023 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3024 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3027 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3028 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3031 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3032 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3035 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3036 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3039 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3040 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3043 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3044 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3045 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3046 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3049 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3050 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3051 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3054 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3055 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3056 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3059 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3060 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3061 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3064 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3065 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3066 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3069 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3070 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3071 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3074 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3075 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3076 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3079 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3080 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3081 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3082 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3085 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3086 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3087 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3088 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3091 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3092 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3093 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3096 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3097 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3098 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3101 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3102 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3103 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3107 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3108 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3109 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3112 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3113 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3114 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3117 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3118 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3119 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3122 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3123 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3124 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3127 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3128 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3129 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3132 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3133 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3134 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3137 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3138 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3139 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3142 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3143 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3144 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3147 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3148 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3149 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3152 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3153 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3154 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3157 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3158 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3159 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3162 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3163 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3164 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3167 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3168 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3169 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3172 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3173 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3174 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3177 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3178 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3179 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3182 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3183 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3184 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3187 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3188 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3189 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3192 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3193 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3194 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3197 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3198 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3199 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3203 static void test_style2(IHTMLStyle2 *style2)
3208 str = (void*)0xdeadbeef;
3209 hres = IHTMLStyle2_get_position(style2, &str);
3210 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3211 ok(!str, "str != NULL\n");
3213 str = a2bstr("absolute");
3214 hres = IHTMLStyle2_put_position(style2, str);
3215 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3219 hres = IHTMLStyle2_get_position(style2, &str);
3220 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3221 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3225 static void test_style3(IHTMLStyle3 *style3)
3230 str = (void*)0xdeadbeef;
3231 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3232 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3233 ok(!str, "str != NULL\n");
3235 str = a2bstr("break-word");
3236 hres = IHTMLStyle3_put_wordWrap(style3, str);
3237 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3241 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3242 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3243 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3247 static void test_style4(IHTMLStyle4 *style4)
3253 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3254 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3257 V_BSTR(&v) = a2bstr("10px");
3258 hres = IHTMLStyle4_put_minHeight(style4, v);
3259 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3262 hres = IHTMLStyle4_get_minHeight(style4, &v);
3263 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3264 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3265 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3267 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3268 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3269 VariantClear(&vdefault);
3272 static void test_default_style(IHTMLStyle *style)
3274 IHTMLStyle2 *style2;
3275 IHTMLStyle3 *style3;
3276 IHTMLStyle4 *style4;
3282 BSTR sOverflowDefault;
3286 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3287 test_ifaces((IUnknown*)style, style_iids);
3289 test_style_csstext(style, NULL);
3291 hres = IHTMLStyle_get_position(style, &str);
3292 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3293 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3296 hres = IHTMLStyle_get_marginRight(style, &v);
3297 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3298 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3299 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3302 hres = IHTMLStyle_get_marginLeft(style, &v);
3303 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3304 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3305 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3307 str = (void*)0xdeadbeef;
3308 hres = IHTMLStyle_get_fontFamily(style, &str);
3309 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3310 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3312 str = (void*)0xdeadbeef;
3313 hres = IHTMLStyle_get_fontWeight(style, &str);
3314 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3315 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3317 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3318 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3320 str = a2bstr("test");
3321 hres = IHTMLStyle_put_fontWeight(style, str);
3322 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3325 str = a2bstr("bold");
3326 hres = IHTMLStyle_put_fontWeight(style, str);
3327 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3330 str = a2bstr("bolder");
3331 hres = IHTMLStyle_put_fontWeight(style, str);
3332 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3335 str = a2bstr("lighter");
3336 hres = IHTMLStyle_put_fontWeight(style, str);
3337 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3340 str = a2bstr("100");
3341 hres = IHTMLStyle_put_fontWeight(style, str);
3342 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3345 str = a2bstr("200");
3346 hres = IHTMLStyle_put_fontWeight(style, str);
3347 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3350 str = a2bstr("300");
3351 hres = IHTMLStyle_put_fontWeight(style, str);
3352 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3355 str = a2bstr("400");
3356 hres = IHTMLStyle_put_fontWeight(style, str);
3357 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3360 str = a2bstr("500");
3361 hres = IHTMLStyle_put_fontWeight(style, str);
3362 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3365 str = a2bstr("600");
3366 hres = IHTMLStyle_put_fontWeight(style, str);
3367 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3370 str = a2bstr("700");
3371 hres = IHTMLStyle_put_fontWeight(style, str);
3372 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3375 str = a2bstr("800");
3376 hres = IHTMLStyle_put_fontWeight(style, str);
3377 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3380 str = a2bstr("900");
3381 hres = IHTMLStyle_put_fontWeight(style, str);
3382 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3385 hres = IHTMLStyle_get_fontWeight(style, &str);
3386 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3387 ok(!strcmp_wa(str, "900"), "str != style900\n");
3390 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3391 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3392 SysFreeString(sDefault);
3395 hres = IHTMLStyle_get_fontVariant(style, NULL);
3396 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3398 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3399 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3401 str = a2bstr("test");
3402 hres = IHTMLStyle_put_fontVariant(style, str);
3403 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3406 str = a2bstr("small-caps");
3407 hres = IHTMLStyle_put_fontVariant(style, str);
3408 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3411 str = a2bstr("normal");
3412 hres = IHTMLStyle_put_fontVariant(style, str);
3413 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3416 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3417 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3418 SysFreeString(sDefault);
3420 str = (void*)0xdeadbeef;
3421 hres = IHTMLStyle_get_display(style, &str);
3422 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3423 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3425 str = (void*)0xdeadbeef;
3426 hres = IHTMLStyle_get_visibility(style, &str);
3427 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3428 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3431 hres = IHTMLStyle_get_fontSize(style, &v);
3432 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3433 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3434 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3437 hres = IHTMLStyle_get_color(style, &v);
3438 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3439 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3440 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3443 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3444 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3445 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3447 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3448 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3449 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3451 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3452 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3453 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3455 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3456 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3459 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3460 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3461 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3463 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3464 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3465 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3467 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3468 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3469 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3471 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3472 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3475 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3476 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3477 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3479 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3480 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3481 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3483 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3484 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3485 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3487 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3488 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3491 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3492 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3493 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3495 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3496 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3497 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3499 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3500 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3501 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3503 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3504 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3507 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3508 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3509 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3511 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3512 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3513 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3515 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3516 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3517 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3519 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3520 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3522 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3523 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3525 str = a2bstr("invalid");
3526 hres = IHTMLStyle_put_textDecoration(style, str);
3527 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3530 str = a2bstr("none");
3531 hres = IHTMLStyle_put_textDecoration(style, str);
3532 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3535 str = a2bstr("underline");
3536 hres = IHTMLStyle_put_textDecoration(style, str);
3537 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3540 str = a2bstr("overline");
3541 hres = IHTMLStyle_put_textDecoration(style, str);
3542 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3545 str = a2bstr("line-through");
3546 hres = IHTMLStyle_put_textDecoration(style, str);
3547 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3550 str = a2bstr("blink");
3551 hres = IHTMLStyle_put_textDecoration(style, str);
3552 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3555 hres = IHTMLStyle_get_textDecoration(style, &str);
3556 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3557 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3560 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3561 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3562 SysFreeString(sDefault);
3564 hres = IHTMLStyle_get_posWidth(style, NULL);
3565 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3567 hres = IHTMLStyle_get_posWidth(style, &f);
3568 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3569 ok(f == 0.0f, "f = %f\n", f);
3571 V_VT(&v) = VT_EMPTY;
3572 hres = IHTMLStyle_get_width(style, &v);
3573 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3574 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3575 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3577 hres = IHTMLStyle_put_posWidth(style, 2.2);
3578 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3580 hres = IHTMLStyle_get_posWidth(style, &f);
3581 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3583 f == 2.2f, /* IE8 */
3587 V_BSTR(&v) = a2bstr("auto");
3588 hres = IHTMLStyle_put_width(style, v);
3589 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3592 V_VT(&v) = VT_EMPTY;
3593 hres = IHTMLStyle_get_width(style, &v);
3594 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3595 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3596 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3600 str = (void*)0xdeadbeef;
3601 hres = IHTMLStyle_get_margin(style, &str);
3602 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3603 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3606 hres = IHTMLStyle_put_margin(style, str);
3607 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3610 hres = IHTMLStyle_get_margin(style, &str);
3611 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3612 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3614 hres = IHTMLStyle_put_margin(style, NULL);
3615 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3618 hres = IHTMLStyle_get_border(style, &str);
3619 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3620 ok(!str || !*str, "str is not empty\n");
3623 str = a2bstr("1px");
3624 hres = IHTMLStyle_put_border(style, str);
3625 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3628 V_VT(&v) = VT_EMPTY;
3629 hres = IHTMLStyle_get_left(style, &v);
3630 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3631 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3632 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3636 hres = IHTMLStyle_get_posLeft(style, NULL);
3637 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3640 hres = IHTMLStyle_get_posLeft(style, &f);
3641 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3642 ok(f == 0.0, "expected 0.0 got %f\n", f);
3644 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3645 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3647 hres = IHTMLStyle_get_posLeft(style, &f);
3648 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3650 f == 4.9f, /* IE8 */
3651 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3653 /* Ensure left is updated correctly. */
3654 V_VT(&v) = VT_EMPTY;
3655 hres = IHTMLStyle_get_left(style, &v);
3656 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3657 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3658 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3659 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3660 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3665 V_BSTR(&v) = a2bstr("3px");
3666 hres = IHTMLStyle_put_left(style, v);
3667 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3670 hres = IHTMLStyle_get_posLeft(style, &f);
3671 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3672 ok(f == 3.0, "expected 3.0 got %f\n", f);
3674 V_VT(&v) = VT_EMPTY;
3675 hres = IHTMLStyle_get_left(style, &v);
3676 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3677 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3678 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3682 hres = IHTMLStyle_put_left(style, v);
3683 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3685 V_VT(&v) = VT_EMPTY;
3686 hres = IHTMLStyle_get_left(style, &v);
3687 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3688 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3689 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3692 V_VT(&v) = VT_EMPTY;
3693 hres = IHTMLStyle_get_top(style, &v);
3694 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3695 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3696 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3700 hres = IHTMLStyle_get_posTop(style, NULL);
3701 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3704 hres = IHTMLStyle_get_posTop(style, &f);
3705 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3706 ok(f == 0.0, "expected 0.0 got %f\n", f);
3708 hres = IHTMLStyle_put_posTop(style, 4.9f);
3709 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3711 hres = IHTMLStyle_get_posTop(style, &f);
3712 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3714 f == 4.9f, /* IE8 */
3715 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3718 V_BSTR(&v) = a2bstr("3px");
3719 hres = IHTMLStyle_put_top(style, v);
3720 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3723 V_VT(&v) = VT_EMPTY;
3724 hres = IHTMLStyle_get_top(style, &v);
3725 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3726 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3727 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3730 hres = IHTMLStyle_get_posTop(style, &f);
3731 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3732 ok(f == 3.0, "expected 3.0 got %f\n", f);
3735 hres = IHTMLStyle_put_top(style, v);
3736 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3738 V_VT(&v) = VT_EMPTY;
3739 hres = IHTMLStyle_get_top(style, &v);
3740 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3741 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3742 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3745 /* Test posHeight */
3746 hres = IHTMLStyle_get_posHeight(style, NULL);
3747 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3749 V_VT(&v) = VT_EMPTY;
3750 hres = IHTMLStyle_get_height(style, &v);
3751 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3752 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3753 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3757 hres = IHTMLStyle_get_posHeight(style, &f);
3758 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3759 ok(f == 0.0, "expected 0.0 got %f\n", f);
3761 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3762 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3764 hres = IHTMLStyle_get_posHeight(style, &f);
3765 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3767 f == 4.9f, /* IE8 */
3768 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3771 V_BSTR(&v) = a2bstr("64px");
3772 hres = IHTMLStyle_put_height(style, v);
3773 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3776 V_VT(&v) = VT_EMPTY;
3777 hres = IHTMLStyle_get_height(style, &v);
3778 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3779 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3780 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3783 hres = IHTMLStyle_get_posHeight(style, &f);
3784 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3785 ok(f == 64.0, "expected 64.0 got %f\n", f);
3787 str = (void*)0xdeadbeef;
3788 hres = IHTMLStyle_get_cursor(style, &str);
3789 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3790 ok(!str, "get_cursor != NULL\n");
3793 str = a2bstr("default");
3794 hres = IHTMLStyle_put_cursor(style, str);
3795 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3799 hres = IHTMLStyle_get_cursor(style, &str);
3800 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3801 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3804 V_VT(&v) = VT_EMPTY;
3805 hres = IHTMLStyle_get_verticalAlign(style, &v);
3806 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3807 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3808 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3812 V_BSTR(&v) = a2bstr("middle");
3813 hres = IHTMLStyle_put_verticalAlign(style, v);
3814 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3817 V_VT(&v) = VT_EMPTY;
3818 hres = IHTMLStyle_get_verticalAlign(style, &v);
3819 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3820 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3821 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3824 str = (void*)0xdeadbeef;
3825 hres = IHTMLStyle_get_textAlign(style, &str);
3826 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3827 ok(!str, "textAlign != NULL\n");
3829 str = a2bstr("center");
3830 hres = IHTMLStyle_put_textAlign(style, str);
3831 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3835 hres = IHTMLStyle_get_textAlign(style, &str);
3836 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3837 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3840 str = (void*)0xdeadbeef;
3841 hres = IHTMLStyle_get_filter(style, &str);
3842 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3843 ok(!str, "filter != NULL\n");
3845 str = a2bstr("alpha(opacity=100)");
3846 hres = IHTMLStyle_put_filter(style, str);
3847 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3850 V_VT(&v) = VT_EMPTY;
3851 hres = IHTMLStyle_get_zIndex(style, &v);
3852 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3853 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3854 ok(!V_I4(&v), "V_I4(v) != 0\n");
3858 V_BSTR(&v) = a2bstr("1");
3859 hres = IHTMLStyle_put_zIndex(style, v);
3860 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3863 V_VT(&v) = VT_EMPTY;
3864 hres = IHTMLStyle_get_zIndex(style, &v);
3865 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3866 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3867 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3871 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3872 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3874 str = a2bstr("test");
3875 hres = IHTMLStyle_put_fontStyle(style, str);
3876 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3879 str = a2bstr("italic");
3880 hres = IHTMLStyle_put_fontStyle(style, str);
3881 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3884 str = a2bstr("oblique");
3885 hres = IHTMLStyle_put_fontStyle(style, str);
3886 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3889 str = a2bstr("normal");
3890 hres = IHTMLStyle_put_fontStyle(style, str);
3891 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3894 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3895 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3896 SysFreeString(sDefault);
3899 hres = IHTMLStyle_get_overflow(style, NULL);
3900 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3902 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3903 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3905 str = a2bstr("test");
3906 hres = IHTMLStyle_put_overflow(style, str);
3907 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3910 str = a2bstr("visible");
3911 hres = IHTMLStyle_put_overflow(style, str);
3912 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3915 str = a2bstr("scroll");
3916 hres = IHTMLStyle_put_overflow(style, str);
3917 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3920 str = a2bstr("hidden");
3921 hres = IHTMLStyle_put_overflow(style, str);
3922 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3925 str = a2bstr("auto");
3926 hres = IHTMLStyle_put_overflow(style, str);
3927 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3930 hres = IHTMLStyle_get_overflow(style, &str);
3931 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3932 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3936 hres = IHTMLStyle_put_overflow(style, str);
3937 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3940 hres = IHTMLStyle_get_overflow(style, &str);
3941 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3942 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3945 /* restore overflow default */
3946 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3947 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3948 SysFreeString(sOverflowDefault);
3950 /* Attribute Tests*/
3951 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3952 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3954 str = a2bstr("position");
3955 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3956 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3958 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3959 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3960 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3963 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3964 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3967 V_BSTR(&v) = a2bstr("absolute");
3968 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3969 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3972 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3973 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3974 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3975 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3980 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3981 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3986 str = a2bstr("borderLeftStyle");
3987 test_border_styles(style, str);
3990 str = a2bstr("borderbottomstyle");
3991 test_border_styles(style, str);
3994 str = a2bstr("borderrightstyle");
3995 test_border_styles(style, str);
3998 str = a2bstr("bordertopstyle");
3999 test_border_styles(style, str);
4002 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4003 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4005 str = a2bstr("none dotted dashed solid");
4006 hres = IHTMLStyle_put_borderStyle(style, str);
4007 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4010 str = a2bstr("none dotted dashed solid");
4011 hres = IHTMLStyle_get_borderStyle(style, &str);
4012 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4013 ok(!strcmp_wa(str, "none dotted dashed solid"),
4014 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4017 str = a2bstr("double groove ridge inset");
4018 hres = IHTMLStyle_put_borderStyle(style, str);
4019 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4022 str = a2bstr("window-inset outset ridge inset");
4023 hres = IHTMLStyle_put_borderStyle(style, str);
4024 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4027 str = a2bstr("window-inset");
4028 hres = IHTMLStyle_put_borderStyle(style, str);
4029 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4032 str = a2bstr("none none none none none");
4033 hres = IHTMLStyle_put_borderStyle(style, str);
4034 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4037 str = a2bstr("invalid none none none");
4038 hres = IHTMLStyle_put_borderStyle(style, str);
4039 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4042 str = a2bstr("none invalid none none");
4043 hres = IHTMLStyle_put_borderStyle(style, str);
4044 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4047 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4048 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4049 SysFreeString(sDefault);
4051 /* backgoundColor */
4052 hres = IHTMLStyle_get_backgroundColor(style, &v);
4053 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4054 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4055 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4059 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4060 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4063 V_BSTR(&v) = a2bstr("10");
4064 hres = IHTMLStyle_put_paddingLeft(style, v);
4065 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4068 hres = IHTMLStyle_get_paddingLeft(style, &v);
4069 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4070 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4072 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4073 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4075 /* BackgroundRepeat */
4076 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4077 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4079 str = a2bstr("invalid");
4080 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4081 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4084 str = a2bstr("repeat");
4085 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4086 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4089 str = a2bstr("no-repeat");
4090 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4091 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4094 str = a2bstr("repeat-x");
4095 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4096 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4099 str = a2bstr("repeat-y");
4100 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4101 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4104 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4105 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4106 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4109 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4110 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4111 SysFreeString(sDefault);
4114 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4115 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4117 str = a2bstr("red green red blue");
4118 hres = IHTMLStyle_put_borderColor(style, str);
4119 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4122 hres = IHTMLStyle_get_borderColor(style, &str);
4123 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4124 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4127 hres = IHTMLStyle_put_borderColor(style, sDefault);
4128 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4129 SysFreeString(sDefault);
4132 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4133 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4135 str = a2bstr("thick dotted red");
4136 hres = IHTMLStyle_put_borderLeft(style, str);
4137 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4140 /* IHTMLStyle_get_borderLeft appears to have a bug where
4141 it returns the first letter of the color. So we check
4142 each style individually.
4145 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4146 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4147 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4151 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4152 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4153 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4156 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4157 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4158 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4161 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4162 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4163 SysFreeString(sDefault);
4165 /* backgroundPositionX */
4166 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4167 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4170 V_BSTR(&v) = a2bstr("10px");
4171 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4172 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4175 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4176 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4177 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4180 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4181 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4182 VariantClear(&vDefault);
4184 /* backgroundPositionY */
4185 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4186 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4189 V_BSTR(&v) = a2bstr("10px");
4190 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4191 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4194 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4195 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4196 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4199 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4200 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4201 VariantClear(&vDefault);
4203 /* borderTopWidth */
4204 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4205 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4208 V_BSTR(&v) = a2bstr("10px");
4209 hres = IHTMLStyle_put_borderTopWidth(style, v);
4210 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4213 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4214 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4215 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4218 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4219 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4220 VariantClear(&vDefault);
4222 /* borderRightWidth */
4223 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4224 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4227 V_BSTR(&v) = a2bstr("10");
4228 hres = IHTMLStyle_put_borderRightWidth(style, v);
4229 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4232 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4233 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4234 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4237 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4238 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4239 VariantClear(&vDefault);
4241 /* borderBottomWidth */
4242 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4243 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4246 V_BSTR(&v) = a2bstr("10");
4247 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4248 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4251 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4252 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4253 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4256 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4257 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4258 VariantClear(&vDefault);
4260 /* borderLeftWidth */
4261 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4262 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4265 V_BSTR(&v) = a2bstr("10");
4266 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4267 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4270 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4271 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4272 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4275 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4276 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4277 VariantClear(&vDefault);
4280 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4281 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4284 V_BSTR(&v) = a2bstr("10");
4285 hres = IHTMLStyle_put_wordSpacing(style, v);
4286 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4289 hres = IHTMLStyle_get_wordSpacing(style, &v);
4290 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4291 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4292 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4295 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4296 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4297 VariantClear(&vDefault);
4300 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4301 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4304 V_BSTR(&v) = a2bstr("11");
4305 hres = IHTMLStyle_put_letterSpacing(style, v);
4306 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4309 hres = IHTMLStyle_get_letterSpacing(style, &v);
4310 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4311 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4312 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4315 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4316 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4317 VariantClear(&vDefault);
4319 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4320 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4321 if(SUCCEEDED(hres)) {
4322 test_style2(style2);
4323 IHTMLStyle2_Release(style2);
4326 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4327 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4328 if(SUCCEEDED(hres)) {
4329 test_style3(style3);
4330 IHTMLStyle3_Release(style3);
4333 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4334 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4335 if(SUCCEEDED(hres)) {
4336 test_style4(style4);
4337 IHTMLStyle4_Release(style4);
4341 static void test_set_csstext(IHTMLStyle *style)
4346 test_style_set_csstext(style, "background-color: black;");
4348 hres = IHTMLStyle_get_backgroundColor(style, &v);
4349 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4350 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4351 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4355 static void test_default_selection(IHTMLDocument2 *doc)
4357 IHTMLSelectionObject *selection;
4358 IHTMLTxtRange *range;
4363 hres = IHTMLDocument2_get_selection(doc, &selection);
4364 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4366 hres = IHTMLSelectionObject_get_type(selection, &str);
4367 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4368 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4371 hres = IHTMLSelectionObject_createRange(selection, &disp);
4372 IHTMLSelectionObject_Release(selection);
4373 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4375 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4376 IDispatch_Release(disp);
4377 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4379 test_range_text(range, NULL);
4380 IHTMLTxtRange_Release(range);
4383 static void test_doc_elem(IHTMLDocument2 *doc)
4385 IHTMLDocument2 *doc_node, *owner_doc;
4387 IHTMLDocument3 *doc3;
4390 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4391 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4393 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4394 IHTMLDocument3_Release(doc3);
4395 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4397 test_node_name((IUnknown*)elem, "HTML");
4398 test_elem_tag((IUnknown*)elem, "HTML");
4400 doc_node = get_doc_node(doc);
4401 owner_doc = get_owner_doc((IUnknown*)elem);
4402 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4403 IHTMLDocument2_Release(doc_node);
4404 IHTMLDocument2_Release(owner_doc);
4406 test_elem_client_rect((IUnknown*)elem);
4408 IHTMLElement_Release(elem);
4411 static void test_default_body(IHTMLBodyElement *body)
4417 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4418 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4420 bstr = (void*)0xdeadbeef;
4421 hres = IHTMLBodyElement_get_background(body, &bstr);
4422 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4423 ok(bstr == NULL, "bstr != NULL\n");
4425 l = elem_get_scroll_height((IUnknown*)body);
4426 ok(l != -1, "scrollHeight == -1\n");
4427 l = elem_get_scroll_width((IUnknown*)body);
4428 ok(l != -1, "scrollWidth == -1\n");
4429 l = elem_get_scroll_top((IUnknown*)body);
4430 ok(!l, "scrollTop = %d\n", l);
4431 elem_get_scroll_left((IUnknown*)body);
4433 /* get_text tests */
4434 hres = IHTMLBodyElement_get_text(body, &v);
4435 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4436 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4437 ok(bstr == NULL, "bstr != NULL\n");
4440 /* get_text - Invalid Text */
4442 V_BSTR(&v) = SysAllocString(sTextInvalid);
4443 hres = IHTMLBodyElement_put_text(body, v);
4444 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4448 hres = IHTMLBodyElement_get_text(body, &v);
4449 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4450 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4451 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4454 /* get_text - Valid Text */
4456 V_BSTR(&v) = SysAllocString(sBodyText);
4457 hres = IHTMLBodyElement_put_text(body, v);
4458 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4462 hres = IHTMLBodyElement_get_text(body, &v);
4463 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4464 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4465 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4469 static void test_body_funs(IHTMLBodyElement *body)
4471 static WCHAR sRed[] = {'r','e','d',0};
4476 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4477 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4478 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4480 V_VT(&vbg) = VT_BSTR;
4481 V_BSTR(&vbg) = SysAllocString(sRed);
4482 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4483 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4486 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4487 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4488 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4489 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4492 /* Restore Originial */
4493 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4494 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4495 VariantClear(&vDefaultbg);
4498 static void test_window(IHTMLDocument2 *doc)
4500 IHTMLWindow2 *window, *window2, *self;
4501 IHTMLDocument2 *doc2 = NULL;
4507 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4508 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4509 test_ifaces((IUnknown*)window, window_iids);
4510 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4512 hres = IHTMLWindow2_get_document(window, &doc2);
4513 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4514 ok(doc2 != NULL, "doc2 == NULL\n");
4516 test_ifaces((IUnknown*)doc2, doc_node_iids);
4517 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4519 test_ifaces((IUnknown*)doc, doc_obj_iids);
4520 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4522 unk = (void*)0xdeadbeef;
4523 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4524 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4525 ok(!unk, "unk = %p\n", unk);
4527 IHTMLDocument_Release(doc2);
4529 hres = IHTMLWindow2_get_window(window, &window2);
4530 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4531 ok(window2 != NULL, "window2 == NULL\n");
4533 hres = IHTMLWindow2_get_self(window, &self);
4534 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4535 ok(window2 != NULL, "self == NULL\n");
4537 ok(self == window2, "self != window2\n");
4539 IHTMLWindow2_Release(window2);
4540 IHTMLWindow2_Release(self);
4543 hres = IHTMLDocument2_get_Script(doc, &disp);
4544 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4545 ok(disp == (void*)window, "disp != window\n");
4546 IDispatch_Release(disp);
4548 hres = IHTMLWindow2_toString(window, NULL);
4549 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4552 hres = IHTMLWindow2_toString(window, &str);
4553 ok(hres == S_OK, "toString failed: %08x\n", hres);
4554 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4557 test_window_name(window, NULL);
4558 set_window_name(window, "test");
4559 test_window_length(window, 0);
4561 IHTMLWindow2_Release(window);
4564 static void test_defaults(IHTMLDocument2 *doc)
4566 IHTMLStyleSheetsCollection *stylesheetcol;
4567 IHTMLCurrentStyle *cstyle;
4568 IHTMLBodyElement *body;
4569 IHTMLElement2 *elem2;
4574 IHTMLElementCollection *collection;
4576 hres = IHTMLDocument2_get_body(doc, &elem);
4577 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4579 hres = IHTMLDocument2_get_images(doc, NULL);
4580 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4582 hres = IHTMLDocument2_get_images(doc, &collection);
4583 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4586 test_elem_collection((IUnknown*)collection, NULL, 0);
4587 IHTMLElementCollection_Release(collection);
4590 hres = IHTMLDocument2_get_applets(doc, NULL);
4591 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4593 hres = IHTMLDocument2_get_applets(doc, &collection);
4594 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4597 test_elem_collection((IUnknown*)collection, NULL, 0);
4598 IHTMLElementCollection_Release(collection);
4601 hres = IHTMLDocument2_get_links(doc, NULL);
4602 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4604 hres = IHTMLDocument2_get_links(doc, &collection);
4605 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4608 test_elem_collection((IUnknown*)collection, NULL, 0);
4609 IHTMLElementCollection_Release(collection);
4612 hres = IHTMLDocument2_get_forms(doc, NULL);
4613 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4615 hres = IHTMLDocument2_get_forms(doc, &collection);
4616 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4619 test_elem_collection((IUnknown*)collection, NULL, 0);
4620 IHTMLElementCollection_Release(collection);
4623 hres = IHTMLDocument2_get_anchors(doc, NULL);
4624 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4626 hres = IHTMLDocument2_get_anchors(doc, &collection);
4627 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4630 test_elem_collection((IUnknown*)collection, NULL, 0);
4631 IHTMLElementCollection_Release(collection);
4634 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4635 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4636 test_default_body(body);
4637 test_body_funs(body);
4638 IHTMLBodyElement_Release(body);
4640 hres = IHTMLElement_get_style(elem, &style);
4641 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4643 test_default_style(style);
4645 test_compatmode(doc);
4647 test_navigator(doc);
4649 elem2 = get_elem2_iface((IUnknown*)elem);
4650 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4651 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4652 if(SUCCEEDED(hres)) {
4653 test_current_style(cstyle);
4654 IHTMLCurrentStyle_Release(cstyle);
4656 IHTMLElement2_Release(elem2);
4658 IHTMLElement_Release(elem);
4660 test_set_csstext(style);
4661 IHTMLStyle_Release(style);
4663 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4664 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4667 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4668 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4669 ok(l == 0, "length = %d\n", l);
4671 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4673 test_default_selection(doc);
4674 test_doc_title(doc, "");
4677 static void test_tr_elem(IHTMLElement *elem)
4679 IHTMLElementCollection *col;
4683 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4685 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4686 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4691 hres = IHTMLTableRow_get_cells(row, &col);
4692 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4693 ok(col != NULL, "get_cells returned NULL\n");
4695 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4696 IHTMLElementCollection_Release(col);
4698 IHTMLTable_Release(row);
4701 static void test_table_elem(IHTMLElement *elem)
4703 IHTMLElementCollection *col;
4708 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4709 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4711 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4712 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4717 hres = IHTMLTable_get_rows(table, &col);
4718 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4719 ok(col != NULL, "get_ros returned NULL\n");
4721 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4722 IHTMLElementCollection_Release(col);
4724 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4726 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4727 test_elem_tag((IUnknown*)node, "TABLE");
4728 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4729 IHTMLDOMNode_Release(node);
4731 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4732 test_elem_tag((IUnknown*)node, "TABLE");
4733 test_elem_all((IUnknown*)node, NULL, 0);
4734 IHTMLDOMNode_Release(node);
4736 IHTMLTable_Release(table);
4739 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4749 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4750 SafeArrayAccessData(sa, (void**)&var);
4751 V_VT(var) = VT_BSTR;
4752 V_BSTR(var) = str = a2bstr(text);
4753 SafeArrayUnaccessData(sa);
4756 hres = IHTMLDocument2_writeln(doc, sa);
4758 hres = IHTMLDocument2_write(doc, sa);
4759 ok(hres == S_OK, "write failed: %08x\n", hres);
4762 SafeArrayDestroy(sa);
4765 static void test_iframe_elem(IHTMLElement *elem)
4767 IHTMLElementCollection *col;
4768 IHTMLDocument2 *content_doc;
4769 IHTMLWindow2 *content_window;
4770 IHTMLFrameBase2 *base2;
4776 static const elem_type_t all_types[] = {
4784 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4785 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4788 content_window = NULL;
4789 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4790 IHTMLFrameBase2_Release(base2);
4791 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4792 ok(content_window != NULL, "contentWindow = NULL\n");
4794 test_window_length(content_window, 0);
4797 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4798 IHTMLWindow2_Release(content_window);
4799 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4800 ok(content_doc != NULL, "content_doc = NULL\n");
4802 str = a2bstr("text/html");
4803 V_VT(&errv) = VT_ERROR;
4805 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4807 ok(hres == S_OK, "open failed: %08x\n", hres);
4808 ok(disp != NULL, "disp == NULL\n");
4809 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4810 IDispatch_Release(disp);
4812 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4813 doc_write(content_doc, TRUE, "</html>");
4815 hres = IHTMLDocument2_get_all(content_doc, &col);
4816 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4817 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4818 IHTMLElementCollection_Release(col);
4820 hres = IHTMLDocument2_close(content_doc);
4821 ok(hres == S_OK, "close failed: %08x\n", hres);
4823 IHTMLDocument2_Release(content_doc);
4826 static void test_stylesheet(IDispatch *disp)
4828 IHTMLStyleSheetRulesCollection *col = NULL;
4829 IHTMLStyleSheet *stylesheet;
4832 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4833 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4835 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4836 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4837 ok(col != NULL, "col == NULL\n");
4839 IHTMLStyleSheetRulesCollection_Release(col);
4840 IHTMLStyleSheet_Release(stylesheet);
4843 static void test_stylesheets(IHTMLDocument2 *doc)
4845 IHTMLStyleSheetsCollection *col = NULL;
4850 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4851 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4852 ok(col != NULL, "col == NULL\n");
4854 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4855 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4856 ok(len == 1, "len=%d\n", len);
4862 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4863 ok(hres == S_OK, "item failed: %08x\n", hres);
4864 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4865 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4866 test_stylesheet(V_DISPATCH(&res));
4873 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4874 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4875 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4876 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4879 IHTMLStyleSheetsCollection_Release(col);
4882 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4884 IDispatchEx *dispex;
4886 DISPPARAMS dp = {NULL, NULL, 0, 0};
4894 static const WCHAR w0[] = {'0',0};
4895 static const WCHAR w100[] = {'1','0','0',0};
4897 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4898 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4900 bstr = SysAllocString(w0);
4901 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4902 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4903 SysFreeString(bstr);
4906 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4907 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4908 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4909 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4910 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4911 type = get_node_type((IUnknown*)node);
4912 ok(type == 3, "type=%d\n", type);
4913 IHTMLDOMNode_Release(node);
4916 bstr = SysAllocString(w100);
4917 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4918 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4919 SysFreeString(bstr);
4921 IDispatchEx_Release(dispex);
4926 static void test_elems(IHTMLDocument2 *doc)
4928 IHTMLElementCollection *col;
4929 IHTMLDOMChildrenCollection *child_col;
4930 IHTMLElement *elem, *elem2, *elem3;
4931 IHTMLDOMNode *node, *node2;
4932 IHTMLWindow2 *window;
4936 IHTMLElementCollection *collection;
4937 IHTMLDocument3 *doc3;
4940 static const elem_type_t all_types[] = {
4965 static const elem_type_t item_types[] = {
4971 hres = IHTMLDocument2_get_all(doc, &col);
4972 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4973 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4974 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4975 IHTMLElementCollection_Release(col);
4977 hres = IHTMLDocument2_get_images(doc, &collection);
4978 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4981 static const elem_type_t images_types[] = {ET_IMG};
4982 test_elem_collection((IUnknown*)collection, images_types, 1);
4984 IHTMLElementCollection_Release(collection);
4987 hres = IHTMLDocument2_get_links(doc, &collection);
4988 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4991 static const elem_type_t images_types[] = {ET_A};
4992 test_elem_collection((IUnknown*)collection, images_types, 1);
4994 IHTMLElementCollection_Release(collection);
4997 hres = IHTMLDocument2_get_anchors(doc, &collection);
4998 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5001 static const elem_type_t anchor_types[] = {ET_A};
5002 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5004 IHTMLElementCollection_Release(collection);
5007 elem = get_doc_elem(doc);
5008 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5009 IHTMLElement_Release(elem);
5011 get_elem_by_id(doc, "xxx", FALSE);
5012 elem = get_doc_elem_by_id(doc, "xxx");
5013 ok(!elem, "elem != NULL\n");
5015 elem = get_doc_elem_by_id(doc, "s");
5016 ok(elem != NULL, "elem == NULL\n");
5018 test_elem_type((IUnknown*)elem, ET_SELECT);
5019 test_elem_attr(elem, "xxx", NULL);
5020 test_elem_attr(elem, "id", "s");
5021 test_elem_class((IUnknown*)elem, NULL);
5022 test_elem_set_class((IUnknown*)elem, "cl");
5023 test_elem_set_class((IUnknown*)elem, NULL);
5024 test_elem_tabindex((IUnknown*)elem, 0);
5025 test_elem_set_tabindex((IUnknown*)elem, 1);
5027 node = test_node_get_parent((IUnknown*)elem);
5028 ok(node != NULL, "node == NULL\n");
5029 test_node_name((IUnknown*)node, "BODY");
5030 node2 = test_node_get_parent((IUnknown*)node);
5031 IHTMLDOMNode_Release(node);
5032 ok(node2 != NULL, "node == NULL\n");
5033 test_node_name((IUnknown*)node2, "HTML");
5034 node = test_node_get_parent((IUnknown*)node2);
5035 IHTMLDOMNode_Release(node2);
5036 ok(node != NULL, "node == NULL\n");
5039 test_node_name((IUnknown*)node, "#document");
5040 type = get_node_type((IUnknown*)node);
5041 ok(type == 9, "type=%d, expected 9\n", type);
5042 node2 = test_node_get_parent((IUnknown*)node);
5043 IHTMLDOMNode_Release(node);
5044 ok(node2 == NULL, "node != NULL\n");
5047 elem2 = test_elem_get_parent((IUnknown*)elem);
5048 ok(elem2 != NULL, "elem2 == NULL\n");
5049 test_node_name((IUnknown*)elem2, "BODY");
5050 elem3 = test_elem_get_parent((IUnknown*)elem2);
5051 IHTMLElement_Release(elem2);
5052 ok(elem3 != NULL, "elem3 == NULL\n");
5053 test_node_name((IUnknown*)elem3, "HTML");
5054 elem2 = test_elem_get_parent((IUnknown*)elem3);
5055 IHTMLElement_Release(elem3);
5056 ok(elem2 == NULL, "elem2 != NULL\n");
5058 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5059 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5060 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5062 test_elem_innertext(elem, "opt1opt2");
5064 IHTMLElement_Release(elem);
5067 elem = get_elem_by_id(doc, "s", TRUE);
5069 IHTMLSelectElement *select;
5070 IHTMLDocument2 *doc_node;
5072 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5073 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5075 test_select_elem(select);
5077 test_elem_title((IUnknown*)select, NULL);
5078 test_elem_set_title((IUnknown*)select, "Title");
5079 test_elem_title((IUnknown*)select, "Title");
5080 test_elem_offset((IUnknown*)select);
5082 node = get_first_child((IUnknown*)select);
5083 ok(node != NULL, "node == NULL\n");
5085 test_elem_type((IUnknown*)node, ET_OPTION);
5086 IHTMLDOMNode_Release(node);
5089 type = get_node_type((IUnknown*)select);
5090 ok(type == 1, "type=%d\n", type);
5092 IHTMLSelectElement_Release(select);
5094 hres = IHTMLElement_get_document(elem, &disp);
5095 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5097 doc_node = get_doc_node(doc);
5098 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
5099 IHTMLDocument2_Release(doc_node);
5101 IHTMLElement_Release(elem);
5104 elem = get_elem_by_id(doc, "sc", TRUE);
5106 IHTMLScriptElement *script;
5109 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5110 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5116 hres = IHTMLScriptElement_get_type(script, &type);
5117 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5118 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5119 SysFreeString(type);
5122 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5123 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5125 hres = IHTMLScriptElement_get_defer(script, &vb);
5126 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5127 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5129 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5130 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5133 IHTMLScriptElement_Release(script);
5136 elem = get_elem_by_id(doc, "in", TRUE);
5138 IHTMLInputElement *input;
5140 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5141 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5143 test_elem_id((IUnknown*)elem, "in");
5144 test_elem_put_id((IUnknown*)elem, "newin");
5145 test_input_get_disabled(input, VARIANT_FALSE);
5146 test_input_set_disabled(input, VARIANT_TRUE);
5147 test_input_set_disabled(input, VARIANT_FALSE);
5148 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5149 test_input_get_disabled(input, VARIANT_TRUE);
5150 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5151 test_input_get_disabled(input, VARIANT_FALSE);
5152 test_elem_client_size((IUnknown*)elem);
5154 test_node_get_value_str((IUnknown*)elem, NULL);
5155 test_node_put_value_str((IUnknown*)elem, "test");
5156 test_node_get_value_str((IUnknown*)elem, NULL);
5157 test_input_value((IUnknown*)elem, NULL);
5158 test_input_put_value((IUnknown*)elem, "test");
5159 test_input_value((IUnknown*)elem, NULL);
5160 test_elem_class((IUnknown*)elem, "testclass");
5161 test_elem_tabindex((IUnknown*)elem, 2);
5162 test_elem_set_tabindex((IUnknown*)elem, 3);
5163 test_elem_title((IUnknown*)elem, "test title");
5165 test_input_get_defaultchecked(input, VARIANT_FALSE);
5166 test_input_set_defaultchecked(input, VARIANT_TRUE);
5167 test_input_set_defaultchecked(input, VARIANT_FALSE);
5169 test_input_get_checked(input, VARIANT_FALSE);
5170 test_input_set_checked(input, VARIANT_TRUE);
5171 test_input_set_checked(input, VARIANT_FALSE);
5173 test_input_src(input, NULL);
5174 test_input_set_src(input, "about:blank");
5176 IHTMLInputElement_Release(input);
5177 IHTMLElement_Release(elem);
5180 elem = get_elem_by_id(doc, "imgid", TRUE);
5182 test_img_src((IUnknown*)elem, "");
5183 test_img_set_src((IUnknown*)elem, "about:blank");
5184 test_img_alt((IUnknown*)elem, NULL);
5185 test_img_set_alt((IUnknown*)elem, "alt test");
5186 IHTMLElement_Release(elem);
5189 elem = get_doc_elem_by_id(doc, "tbl");
5190 ok(elem != NULL, "elem == NULL\n");
5192 test_table_elem(elem);
5193 IHTMLElement_Release(elem);
5196 elem = get_doc_elem_by_id(doc, "row2");
5197 ok(elem != NULL, "elem == NULL\n");
5200 IHTMLElement_Release(elem);
5203 elem = get_doc_elem_by_id(doc, "ifr");
5204 ok(elem != NULL, "elem == NULL\n");
5206 test_iframe_elem(elem);
5207 IHTMLElement_Release(elem);
5210 elem = get_elem_by_id(doc, "a", TRUE);
5212 test_anchor_href((IUnknown*)elem, "http://test/");
5213 IHTMLElement_Release(elem);
5216 hres = IHTMLDocument2_get_body(doc, &elem);
5217 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5219 node = get_first_child((IUnknown*)elem);
5220 ok(node != NULL, "node == NULL\n");
5222 test_ifaces((IUnknown*)node, text_iids);
5223 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5225 node2 = get_first_child((IUnknown*)node);
5226 ok(!node2, "node2 != NULL\n");
5228 type = get_node_type((IUnknown*)node);
5229 ok(type == 3, "type=%d\n", type);
5231 test_node_get_value_str((IUnknown*)node, "text test");
5232 test_node_put_value_str((IUnknown*)elem, "test text");
5233 test_node_get_value_str((IUnknown*)node, "text test");
5235 IHTMLDOMNode_Release(node);
5238 child_col = get_child_nodes((IUnknown*)elem);
5239 ok(child_col != NULL, "child_coll == NULL\n");
5243 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5245 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5246 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5247 ok(length, "length=0\n");
5249 node = get_child_item(child_col, 0);
5250 ok(node != NULL, "node == NULL\n");
5252 type = get_node_type((IUnknown*)node);
5253 ok(type == 3, "type=%d\n", type);
5254 IHTMLDOMNode_Release(node);
5257 node = get_child_item(child_col, 1);
5258 ok(node != NULL, "node == NULL\n");
5260 type = get_node_type((IUnknown*)node);
5261 ok(type == 8, "type=%d\n", type);
5263 test_elem_id((IUnknown*)node, NULL);
5264 IHTMLDOMNode_Release(node);
5267 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5268 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5270 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5271 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5273 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5274 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5276 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5277 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5279 test_child_col_disp(child_col);
5281 IHTMLDOMChildrenCollection_Release(child_col);
5284 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5285 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5286 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5288 IHTMLElement_Release(elem);
5290 test_stylesheets(doc);
5291 test_create_option_elem(doc);
5292 test_create_img_elem(doc);
5294 elem = get_doc_elem_by_id(doc, "tbl");
5295 ok(elem != NULL, "elem = NULL\n");
5296 test_elem_set_innertext(elem, "inner text");
5297 IHTMLElement_Release(elem);
5299 test_doc_title(doc, "test");
5300 test_doc_set_title(doc, "test title");
5301 test_doc_title(doc, "test title");
5304 hres = IHTMLDocument2_get_Script(doc, &disp);
5305 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5308 IDispatchEx *dispex;
5309 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5310 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5314 BSTR str = a2bstr("Testing");
5315 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5316 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5317 ok(pid != -1, "pid == -1\n");
5319 IDispatchEx_Release(dispex);
5322 IDispatch_Release(disp);
5324 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5325 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5327 str = a2bstr("img");
5328 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5329 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5333 static const elem_type_t img_types[] = { ET_IMG };
5335 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5336 IHTMLElementCollection_Release(col);
5339 elem = get_doc_elem_by_id(doc, "y");
5340 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5341 test_elem_innerhtml((IUnknown*)elem, "inner html");
5342 test_elem_set_innerhtml((IUnknown*)elem, "");
5343 test_elem_innerhtml((IUnknown*)elem, NULL);
5344 IHTMLElement_Release(elem);
5346 IHTMLDocument3_Release(doc3);
5348 window = get_doc_window(doc);
5349 test_window_name(window, NULL);
5350 set_window_name(window, "test name");
5351 test_window_length(window, 1);
5352 IHTMLWindow2_Release(window);
5355 static void test_create_elems(IHTMLDocument2 *doc)
5357 IHTMLElement *elem, *body, *elem2;
5358 IHTMLDOMNode *node, *node2, *node3, *comment;
5359 IHTMLDocument5 *doc5;
5366 static const elem_type_t types1[] = { ET_TESTG };
5368 elem = test_create_elem(doc, "TEST");
5369 test_elem_tag((IUnknown*)elem, "TEST");
5370 type = get_node_type((IUnknown*)elem);
5371 ok(type == 1, "type=%d\n", type);
5372 test_ifaces((IUnknown*)elem, elem_iids);
5373 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5375 hres = IHTMLDocument2_get_body(doc, &body);
5376 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5377 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5379 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5380 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5381 elem2 = get_elem_iface((IUnknown*)node);
5382 IHTMLElement_Release(elem2);
5384 hres = IHTMLElement_get_all(body, &disp);
5385 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5386 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5387 IDispatch_Release(disp);
5389 test_node_remove_child((IUnknown*)body, node);
5391 hres = IHTMLElement_get_all(body, &disp);
5392 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5393 test_elem_collection((IUnknown*)disp, NULL, 0);
5394 IDispatch_Release(disp);
5395 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5397 IHTMLElement_Release(elem);
5398 IHTMLDOMNode_Release(node);
5400 node = test_create_text(doc, "test");
5401 test_ifaces((IUnknown*)node, text_iids);
5402 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5404 V_VT(&var) = VT_NULL;
5405 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5406 IHTMLDOMNode_Release(node);
5408 node = test_create_text(doc, "insert ");
5410 V_VT(&var) = VT_DISPATCH;
5411 V_DISPATCH(&var) = (IDispatch*)node2;
5412 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5413 IHTMLDOMNode_Release(node);
5414 IHTMLDOMNode_Release(node2);
5415 IHTMLDOMNode_Release(node3);
5417 test_elem_innertext(body, "insert test");
5418 test_elem_innerhtml((IUnknown*)body, "insert test");
5420 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5423 str = a2bstr("testing");
5424 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5426 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5429 type = get_node_type((IUnknown*)comment);
5430 ok(type == 8, "type=%d, expected 8\n", type);
5432 test_node_get_value_str((IUnknown*)comment, "testing");
5434 IHTMLDOMNode_Release(comment);
5437 IHTMLDocument5_Release(doc5);
5440 IHTMLElement_Release(body);
5443 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5445 IOleCommandTarget *cmdtrg;
5448 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5449 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5451 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5452 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5454 IOleCommandTarget_Release(cmdtrg);
5457 static void test_indent(IHTMLDocument2 *doc)
5459 IHTMLElementCollection *col;
5460 IHTMLTxtRange *range;
5463 static const elem_type_t all_types[] = {
5472 static const elem_type_t indent_types[] = {
5483 hres = IHTMLDocument2_get_all(doc, &col);
5484 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5485 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5486 IHTMLElementCollection_Release(col);
5488 range = test_create_body_range(doc);
5489 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5490 IHTMLTxtRange_Release(range);
5492 hres = IHTMLDocument2_get_all(doc, &col);
5493 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5494 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5495 IHTMLElementCollection_Release(col);
5498 static void test_cond_comment(IHTMLDocument2 *doc)
5500 IHTMLElementCollection *col;
5503 static const elem_type_t all_types[] = {
5511 hres = IHTMLDocument2_get_all(doc, &col);
5512 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5513 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5514 IHTMLElementCollection_Release(col);
5517 static IHTMLDocument2 *notif_doc;
5518 static BOOL doc_complete;
5520 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5521 REFIID riid, void**ppv)
5523 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5528 ok(0, "unexpected call\n");
5529 return E_NOINTERFACE;
5532 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5537 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5542 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5544 if(dispID == DISPID_READYSTATE){
5548 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5549 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5551 if(!strcmp_wa(state, "complete"))
5552 doc_complete = TRUE;
5554 SysFreeString(state);
5560 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5562 ok(0, "unexpected call\n");
5566 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5567 PropertyNotifySink_QueryInterface,
5568 PropertyNotifySink_AddRef,
5569 PropertyNotifySink_Release,
5570 PropertyNotifySink_OnChanged,
5571 PropertyNotifySink_OnRequestEdit
5574 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5576 static IHTMLDocument2 *create_doc_with_string(const char *str)
5578 IPersistStreamInit *init;
5580 IHTMLDocument2 *doc;
5584 notif_doc = doc = create_document();
5588 doc_complete = FALSE;
5590 mem = GlobalAlloc(0, len);
5591 memcpy(mem, str, len);
5592 CreateStreamOnHGlobal(mem, TRUE, &stream);
5594 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5596 IPersistStreamInit_Load(init, stream);
5597 IPersistStreamInit_Release(init);
5598 IStream_Release(stream);
5603 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5605 IConnectionPointContainer *container;
5606 IConnectionPoint *cp;
5610 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5611 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5613 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5614 IConnectionPointContainer_Release(container);
5615 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5617 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5618 IConnectionPoint_Release(cp);
5619 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5622 typedef void (*domtest_t)(IHTMLDocument2*);
5624 static void run_domtest(const char *str, domtest_t test)
5626 IHTMLDocument2 *doc;
5627 IHTMLElement *body = NULL;
5632 doc = create_doc_with_string(str);
5636 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5638 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5639 TranslateMessage(&msg);
5640 DispatchMessage(&msg);
5643 hres = IHTMLDocument2_get_body(doc, &body);
5644 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5647 IHTMLElement_Release(body);
5650 skip("Could not get document body. Assuming no Gecko installed.\n");
5653 ref = IHTMLDocument2_Release(doc);
5655 ref == 1, /* Vista */
5659 static void gecko_installer_workaround(BOOL disable)
5664 static BOOL has_url = FALSE;
5665 static char url[2048];
5667 if(!disable && !has_url)
5670 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5671 if(res != ERROR_SUCCESS)
5675 DWORD type, size = sizeof(url);
5677 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5678 if(res == ERROR_SUCCESS && type == REG_SZ)
5681 RegDeleteValue(hkey, "GeckoUrl");
5683 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5691 gecko_installer_workaround(TRUE);
5694 run_domtest(doc_str1, test_doc_elem);
5695 run_domtest(doc_str1, test_get_set_attr);
5696 run_domtest(range_test_str, test_txtrange);
5697 run_domtest(range_test2_str, test_txtrange2);
5698 if (winetest_interactive || ! is_ie_hardened()) {
5699 run_domtest(elem_test_str, test_elems);
5701 skip("IE running in Enhanced Security Configuration\n");
5703 run_domtest(doc_blank, test_create_elems);
5704 run_domtest(doc_blank, test_defaults);
5705 run_domtest(indent_test_str, test_indent);
5706 run_domtest(cond_comment_str, test_cond_comment);
5709 gecko_installer_workaround(FALSE);