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 elem_test2_str[] =
56 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
57 "<body><div id=\"divid\"></div></body>"
60 static const char indent_test_str[] =
61 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
62 static const char cond_comment_str[] =
63 "<html><head><title>test</title></head><body>"
64 "<!--[if gte IE 4]> <br> <![endif]-->"
66 static const char frameset_str[] =
67 "<html><head><title>frameset test</title></head><frameset rows=\"28, *\">"
68 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
71 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
72 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
73 static WCHAR wordW[] = {'w','o','r','d',0};
102 static const IID * const none_iids[] = {
107 static const IID * const doc_node_iids[] = {
116 &IID_IConnectionPointContainer,
117 &IID_IInternetHostSecurityManager,
121 static const IID * const doc_obj_iids[] = {
128 &IID_IConnectionPointContainer,
133 static const IID * const elem_iids[] = {
140 &IID_IConnectionPointContainer,
144 static const IID * const body_iids[] = {
150 &IID_IHTMLTextContainer,
151 &IID_IHTMLBodyElement,
153 &IID_IConnectionPointContainer,
157 static const IID * const anchor_iids[] = {
163 &IID_IHTMLAnchorElement,
165 &IID_IConnectionPointContainer,
169 static const IID * const input_iids[] = {
175 &IID_IHTMLInputElement,
176 &IID_IHTMLInputTextElement,
178 &IID_IConnectionPointContainer,
182 static const IID * const select_iids[] = {
188 &IID_IHTMLSelectElement,
190 &IID_IConnectionPointContainer,
194 static const IID * const textarea_iids[] = {
200 &IID_IHTMLTextAreaElement,
202 &IID_IConnectionPointContainer,
206 static const IID * const option_iids[] = {
212 &IID_IHTMLOptionElement,
214 &IID_IConnectionPointContainer,
218 static const IID * const table_iids[] = {
226 &IID_IConnectionPointContainer,
230 static const IID * const script_iids[] = {
236 &IID_IHTMLScriptElement,
238 &IID_IConnectionPointContainer,
242 static const IID * const text_iids[] = {
245 &IID_IHTMLDOMTextNode,
249 static const IID * const location_iids[] = {
255 static const IID * const window_iids[] = {
263 static const IID * const comment_iids[] = {
269 &IID_IHTMLCommentElement,
271 &IID_IConnectionPointContainer,
275 static const IID * const img_iids[] = {
282 &IID_IHTMLImgElement,
283 &IID_IConnectionPointContainer,
287 static const IID * const tr_iids[] = {
295 &IID_IConnectionPointContainer,
299 static const IID * const td_iids[] = {
306 &IID_IConnectionPointContainer,
310 static const IID * const iframe_iids[] = {
317 &IID_IHTMLFrameBase2,
319 &IID_IConnectionPointContainer,
323 static const IID * const generic_iids[] = {
329 &IID_IHTMLGenericElement,
331 &IID_IConnectionPointContainer,
335 static const IID * const style_iids[] = {
346 static const IID * const cstyle_iids[] = {
350 &IID_IHTMLCurrentStyle,
354 static const IID * const img_factory_iids[] = {
358 &IID_IHTMLImageElementFactory,
368 static const elem_type_info_t elem_type_infos[] = {
369 {"", none_iids, NULL},
370 {"HTML", elem_iids, NULL},
371 {"HEAD", elem_iids, NULL},
372 {"TITLE", elem_iids, NULL},
373 {"BODY", body_iids, &DIID_DispHTMLBody},
374 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
375 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
376 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
377 {"TEXTAREA", textarea_iids, NULL},
378 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
379 {"STYLE", elem_iids, NULL},
380 {"BLOCKQUOTE",elem_iids, NULL},
381 {"P", elem_iids, NULL},
382 {"BR", elem_iids, NULL},
383 {"TABLE", table_iids, &DIID_DispHTMLTable},
384 {"TBODY", elem_iids, NULL},
385 {"SCRIPT", script_iids, NULL},
386 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
387 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
388 {"!", comment_iids, &DIID_DispHTMLCommentElement},
389 {"IMG", img_iids, &DIID_DispHTMLImg},
390 {"TR", tr_iids, &DIID_DispHTMLTableRow},
391 {"TD", td_iids, NULL},
392 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
395 static const char *dbgstr_guid(REFIID riid)
399 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
400 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
401 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
402 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
407 static int strcmp_wa(LPCWSTR strw, const char *stra)
410 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
411 return lstrcmpA(stra, buf);
414 static BSTR a2bstr(const char *str)
419 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
420 ret = SysAllocStringLen(NULL, len);
421 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
426 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
428 IUnknown *unk1, *unk2;
433 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
434 IUnknown_Release(unk1);
435 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
436 IUnknown_Release(unk2);
441 static IHTMLDocument2 *create_document(void)
444 IHTMLDocument5 *doc5;
447 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
448 &IID_IHTMLDocument2, (void**)&doc);
449 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
453 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
455 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
456 IHTMLDocument2_Release(doc);
460 IHTMLDocument5_Release(doc5);
464 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
465 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
467 const IID * const *piid;
471 for(piid = iids; *piid; piid++) {
472 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
473 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
475 IUnknown_Release(unk);
479 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
480 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
488 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
489 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
494 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
495 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
496 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
498 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
499 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
501 if(SUCCEEDED(hres)) {
504 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
505 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
507 *iid = type_attr->guid;
511 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
512 ITypeInfo_Release(typeinfo);
515 IDispatchEx_Release(dispex);
519 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
520 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
522 DISPPARAMS dp = {NULL,NULL,0,0};
528 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
529 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
533 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
534 IDispatchEx_Release(dispex);
535 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
537 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
538 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
542 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
543 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
547 if(_test_get_dispid(line, unk, &iid))
548 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
551 _test_disp_value(line, unk, val);
554 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
555 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
559 if(_test_get_dispid(line, unk, &iid))
560 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
561 "unexpected guid %s\n", dbgstr_guid(&iid));
564 _test_disp_value(line, unk, val);
567 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
568 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
574 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
578 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
579 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
584 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
585 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
589 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
590 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
595 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
596 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
600 #define get_node_iface(u) _get_node_iface(__LINE__,u)
601 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
606 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
607 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
611 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
612 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
617 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
618 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
622 #define get_img_iface(u) _get_img_iface(__LINE__,u)
623 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
625 IHTMLImgElement *img;
628 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
629 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
633 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
634 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
636 IHTMLAnchorElement *anchor;
639 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
640 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
644 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
645 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
647 IHTMLDOMNode *node = _get_node_iface(line, unk);
651 hres = IHTMLDOMNode_get_nodeName(node, &name);
652 IHTMLDOMNode_Release(node);
653 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
654 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
659 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
660 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
662 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
663 IDispatch *disp = (void*)0xdeadbeef;
664 IHTMLDocument2 *doc = NULL;
667 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
668 IHTMLDOMNode2_Release(node);
669 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
672 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
673 IDispatch_Release(disp);
674 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
680 #define get_doc_window(d) _get_doc_window(__LINE__,d)
681 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
683 IHTMLWindow2 *window;
687 hres = IHTMLDocument2_get_parentWindow(doc, &window);
688 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
689 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
694 #define clone_node(n,d) _clone_node(__LINE__,n,d)
695 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
697 IHTMLDOMNode *node = _get_node_iface(line, unk);
698 IHTMLDOMNode *ret = NULL;
701 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
702 IHTMLDOMNode_Release(node);
703 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
704 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
710 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
711 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
713 IHTMLElement *elem = _get_elem_iface(line, unk);
717 hres = IHTMLElement_get_tagName(elem, &tag);
718 IHTMLElement_Release(elem);
719 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
720 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
725 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
726 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
728 _test_elem_tag(line, unk, elem_type_infos[type].tag);
729 _test_ifaces(line, unk, elem_type_infos[type].iids);
731 if(elem_type_infos[type].dispiid && type != ET_A)
732 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
735 #define get_node_type(n) _get_node_type(__LINE__,n)
736 static LONG _get_node_type(unsigned line, IUnknown *unk)
738 IHTMLDOMNode *node = _get_node_iface(line, unk);
742 hres = IHTMLDOMNode_get_nodeType(node, &type);
743 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
745 IHTMLDOMNode_Release(node);
750 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
751 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
753 IHTMLDOMNode *node = _get_node_iface(line, unk);
754 IHTMLDOMChildrenCollection *col = NULL;
758 hres = IHTMLDOMNode_get_childNodes(node, &disp);
759 IHTMLDOMNode_Release(node);
760 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
764 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
765 IDispatch_Release(disp);
766 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
771 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
772 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
774 IHTMLDOMNode *node = NULL;
778 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
779 ok(hres == S_OK, "item failed: %08x\n", hres);
781 node = _get_node_iface(line, (IUnknown*)disp);
782 IDispatch_Release(disp);
787 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
788 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
797 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
799 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
802 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
803 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
805 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
808 VariantClear(&value);
811 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
812 static void _test_elem_offset(unsigned line, IUnknown *unk)
814 IHTMLElement *elem = _get_elem_iface(line, unk);
818 hres = IHTMLElement_get_offsetTop(elem, &l);
819 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
821 hres = IHTMLElement_get_offsetHeight(elem, &l);
822 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
824 hres = IHTMLElement_get_offsetWidth(elem, &l);
825 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
827 IHTMLElement_Release(elem);
830 #define get_doc_node(d) _get_doc_node(__LINE__,d)
831 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
833 IHTMLWindow2 *window;
837 hres = IHTMLDocument2_get_parentWindow(doc, &window);
838 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
840 hres = IHTMLWindow2_get_document(window, &ret);
841 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
842 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
847 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
848 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
853 hres = IHTMLWindow2_get_name(window, &name);
854 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
856 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
858 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
861 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
862 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
868 hres = IHTMLWindow2_put_name(window, str);
870 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
872 _test_window_name(line, window, name);
875 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
876 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
881 hres = IHTMLWindow2_get_length(window, &length);
882 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
883 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
886 static void test_get_set_attr(IHTMLDocument2 *doc)
889 IHTMLDocument3 *doc3;
894 /* grab an element to test with */
895 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
896 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
898 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
899 IHTMLDocument3_Release(doc3);
900 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
902 /* get a non-present attribute */
903 bstr = a2bstr("notAnAttribute");
904 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
905 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
906 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
910 /* get a present attribute */
911 bstr = a2bstr("scrollHeight");
912 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
913 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
914 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
918 /* create a new BSTR attribute */
919 bstr = a2bstr("newAttribute");
921 V_VT(&val) = VT_BSTR;
922 V_BSTR(&val) = a2bstr("the value");
923 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
924 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
927 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
928 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
929 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
930 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)));
933 /* overwrite the attribute with a BOOL */
934 V_VT(&val) = VT_BOOL;
935 V_BOOL(&val) = VARIANT_TRUE;
936 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
937 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
940 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
941 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
942 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
943 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
948 /* case-insensitive */
949 bstr = a2bstr("newattribute");
950 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
951 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
952 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
953 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
957 IHTMLElement_Release(elem);
960 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
961 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
964 IHTMLDocument3 *doc3;
967 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
968 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
969 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
970 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
971 IHTMLDocument3_Release(doc3);
976 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
977 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
979 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
983 hres = IHTMLAnchorElement_get_href(anchor, &str);
984 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
985 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
988 _test_disp_value(line, unk, exhref);
991 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
992 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
997 hres = IHTMLOptionElement_get_text(option, &bstr);
998 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
999 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1000 SysFreeString(bstr);
1003 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1004 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1009 bstr = a2bstr(text);
1010 hres = IHTMLOptionElement_put_text(option, bstr);
1011 SysFreeString(bstr);
1012 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1014 _test_option_text(line, option, text);
1017 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1018 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1023 hres = IHTMLOptionElement_get_value(option, &bstr);
1024 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1025 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1026 SysFreeString(bstr);
1029 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1030 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1035 bstr = a2bstr(value);
1036 hres = IHTMLOptionElement_put_value(option, bstr);
1037 SysFreeString(bstr);
1038 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1040 _test_option_value(line, option, value);
1043 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1044 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1045 const char *txt, const char *val)
1047 IHTMLOptionElementFactory *factory;
1048 IHTMLOptionElement *option;
1049 IHTMLWindow2 *window;
1050 VARIANT text, value, empty;
1053 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1054 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1056 hres = IHTMLWindow2_get_Option(window, &factory);
1057 IHTMLWindow2_Release(window);
1058 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1060 V_VT(&text) = VT_BSTR;
1061 V_BSTR(&text) = a2bstr(txt);
1062 V_VT(&value) = VT_BSTR;
1063 V_BSTR(&value) = a2bstr(val);
1064 V_VT(&empty) = VT_EMPTY;
1066 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1067 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1069 IHTMLOptionElementFactory_Release(factory);
1070 VariantClear(&text);
1071 VariantClear(&value);
1073 _test_option_text(line, option, txt);
1074 _test_option_value(line, option, val);
1079 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1080 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1085 hres = IHTMLImgElement_get_width(img, &found);
1086 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1087 todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1090 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1091 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1095 hres = IHTMLImgElement_put_width(img, width);
1096 todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres);
1098 _test_img_width(line, img, width);
1101 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1102 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1107 hres = IHTMLImgElement_get_height(img, &found);
1108 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1109 todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1112 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1113 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1117 hres = IHTMLImgElement_put_height(img, height);
1118 todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres);
1120 _test_img_height(line, img, height);
1123 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1124 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1125 LONG wdth, LONG hght)
1127 IHTMLImageElementFactory *factory;
1128 IHTMLImgElement *img;
1129 IHTMLWindow2 *window;
1130 VARIANT width, height;
1134 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1135 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1137 hres = IHTMLWindow2_get_Image(window, &factory);
1138 IHTMLWindow2_Release(window);
1139 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1141 test_ifaces((IUnknown*)factory, img_factory_iids);
1142 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1145 snprintf(buf, 16, "%d", wdth);
1146 V_VT(&width) = VT_BSTR;
1147 V_BSTR(&width) = a2bstr(buf);
1149 V_VT(&width) = VT_EMPTY;
1154 snprintf(buf, 16, "%d", hght);
1155 V_VT(&height) = VT_BSTR;
1156 V_BSTR(&height) = a2bstr(buf);
1158 V_VT(&height) = VT_EMPTY;
1162 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1163 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1165 IHTMLImageElementFactory_Release(factory);
1166 VariantClear(&width);
1167 VariantClear(&height);
1169 if(SUCCEEDED(hres)) {
1170 _test_img_width(line, img, wdth);
1171 _test_img_height(line, img, hght);
1178 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1179 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1181 LONG len = 0xdeadbeef;
1184 hres = IHTMLSelectElement_get_length(select, &len);
1185 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1186 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1189 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1190 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1192 LONG idx = 0xdeadbeef;
1195 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1196 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1197 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1200 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1201 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1205 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1206 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1207 _test_select_selidx(line, select, index);
1210 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1211 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1216 hres = IHTMLSelectElement_get_value(select, &val);
1217 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1219 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1221 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1224 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1225 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1231 hres = IHTMLSelectElement_put_value(select, bstr);
1232 SysFreeString(bstr);
1233 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1236 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1237 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1242 hres = IHTMLSelectElement_get_type(select, &type);
1243 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1244 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1247 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1248 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1253 hres = IHTMLTxtRange_get_text(range, &text);
1254 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1257 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1258 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1260 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1263 SysFreeString(text);
1267 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1268 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1272 hres = IHTMLTxtRange_collapse(range, b);
1273 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1274 _test_range_text(line, range, NULL);
1277 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1278 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1279 VARIANT_BOOL exb, const char *extext)
1281 VARIANT_BOOL b = 0xe0e0;
1284 hres = IHTMLTxtRange_expand(range, unit, &b);
1285 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1286 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1287 _test_range_text(line, range, extext);
1290 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1291 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1293 LONG c = 0xdeadbeef;
1296 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1297 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1298 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1299 _test_range_text(line, range, NULL);
1302 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1303 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1304 LPWSTR unit, LONG cnt, LONG excnt)
1306 LONG c = 0xdeadbeef;
1309 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1310 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1311 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1314 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1315 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1317 LONG c = 0xdeadbeef;
1320 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1321 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1322 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1325 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1326 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1329 BSTR bstr = a2bstr(text);
1331 hres = IHTMLTxtRange_put_text(range, bstr);
1332 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1333 SysFreeString(bstr);
1334 _test_range_text(line, range, NULL);
1337 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1338 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1344 hres = IHTMLTxtRange_inRange(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 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1350 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1356 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1357 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1358 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1361 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1362 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1363 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1366 test_range_inrange(range1, range2, VARIANT_TRUE);
1367 test_range_inrange(range2, range1, VARIANT_TRUE);
1371 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1372 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1377 hres = IHTMLTxtRange_parentElement(range, &elem);
1378 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1380 _test_elem_type(line, (IUnknown*)elem, type);
1382 IHTMLElement_Release(elem);
1385 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1386 static void _test_elem_collection(unsigned line, IUnknown *unk,
1387 const elem_type_t *elem_types, LONG exlen)
1389 IHTMLElementCollection *col;
1392 VARIANT name, index;
1393 IDispatch *disp, *disp2;
1396 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1397 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1399 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1401 hres = IHTMLElementCollection_get_length(col, &len);
1402 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1403 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1408 V_VT(&index) = VT_EMPTY;
1410 for(i=0; i<len; i++) {
1411 V_VT(&name) = VT_I4;
1413 disp = (void*)0xdeadbeef;
1414 hres = IHTMLElementCollection_item(col, name, index, &disp);
1415 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1416 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1417 if(FAILED(hres) || !disp)
1420 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1423 V_VT(&name) = VT_UINT;
1425 disp2 = (void*)0xdeadbeef;
1426 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1427 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1428 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1430 IDispatch_Release(disp2);
1433 IDispatch_Release(disp);
1436 V_VT(&name) = VT_I4;
1438 disp = (void*)0xdeadbeef;
1439 hres = IHTMLElementCollection_item(col, name, index, &disp);
1440 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1441 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1443 V_VT(&name) = VT_I4;
1445 disp = (void*)0xdeadbeef;
1446 hres = IHTMLElementCollection_item(col, name, index, &disp);
1447 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1448 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1450 IHTMLElementCollection_Release(col);
1453 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1454 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1456 IHTMLElement *elem = _get_elem_iface(line, unk);
1460 hres = IHTMLElement_get_all(elem, &disp);
1461 IHTMLElement_Release(elem);
1462 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1464 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1465 IDispatch_Release(disp);
1468 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1469 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1471 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1472 IHTMLElementCollection *col = NULL;
1473 elem_type_t *types = NULL;
1478 tmp = a2bstr(elem_type_infos[type].tag);
1479 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1481 IHTMLElement2_Release(elem);
1482 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1483 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1486 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1487 for(i=0; i<exlen; i++)
1491 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1493 HeapFree(GetProcessHeap(), 0, types);
1496 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1497 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1502 hres = IHTMLElement_get_innerText(elem, &text);
1503 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1504 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1505 wine_dbgstr_w(text), extext);
1506 SysFreeString(text);
1509 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1510 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1512 IHTMLDOMChildrenCollection *col;
1517 hres = IHTMLElement_put_innerText(elem, str);
1518 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1521 _test_elem_innertext(line, elem, text);
1524 col = _get_child_nodes(line, (IUnknown*)elem);
1525 ok(col != NULL, "col == NULL\n");
1527 LONG length = 0, type;
1530 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1531 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1532 ok(length == 1, "length = %d\n", length);
1534 node = _get_child_item(line, col, 0);
1535 ok(node != NULL, "node == NULL\n");
1537 type = _get_node_type(line, (IUnknown*)node);
1538 ok(type == 3, "type=%d\n", type);
1539 IHTMLDOMNode_Release(node);
1542 IHTMLDOMChildrenCollection_Release(col);
1547 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1548 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1550 IHTMLElement *elem = _get_elem_iface(line, unk);
1554 hres = IHTMLElement_get_innerHTML(elem, &html);
1555 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1557 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1559 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1561 IHTMLElement_Release(elem);
1562 SysFreeString(html);
1565 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1566 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1568 IHTMLElement *elem = _get_elem_iface(line, unk);
1572 html = a2bstr(inner_html);
1573 hres = IHTMLElement_put_innerHTML(elem, html);
1574 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1576 IHTMLElement_Release(elem);
1577 SysFreeString(html);
1580 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1581 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1583 IHTMLElement *elem = _get_elem_iface(line, unk);
1587 html = a2bstr(outer_html);
1588 hres = IHTMLElement_put_outerHTML(elem, html);
1589 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1591 IHTMLElement_Release(elem);
1592 SysFreeString(html);
1595 #define get_first_child(n) _get_first_child(__LINE__,n)
1596 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1598 IHTMLDOMNode *node = _get_node_iface(line, unk);
1599 IHTMLDOMNode *child = NULL;
1602 hres = IHTMLDOMNode_get_firstChild(node, &child);
1603 IHTMLDOMNode_Release(node);
1604 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1609 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1610 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1612 IHTMLDOMNode *node = _get_node_iface(line, unk);
1613 VARIANT_BOOL b = 0xdead;
1616 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1617 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1618 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1620 IHTMLDOMNode_Release(node);
1623 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1624 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1626 IHTMLDOMNode *node = _get_node_iface(line, unk);
1627 IHTMLDOMNode *parent;
1630 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1631 IHTMLDOMNode_Release(node);
1632 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1637 #define node_get_next(u) _node_get_next(__LINE__,u)
1638 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1640 IHTMLDOMNode *node = _get_node_iface(line, unk);
1644 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1645 IHTMLDOMNode_Release(node);
1646 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1651 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1652 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1654 IHTMLElement *elem = _get_elem_iface(line, unk);
1655 IHTMLElement *parent;
1658 hres = IHTMLElement_get_parentElement(elem, &parent);
1659 IHTMLElement_Release(elem);
1660 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1665 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1666 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1668 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1669 VARIANT_BOOL disabled = 100;
1673 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1674 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1675 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1676 IHTMLElement3_Release(elem3);
1679 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1680 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1682 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1686 hres = IHTMLElement3_put_disabled(elem3, b);
1687 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1689 IHTMLElement3_Release(elem3);
1690 _test_elem3_get_disabled(line, unk, b);
1693 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1694 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1696 VARIANT_BOOL disabled = 100;
1699 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1700 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1701 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1703 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1706 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1707 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1711 hres = IHTMLSelectElement_put_disabled(select, b);
1712 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1714 _test_select_get_disabled(line, select, b);
1717 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1718 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1720 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1721 IHTMLTextContainer *txtcont;
1722 LONG l = -1, l2 = -1;
1725 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1726 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1727 IHTMLElement2_Release(elem);
1729 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1730 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1732 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1733 IHTMLTextContainer_Release(txtcont);
1734 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1735 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1740 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1741 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1743 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1744 IHTMLTextContainer *txtcont;
1745 LONG l = -1, l2 = -1;
1748 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1749 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1750 IHTMLElement2_Release(elem);
1752 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1753 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1755 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1756 IHTMLTextContainer_Release(txtcont);
1757 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1758 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1763 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1764 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1766 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1767 IHTMLTextContainer *txtcont;
1768 LONG l = -1, l2 = -1;
1771 hres = IHTMLElement2_get_scrollTop(elem, &l);
1772 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1773 IHTMLElement2_Release(elem);
1775 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1776 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1778 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1779 IHTMLTextContainer_Release(txtcont);
1780 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1781 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1786 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1787 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1789 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1790 IHTMLTextContainer *txtcont;
1791 LONG l = -1, l2 = -1;
1794 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1795 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1797 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1798 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1799 IHTMLElement2_Release(elem);
1801 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1802 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1804 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1805 IHTMLTextContainer_Release(txtcont);
1806 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1807 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1810 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1811 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1813 IHTMLImgElement *img = _get_img_iface(line, unk);
1817 hres = IHTMLImgElement_get_src(img, &src);
1818 IHTMLImgElement_Release(img);
1819 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1820 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1824 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1825 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1827 IHTMLImgElement *img = _get_img_iface(line, unk);
1832 hres = IHTMLImgElement_put_src(img, tmp);
1833 IHTMLImgElement_Release(img);
1835 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1837 _test_img_src(line, unk, src);
1840 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1841 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1843 IHTMLImgElement *img = _get_img_iface(line, unk);
1847 hres = IHTMLImgElement_get_alt(img, &alt);
1848 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1850 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1852 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1856 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1857 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1859 IHTMLImgElement *img = _get_img_iface(line, unk);
1864 hres = IHTMLImgElement_put_alt(img, tmp);
1865 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1868 _test_img_alt(line, unk, alt);
1871 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1872 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1874 VARIANT_BOOL disabled = 100;
1877 hres = IHTMLInputElement_get_disabled(input, &disabled);
1878 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1879 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1881 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1884 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1885 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1889 hres = IHTMLInputElement_put_disabled(input, b);
1890 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1892 _test_input_get_disabled(line, input, b);
1895 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1896 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1898 VARIANT_BOOL checked = 100;
1901 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1902 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1903 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1906 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1907 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1911 hres = IHTMLInputElement_put_defaultChecked(input, b);
1912 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1914 _test_input_get_defaultchecked(line, input, b);
1917 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1918 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1920 VARIANT_BOOL checked = 100;
1923 hres = IHTMLInputElement_get_checked(input, &checked);
1924 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1925 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1928 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1929 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1933 hres = IHTMLInputElement_put_checked(input, b);
1934 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1936 _test_input_get_checked(line, input, b);
1939 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1940 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1942 IHTMLInputElement *input;
1946 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1947 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1951 hres = IHTMLInputElement_get_value(input, &bstr);
1952 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1954 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1956 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1957 SysFreeString(bstr);
1958 IHTMLInputElement_Release(input);
1961 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1962 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1964 IHTMLInputElement *input;
1968 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1969 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1974 hres = IHTMLInputElement_get_value(input, &bstr);
1975 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1976 SysFreeString(bstr);
1977 IHTMLInputElement_Release(input);
1980 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1981 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1986 hres = IHTMLInputElement_get_src(input, &src);
1987 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1989 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1991 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1995 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1996 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2002 hres = IHTMLInputElement_put_src(input, tmp);
2004 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2006 _test_input_src(line, input, src);
2009 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2010 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2012 IHTMLElement *elem = _get_elem_iface(line, unk);
2013 BSTR class = (void*)0xdeadbeef;
2016 hres = IHTMLElement_get_className(elem, &class);
2017 IHTMLElement_Release(elem);
2018 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2020 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2022 ok_(__FILE__,line) (!class, "class != NULL\n");
2023 SysFreeString(class);
2026 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2027 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2029 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2033 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2034 IHTMLElement2_Release(elem2);
2035 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2036 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2039 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2040 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2042 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2045 hres = IHTMLElement2_put_tabIndex(elem2, index);
2046 IHTMLElement2_Release(elem2);
2047 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2049 _test_elem_tabindex(line, unk, index);
2052 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2053 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2055 IHTMLElement *elem = _get_elem_iface(line, unk);
2059 tmp = class ? a2bstr(class) : NULL;
2060 hres = IHTMLElement_put_className(elem, tmp);
2061 IHTMLElement_Release(elem);
2062 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2065 _test_elem_class(line, unk, class);
2068 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2069 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2071 IHTMLElement *elem = _get_elem_iface(line, unk);
2072 BSTR id = (void*)0xdeadbeef;
2075 hres = IHTMLElement_get_id(elem, &id);
2076 IHTMLElement_Release(elem);
2077 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2080 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2082 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2087 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2088 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2090 IHTMLElement *elem = _get_elem_iface(line, unk);
2091 BSTR tmp = a2bstr(new_id);
2094 hres = IHTMLElement_put_id(elem, tmp);
2095 IHTMLElement_Release(elem);
2097 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2099 _test_elem_id(line, unk, new_id);
2102 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2103 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2105 IHTMLElement *elem = _get_elem_iface(line, unk);
2109 hres = IHTMLElement_get_title(elem, &title);
2110 IHTMLElement_Release(elem);
2111 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2113 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2115 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2117 SysFreeString(title);
2120 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2121 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2123 IHTMLElement *elem = _get_elem_iface(line, unk);
2127 tmp = a2bstr(title);
2128 hres = IHTMLElement_put_title(elem, tmp);
2129 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2131 IHTMLElement_Release(elem);
2135 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2136 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2138 IHTMLDOMNode *node = _get_node_iface(line, unk);
2142 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2143 IHTMLDOMNode_Release(node);
2144 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2147 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2148 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2150 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2156 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2157 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2159 IHTMLDOMNode *node = _get_node_iface(line, unk);
2163 V_VT(&var) = VT_BSTR;
2164 V_BSTR(&var) = a2bstr(val);
2166 hres = IHTMLDOMNode_put_nodeValue(node, var);
2167 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2168 IHTMLDOMNode_Release(node);
2172 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2173 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2175 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2179 hres = IHTMLElement2_get_clientWidth(elem, &l);
2180 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2181 hres = IHTMLElement2_get_clientHeight(elem, &l);
2182 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2184 IHTMLElement2_Release(elem);
2187 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2188 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2190 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2194 hres = IHTMLElement2_get_clientLeft(elem, &l);
2195 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2196 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2198 hres = IHTMLElement2_get_clientTop(elem, &l);
2199 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2200 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2202 IHTMLElement2_Release(elem);
2205 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2206 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2208 IHTMLElement *elem = NULL;
2213 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2214 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2215 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2220 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2221 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2223 IHTMLDocument3 *doc3;
2224 IHTMLDOMNode *node = NULL;
2228 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2229 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2232 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2233 IHTMLDocument3_Release(doc3);
2234 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2235 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2240 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2241 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2243 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2244 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2245 IHTMLDOMNode *new_child = NULL;
2248 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2249 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2250 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2251 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2253 IHTMLDOMNode_Release(node);
2254 IHTMLDOMNode_Release(child);
2259 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2260 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2262 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2263 IHTMLDOMNode *new_child = NULL;
2266 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2267 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2268 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2269 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2271 IHTMLDOMNode_Release(node);
2276 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2277 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2279 IHTMLDOMNode *node = _get_node_iface(line, unk);
2280 IHTMLDOMNode *new_node = NULL;
2283 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2284 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2285 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2286 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2288 IHTMLDOMNode_Release(node);
2289 IHTMLDOMNode_Release(new_node);
2292 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2293 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2298 hres = IHTMLDocument2_get_title(doc, &title);
2299 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2300 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2301 SysFreeString(title);
2304 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2305 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2310 tmp = a2bstr(title);
2311 hres = IHTMLDocument2_put_title(doc, tmp);
2312 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2316 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2317 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2322 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2323 LOCALE_USER_DEFAULT, &dispid);
2324 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2327 DISPPARAMS params = {NULL,NULL,0,0};
2328 DISPID dispidNamed = DISPID_PROPERTYPUT;
2333 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2334 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2335 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2338 params.cNamedArgs = 1;
2339 params.rgdispidNamedArgs = &dispidNamed;
2340 V_VT(&arg) = VT_BSTR;
2341 V_BSTR(&arg) = a2bstr("none");
2342 params.rgvarg = &arg;
2343 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2344 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2345 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2348 V_VT(&arg) = VT_BSTR;
2349 V_BSTR(&arg) = a2bstr("dotted");
2350 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2351 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2352 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2355 V_VT(&arg) = VT_BSTR;
2356 V_BSTR(&arg) = a2bstr("dashed");
2357 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2358 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2359 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2362 V_VT(&arg) = VT_BSTR;
2363 V_BSTR(&arg) = a2bstr("solid");
2364 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2365 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2366 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2369 V_VT(&arg) = VT_BSTR;
2370 V_BSTR(&arg) = a2bstr("double");
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, "double. ret: %08x\n", hres);
2376 V_VT(&arg) = VT_BSTR;
2377 V_BSTR(&arg) = a2bstr("groove");
2378 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2379 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2380 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2383 V_VT(&arg) = VT_BSTR;
2384 V_BSTR(&arg) = a2bstr("ridge");
2385 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2386 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2387 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2390 V_VT(&arg) = VT_BSTR;
2391 V_BSTR(&arg) = a2bstr("inset");
2392 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2393 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2394 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2397 V_VT(&arg) = VT_BSTR;
2398 V_BSTR(&arg) = a2bstr("outset");
2399 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2400 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2401 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2404 V_VT(&arg) = VT_BSTR;
2405 V_BSTR(&arg) = a2bstr("invalid");
2406 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2407 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2408 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2411 params.rgvarg = &vDefault;
2412 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2413 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2414 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2418 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2419 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2421 BSTR text = (void*)0xdeadbeef;
2424 hres = IHTMLStyle_get_cssText(style, &text);
2425 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2427 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2429 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2431 SysFreeString(text);
2434 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2435 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2441 hres = IHTMLStyle_put_cssText(style, tmp);
2442 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2446 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2447 const elem_type_t *elem_types, LONG len)
2450 VARIANT name, index;
2454 V_VT(&index) = VT_EMPTY;
2455 V_VT(&name) = VT_BSTR;
2456 V_BSTR(&name) = a2bstr(n);
2458 hres = IHTMLElementCollection_item(col, name, index, &disp);
2459 ok(hres == S_OK, "item failed: %08x\n", hres);
2461 test_elem_collection((IUnknown*)disp, elem_types, len);
2462 IDispatch_Release(disp);
2463 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2467 V_VT(&index) = VT_I4;
2469 for(i=0; i<len; i++) {
2471 disp = (void*)0xdeadbeef;
2472 hres = IHTMLElementCollection_item(col, name, index, &disp);
2473 ok(hres == S_OK, "item failed: %08x\n", hres);
2474 ok(disp != NULL, "disp == NULL\n");
2475 if(FAILED(hres) || !disp)
2478 test_elem_type((IUnknown*)disp, elem_types[i]);
2480 IDispatch_Release(disp);
2484 disp = (void*)0xdeadbeef;
2485 hres = IHTMLElementCollection_item(col, name, index, &disp);
2486 ok(hres == S_OK, "item failed: %08x\n", hres);
2487 ok(disp == NULL, "disp != NULL\n");
2490 disp = (void*)0xdeadbeef;
2491 hres = IHTMLElementCollection_item(col, name, index, &disp);
2492 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2493 ok(disp == NULL, "disp != NULL\n");
2496 SysFreeString(V_BSTR(&name));
2499 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2501 IHTMLElementCollection *col;
2503 IDispatch *disp = (void*)0xdeadbeef;
2504 VARIANT name, index;
2507 hres = IHTMLDocument2_get_all(doc, &col);
2508 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2509 ok(col != NULL, "col == NULL\n");
2510 if(FAILED(hres) || !col)
2513 V_VT(&index) = VT_EMPTY;
2514 V_VT(&name) = VT_BSTR;
2515 V_BSTR(&name) = a2bstr(id);
2517 hres = IHTMLElementCollection_item(col, name, index, &disp);
2518 IHTMLElementCollection_Release(col);
2519 SysFreeString(V_BSTR(&name));
2520 ok(hres == S_OK, "item failed: %08x\n", hres);
2521 if(!expect_success) {
2522 ok(disp == NULL, "disp != NULL\n");
2526 ok(disp != NULL, "disp == NULL\n");
2530 elem = get_elem_iface((IUnknown*)disp);
2531 IDispatch_Release(disp);
2536 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2538 IHTMLDocument3 *doc3;
2543 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2544 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2547 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2549 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2551 IHTMLDocument3_Release(doc3);
2556 static void test_select_elem(IHTMLSelectElement *select)
2558 test_select_type(select, "select-one");
2559 test_select_length(select, 2);
2560 test_select_selidx(select, 0);
2561 test_select_put_selidx(select, 1);
2563 test_select_set_value(select, "val1");
2564 test_select_value(select, "val1");
2566 test_select_get_disabled(select, VARIANT_FALSE);
2567 test_select_set_disabled(select, VARIANT_TRUE);
2568 test_select_set_disabled(select, VARIANT_FALSE);
2571 static void test_create_option_elem(IHTMLDocument2 *doc)
2573 IHTMLOptionElement *option;
2575 option = create_option_elem(doc, "test text", "test value");
2577 test_option_put_text(option, "new text");
2578 test_option_put_value(option, "new value");
2580 IHTMLOptionElement_Release(option);
2583 static void test_create_img_elem(IHTMLDocument2 *doc)
2585 IHTMLImgElement *img;
2587 img = create_img_elem(doc, 10, 15);
2590 test_img_put_width(img, 5);
2591 test_img_put_height(img, 20);
2593 IHTMLImgElement_Release(img);
2597 img = create_img_elem(doc, -1, -1);
2600 test_img_put_width(img, 5);
2601 test_img_put_height(img, 20);
2603 IHTMLImgElement_Release(img);
2607 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2609 IHTMLBodyElement *body;
2610 IHTMLTxtRange *range;
2614 hres = IHTMLDocument2_get_body(doc, &elem);
2615 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2617 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2618 IHTMLElement_Release(elem);
2620 hres = IHTMLBodyElement_createTextRange(body, &range);
2621 IHTMLBodyElement_Release(body);
2622 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2627 static void test_txtrange(IHTMLDocument2 *doc)
2629 IHTMLTxtRange *body_range, *range, *range2;
2630 IHTMLSelectionObject *selection;
2631 IDispatch *disp_range;
2634 body_range = test_create_body_range(doc);
2636 test_range_text(body_range, "test abc 123\r\nit's text");
2638 hres = IHTMLTxtRange_duplicate(body_range, &range);
2639 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2641 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2642 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2643 test_range_isequal(range, range2, VARIANT_TRUE);
2645 test_range_text(range, "test abc 123\r\nit's text");
2646 test_range_text(body_range, "test abc 123\r\nit's text");
2648 test_range_collapse(range, TRUE);
2649 test_range_isequal(range, range2, VARIANT_FALSE);
2650 test_range_inrange(range, range2, VARIANT_FALSE);
2651 test_range_inrange(range2, range, VARIANT_TRUE);
2652 IHTMLTxtRange_Release(range2);
2654 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2655 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2656 test_range_move(range, characterW, 2, 2);
2657 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2659 test_range_collapse(range, FALSE);
2660 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2662 test_range_collapse(range, FALSE);
2663 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2664 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2665 test_range_move(range, characterW, 2, 2);
2666 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2667 test_range_moveend(range, characterW, -5, -5);
2668 test_range_text(range, NULL);
2669 test_range_moveend(range, characterW, 3, 3);
2670 test_range_text(range, "c 1");
2671 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2672 test_range_collapse(range, TRUE);
2673 test_range_move(range, characterW, 4, 4);
2674 test_range_moveend(range, characterW, 1, 1);
2675 test_range_text(range, " ");
2676 test_range_move(range, wordW, 1, 1);
2677 test_range_moveend(range, characterW, 2, 2);
2678 test_range_text(range, "ab");
2680 IHTMLTxtRange_Release(range);
2682 hres = IHTMLTxtRange_duplicate(body_range, &range);
2683 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2685 test_range_text(range, "test abc 123\r\nit's text");
2686 test_range_move(range, characterW, 3, 3);
2687 test_range_moveend(range, characterW, 1, 1);
2688 test_range_text(range, "t");
2689 test_range_moveend(range, characterW, 3, 3);
2690 test_range_text(range, "t ab");
2691 test_range_moveend(range, characterW, -2, -2);
2692 test_range_text(range, "t ");
2693 test_range_move(range, characterW, 6, 6);
2694 test_range_moveend(range, characterW, 3, 3);
2695 test_range_text(range, "123");
2696 test_range_moveend(range, characterW, 2, 2);
2697 test_range_text(range, "123\r\ni");
2699 IHTMLTxtRange_Release(range);
2701 hres = IHTMLTxtRange_duplicate(body_range, &range);
2702 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2704 test_range_move(range, wordW, 1, 1);
2705 test_range_moveend(range, characterW, 2, 2);
2706 test_range_text(range, "ab");
2708 test_range_move(range, characterW, -2, -2);
2709 test_range_moveend(range, characterW, 2, 2);
2710 test_range_text(range, "t ");
2712 test_range_move(range, wordW, 3, 3);
2713 test_range_move(range, wordW, -2, -2);
2714 test_range_moveend(range, characterW, 2, 2);
2715 test_range_text(range, "ab");
2717 test_range_move(range, characterW, -6, -5);
2718 test_range_moveend(range, characterW, -1, 0);
2719 test_range_moveend(range, characterW, -6, 0);
2720 test_range_move(range, characterW, 2, 2);
2721 test_range_moveend(range, characterW, 2, 2);
2722 test_range_text(range, "st");
2723 test_range_moveend(range, characterW, -6, -4);
2724 test_range_moveend(range, characterW, 2, 2);
2726 IHTMLTxtRange_Release(range);
2728 hres = IHTMLTxtRange_duplicate(body_range, &range);
2729 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2731 test_range_move(range, wordW, 2, 2);
2732 test_range_moveend(range, characterW, 2, 2);
2733 test_range_text(range, "12");
2735 test_range_move(range, characterW, 15, 14);
2736 test_range_move(range, characterW, -2, -2);
2737 test_range_moveend(range, characterW, 3, 2);
2738 test_range_text(range, "t");
2739 test_range_moveend(range, characterW, -1, -1);
2740 test_range_text(range, "t");
2741 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2742 test_range_move(range, characterW, -2, -2);
2743 test_range_moveend(range, characterW, 2, 2);
2744 test_range_text(range, "s ");
2745 test_range_move(range, characterW, 100, 7);
2746 test_range_move(range, wordW, 1, 0);
2747 test_range_move(range, characterW, -2, -2);
2748 test_range_moveend(range, characterW, 3, 2);
2749 test_range_text(range, "t");
2751 IHTMLTxtRange_Release(range);
2753 hres = IHTMLTxtRange_duplicate(body_range, &range);
2754 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2756 test_range_collapse(range, TRUE);
2757 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2758 test_range_put_text(range, "word");
2759 test_range_text(body_range, "wordabc 123\r\nit's text");
2760 test_range_text(range, NULL);
2761 test_range_moveend(range, characterW, 3, 3);
2762 test_range_text(range, "abc");
2763 test_range_movestart(range, characterW, -2, -2);
2764 test_range_text(range, "rdabc");
2765 test_range_movestart(range, characterW, 3, 3);
2766 test_range_text(range, "bc");
2767 test_range_movestart(range, characterW, 4, 4);
2768 test_range_text(range, NULL);
2769 test_range_movestart(range, characterW, -3, -3);
2770 test_range_text(range, "c 1");
2771 test_range_movestart(range, characterW, -7, -6);
2772 test_range_text(range, "wordabc 1");
2773 test_range_movestart(range, characterW, 100, 22);
2774 test_range_text(range, NULL);
2776 IHTMLTxtRange_Release(range);
2777 IHTMLTxtRange_Release(body_range);
2779 hres = IHTMLDocument2_get_selection(doc, &selection);
2780 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2782 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2783 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2784 IHTMLSelectionObject_Release(selection);
2786 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2787 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2788 IDispatch_Release(disp_range);
2790 test_range_text(range, NULL);
2791 test_range_moveend(range, characterW, 3, 3);
2792 test_range_text(range, "wor");
2793 test_range_parent(range, ET_BODY);
2794 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2795 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2796 test_range_move(range, characterW, 3, 3);
2797 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2798 test_range_moveend(range, characterW, -4, -4);
2799 test_range_put_text(range, "abc def ");
2800 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2801 test_range_move(range, wordW, 1, 1);
2802 test_range_movestart(range, characterW, -1, -1);
2803 test_range_text(range, " ");
2804 test_range_move(range, wordW, 1, 1);
2805 test_range_moveend(range, characterW, 3, 3);
2806 test_range_text(range, "def");
2807 test_range_put_text(range, "xyz");
2808 test_range_moveend(range, characterW, 1, 1);
2809 test_range_move(range, wordW, 1, 1);
2810 test_range_moveend(range, characterW, 2, 2);
2811 test_range_text(range, "ab");
2813 IHTMLTxtRange_Release(range);
2816 static void test_txtrange2(IHTMLDocument2 *doc)
2818 IHTMLTxtRange *range;
2820 range = test_create_body_range(doc);
2822 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2823 test_range_move(range, characterW, 5, 5);
2824 test_range_moveend(range, characterW, 1, 1);
2825 test_range_text(range, "2");
2826 test_range_move(range, characterW, -3, -3);
2827 test_range_moveend(range, characterW, 3, 3);
2828 test_range_text(range, "c\r\n\r\n1");
2829 test_range_collapse(range, VARIANT_FALSE);
2830 test_range_moveend(range, characterW, 4, 4);
2831 test_range_text(range, "23");
2832 test_range_moveend(range, characterW, 1, 1);
2833 test_range_text(range, "23\r\n\r\n\r\nd");
2834 test_range_moveend(range, characterW, -1, -1);
2835 test_range_text(range, "23");
2836 test_range_moveend(range, characterW, -1, -1);
2837 test_range_text(range, "23");
2838 test_range_moveend(range, characterW, -2, -2);
2839 test_range_text(range, "2");
2841 IHTMLTxtRange_Release(range);
2844 static void test_compatmode(IHTMLDocument2 *doc)
2846 IHTMLDocument5 *doc5;
2850 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2851 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2855 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2856 IHTMLDocument5_Release(doc5);
2857 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2858 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2859 SysFreeString(mode);
2862 static void test_location(IHTMLDocument2 *doc)
2864 IHTMLLocation *location, *location2;
2865 IHTMLWindow2 *window;
2870 hres = IHTMLDocument2_get_location(doc, &location);
2871 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2873 hres = IHTMLDocument2_get_location(doc, &location2);
2874 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2876 ok(location == location2, "location != location2\n");
2877 IHTMLLocation_Release(location2);
2879 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2880 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2882 hres = IHTMLWindow2_get_location(window, &location2);
2883 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2884 ok(location == location2, "location != location2\n");
2885 IHTMLLocation_Release(location2);
2887 test_ifaces((IUnknown*)location, location_iids);
2888 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2890 hres = IHTMLLocation_get_pathname(location, &str);
2891 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2892 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2894 hres = IHTMLLocation_get_href(location, NULL);
2895 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2897 hres = IHTMLLocation_get_href(location, &str);
2898 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2899 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2901 ref = IHTMLLocation_Release(location);
2902 ok(!ref, "location chould be destroyed here\n");
2905 static void test_navigator(IHTMLDocument2 *doc)
2907 IHTMLWindow2 *window;
2908 IOmNavigator *navigator, *navigator2;
2915 static const WCHAR v40[] = {'4','.','0'};
2917 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2918 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2920 hres = IHTMLWindow2_get_navigator(window, &navigator);
2921 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2922 ok(navigator != NULL, "navigator == NULL\n");
2923 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2925 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2926 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2927 ok(navigator != navigator2, "navigator2 != navihgator\n");
2929 IHTMLWindow2_Release(window);
2930 IOmNavigator_Release(navigator2);
2932 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2933 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2934 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2935 SysFreeString(bstr);
2938 hres = IOmNavigator_get_appName(navigator, &bstr);
2939 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2940 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2941 SysFreeString(bstr);
2944 hres = IOmNavigator_get_platform(navigator, &bstr);
2945 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2947 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2949 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2951 SysFreeString(bstr);
2954 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2955 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2956 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2957 SysFreeString(bstr);
2959 hres = IOmNavigator_toString(navigator, NULL);
2960 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2963 hres = IOmNavigator_toString(navigator, &bstr);
2964 ok(hres == S_OK, "toString failed: %08x\n", hres);
2965 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2966 SysFreeString(bstr);
2969 hres = ObtainUserAgentString(0, buf, &size);
2970 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2973 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2974 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2975 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2976 SysFreeString(bstr);
2978 ref = IOmNavigator_Release(navigator);
2979 ok(!ref, "navigator should be destroyed here\n");
2982 static void test_current_style(IHTMLCurrentStyle *current_style)
2988 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2989 test_ifaces((IUnknown*)current_style, cstyle_iids);
2991 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2992 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2993 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2996 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2997 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2998 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3001 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3002 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3005 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3006 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3007 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3010 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3011 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3012 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3015 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3016 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3017 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3020 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3021 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3022 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3025 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3026 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3027 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3030 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3031 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3032 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3035 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3036 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3037 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3040 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3041 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3042 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3045 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3046 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3047 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3050 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3051 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3052 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3055 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3056 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3057 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3060 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3061 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3064 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3065 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3068 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3069 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3072 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3073 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3076 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3077 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3080 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3081 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3084 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3085 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3086 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3087 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3090 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3091 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3092 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3095 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3096 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3097 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3100 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3101 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3102 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3105 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3106 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3107 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3110 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3111 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3112 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3115 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3116 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3117 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3120 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3121 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3122 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3123 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3126 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3127 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3128 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3129 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3132 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3133 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3134 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3137 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3138 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3139 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3142 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3143 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3144 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3148 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3149 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3150 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3153 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3154 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3155 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3158 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3159 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3160 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3163 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3164 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3165 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3168 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3169 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3170 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3173 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3174 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3175 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3178 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3179 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3180 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3183 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3184 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3185 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3188 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3189 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3190 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3193 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3194 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3195 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3198 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3199 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3200 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3203 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3204 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3205 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3208 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3209 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3210 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3213 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3214 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3215 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3218 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3219 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3220 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3223 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3224 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3225 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3228 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3229 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3230 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3233 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3234 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3235 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3238 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3239 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3240 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3244 static void test_style2(IHTMLStyle2 *style2)
3249 str = (void*)0xdeadbeef;
3250 hres = IHTMLStyle2_get_position(style2, &str);
3251 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3252 ok(!str, "str != NULL\n");
3254 str = a2bstr("absolute");
3255 hres = IHTMLStyle2_put_position(style2, str);
3256 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3260 hres = IHTMLStyle2_get_position(style2, &str);
3261 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3262 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3266 static void test_style3(IHTMLStyle3 *style3)
3271 str = (void*)0xdeadbeef;
3272 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3273 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3274 ok(!str, "str != NULL\n");
3276 str = a2bstr("break-word");
3277 hres = IHTMLStyle3_put_wordWrap(style3, str);
3278 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3282 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3283 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3284 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3288 static void test_style4(IHTMLStyle4 *style4)
3294 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3295 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3298 V_BSTR(&v) = a2bstr("10px");
3299 hres = IHTMLStyle4_put_minHeight(style4, v);
3300 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3303 hres = IHTMLStyle4_get_minHeight(style4, &v);
3304 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3305 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3306 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3308 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3309 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3310 VariantClear(&vdefault);
3313 static void test_default_style(IHTMLStyle *style)
3315 IHTMLStyle2 *style2;
3316 IHTMLStyle3 *style3;
3317 IHTMLStyle4 *style4;
3323 BSTR sOverflowDefault;
3327 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3328 test_ifaces((IUnknown*)style, style_iids);
3330 test_style_csstext(style, NULL);
3332 hres = IHTMLStyle_get_position(style, &str);
3333 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3334 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3337 hres = IHTMLStyle_get_marginRight(style, &v);
3338 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3339 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3340 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3343 hres = IHTMLStyle_get_marginLeft(style, &v);
3344 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3345 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3346 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3348 str = (void*)0xdeadbeef;
3349 hres = IHTMLStyle_get_fontFamily(style, &str);
3350 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3351 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3353 str = (void*)0xdeadbeef;
3354 hres = IHTMLStyle_get_fontWeight(style, &str);
3355 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3356 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3358 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3359 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3361 str = a2bstr("test");
3362 hres = IHTMLStyle_put_fontWeight(style, str);
3363 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3366 str = a2bstr("bold");
3367 hres = IHTMLStyle_put_fontWeight(style, str);
3368 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3371 str = a2bstr("bolder");
3372 hres = IHTMLStyle_put_fontWeight(style, str);
3373 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3376 str = a2bstr("lighter");
3377 hres = IHTMLStyle_put_fontWeight(style, str);
3378 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3381 str = a2bstr("100");
3382 hres = IHTMLStyle_put_fontWeight(style, str);
3383 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3386 str = a2bstr("200");
3387 hres = IHTMLStyle_put_fontWeight(style, str);
3388 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3391 str = a2bstr("300");
3392 hres = IHTMLStyle_put_fontWeight(style, str);
3393 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3396 str = a2bstr("400");
3397 hres = IHTMLStyle_put_fontWeight(style, str);
3398 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3401 str = a2bstr("500");
3402 hres = IHTMLStyle_put_fontWeight(style, str);
3403 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3406 str = a2bstr("600");
3407 hres = IHTMLStyle_put_fontWeight(style, str);
3408 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3411 str = a2bstr("700");
3412 hres = IHTMLStyle_put_fontWeight(style, str);
3413 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3416 str = a2bstr("800");
3417 hres = IHTMLStyle_put_fontWeight(style, str);
3418 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3421 str = a2bstr("900");
3422 hres = IHTMLStyle_put_fontWeight(style, str);
3423 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3426 hres = IHTMLStyle_get_fontWeight(style, &str);
3427 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3428 ok(!strcmp_wa(str, "900"), "str != style900\n");
3431 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3432 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3433 SysFreeString(sDefault);
3436 hres = IHTMLStyle_get_fontVariant(style, NULL);
3437 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3439 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3440 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3442 str = a2bstr("test");
3443 hres = IHTMLStyle_put_fontVariant(style, str);
3444 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3447 str = a2bstr("small-caps");
3448 hres = IHTMLStyle_put_fontVariant(style, str);
3449 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3452 str = a2bstr("normal");
3453 hres = IHTMLStyle_put_fontVariant(style, str);
3454 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3457 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3458 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3459 SysFreeString(sDefault);
3461 str = (void*)0xdeadbeef;
3462 hres = IHTMLStyle_get_display(style, &str);
3463 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3464 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3466 str = (void*)0xdeadbeef;
3467 hres = IHTMLStyle_get_visibility(style, &str);
3468 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3469 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3472 hres = IHTMLStyle_get_fontSize(style, &v);
3473 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3474 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3475 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3478 hres = IHTMLStyle_get_color(style, &v);
3479 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3480 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3481 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3484 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3485 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3486 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3488 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3489 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3490 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3492 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3493 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3494 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3496 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3497 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3500 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3501 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3502 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3504 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3505 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3506 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3508 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3509 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3510 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3512 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3513 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3516 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3517 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3518 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3520 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3521 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3522 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3524 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3525 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3526 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3528 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3529 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3532 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3533 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3534 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3536 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3537 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3538 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3540 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3541 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3542 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3544 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3545 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3548 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3549 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3550 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3552 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3553 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3554 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3556 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3557 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3558 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3560 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3561 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3563 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3564 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3566 str = a2bstr("invalid");
3567 hres = IHTMLStyle_put_textDecoration(style, str);
3568 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3571 str = a2bstr("none");
3572 hres = IHTMLStyle_put_textDecoration(style, str);
3573 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3576 str = a2bstr("underline");
3577 hres = IHTMLStyle_put_textDecoration(style, str);
3578 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3581 str = a2bstr("overline");
3582 hres = IHTMLStyle_put_textDecoration(style, str);
3583 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3586 str = a2bstr("line-through");
3587 hres = IHTMLStyle_put_textDecoration(style, str);
3588 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3591 str = a2bstr("blink");
3592 hres = IHTMLStyle_put_textDecoration(style, str);
3593 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3596 hres = IHTMLStyle_get_textDecoration(style, &str);
3597 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3598 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3601 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3602 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3603 SysFreeString(sDefault);
3605 hres = IHTMLStyle_get_posWidth(style, NULL);
3606 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3608 hres = IHTMLStyle_get_posWidth(style, &f);
3609 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3610 ok(f == 0.0f, "f = %f\n", f);
3612 V_VT(&v) = VT_EMPTY;
3613 hres = IHTMLStyle_get_width(style, &v);
3614 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3615 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3616 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3618 hres = IHTMLStyle_put_posWidth(style, 2.2);
3619 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3621 hres = IHTMLStyle_get_posWidth(style, &f);
3622 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3624 f == 2.2f, /* IE8 */
3628 V_BSTR(&v) = a2bstr("auto");
3629 hres = IHTMLStyle_put_width(style, v);
3630 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3633 V_VT(&v) = VT_EMPTY;
3634 hres = IHTMLStyle_get_width(style, &v);
3635 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3636 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3637 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3641 str = (void*)0xdeadbeef;
3642 hres = IHTMLStyle_get_margin(style, &str);
3643 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3644 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3647 hres = IHTMLStyle_put_margin(style, str);
3648 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3651 hres = IHTMLStyle_get_margin(style, &str);
3652 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3653 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3655 hres = IHTMLStyle_put_margin(style, NULL);
3656 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3659 hres = IHTMLStyle_get_border(style, &str);
3660 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3661 ok(!str || !*str, "str is not empty\n");
3664 str = a2bstr("1px");
3665 hres = IHTMLStyle_put_border(style, str);
3666 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3669 V_VT(&v) = VT_EMPTY;
3670 hres = IHTMLStyle_get_left(style, &v);
3671 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3672 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3673 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3677 hres = IHTMLStyle_get_posLeft(style, NULL);
3678 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3681 hres = IHTMLStyle_get_posLeft(style, &f);
3682 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3683 ok(f == 0.0, "expected 0.0 got %f\n", f);
3685 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3686 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3688 hres = IHTMLStyle_get_posLeft(style, &f);
3689 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3691 f == 4.9f, /* IE8 */
3692 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3694 /* Ensure left is updated correctly. */
3695 V_VT(&v) = VT_EMPTY;
3696 hres = IHTMLStyle_get_left(style, &v);
3697 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3698 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3699 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3700 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3701 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3706 V_BSTR(&v) = a2bstr("3px");
3707 hres = IHTMLStyle_put_left(style, v);
3708 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3711 hres = IHTMLStyle_get_posLeft(style, &f);
3712 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3713 ok(f == 3.0, "expected 3.0 got %f\n", f);
3715 V_VT(&v) = VT_EMPTY;
3716 hres = IHTMLStyle_get_left(style, &v);
3717 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3718 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3719 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3723 hres = IHTMLStyle_put_left(style, v);
3724 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3726 V_VT(&v) = VT_EMPTY;
3727 hres = IHTMLStyle_get_left(style, &v);
3728 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3729 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3730 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3733 V_VT(&v) = VT_EMPTY;
3734 hres = IHTMLStyle_get_top(style, &v);
3735 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3736 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3737 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3741 hres = IHTMLStyle_get_posTop(style, NULL);
3742 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3745 hres = IHTMLStyle_get_posTop(style, &f);
3746 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3747 ok(f == 0.0, "expected 0.0 got %f\n", f);
3749 hres = IHTMLStyle_put_posTop(style, 4.9f);
3750 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3752 hres = IHTMLStyle_get_posTop(style, &f);
3753 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3755 f == 4.9f, /* IE8 */
3756 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3759 V_BSTR(&v) = a2bstr("3px");
3760 hres = IHTMLStyle_put_top(style, v);
3761 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3764 V_VT(&v) = VT_EMPTY;
3765 hres = IHTMLStyle_get_top(style, &v);
3766 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3767 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3768 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3771 hres = IHTMLStyle_get_posTop(style, &f);
3772 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3773 ok(f == 3.0, "expected 3.0 got %f\n", f);
3776 hres = IHTMLStyle_put_top(style, v);
3777 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3779 V_VT(&v) = VT_EMPTY;
3780 hres = IHTMLStyle_get_top(style, &v);
3781 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3782 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3783 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3786 /* Test posHeight */
3787 hres = IHTMLStyle_get_posHeight(style, NULL);
3788 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3790 V_VT(&v) = VT_EMPTY;
3791 hres = IHTMLStyle_get_height(style, &v);
3792 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3793 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3794 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3798 hres = IHTMLStyle_get_posHeight(style, &f);
3799 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3800 ok(f == 0.0, "expected 0.0 got %f\n", f);
3802 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3803 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3805 hres = IHTMLStyle_get_posHeight(style, &f);
3806 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3808 f == 4.9f, /* IE8 */
3809 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3812 V_BSTR(&v) = a2bstr("64px");
3813 hres = IHTMLStyle_put_height(style, v);
3814 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3817 V_VT(&v) = VT_EMPTY;
3818 hres = IHTMLStyle_get_height(style, &v);
3819 ok(hres == S_OK, "get_height 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), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3824 hres = IHTMLStyle_get_posHeight(style, &f);
3825 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3826 ok(f == 64.0, "expected 64.0 got %f\n", f);
3828 str = (void*)0xdeadbeef;
3829 hres = IHTMLStyle_get_cursor(style, &str);
3830 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3831 ok(!str, "get_cursor != NULL\n");
3834 str = a2bstr("default");
3835 hres = IHTMLStyle_put_cursor(style, str);
3836 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3840 hres = IHTMLStyle_get_cursor(style, &str);
3841 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3842 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3845 V_VT(&v) = VT_EMPTY;
3846 hres = IHTMLStyle_get_verticalAlign(style, &v);
3847 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3848 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3849 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3853 V_BSTR(&v) = a2bstr("middle");
3854 hres = IHTMLStyle_put_verticalAlign(style, v);
3855 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3858 V_VT(&v) = VT_EMPTY;
3859 hres = IHTMLStyle_get_verticalAlign(style, &v);
3860 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3861 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3862 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3865 str = (void*)0xdeadbeef;
3866 hres = IHTMLStyle_get_textAlign(style, &str);
3867 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3868 ok(!str, "textAlign != NULL\n");
3870 str = a2bstr("center");
3871 hres = IHTMLStyle_put_textAlign(style, str);
3872 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3876 hres = IHTMLStyle_get_textAlign(style, &str);
3877 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3878 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3881 str = (void*)0xdeadbeef;
3882 hres = IHTMLStyle_get_filter(style, &str);
3883 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3884 ok(!str, "filter != NULL\n");
3886 str = a2bstr("alpha(opacity=100)");
3887 hres = IHTMLStyle_put_filter(style, str);
3888 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3891 V_VT(&v) = VT_EMPTY;
3892 hres = IHTMLStyle_get_zIndex(style, &v);
3893 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3894 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3895 ok(!V_I4(&v), "V_I4(v) != 0\n");
3899 V_BSTR(&v) = a2bstr("1");
3900 hres = IHTMLStyle_put_zIndex(style, v);
3901 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3904 V_VT(&v) = VT_EMPTY;
3905 hres = IHTMLStyle_get_zIndex(style, &v);
3906 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3907 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3908 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3912 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3913 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3915 str = a2bstr("test");
3916 hres = IHTMLStyle_put_fontStyle(style, str);
3917 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3920 str = a2bstr("italic");
3921 hres = IHTMLStyle_put_fontStyle(style, str);
3922 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3925 str = a2bstr("oblique");
3926 hres = IHTMLStyle_put_fontStyle(style, str);
3927 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3930 str = a2bstr("normal");
3931 hres = IHTMLStyle_put_fontStyle(style, str);
3932 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3935 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3936 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3937 SysFreeString(sDefault);
3940 hres = IHTMLStyle_get_overflow(style, NULL);
3941 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3943 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3944 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3946 str = a2bstr("test");
3947 hres = IHTMLStyle_put_overflow(style, str);
3948 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3951 str = a2bstr("visible");
3952 hres = IHTMLStyle_put_overflow(style, str);
3953 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3956 str = a2bstr("scroll");
3957 hres = IHTMLStyle_put_overflow(style, str);
3958 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3961 str = a2bstr("hidden");
3962 hres = IHTMLStyle_put_overflow(style, str);
3963 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3966 str = a2bstr("auto");
3967 hres = IHTMLStyle_put_overflow(style, str);
3968 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3971 hres = IHTMLStyle_get_overflow(style, &str);
3972 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3973 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3977 hres = IHTMLStyle_put_overflow(style, str);
3978 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3981 hres = IHTMLStyle_get_overflow(style, &str);
3982 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3983 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3986 /* restore overflow default */
3987 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3988 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3989 SysFreeString(sOverflowDefault);
3991 /* Attribute Tests*/
3992 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3993 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3995 str = a2bstr("position");
3996 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3997 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3999 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4000 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4001 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4004 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4005 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4008 V_BSTR(&v) = a2bstr("absolute");
4009 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4010 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4013 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4014 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4015 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4016 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4021 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4022 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4027 str = a2bstr("borderLeftStyle");
4028 test_border_styles(style, str);
4031 str = a2bstr("borderbottomstyle");
4032 test_border_styles(style, str);
4035 str = a2bstr("borderrightstyle");
4036 test_border_styles(style, str);
4039 str = a2bstr("bordertopstyle");
4040 test_border_styles(style, str);
4043 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4044 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4046 str = a2bstr("none dotted dashed solid");
4047 hres = IHTMLStyle_put_borderStyle(style, str);
4048 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4051 str = a2bstr("none dotted dashed solid");
4052 hres = IHTMLStyle_get_borderStyle(style, &str);
4053 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4054 ok(!strcmp_wa(str, "none dotted dashed solid"),
4055 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4058 str = a2bstr("double groove ridge inset");
4059 hres = IHTMLStyle_put_borderStyle(style, str);
4060 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4063 str = a2bstr("window-inset outset ridge inset");
4064 hres = IHTMLStyle_put_borderStyle(style, str);
4065 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4068 str = a2bstr("window-inset");
4069 hres = IHTMLStyle_put_borderStyle(style, str);
4070 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4073 str = a2bstr("none none none none none");
4074 hres = IHTMLStyle_put_borderStyle(style, str);
4075 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4078 str = a2bstr("invalid none none none");
4079 hres = IHTMLStyle_put_borderStyle(style, str);
4080 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4083 str = a2bstr("none invalid none none");
4084 hres = IHTMLStyle_put_borderStyle(style, str);
4085 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4088 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4089 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4090 SysFreeString(sDefault);
4092 /* backgoundColor */
4093 hres = IHTMLStyle_get_backgroundColor(style, &v);
4094 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4095 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4096 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4100 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4101 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4104 V_BSTR(&v) = a2bstr("10");
4105 hres = IHTMLStyle_put_paddingLeft(style, v);
4106 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4109 hres = IHTMLStyle_get_paddingLeft(style, &v);
4110 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4111 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4113 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4114 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4116 /* BackgroundRepeat */
4117 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4118 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4120 str = a2bstr("invalid");
4121 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4122 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4125 str = a2bstr("repeat");
4126 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4127 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4130 str = a2bstr("no-repeat");
4131 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4132 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4135 str = a2bstr("repeat-x");
4136 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4137 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4140 str = a2bstr("repeat-y");
4141 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4142 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4145 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4146 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4147 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4150 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4151 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4152 SysFreeString(sDefault);
4155 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4156 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4158 str = a2bstr("red green red blue");
4159 hres = IHTMLStyle_put_borderColor(style, str);
4160 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4163 hres = IHTMLStyle_get_borderColor(style, &str);
4164 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4165 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4168 hres = IHTMLStyle_put_borderColor(style, sDefault);
4169 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4170 SysFreeString(sDefault);
4173 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4174 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4176 str = a2bstr("thick dotted red");
4177 hres = IHTMLStyle_put_borderLeft(style, str);
4178 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4181 /* IHTMLStyle_get_borderLeft appears to have a bug where
4182 it returns the first letter of the color. So we check
4183 each style individually.
4186 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4187 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4188 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4192 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4193 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4194 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4197 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4198 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4199 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4202 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4203 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4204 SysFreeString(sDefault);
4206 /* backgroundPositionX */
4207 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4208 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4211 V_BSTR(&v) = a2bstr("10px");
4212 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4213 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4216 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4217 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4218 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4221 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4222 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4223 VariantClear(&vDefault);
4225 /* backgroundPositionY */
4226 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4227 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4230 V_BSTR(&v) = a2bstr("10px");
4231 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4232 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4235 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4236 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4237 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4240 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4241 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4242 VariantClear(&vDefault);
4244 /* borderTopWidth */
4245 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4246 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4249 V_BSTR(&v) = a2bstr("10px");
4250 hres = IHTMLStyle_put_borderTopWidth(style, v);
4251 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4254 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4255 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4256 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4259 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4260 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4261 VariantClear(&vDefault);
4263 /* borderRightWidth */
4264 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4265 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4268 V_BSTR(&v) = a2bstr("10");
4269 hres = IHTMLStyle_put_borderRightWidth(style, v);
4270 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4273 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4274 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4275 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4278 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4279 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4280 VariantClear(&vDefault);
4282 /* borderBottomWidth */
4283 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4284 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4287 V_BSTR(&v) = a2bstr("10");
4288 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4289 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4292 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4293 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4294 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4297 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4298 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4299 VariantClear(&vDefault);
4301 /* borderLeftWidth */
4302 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4303 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4306 V_BSTR(&v) = a2bstr("10");
4307 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4308 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4311 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4312 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4313 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4316 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4317 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4318 VariantClear(&vDefault);
4321 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4322 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4325 V_BSTR(&v) = a2bstr("10");
4326 hres = IHTMLStyle_put_wordSpacing(style, v);
4327 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4330 hres = IHTMLStyle_get_wordSpacing(style, &v);
4331 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4332 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4333 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4336 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4337 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4338 VariantClear(&vDefault);
4341 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4342 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4345 V_BSTR(&v) = a2bstr("11");
4346 hres = IHTMLStyle_put_letterSpacing(style, v);
4347 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4350 hres = IHTMLStyle_get_letterSpacing(style, &v);
4351 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4352 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4353 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4356 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4357 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4358 VariantClear(&vDefault);
4360 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4361 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4362 if(SUCCEEDED(hres)) {
4363 test_style2(style2);
4364 IHTMLStyle2_Release(style2);
4367 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4368 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4369 if(SUCCEEDED(hres)) {
4370 test_style3(style3);
4371 IHTMLStyle3_Release(style3);
4374 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4375 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4376 if(SUCCEEDED(hres)) {
4377 test_style4(style4);
4378 IHTMLStyle4_Release(style4);
4382 static void test_set_csstext(IHTMLStyle *style)
4387 test_style_set_csstext(style, "background-color: black;");
4389 hres = IHTMLStyle_get_backgroundColor(style, &v);
4390 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4391 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4392 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4396 static void test_default_selection(IHTMLDocument2 *doc)
4398 IHTMLSelectionObject *selection;
4399 IHTMLTxtRange *range;
4404 hres = IHTMLDocument2_get_selection(doc, &selection);
4405 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4407 hres = IHTMLSelectionObject_get_type(selection, &str);
4408 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4409 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4412 hres = IHTMLSelectionObject_createRange(selection, &disp);
4413 IHTMLSelectionObject_Release(selection);
4414 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4416 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4417 IDispatch_Release(disp);
4418 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4420 test_range_text(range, NULL);
4421 IHTMLTxtRange_Release(range);
4424 static void test_doc_elem(IHTMLDocument2 *doc)
4426 IHTMLDocument2 *doc_node, *owner_doc;
4428 IHTMLDocument3 *doc3;
4431 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4432 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4434 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4435 IHTMLDocument3_Release(doc3);
4436 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4438 test_node_name((IUnknown*)elem, "HTML");
4439 test_elem_tag((IUnknown*)elem, "HTML");
4441 doc_node = get_doc_node(doc);
4442 owner_doc = get_owner_doc((IUnknown*)elem);
4443 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4444 IHTMLDocument2_Release(owner_doc);
4446 owner_doc = get_owner_doc((IUnknown*)doc_node);
4447 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4448 IHTMLDocument2_Release(doc_node);
4450 test_elem_client_rect((IUnknown*)elem);
4452 IHTMLElement_Release(elem);
4455 static void test_default_body(IHTMLBodyElement *body)
4461 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4462 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4464 bstr = (void*)0xdeadbeef;
4465 hres = IHTMLBodyElement_get_background(body, &bstr);
4466 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4467 ok(bstr == NULL, "bstr != NULL\n");
4469 l = elem_get_scroll_height((IUnknown*)body);
4470 ok(l != -1, "scrollHeight == -1\n");
4471 l = elem_get_scroll_width((IUnknown*)body);
4472 ok(l != -1, "scrollWidth == -1\n");
4473 l = elem_get_scroll_top((IUnknown*)body);
4474 ok(!l, "scrollTop = %d\n", l);
4475 elem_get_scroll_left((IUnknown*)body);
4477 /* get_text tests */
4478 hres = IHTMLBodyElement_get_text(body, &v);
4479 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4480 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4481 ok(bstr == NULL, "bstr != NULL\n");
4484 /* get_text - Invalid Text */
4486 V_BSTR(&v) = SysAllocString(sTextInvalid);
4487 hres = IHTMLBodyElement_put_text(body, v);
4488 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4492 hres = IHTMLBodyElement_get_text(body, &v);
4493 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4494 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4495 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4498 /* get_text - Valid Text */
4500 V_BSTR(&v) = SysAllocString(sBodyText);
4501 hres = IHTMLBodyElement_put_text(body, v);
4502 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4506 hres = IHTMLBodyElement_get_text(body, &v);
4507 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4508 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4509 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4513 static void test_body_funs(IHTMLBodyElement *body)
4515 static WCHAR sRed[] = {'r','e','d',0};
4520 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4521 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4522 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4524 V_VT(&vbg) = VT_BSTR;
4525 V_BSTR(&vbg) = SysAllocString(sRed);
4526 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4527 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4530 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4531 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4532 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4533 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4536 /* Restore Originial */
4537 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4538 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4539 VariantClear(&vDefaultbg);
4542 static void test_window(IHTMLDocument2 *doc)
4544 IHTMLWindow2 *window, *window2, *self;
4545 IHTMLDocument2 *doc2 = NULL;
4551 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4552 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4553 test_ifaces((IUnknown*)window, window_iids);
4554 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4556 hres = IHTMLWindow2_get_document(window, &doc2);
4557 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4558 ok(doc2 != NULL, "doc2 == NULL\n");
4560 test_ifaces((IUnknown*)doc2, doc_node_iids);
4561 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4563 test_ifaces((IUnknown*)doc, doc_obj_iids);
4564 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4566 unk = (void*)0xdeadbeef;
4567 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4568 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4569 ok(!unk, "unk = %p\n", unk);
4571 IHTMLDocument_Release(doc2);
4573 hres = IHTMLWindow2_get_window(window, &window2);
4574 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4575 ok(window2 != NULL, "window2 == NULL\n");
4577 hres = IHTMLWindow2_get_self(window, &self);
4578 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4579 ok(window2 != NULL, "self == NULL\n");
4581 ok(self == window2, "self != window2\n");
4583 IHTMLWindow2_Release(window2);
4584 IHTMLWindow2_Release(self);
4587 hres = IHTMLDocument2_get_Script(doc, &disp);
4588 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4589 ok(disp == (void*)window, "disp != window\n");
4590 IDispatch_Release(disp);
4592 hres = IHTMLWindow2_toString(window, NULL);
4593 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4596 hres = IHTMLWindow2_toString(window, &str);
4597 ok(hres == S_OK, "toString failed: %08x\n", hres);
4598 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4601 test_window_name(window, NULL);
4602 set_window_name(window, "test");
4603 test_window_length(window, 0);
4605 IHTMLWindow2_Release(window);
4608 static void test_defaults(IHTMLDocument2 *doc)
4610 IHTMLStyleSheetsCollection *stylesheetcol;
4611 IHTMLCurrentStyle *cstyle;
4612 IHTMLBodyElement *body;
4613 IHTMLElement2 *elem2;
4618 IHTMLElementCollection *collection;
4620 hres = IHTMLDocument2_get_body(doc, &elem);
4621 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4623 hres = IHTMLDocument2_get_images(doc, NULL);
4624 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4626 hres = IHTMLDocument2_get_images(doc, &collection);
4627 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4630 test_elem_collection((IUnknown*)collection, NULL, 0);
4631 IHTMLElementCollection_Release(collection);
4634 hres = IHTMLDocument2_get_applets(doc, NULL);
4635 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4637 hres = IHTMLDocument2_get_applets(doc, &collection);
4638 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4641 test_elem_collection((IUnknown*)collection, NULL, 0);
4642 IHTMLElementCollection_Release(collection);
4645 hres = IHTMLDocument2_get_links(doc, NULL);
4646 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4648 hres = IHTMLDocument2_get_links(doc, &collection);
4649 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4652 test_elem_collection((IUnknown*)collection, NULL, 0);
4653 IHTMLElementCollection_Release(collection);
4656 hres = IHTMLDocument2_get_forms(doc, NULL);
4657 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4659 hres = IHTMLDocument2_get_forms(doc, &collection);
4660 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4663 test_elem_collection((IUnknown*)collection, NULL, 0);
4664 IHTMLElementCollection_Release(collection);
4667 hres = IHTMLDocument2_get_anchors(doc, NULL);
4668 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4670 hres = IHTMLDocument2_get_anchors(doc, &collection);
4671 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4674 test_elem_collection((IUnknown*)collection, NULL, 0);
4675 IHTMLElementCollection_Release(collection);
4678 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4679 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4680 test_default_body(body);
4681 test_body_funs(body);
4682 IHTMLBodyElement_Release(body);
4684 hres = IHTMLElement_get_style(elem, &style);
4685 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4687 test_default_style(style);
4689 test_compatmode(doc);
4691 test_navigator(doc);
4693 elem2 = get_elem2_iface((IUnknown*)elem);
4694 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4695 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4696 if(SUCCEEDED(hres)) {
4697 test_current_style(cstyle);
4698 IHTMLCurrentStyle_Release(cstyle);
4700 IHTMLElement2_Release(elem2);
4702 IHTMLElement_Release(elem);
4704 test_set_csstext(style);
4705 IHTMLStyle_Release(style);
4707 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4708 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4711 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4712 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4713 ok(l == 0, "length = %d\n", l);
4715 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4717 test_default_selection(doc);
4718 test_doc_title(doc, "");
4721 static void test_tr_elem(IHTMLElement *elem)
4723 IHTMLElementCollection *col;
4727 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4729 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4730 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4735 hres = IHTMLTableRow_get_cells(row, &col);
4736 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4737 ok(col != NULL, "get_cells returned NULL\n");
4739 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4740 IHTMLElementCollection_Release(col);
4742 IHTMLTable_Release(row);
4745 static void test_table_elem(IHTMLElement *elem)
4747 IHTMLElementCollection *col;
4752 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4753 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4755 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4756 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4761 hres = IHTMLTable_get_rows(table, &col);
4762 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4763 ok(col != NULL, "get_ros returned NULL\n");
4765 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4766 IHTMLElementCollection_Release(col);
4768 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4770 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4771 test_elem_tag((IUnknown*)node, "TABLE");
4772 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4773 IHTMLDOMNode_Release(node);
4775 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4776 test_elem_tag((IUnknown*)node, "TABLE");
4777 test_elem_all((IUnknown*)node, NULL, 0);
4778 IHTMLDOMNode_Release(node);
4780 IHTMLTable_Release(table);
4783 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4793 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4794 SafeArrayAccessData(sa, (void**)&var);
4795 V_VT(var) = VT_BSTR;
4796 V_BSTR(var) = str = a2bstr(text);
4797 SafeArrayUnaccessData(sa);
4800 hres = IHTMLDocument2_writeln(doc, sa);
4802 hres = IHTMLDocument2_write(doc, sa);
4803 ok(hres == S_OK, "write failed: %08x\n", hres);
4806 SafeArrayDestroy(sa);
4809 static void test_iframe_elem(IHTMLElement *elem)
4811 IHTMLDocument2 *content_doc, *owner_doc;
4812 IHTMLElementCollection *col;
4813 IHTMLWindow2 *content_window;
4814 IHTMLFrameBase2 *base2;
4820 static const elem_type_t all_types[] = {
4828 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4829 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4832 content_window = NULL;
4833 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4834 IHTMLFrameBase2_Release(base2);
4835 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4836 ok(content_window != NULL, "contentWindow = NULL\n");
4838 test_window_length(content_window, 0);
4841 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4842 IHTMLWindow2_Release(content_window);
4843 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4844 ok(content_doc != NULL, "content_doc = NULL\n");
4846 str = a2bstr("text/html");
4847 V_VT(&errv) = VT_ERROR;
4849 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4851 ok(hres == S_OK, "open failed: %08x\n", hres);
4852 ok(disp != NULL, "disp == NULL\n");
4853 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4854 IDispatch_Release(disp);
4856 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4857 doc_write(content_doc, TRUE, "</html>");
4859 hres = IHTMLDocument2_get_all(content_doc, &col);
4860 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4861 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4862 IHTMLElementCollection_Release(col);
4864 hres = IHTMLDocument2_close(content_doc);
4865 ok(hres == S_OK, "close failed: %08x\n", hres);
4867 owner_doc = get_owner_doc((IUnknown*)content_doc);
4868 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4870 IHTMLDocument2_Release(content_doc);
4873 static void test_stylesheet(IDispatch *disp)
4875 IHTMLStyleSheetRulesCollection *col = NULL;
4876 IHTMLStyleSheet *stylesheet;
4879 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4880 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4882 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4883 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4884 ok(col != NULL, "col == NULL\n");
4886 IHTMLStyleSheetRulesCollection_Release(col);
4887 IHTMLStyleSheet_Release(stylesheet);
4890 static void test_stylesheets(IHTMLDocument2 *doc)
4892 IHTMLStyleSheetsCollection *col = NULL;
4897 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4898 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4899 ok(col != NULL, "col == NULL\n");
4901 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4902 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4903 ok(len == 1, "len=%d\n", len);
4909 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4910 ok(hres == S_OK, "item failed: %08x\n", hres);
4911 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4912 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4913 test_stylesheet(V_DISPATCH(&res));
4920 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4921 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4922 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4923 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4926 IHTMLStyleSheetsCollection_Release(col);
4929 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4931 IDispatchEx *dispex;
4933 DISPPARAMS dp = {NULL, NULL, 0, 0};
4941 static const WCHAR w0[] = {'0',0};
4942 static const WCHAR w100[] = {'1','0','0',0};
4944 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4945 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4947 bstr = SysAllocString(w0);
4948 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4949 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4950 SysFreeString(bstr);
4953 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4954 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4955 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4956 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4957 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4958 type = get_node_type((IUnknown*)node);
4959 ok(type == 3, "type=%d\n", type);
4960 IHTMLDOMNode_Release(node);
4963 bstr = SysAllocString(w100);
4964 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4965 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4966 SysFreeString(bstr);
4968 IDispatchEx_Release(dispex);
4973 static void test_elems(IHTMLDocument2 *doc)
4975 IHTMLElementCollection *col;
4976 IHTMLDOMChildrenCollection *child_col;
4977 IHTMLElement *elem, *elem2, *elem3;
4978 IHTMLDOMNode *node, *node2;
4979 IHTMLWindow2 *window;
4983 IHTMLElementCollection *collection;
4984 IHTMLDocument3 *doc3;
4987 static const elem_type_t all_types[] = {
5012 static const elem_type_t item_types[] = {
5018 hres = IHTMLDocument2_get_all(doc, &col);
5019 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5020 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5021 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5022 IHTMLElementCollection_Release(col);
5024 hres = IHTMLDocument2_get_images(doc, &collection);
5025 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5028 static const elem_type_t images_types[] = {ET_IMG};
5029 test_elem_collection((IUnknown*)collection, images_types, 1);
5031 IHTMLElementCollection_Release(collection);
5034 hres = IHTMLDocument2_get_links(doc, &collection);
5035 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5038 static const elem_type_t images_types[] = {ET_A};
5039 test_elem_collection((IUnknown*)collection, images_types, 1);
5041 IHTMLElementCollection_Release(collection);
5044 hres = IHTMLDocument2_get_anchors(doc, &collection);
5045 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5048 static const elem_type_t anchor_types[] = {ET_A};
5049 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5051 IHTMLElementCollection_Release(collection);
5054 elem = get_doc_elem(doc);
5055 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5056 IHTMLElement_Release(elem);
5058 get_elem_by_id(doc, "xxx", FALSE);
5059 elem = get_doc_elem_by_id(doc, "xxx");
5060 ok(!elem, "elem != NULL\n");
5062 elem = get_doc_elem_by_id(doc, "s");
5063 ok(elem != NULL, "elem == NULL\n");
5065 test_elem_type((IUnknown*)elem, ET_SELECT);
5066 test_elem_attr(elem, "xxx", NULL);
5067 test_elem_attr(elem, "id", "s");
5068 test_elem_class((IUnknown*)elem, NULL);
5069 test_elem_set_class((IUnknown*)elem, "cl");
5070 test_elem_set_class((IUnknown*)elem, NULL);
5071 test_elem_tabindex((IUnknown*)elem, 0);
5072 test_elem_set_tabindex((IUnknown*)elem, 1);
5074 node = test_node_get_parent((IUnknown*)elem);
5075 ok(node != NULL, "node == NULL\n");
5076 test_node_name((IUnknown*)node, "BODY");
5077 node2 = test_node_get_parent((IUnknown*)node);
5078 IHTMLDOMNode_Release(node);
5079 ok(node2 != NULL, "node == NULL\n");
5080 test_node_name((IUnknown*)node2, "HTML");
5081 node = test_node_get_parent((IUnknown*)node2);
5082 IHTMLDOMNode_Release(node2);
5083 ok(node != NULL, "node == NULL\n");
5086 test_node_name((IUnknown*)node, "#document");
5087 type = get_node_type((IUnknown*)node);
5088 ok(type == 9, "type=%d, expected 9\n", type);
5089 node2 = test_node_get_parent((IUnknown*)node);
5090 IHTMLDOMNode_Release(node);
5091 ok(node2 == NULL, "node != NULL\n");
5094 elem2 = test_elem_get_parent((IUnknown*)elem);
5095 ok(elem2 != NULL, "elem2 == NULL\n");
5096 test_node_name((IUnknown*)elem2, "BODY");
5097 elem3 = test_elem_get_parent((IUnknown*)elem2);
5098 IHTMLElement_Release(elem2);
5099 ok(elem3 != NULL, "elem3 == NULL\n");
5100 test_node_name((IUnknown*)elem3, "HTML");
5101 elem2 = test_elem_get_parent((IUnknown*)elem3);
5102 IHTMLElement_Release(elem3);
5103 ok(elem2 == NULL, "elem2 != NULL\n");
5105 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5106 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5107 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5109 test_elem_innertext(elem, "opt1opt2");
5111 IHTMLElement_Release(elem);
5114 elem = get_elem_by_id(doc, "s", TRUE);
5116 IHTMLSelectElement *select;
5117 IHTMLDocument2 *doc_node;
5119 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5120 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5122 test_select_elem(select);
5124 test_elem_title((IUnknown*)select, NULL);
5125 test_elem_set_title((IUnknown*)select, "Title");
5126 test_elem_title((IUnknown*)select, "Title");
5127 test_elem_offset((IUnknown*)select);
5129 node = get_first_child((IUnknown*)select);
5130 ok(node != NULL, "node == NULL\n");
5132 test_elem_type((IUnknown*)node, ET_OPTION);
5133 IHTMLDOMNode_Release(node);
5136 type = get_node_type((IUnknown*)select);
5137 ok(type == 1, "type=%d\n", type);
5139 IHTMLSelectElement_Release(select);
5141 hres = IHTMLElement_get_document(elem, &disp);
5142 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5144 doc_node = get_doc_node(doc);
5145 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
5146 IHTMLDocument2_Release(doc_node);
5148 IHTMLElement_Release(elem);
5151 elem = get_elem_by_id(doc, "sc", TRUE);
5153 IHTMLScriptElement *script;
5156 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5157 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5163 hres = IHTMLScriptElement_get_type(script, &type);
5164 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5165 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5166 SysFreeString(type);
5169 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5170 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5172 hres = IHTMLScriptElement_get_defer(script, &vb);
5173 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5174 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5176 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5177 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5180 IHTMLScriptElement_Release(script);
5183 elem = get_elem_by_id(doc, "in", TRUE);
5185 IHTMLInputElement *input;
5187 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5188 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5190 test_elem_id((IUnknown*)elem, "in");
5191 test_elem_put_id((IUnknown*)elem, "newin");
5192 test_input_get_disabled(input, VARIANT_FALSE);
5193 test_input_set_disabled(input, VARIANT_TRUE);
5194 test_input_set_disabled(input, VARIANT_FALSE);
5195 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5196 test_input_get_disabled(input, VARIANT_TRUE);
5197 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5198 test_input_get_disabled(input, VARIANT_FALSE);
5199 test_elem_client_size((IUnknown*)elem);
5201 test_node_get_value_str((IUnknown*)elem, NULL);
5202 test_node_put_value_str((IUnknown*)elem, "test");
5203 test_node_get_value_str((IUnknown*)elem, NULL);
5204 test_input_value((IUnknown*)elem, NULL);
5205 test_input_put_value((IUnknown*)elem, "test");
5206 test_input_value((IUnknown*)elem, NULL);
5207 test_elem_class((IUnknown*)elem, "testclass");
5208 test_elem_tabindex((IUnknown*)elem, 2);
5209 test_elem_set_tabindex((IUnknown*)elem, 3);
5210 test_elem_title((IUnknown*)elem, "test title");
5212 test_input_get_defaultchecked(input, VARIANT_FALSE);
5213 test_input_set_defaultchecked(input, VARIANT_TRUE);
5214 test_input_set_defaultchecked(input, VARIANT_FALSE);
5216 test_input_get_checked(input, VARIANT_FALSE);
5217 test_input_set_checked(input, VARIANT_TRUE);
5218 test_input_set_checked(input, VARIANT_FALSE);
5220 test_input_src(input, NULL);
5221 test_input_set_src(input, "about:blank");
5223 IHTMLInputElement_Release(input);
5224 IHTMLElement_Release(elem);
5227 elem = get_elem_by_id(doc, "imgid", TRUE);
5229 test_img_src((IUnknown*)elem, "");
5230 test_img_set_src((IUnknown*)elem, "about:blank");
5231 test_img_alt((IUnknown*)elem, NULL);
5232 test_img_set_alt((IUnknown*)elem, "alt test");
5233 IHTMLElement_Release(elem);
5236 elem = get_doc_elem_by_id(doc, "tbl");
5237 ok(elem != NULL, "elem == NULL\n");
5239 test_table_elem(elem);
5240 IHTMLElement_Release(elem);
5243 elem = get_doc_elem_by_id(doc, "row2");
5244 ok(elem != NULL, "elem == NULL\n");
5247 IHTMLElement_Release(elem);
5250 elem = get_doc_elem_by_id(doc, "ifr");
5251 ok(elem != NULL, "elem == NULL\n");
5253 test_iframe_elem(elem);
5254 IHTMLElement_Release(elem);
5257 elem = get_elem_by_id(doc, "a", TRUE);
5259 test_anchor_href((IUnknown*)elem, "http://test/");
5260 IHTMLElement_Release(elem);
5263 hres = IHTMLDocument2_get_body(doc, &elem);
5264 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5266 node = get_first_child((IUnknown*)elem);
5267 ok(node != NULL, "node == NULL\n");
5269 test_ifaces((IUnknown*)node, text_iids);
5270 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5272 node2 = get_first_child((IUnknown*)node);
5273 ok(!node2, "node2 != NULL\n");
5275 type = get_node_type((IUnknown*)node);
5276 ok(type == 3, "type=%d\n", type);
5278 test_node_get_value_str((IUnknown*)node, "text test");
5279 test_node_put_value_str((IUnknown*)elem, "test text");
5280 test_node_get_value_str((IUnknown*)node, "text test");
5282 IHTMLDOMNode_Release(node);
5285 child_col = get_child_nodes((IUnknown*)elem);
5286 ok(child_col != NULL, "child_coll == NULL\n");
5290 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5292 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5293 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5294 ok(length, "length=0\n");
5297 node = get_child_item(child_col, 0);
5298 ok(node != NULL, "node == NULL\n");
5300 type = get_node_type((IUnknown*)node);
5301 ok(type == 3, "type=%d\n", type);
5302 node2 = node_get_next((IUnknown*)node);
5303 IHTMLDOMNode_Release(node);
5306 node = get_child_item(child_col, 1);
5307 ok(node != NULL, "node == NULL\n");
5309 type = get_node_type((IUnknown*)node);
5310 ok(type == 8, "type=%d\n", type);
5312 test_elem_id((IUnknown*)node, NULL);
5313 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5314 IHTMLDOMNode_Release(node2);
5315 IHTMLDOMNode_Release(node);
5318 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5319 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5321 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5322 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5324 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5325 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5327 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5328 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5330 test_child_col_disp(child_col);
5332 IHTMLDOMChildrenCollection_Release(child_col);
5335 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5336 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5337 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5339 IHTMLElement_Release(elem);
5341 test_stylesheets(doc);
5342 test_create_option_elem(doc);
5343 test_create_img_elem(doc);
5345 elem = get_doc_elem_by_id(doc, "tbl");
5346 ok(elem != NULL, "elem = NULL\n");
5347 test_elem_set_innertext(elem, "inner text");
5348 IHTMLElement_Release(elem);
5350 test_doc_title(doc, "test");
5351 test_doc_set_title(doc, "test title");
5352 test_doc_title(doc, "test title");
5355 hres = IHTMLDocument2_get_Script(doc, &disp);
5356 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5359 IDispatchEx *dispex;
5360 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5361 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5365 BSTR str = a2bstr("Testing");
5366 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5367 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5368 ok(pid != -1, "pid == -1\n");
5370 IDispatchEx_Release(dispex);
5373 IDispatch_Release(disp);
5375 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5376 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5378 str = a2bstr("img");
5379 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5380 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5384 static const elem_type_t img_types[] = { ET_IMG };
5386 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5387 IHTMLElementCollection_Release(col);
5390 elem = get_doc_elem_by_id(doc, "y");
5391 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5392 test_elem_innerhtml((IUnknown*)elem, "inner html");
5393 test_elem_set_innerhtml((IUnknown*)elem, "");
5394 test_elem_innerhtml((IUnknown*)elem, NULL);
5395 node = node_get_next((IUnknown*)elem);
5396 ok(!node, "node = %p\n", node);
5398 elem2 = get_doc_elem_by_id(doc, "x");
5399 test_elem_tag((IUnknown*)elem2, "A");
5400 node = node_get_next((IUnknown*)elem2);
5401 IHTMLDOMNode_Release(node);
5402 IHTMLElement_Release(elem2);
5403 IHTMLElement_Release(elem);
5405 IHTMLDocument3_Release(doc3);
5407 window = get_doc_window(doc);
5408 test_window_name(window, NULL);
5409 set_window_name(window, "test name");
5410 test_window_length(window, 1);
5411 IHTMLWindow2_Release(window);
5414 static void test_elems2(IHTMLDocument2 *doc)
5416 IHTMLElement *elem, *elem2;
5418 static const elem_type_t outer_types[] = {
5423 elem = get_doc_elem_by_id(doc, "divid");
5425 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5426 elem2 = get_doc_elem_by_id(doc, "innerid");
5427 ok(elem2 != NULL, "elem2 == NULL\n");
5428 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5429 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5430 IHTMLElement_Release(elem2);
5432 elem2 = get_doc_elem_by_id(doc, "aid");
5433 ok(elem2 != NULL, "elem2 == NULL\n");
5434 test_elem_set_outerhtml((IUnknown*)elem2, "");
5435 test_elem_all((IUnknown*)elem, outer_types, 1);
5436 IHTMLElement_Release(elem2);
5438 IHTMLElement_Release(elem);
5441 static void test_create_elems(IHTMLDocument2 *doc)
5443 IHTMLElement *elem, *body, *elem2;
5444 IHTMLDOMNode *node, *node2, *node3, *comment;
5445 IHTMLDocument5 *doc5;
5452 static const elem_type_t types1[] = { ET_TESTG };
5454 elem = test_create_elem(doc, "TEST");
5455 test_elem_tag((IUnknown*)elem, "TEST");
5456 type = get_node_type((IUnknown*)elem);
5457 ok(type == 1, "type=%d\n", type);
5458 test_ifaces((IUnknown*)elem, elem_iids);
5459 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5461 hres = IHTMLDocument2_get_body(doc, &body);
5462 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5463 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5465 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5466 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5467 elem2 = get_elem_iface((IUnknown*)node);
5468 IHTMLElement_Release(elem2);
5470 hres = IHTMLElement_get_all(body, &disp);
5471 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5472 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5473 IDispatch_Release(disp);
5475 test_node_remove_child((IUnknown*)body, node);
5477 hres = IHTMLElement_get_all(body, &disp);
5478 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5479 test_elem_collection((IUnknown*)disp, NULL, 0);
5480 IDispatch_Release(disp);
5481 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5483 IHTMLElement_Release(elem);
5484 IHTMLDOMNode_Release(node);
5486 node = test_create_text(doc, "test");
5487 test_ifaces((IUnknown*)node, text_iids);
5488 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5490 V_VT(&var) = VT_NULL;
5491 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5492 IHTMLDOMNode_Release(node);
5494 node = test_create_text(doc, "insert ");
5496 V_VT(&var) = VT_DISPATCH;
5497 V_DISPATCH(&var) = (IDispatch*)node2;
5498 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5499 IHTMLDOMNode_Release(node);
5500 IHTMLDOMNode_Release(node2);
5501 IHTMLDOMNode_Release(node3);
5503 test_elem_innertext(body, "insert test");
5504 test_elem_innerhtml((IUnknown*)body, "insert test");
5506 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5509 str = a2bstr("testing");
5510 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5512 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5515 type = get_node_type((IUnknown*)comment);
5516 ok(type == 8, "type=%d, expected 8\n", type);
5518 test_node_get_value_str((IUnknown*)comment, "testing");
5520 IHTMLDOMNode_Release(comment);
5523 IHTMLDocument5_Release(doc5);
5526 IHTMLElement_Release(body);
5529 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5531 IOleCommandTarget *cmdtrg;
5534 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5535 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5537 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5538 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5540 IOleCommandTarget_Release(cmdtrg);
5543 static void test_indent(IHTMLDocument2 *doc)
5545 IHTMLElementCollection *col;
5546 IHTMLTxtRange *range;
5549 static const elem_type_t all_types[] = {
5558 static const elem_type_t indent_types[] = {
5569 hres = IHTMLDocument2_get_all(doc, &col);
5570 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5571 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5572 IHTMLElementCollection_Release(col);
5574 range = test_create_body_range(doc);
5575 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5576 IHTMLTxtRange_Release(range);
5578 hres = IHTMLDocument2_get_all(doc, &col);
5579 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5580 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5581 IHTMLElementCollection_Release(col);
5584 static void test_cond_comment(IHTMLDocument2 *doc)
5586 IHTMLElementCollection *col;
5589 static const elem_type_t all_types[] = {
5597 hres = IHTMLDocument2_get_all(doc, &col);
5598 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5599 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5600 IHTMLElementCollection_Release(col);
5603 static void test_frame(IDispatch *disp, const char *exp_id)
5605 IHTMLWindow2 *frame2, *parent, *top;
5606 IHTMLDocument2 *parent_doc, *top_doc;
5607 IHTMLWindow4 *frame;
5608 IHTMLFrameBase *frame_elem;
5609 IHTMLElement *html_elem;
5613 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5614 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5618 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5619 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5620 IHTMLWindow4_Release(frame);
5624 hres = IHTMLFrameBase_QueryInterface(frame_elem, &IID_IHTMLElement, (void**)&html_elem);
5625 ok(hres == S_OK, "Could not get IHTMLElement interface: 0x%08x\n", hres);
5626 IHTMLFrameBase_Release(frame_elem);
5630 hres = IHTMLElement_get_id(html_elem, &bstr);
5631 ok(hres == S_OK, "IHTMLElement_get_id failed: 0x%08x\n", hres);
5632 ok(!strcmp_wa(bstr, exp_id), "Expected ID: \"%s\", found ID: %s\n", exp_id, wine_dbgstr_w(bstr));
5633 IHTMLElement_Release(html_elem);
5634 SysFreeString(bstr);
5636 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5637 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5641 hres = IHTMLWindow2_get_parent(frame2, &parent);
5642 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5644 IHTMLWindow2_Release(frame2);
5648 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5649 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5650 IHTMLWindow2_Release(parent);
5652 IHTMLWindow2_Release(frame2);
5656 hres = IHTMLDocument2_get_title(parent_doc, &bstr);
5657 ok(hres == S_OK, "IHTMLDocument2_get_title failed: 0x%08x\n", hres);
5658 ok(!strcmp_wa(bstr, "frameset test"), "Did not get the right parent. Expected \"frameset test\", found %s\n", wine_dbgstr_w(bstr));
5659 IHTMLDocument2_Release(parent_doc);
5660 SysFreeString(bstr);
5663 hres = IHTMLWindow2_get_top(frame2, &top);
5664 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5665 IHTMLWindow2_Release(frame2);
5669 hres = IHTMLWindow2_get_document(top, &top_doc);
5670 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5671 IHTMLWindow2_Release(top);
5675 hres = IHTMLDocument2_get_title(top_doc, &bstr);
5676 ok(hres == S_OK, "IHTMLDocument2_get_title failed: 0x%08x\n", hres);
5677 ok(!strcmp_wa(bstr, "frameset test"), "Did not get the right parent. Expected \"frameset test\", found %s\n", wine_dbgstr_w(bstr));
5678 IHTMLDocument2_Release(top_doc);
5679 SysFreeString(bstr);
5682 static void test_frameset(IHTMLDocument2 *doc)
5684 IHTMLWindow2 *window;
5685 IHTMLFramesCollection2 *frames;
5688 VARIANT index_var, result_var;
5691 window = get_doc_window(doc);
5693 /* test using IHTMLFramesCollection object */
5695 hres = IHTMLWindow2_get_frames(window, &frames);
5696 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5697 IHTMLWindow2_Release(window);
5701 /* test result length */
5702 hres = IHTMLFramesCollection2_get_length(frames, &length);
5703 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5704 ok(length == 2, "IHTMLFramesCollection2_get_length should have been 2, was: %d\n", length);
5706 /* test first frame */
5707 V_VT(&index_var) = VT_I4;
5708 V_I4(&index_var) = 0;
5709 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5710 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5711 if(SUCCEEDED(hres)) {
5712 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5713 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5715 VariantClear(&result_var);
5717 /* test second frame */
5718 V_I4(&index_var) = 1;
5719 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5720 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5721 if(SUCCEEDED(hres)) {
5722 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5723 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5725 VariantClear(&result_var);
5727 /* fail on third frame */
5728 V_I4(&index_var) = 2;
5729 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5730 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5731 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5732 VariantClear(&result_var);
5734 /* string argument (element id lookup) */
5735 V_VT(&index_var) = VT_BSTR;
5736 V_BSTR(&index_var) = a2bstr("fr1");
5737 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5738 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5739 if(SUCCEEDED(hres)) {
5740 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5741 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5743 VariantClear(&result_var);
5744 VariantClear(&index_var);
5746 /* invalid argument */
5747 V_VT(&index_var) = VT_BOOL;
5748 V_BOOL(&index_var) = VARIANT_TRUE;
5749 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5750 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5751 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5752 VariantClear(&result_var);
5754 IHTMLFramesCollection2_Release(frames);
5756 /* test using IHTMLWindow2 inheritance */
5758 /* test result length */
5759 hres = IHTMLWindow2_get_length(window, &length);
5760 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5761 ok(length == 2, "IHTMLWindow2_get_length should have been 2, was: %d\n", length);
5763 /* test first frame */
5764 V_VT(&index_var) = VT_I4;
5765 V_I4(&index_var) = 0;
5766 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5767 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5768 if(SUCCEEDED(hres)) {
5769 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5770 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5772 VariantClear(&result_var);
5774 /* test second frame */
5775 V_I4(&index_var) = 1;
5776 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5777 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5778 if(SUCCEEDED(hres)) {
5779 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5780 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5782 VariantClear(&result_var);
5784 /* fail on third frame */
5785 V_I4(&index_var) = 2;
5786 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5787 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5788 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5789 VariantClear(&result_var);
5791 /* string argument (element id lookup) */
5792 V_VT(&index_var) = VT_BSTR;
5793 V_BSTR(&index_var) = a2bstr("fr2");
5794 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5795 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5796 if(SUCCEEDED(hres)) {
5797 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5798 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5800 VariantClear(&result_var);
5801 VariantClear(&index_var);
5803 /* invalid argument */
5804 V_VT(&index_var) = VT_BOOL;
5805 V_BOOL(&index_var) = VARIANT_TRUE;
5806 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5807 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5808 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5809 VariantClear(&result_var);
5811 /* getElementById with node name attributes */
5812 elem = get_doc_elem_by_id(doc, "nm1");
5813 test_elem_id((IUnknown*)elem, "fr1");
5814 IHTMLElement_Release(elem);
5817 static IHTMLDocument2 *notif_doc;
5818 static BOOL doc_complete;
5820 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5821 REFIID riid, void**ppv)
5823 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5828 ok(0, "unexpected call\n");
5829 return E_NOINTERFACE;
5832 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5837 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5842 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5844 if(dispID == DISPID_READYSTATE){
5848 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5849 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5851 if(!strcmp_wa(state, "complete"))
5852 doc_complete = TRUE;
5854 SysFreeString(state);
5860 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5862 ok(0, "unexpected call\n");
5866 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5867 PropertyNotifySink_QueryInterface,
5868 PropertyNotifySink_AddRef,
5869 PropertyNotifySink_Release,
5870 PropertyNotifySink_OnChanged,
5871 PropertyNotifySink_OnRequestEdit
5874 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5876 static IHTMLDocument2 *create_doc_with_string(const char *str)
5878 IPersistStreamInit *init;
5880 IHTMLDocument2 *doc;
5884 notif_doc = doc = create_document();
5888 doc_complete = FALSE;
5890 mem = GlobalAlloc(0, len);
5891 memcpy(mem, str, len);
5892 CreateStreamOnHGlobal(mem, TRUE, &stream);
5894 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5896 IPersistStreamInit_Load(init, stream);
5897 IPersistStreamInit_Release(init);
5898 IStream_Release(stream);
5903 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5905 IConnectionPointContainer *container;
5906 IConnectionPoint *cp;
5910 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5911 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5913 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5914 IConnectionPointContainer_Release(container);
5915 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5917 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5918 IConnectionPoint_Release(cp);
5919 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5922 typedef void (*domtest_t)(IHTMLDocument2*);
5924 static void run_domtest(const char *str, domtest_t test)
5926 IHTMLDocument2 *doc;
5930 doc = create_doc_with_string(str);
5934 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5936 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5937 TranslateMessage(&msg);
5938 DispatchMessage(&msg);
5943 ref = IHTMLDocument2_Release(doc);
5945 ref == 1, /* Vista */
5953 run_domtest(doc_str1, test_doc_elem);
5954 run_domtest(doc_str1, test_get_set_attr);
5955 run_domtest(range_test_str, test_txtrange);
5956 run_domtest(range_test2_str, test_txtrange2);
5957 if (winetest_interactive || ! is_ie_hardened()) {
5958 run_domtest(elem_test_str, test_elems);
5960 skip("IE running in Enhanced Security Configuration\n");
5962 run_domtest(elem_test2_str, test_elems2);
5963 run_domtest(doc_blank, test_create_elems);
5964 run_domtest(doc_blank, test_defaults);
5965 run_domtest(indent_test_str, test_indent);
5966 run_domtest(cond_comment_str, test_cond_comment);
5967 run_domtest(frameset_str, test_frameset);