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 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
887 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
889 IHTMLFrameBase2 *base2;
890 IHTMLWindow2 *window;
893 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
894 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
897 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
898 IHTMLFrameBase2_Release(base2);
899 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
900 ok(window != NULL, "contentWindow = NULL\n");
905 static void test_get_set_attr(IHTMLDocument2 *doc)
908 IHTMLDocument3 *doc3;
913 /* grab an element to test with */
914 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
915 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
917 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
918 IHTMLDocument3_Release(doc3);
919 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
921 /* get a non-present attribute */
922 bstr = a2bstr("notAnAttribute");
923 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
924 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
925 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
929 /* get a present attribute */
930 bstr = a2bstr("scrollHeight");
931 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
932 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
933 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
937 /* create a new BSTR attribute */
938 bstr = a2bstr("newAttribute");
940 V_VT(&val) = VT_BSTR;
941 V_BSTR(&val) = a2bstr("the value");
942 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
943 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
946 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
947 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
948 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
949 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)));
952 /* overwrite the attribute with a BOOL */
953 V_VT(&val) = VT_BOOL;
954 V_BOOL(&val) = VARIANT_TRUE;
955 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
956 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
959 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
960 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
961 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
962 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
967 /* case-insensitive */
968 bstr = a2bstr("newattribute");
969 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
970 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
971 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
972 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
976 IHTMLElement_Release(elem);
979 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
980 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
983 IHTMLDocument3 *doc3;
986 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
987 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
988 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
989 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
990 IHTMLDocument3_Release(doc3);
995 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
996 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
998 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1002 hres = IHTMLAnchorElement_get_href(anchor, &str);
1003 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1004 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1007 _test_disp_value(line, unk, exhref);
1010 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1011 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1016 hres = IHTMLOptionElement_get_text(option, &bstr);
1017 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1018 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1019 SysFreeString(bstr);
1022 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1023 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1028 bstr = a2bstr(text);
1029 hres = IHTMLOptionElement_put_text(option, bstr);
1030 SysFreeString(bstr);
1031 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1033 _test_option_text(line, option, text);
1036 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1037 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1042 hres = IHTMLOptionElement_get_value(option, &bstr);
1043 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1044 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1045 SysFreeString(bstr);
1048 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1049 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1054 bstr = a2bstr(value);
1055 hres = IHTMLOptionElement_put_value(option, bstr);
1056 SysFreeString(bstr);
1057 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1059 _test_option_value(line, option, value);
1062 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1063 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1064 const char *txt, const char *val)
1066 IHTMLOptionElementFactory *factory;
1067 IHTMLOptionElement *option;
1068 IHTMLWindow2 *window;
1069 VARIANT text, value, empty;
1072 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1073 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1075 hres = IHTMLWindow2_get_Option(window, &factory);
1076 IHTMLWindow2_Release(window);
1077 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1079 V_VT(&text) = VT_BSTR;
1080 V_BSTR(&text) = a2bstr(txt);
1081 V_VT(&value) = VT_BSTR;
1082 V_BSTR(&value) = a2bstr(val);
1083 V_VT(&empty) = VT_EMPTY;
1085 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1086 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1088 IHTMLOptionElementFactory_Release(factory);
1089 VariantClear(&text);
1090 VariantClear(&value);
1092 _test_option_text(line, option, txt);
1093 _test_option_value(line, option, val);
1098 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1099 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1104 hres = IHTMLImgElement_get_width(img, &found);
1105 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1106 todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1109 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1110 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1114 hres = IHTMLImgElement_put_width(img, width);
1115 todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres);
1117 _test_img_width(line, img, width);
1120 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1121 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1126 hres = IHTMLImgElement_get_height(img, &found);
1127 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1128 todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1131 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1132 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1136 hres = IHTMLImgElement_put_height(img, height);
1137 todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres);
1139 _test_img_height(line, img, height);
1142 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1143 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1144 LONG wdth, LONG hght)
1146 IHTMLImageElementFactory *factory;
1147 IHTMLImgElement *img;
1148 IHTMLWindow2 *window;
1149 VARIANT width, height;
1153 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1154 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1156 hres = IHTMLWindow2_get_Image(window, &factory);
1157 IHTMLWindow2_Release(window);
1158 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1160 test_ifaces((IUnknown*)factory, img_factory_iids);
1161 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1164 snprintf(buf, 16, "%d", wdth);
1165 V_VT(&width) = VT_BSTR;
1166 V_BSTR(&width) = a2bstr(buf);
1168 V_VT(&width) = VT_EMPTY;
1173 snprintf(buf, 16, "%d", hght);
1174 V_VT(&height) = VT_BSTR;
1175 V_BSTR(&height) = a2bstr(buf);
1177 V_VT(&height) = VT_EMPTY;
1181 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1182 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1184 IHTMLImageElementFactory_Release(factory);
1185 VariantClear(&width);
1186 VariantClear(&height);
1188 if(SUCCEEDED(hres)) {
1189 _test_img_width(line, img, wdth);
1190 _test_img_height(line, img, hght);
1197 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1198 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1200 LONG len = 0xdeadbeef;
1203 hres = IHTMLSelectElement_get_length(select, &len);
1204 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1205 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1208 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1209 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1211 LONG idx = 0xdeadbeef;
1214 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1215 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1216 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1219 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1220 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1224 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1225 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1226 _test_select_selidx(line, select, index);
1229 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1230 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1235 hres = IHTMLSelectElement_get_value(select, &val);
1236 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1238 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1240 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1243 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1244 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1250 hres = IHTMLSelectElement_put_value(select, bstr);
1251 SysFreeString(bstr);
1252 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1255 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1256 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1261 hres = IHTMLSelectElement_get_type(select, &type);
1262 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1263 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1266 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1267 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1272 hres = IHTMLTxtRange_get_text(range, &text);
1273 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1276 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1277 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1279 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1282 SysFreeString(text);
1286 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1287 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1291 hres = IHTMLTxtRange_collapse(range, b);
1292 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1293 _test_range_text(line, range, NULL);
1296 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1297 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1298 VARIANT_BOOL exb, const char *extext)
1300 VARIANT_BOOL b = 0xe0e0;
1303 hres = IHTMLTxtRange_expand(range, unit, &b);
1304 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1305 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1306 _test_range_text(line, range, extext);
1309 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1310 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1312 LONG c = 0xdeadbeef;
1315 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1316 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1317 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1318 _test_range_text(line, range, NULL);
1321 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1322 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1323 LPWSTR unit, LONG cnt, LONG excnt)
1325 LONG c = 0xdeadbeef;
1328 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1329 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1330 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1333 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1334 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1336 LONG c = 0xdeadbeef;
1339 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1340 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1341 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1344 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1345 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1348 BSTR bstr = a2bstr(text);
1350 hres = IHTMLTxtRange_put_text(range, bstr);
1351 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1352 SysFreeString(bstr);
1353 _test_range_text(line, range, NULL);
1356 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1357 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1363 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1364 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1365 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1368 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1369 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1375 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1376 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1377 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1380 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1381 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1382 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1385 test_range_inrange(range1, range2, VARIANT_TRUE);
1386 test_range_inrange(range2, range1, VARIANT_TRUE);
1390 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1391 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1396 hres = IHTMLTxtRange_parentElement(range, &elem);
1397 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1399 _test_elem_type(line, (IUnknown*)elem, type);
1401 IHTMLElement_Release(elem);
1404 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1405 static void _test_elem_collection(unsigned line, IUnknown *unk,
1406 const elem_type_t *elem_types, LONG exlen)
1408 IHTMLElementCollection *col;
1411 VARIANT name, index;
1412 IDispatch *disp, *disp2;
1415 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1416 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1418 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1420 hres = IHTMLElementCollection_get_length(col, &len);
1421 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1422 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1427 V_VT(&index) = VT_EMPTY;
1429 for(i=0; i<len; i++) {
1430 V_VT(&name) = VT_I4;
1432 disp = (void*)0xdeadbeef;
1433 hres = IHTMLElementCollection_item(col, name, index, &disp);
1434 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1435 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1436 if(FAILED(hres) || !disp)
1439 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1442 V_VT(&name) = VT_UINT;
1444 disp2 = (void*)0xdeadbeef;
1445 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1446 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1447 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1449 IDispatch_Release(disp2);
1452 IDispatch_Release(disp);
1455 V_VT(&name) = VT_I4;
1457 disp = (void*)0xdeadbeef;
1458 hres = IHTMLElementCollection_item(col, name, index, &disp);
1459 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1460 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1462 V_VT(&name) = VT_I4;
1464 disp = (void*)0xdeadbeef;
1465 hres = IHTMLElementCollection_item(col, name, index, &disp);
1466 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1467 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1469 IHTMLElementCollection_Release(col);
1472 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1473 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1475 IHTMLElement *elem = _get_elem_iface(line, unk);
1479 hres = IHTMLElement_get_all(elem, &disp);
1480 IHTMLElement_Release(elem);
1481 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1483 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1484 IDispatch_Release(disp);
1487 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1488 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1490 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1491 IHTMLElementCollection *col = NULL;
1492 elem_type_t *types = NULL;
1497 tmp = a2bstr(elem_type_infos[type].tag);
1498 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1500 IHTMLElement2_Release(elem);
1501 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1502 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1505 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1506 for(i=0; i<exlen; i++)
1510 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1512 HeapFree(GetProcessHeap(), 0, types);
1515 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1516 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1521 hres = IHTMLElement_get_innerText(elem, &text);
1522 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1523 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1524 wine_dbgstr_w(text), extext);
1525 SysFreeString(text);
1528 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1529 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1531 IHTMLDOMChildrenCollection *col;
1536 hres = IHTMLElement_put_innerText(elem, str);
1537 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1540 _test_elem_innertext(line, elem, text);
1543 col = _get_child_nodes(line, (IUnknown*)elem);
1544 ok(col != NULL, "col == NULL\n");
1546 LONG length = 0, type;
1549 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1550 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1551 ok(length == 1, "length = %d\n", length);
1553 node = _get_child_item(line, col, 0);
1554 ok(node != NULL, "node == NULL\n");
1556 type = _get_node_type(line, (IUnknown*)node);
1557 ok(type == 3, "type=%d\n", type);
1558 IHTMLDOMNode_Release(node);
1561 IHTMLDOMChildrenCollection_Release(col);
1566 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1567 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1569 IHTMLElement *elem = _get_elem_iface(line, unk);
1573 hres = IHTMLElement_get_innerHTML(elem, &html);
1574 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1576 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1578 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1580 IHTMLElement_Release(elem);
1581 SysFreeString(html);
1584 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1585 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1587 IHTMLElement *elem = _get_elem_iface(line, unk);
1591 html = a2bstr(inner_html);
1592 hres = IHTMLElement_put_innerHTML(elem, html);
1593 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1595 IHTMLElement_Release(elem);
1596 SysFreeString(html);
1599 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1600 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1602 IHTMLElement *elem = _get_elem_iface(line, unk);
1606 html = a2bstr(outer_html);
1607 hres = IHTMLElement_put_outerHTML(elem, html);
1608 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1610 IHTMLElement_Release(elem);
1611 SysFreeString(html);
1614 #define get_first_child(n) _get_first_child(__LINE__,n)
1615 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1617 IHTMLDOMNode *node = _get_node_iface(line, unk);
1618 IHTMLDOMNode *child = NULL;
1621 hres = IHTMLDOMNode_get_firstChild(node, &child);
1622 IHTMLDOMNode_Release(node);
1623 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1628 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1629 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1631 IHTMLDOMNode *node = _get_node_iface(line, unk);
1632 VARIANT_BOOL b = 0xdead;
1635 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1636 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1637 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1639 IHTMLDOMNode_Release(node);
1642 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1643 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1645 IHTMLDOMNode *node = _get_node_iface(line, unk);
1646 IHTMLDOMNode *parent;
1649 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1650 IHTMLDOMNode_Release(node);
1651 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1656 #define node_get_next(u) _node_get_next(__LINE__,u)
1657 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1659 IHTMLDOMNode *node = _get_node_iface(line, unk);
1663 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1664 IHTMLDOMNode_Release(node);
1665 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1670 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1671 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1673 IHTMLElement *elem = _get_elem_iface(line, unk);
1674 IHTMLElement *parent;
1677 hres = IHTMLElement_get_parentElement(elem, &parent);
1678 IHTMLElement_Release(elem);
1679 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1684 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1685 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1687 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1688 VARIANT_BOOL disabled = 100;
1692 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1693 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1694 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1695 IHTMLElement3_Release(elem3);
1698 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1699 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1701 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1705 hres = IHTMLElement3_put_disabled(elem3, b);
1706 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1708 IHTMLElement3_Release(elem3);
1709 _test_elem3_get_disabled(line, unk, b);
1712 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1713 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1715 VARIANT_BOOL disabled = 100;
1718 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1719 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1720 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1722 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1725 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1726 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1730 hres = IHTMLSelectElement_put_disabled(select, b);
1731 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1733 _test_select_get_disabled(line, select, b);
1736 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1737 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1739 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1740 IHTMLTextContainer *txtcont;
1741 LONG l = -1, l2 = -1;
1744 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1745 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1746 IHTMLElement2_Release(elem);
1748 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1749 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1751 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1752 IHTMLTextContainer_Release(txtcont);
1753 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1754 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1759 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1760 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1762 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1763 IHTMLTextContainer *txtcont;
1764 LONG l = -1, l2 = -1;
1767 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1768 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1769 IHTMLElement2_Release(elem);
1771 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1772 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1774 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1775 IHTMLTextContainer_Release(txtcont);
1776 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1777 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1782 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1783 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1785 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1786 IHTMLTextContainer *txtcont;
1787 LONG l = -1, l2 = -1;
1790 hres = IHTMLElement2_get_scrollTop(elem, &l);
1791 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1792 IHTMLElement2_Release(elem);
1794 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1795 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1797 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1798 IHTMLTextContainer_Release(txtcont);
1799 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1800 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1805 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1806 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1808 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1809 IHTMLTextContainer *txtcont;
1810 LONG l = -1, l2 = -1;
1813 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1814 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1816 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1817 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1818 IHTMLElement2_Release(elem);
1820 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1821 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1823 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1824 IHTMLTextContainer_Release(txtcont);
1825 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1826 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1829 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1830 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1832 IHTMLImgElement *img = _get_img_iface(line, unk);
1836 hres = IHTMLImgElement_get_src(img, &src);
1837 IHTMLImgElement_Release(img);
1838 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1839 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1843 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1844 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1846 IHTMLImgElement *img = _get_img_iface(line, unk);
1851 hres = IHTMLImgElement_put_src(img, tmp);
1852 IHTMLImgElement_Release(img);
1854 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1856 _test_img_src(line, unk, src);
1859 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1860 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1862 IHTMLImgElement *img = _get_img_iface(line, unk);
1866 hres = IHTMLImgElement_get_alt(img, &alt);
1867 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1869 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1871 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1875 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1876 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1878 IHTMLImgElement *img = _get_img_iface(line, unk);
1883 hres = IHTMLImgElement_put_alt(img, tmp);
1884 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1887 _test_img_alt(line, unk, alt);
1890 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1891 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1893 VARIANT_BOOL disabled = 100;
1896 hres = IHTMLInputElement_get_disabled(input, &disabled);
1897 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1898 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1900 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1903 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1904 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1908 hres = IHTMLInputElement_put_disabled(input, b);
1909 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1911 _test_input_get_disabled(line, input, b);
1914 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1915 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1917 VARIANT_BOOL checked = 100;
1920 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1921 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1922 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1925 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1926 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1930 hres = IHTMLInputElement_put_defaultChecked(input, b);
1931 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1933 _test_input_get_defaultchecked(line, input, b);
1936 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1937 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1939 VARIANT_BOOL checked = 100;
1942 hres = IHTMLInputElement_get_checked(input, &checked);
1943 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1944 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1947 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1948 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1952 hres = IHTMLInputElement_put_checked(input, b);
1953 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1955 _test_input_get_checked(line, input, b);
1958 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1959 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1961 IHTMLInputElement *input;
1965 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1966 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1970 hres = IHTMLInputElement_get_value(input, &bstr);
1971 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1973 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1975 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1976 SysFreeString(bstr);
1977 IHTMLInputElement_Release(input);
1980 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1981 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1983 IHTMLInputElement *input;
1987 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1988 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1993 hres = IHTMLInputElement_get_value(input, &bstr);
1994 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1995 SysFreeString(bstr);
1996 IHTMLInputElement_Release(input);
1999 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2000 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2005 hres = IHTMLInputElement_get_src(input, &src);
2006 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2008 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2010 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2014 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2015 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2021 hres = IHTMLInputElement_put_src(input, tmp);
2023 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2025 _test_input_src(line, input, src);
2028 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2029 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2031 IHTMLElement *elem = _get_elem_iface(line, unk);
2032 BSTR class = (void*)0xdeadbeef;
2035 hres = IHTMLElement_get_className(elem, &class);
2036 IHTMLElement_Release(elem);
2037 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2039 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2041 ok_(__FILE__,line) (!class, "class != NULL\n");
2042 SysFreeString(class);
2045 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2046 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2048 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2052 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2053 IHTMLElement2_Release(elem2);
2054 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2055 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2058 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2059 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2061 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2064 hres = IHTMLElement2_put_tabIndex(elem2, index);
2065 IHTMLElement2_Release(elem2);
2066 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2068 _test_elem_tabindex(line, unk, index);
2071 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2072 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2074 IHTMLElement *elem = _get_elem_iface(line, unk);
2078 tmp = class ? a2bstr(class) : NULL;
2079 hres = IHTMLElement_put_className(elem, tmp);
2080 IHTMLElement_Release(elem);
2081 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2084 _test_elem_class(line, unk, class);
2087 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2088 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2090 IHTMLElement *elem = _get_elem_iface(line, unk);
2091 BSTR id = (void*)0xdeadbeef;
2094 hres = IHTMLElement_get_id(elem, &id);
2095 IHTMLElement_Release(elem);
2096 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2099 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2101 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2106 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2107 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2109 IHTMLElement *elem = _get_elem_iface(line, unk);
2110 BSTR tmp = a2bstr(new_id);
2113 hres = IHTMLElement_put_id(elem, tmp);
2114 IHTMLElement_Release(elem);
2116 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2118 _test_elem_id(line, unk, new_id);
2121 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2122 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2124 IHTMLElement *elem = _get_elem_iface(line, unk);
2128 hres = IHTMLElement_get_title(elem, &title);
2129 IHTMLElement_Release(elem);
2130 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2132 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2134 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2136 SysFreeString(title);
2139 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2140 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2142 IHTMLElement *elem = _get_elem_iface(line, unk);
2146 tmp = a2bstr(title);
2147 hres = IHTMLElement_put_title(elem, tmp);
2148 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2150 IHTMLElement_Release(elem);
2154 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2155 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2157 IHTMLDOMNode *node = _get_node_iface(line, unk);
2161 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2162 IHTMLDOMNode_Release(node);
2163 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2166 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2167 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2169 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2175 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2176 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2178 IHTMLDOMNode *node = _get_node_iface(line, unk);
2182 V_VT(&var) = VT_BSTR;
2183 V_BSTR(&var) = a2bstr(val);
2185 hres = IHTMLDOMNode_put_nodeValue(node, var);
2186 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2187 IHTMLDOMNode_Release(node);
2191 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2192 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2194 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2198 hres = IHTMLElement2_get_clientWidth(elem, &l);
2199 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2200 hres = IHTMLElement2_get_clientHeight(elem, &l);
2201 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2203 IHTMLElement2_Release(elem);
2206 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2207 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2209 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2213 hres = IHTMLElement2_get_clientLeft(elem, &l);
2214 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2215 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2217 hres = IHTMLElement2_get_clientTop(elem, &l);
2218 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2219 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2221 IHTMLElement2_Release(elem);
2224 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2225 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2227 IHTMLElement *elem = _get_elem_iface(line, unk);
2228 IHTMLDocument2 *doc;
2233 hres = IHTMLElement_get_document(elem, &disp);
2234 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2235 ok(disp != NULL, "disp == NULL\n");
2237 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2238 IDispatch_Release(disp);
2239 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2244 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2245 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2247 IHTMLDocument2 *doc;
2251 hres = IHTMLWindow2_get_document(window, &doc);
2252 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2253 ok(doc != NULL, "disp == NULL\n");
2258 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2259 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2261 IHTMLElement *elem = NULL;
2266 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2267 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2268 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2273 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2274 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2276 IHTMLDocument3 *doc3;
2277 IHTMLDOMNode *node = NULL;
2281 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2282 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2285 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2286 IHTMLDocument3_Release(doc3);
2287 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2288 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2293 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2294 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2296 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2297 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2298 IHTMLDOMNode *new_child = NULL;
2301 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2302 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2303 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2304 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2306 IHTMLDOMNode_Release(node);
2307 IHTMLDOMNode_Release(child);
2312 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2313 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2315 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2316 IHTMLDOMNode *new_child = NULL;
2319 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2320 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2321 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2322 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2324 IHTMLDOMNode_Release(node);
2329 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2330 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2332 IHTMLDOMNode *node = _get_node_iface(line, unk);
2333 IHTMLDOMNode *new_node = NULL;
2336 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2337 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2338 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2339 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2341 IHTMLDOMNode_Release(node);
2342 IHTMLDOMNode_Release(new_node);
2345 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2346 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2351 hres = IHTMLDocument2_get_title(doc, &title);
2352 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2353 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2354 SysFreeString(title);
2357 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2358 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2363 tmp = a2bstr(title);
2364 hres = IHTMLDocument2_put_title(doc, tmp);
2365 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2369 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2370 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2375 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2376 LOCALE_USER_DEFAULT, &dispid);
2377 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2380 DISPPARAMS params = {NULL,NULL,0,0};
2381 DISPID dispidNamed = DISPID_PROPERTYPUT;
2386 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2387 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2388 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2391 params.cNamedArgs = 1;
2392 params.rgdispidNamedArgs = &dispidNamed;
2393 V_VT(&arg) = VT_BSTR;
2394 V_BSTR(&arg) = a2bstr("none");
2395 params.rgvarg = &arg;
2396 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2397 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2398 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2401 V_VT(&arg) = VT_BSTR;
2402 V_BSTR(&arg) = a2bstr("dotted");
2403 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2404 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2405 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2408 V_VT(&arg) = VT_BSTR;
2409 V_BSTR(&arg) = a2bstr("dashed");
2410 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2411 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2412 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2415 V_VT(&arg) = VT_BSTR;
2416 V_BSTR(&arg) = a2bstr("solid");
2417 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2418 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2419 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2422 V_VT(&arg) = VT_BSTR;
2423 V_BSTR(&arg) = a2bstr("double");
2424 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2425 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2426 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2429 V_VT(&arg) = VT_BSTR;
2430 V_BSTR(&arg) = a2bstr("groove");
2431 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2432 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2433 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2436 V_VT(&arg) = VT_BSTR;
2437 V_BSTR(&arg) = a2bstr("ridge");
2438 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2439 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2440 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2443 V_VT(&arg) = VT_BSTR;
2444 V_BSTR(&arg) = a2bstr("inset");
2445 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2446 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2447 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2450 V_VT(&arg) = VT_BSTR;
2451 V_BSTR(&arg) = a2bstr("outset");
2452 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2453 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2454 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2457 V_VT(&arg) = VT_BSTR;
2458 V_BSTR(&arg) = a2bstr("invalid");
2459 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2460 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2461 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2464 params.rgvarg = &vDefault;
2465 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2466 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2467 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2471 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2472 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2474 BSTR text = (void*)0xdeadbeef;
2477 hres = IHTMLStyle_get_cssText(style, &text);
2478 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2480 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2482 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2484 SysFreeString(text);
2487 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2488 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2494 hres = IHTMLStyle_put_cssText(style, tmp);
2495 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2499 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2500 const elem_type_t *elem_types, LONG len)
2503 VARIANT name, index;
2507 V_VT(&index) = VT_EMPTY;
2508 V_VT(&name) = VT_BSTR;
2509 V_BSTR(&name) = a2bstr(n);
2511 hres = IHTMLElementCollection_item(col, name, index, &disp);
2512 ok(hres == S_OK, "item failed: %08x\n", hres);
2514 test_elem_collection((IUnknown*)disp, elem_types, len);
2515 IDispatch_Release(disp);
2516 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2520 V_VT(&index) = VT_I4;
2522 for(i=0; i<len; i++) {
2524 disp = (void*)0xdeadbeef;
2525 hres = IHTMLElementCollection_item(col, name, index, &disp);
2526 ok(hres == S_OK, "item failed: %08x\n", hres);
2527 ok(disp != NULL, "disp == NULL\n");
2528 if(FAILED(hres) || !disp)
2531 test_elem_type((IUnknown*)disp, elem_types[i]);
2533 IDispatch_Release(disp);
2537 disp = (void*)0xdeadbeef;
2538 hres = IHTMLElementCollection_item(col, name, index, &disp);
2539 ok(hres == S_OK, "item failed: %08x\n", hres);
2540 ok(disp == NULL, "disp != NULL\n");
2543 disp = (void*)0xdeadbeef;
2544 hres = IHTMLElementCollection_item(col, name, index, &disp);
2545 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2546 ok(disp == NULL, "disp != NULL\n");
2549 SysFreeString(V_BSTR(&name));
2552 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2554 IHTMLElementCollection *col;
2556 IDispatch *disp = (void*)0xdeadbeef;
2557 VARIANT name, index;
2560 hres = IHTMLDocument2_get_all(doc, &col);
2561 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2562 ok(col != NULL, "col == NULL\n");
2563 if(FAILED(hres) || !col)
2566 V_VT(&index) = VT_EMPTY;
2567 V_VT(&name) = VT_BSTR;
2568 V_BSTR(&name) = a2bstr(id);
2570 hres = IHTMLElementCollection_item(col, name, index, &disp);
2571 IHTMLElementCollection_Release(col);
2572 SysFreeString(V_BSTR(&name));
2573 ok(hres == S_OK, "item failed: %08x\n", hres);
2574 if(!expect_success) {
2575 ok(disp == NULL, "disp != NULL\n");
2579 ok(disp != NULL, "disp == NULL\n");
2583 elem = get_elem_iface((IUnknown*)disp);
2584 IDispatch_Release(disp);
2589 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2591 IHTMLDocument3 *doc3;
2596 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2597 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2600 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2602 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2604 IHTMLDocument3_Release(doc3);
2609 static void test_select_elem(IHTMLSelectElement *select)
2611 test_select_type(select, "select-one");
2612 test_select_length(select, 2);
2613 test_select_selidx(select, 0);
2614 test_select_put_selidx(select, 1);
2616 test_select_set_value(select, "val1");
2617 test_select_value(select, "val1");
2619 test_select_get_disabled(select, VARIANT_FALSE);
2620 test_select_set_disabled(select, VARIANT_TRUE);
2621 test_select_set_disabled(select, VARIANT_FALSE);
2624 static void test_create_option_elem(IHTMLDocument2 *doc)
2626 IHTMLOptionElement *option;
2628 option = create_option_elem(doc, "test text", "test value");
2630 test_option_put_text(option, "new text");
2631 test_option_put_value(option, "new value");
2633 IHTMLOptionElement_Release(option);
2636 static void test_create_img_elem(IHTMLDocument2 *doc)
2638 IHTMLImgElement *img;
2640 img = create_img_elem(doc, 10, 15);
2643 test_img_put_width(img, 5);
2644 test_img_put_height(img, 20);
2646 IHTMLImgElement_Release(img);
2650 img = create_img_elem(doc, -1, -1);
2653 test_img_put_width(img, 5);
2654 test_img_put_height(img, 20);
2656 IHTMLImgElement_Release(img);
2660 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2662 IHTMLBodyElement *body;
2663 IHTMLTxtRange *range;
2667 hres = IHTMLDocument2_get_body(doc, &elem);
2668 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2670 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2671 IHTMLElement_Release(elem);
2673 hres = IHTMLBodyElement_createTextRange(body, &range);
2674 IHTMLBodyElement_Release(body);
2675 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2680 static void test_txtrange(IHTMLDocument2 *doc)
2682 IHTMLTxtRange *body_range, *range, *range2;
2683 IHTMLSelectionObject *selection;
2684 IDispatch *disp_range;
2687 body_range = test_create_body_range(doc);
2689 test_range_text(body_range, "test abc 123\r\nit's text");
2691 hres = IHTMLTxtRange_duplicate(body_range, &range);
2692 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2694 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2695 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2696 test_range_isequal(range, range2, VARIANT_TRUE);
2698 test_range_text(range, "test abc 123\r\nit's text");
2699 test_range_text(body_range, "test abc 123\r\nit's text");
2701 test_range_collapse(range, TRUE);
2702 test_range_isequal(range, range2, VARIANT_FALSE);
2703 test_range_inrange(range, range2, VARIANT_FALSE);
2704 test_range_inrange(range2, range, VARIANT_TRUE);
2705 IHTMLTxtRange_Release(range2);
2707 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2708 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2709 test_range_move(range, characterW, 2, 2);
2710 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2712 test_range_collapse(range, FALSE);
2713 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2715 test_range_collapse(range, FALSE);
2716 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2717 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2718 test_range_move(range, characterW, 2, 2);
2719 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2720 test_range_moveend(range, characterW, -5, -5);
2721 test_range_text(range, NULL);
2722 test_range_moveend(range, characterW, 3, 3);
2723 test_range_text(range, "c 1");
2724 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2725 test_range_collapse(range, TRUE);
2726 test_range_move(range, characterW, 4, 4);
2727 test_range_moveend(range, characterW, 1, 1);
2728 test_range_text(range, " ");
2729 test_range_move(range, wordW, 1, 1);
2730 test_range_moveend(range, characterW, 2, 2);
2731 test_range_text(range, "ab");
2733 IHTMLTxtRange_Release(range);
2735 hres = IHTMLTxtRange_duplicate(body_range, &range);
2736 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2738 test_range_text(range, "test abc 123\r\nit's text");
2739 test_range_move(range, characterW, 3, 3);
2740 test_range_moveend(range, characterW, 1, 1);
2741 test_range_text(range, "t");
2742 test_range_moveend(range, characterW, 3, 3);
2743 test_range_text(range, "t ab");
2744 test_range_moveend(range, characterW, -2, -2);
2745 test_range_text(range, "t ");
2746 test_range_move(range, characterW, 6, 6);
2747 test_range_moveend(range, characterW, 3, 3);
2748 test_range_text(range, "123");
2749 test_range_moveend(range, characterW, 2, 2);
2750 test_range_text(range, "123\r\ni");
2752 IHTMLTxtRange_Release(range);
2754 hres = IHTMLTxtRange_duplicate(body_range, &range);
2755 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2757 test_range_move(range, wordW, 1, 1);
2758 test_range_moveend(range, characterW, 2, 2);
2759 test_range_text(range, "ab");
2761 test_range_move(range, characterW, -2, -2);
2762 test_range_moveend(range, characterW, 2, 2);
2763 test_range_text(range, "t ");
2765 test_range_move(range, wordW, 3, 3);
2766 test_range_move(range, wordW, -2, -2);
2767 test_range_moveend(range, characterW, 2, 2);
2768 test_range_text(range, "ab");
2770 test_range_move(range, characterW, -6, -5);
2771 test_range_moveend(range, characterW, -1, 0);
2772 test_range_moveend(range, characterW, -6, 0);
2773 test_range_move(range, characterW, 2, 2);
2774 test_range_moveend(range, characterW, 2, 2);
2775 test_range_text(range, "st");
2776 test_range_moveend(range, characterW, -6, -4);
2777 test_range_moveend(range, characterW, 2, 2);
2779 IHTMLTxtRange_Release(range);
2781 hres = IHTMLTxtRange_duplicate(body_range, &range);
2782 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2784 test_range_move(range, wordW, 2, 2);
2785 test_range_moveend(range, characterW, 2, 2);
2786 test_range_text(range, "12");
2788 test_range_move(range, characterW, 15, 14);
2789 test_range_move(range, characterW, -2, -2);
2790 test_range_moveend(range, characterW, 3, 2);
2791 test_range_text(range, "t");
2792 test_range_moveend(range, characterW, -1, -1);
2793 test_range_text(range, "t");
2794 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2795 test_range_move(range, characterW, -2, -2);
2796 test_range_moveend(range, characterW, 2, 2);
2797 test_range_text(range, "s ");
2798 test_range_move(range, characterW, 100, 7);
2799 test_range_move(range, wordW, 1, 0);
2800 test_range_move(range, characterW, -2, -2);
2801 test_range_moveend(range, characterW, 3, 2);
2802 test_range_text(range, "t");
2804 IHTMLTxtRange_Release(range);
2806 hres = IHTMLTxtRange_duplicate(body_range, &range);
2807 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2809 test_range_collapse(range, TRUE);
2810 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2811 test_range_put_text(range, "word");
2812 test_range_text(body_range, "wordabc 123\r\nit's text");
2813 test_range_text(range, NULL);
2814 test_range_moveend(range, characterW, 3, 3);
2815 test_range_text(range, "abc");
2816 test_range_movestart(range, characterW, -2, -2);
2817 test_range_text(range, "rdabc");
2818 test_range_movestart(range, characterW, 3, 3);
2819 test_range_text(range, "bc");
2820 test_range_movestart(range, characterW, 4, 4);
2821 test_range_text(range, NULL);
2822 test_range_movestart(range, characterW, -3, -3);
2823 test_range_text(range, "c 1");
2824 test_range_movestart(range, characterW, -7, -6);
2825 test_range_text(range, "wordabc 1");
2826 test_range_movestart(range, characterW, 100, 22);
2827 test_range_text(range, NULL);
2829 IHTMLTxtRange_Release(range);
2830 IHTMLTxtRange_Release(body_range);
2832 hres = IHTMLDocument2_get_selection(doc, &selection);
2833 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2835 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2836 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2837 IHTMLSelectionObject_Release(selection);
2839 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2840 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2841 IDispatch_Release(disp_range);
2843 test_range_text(range, NULL);
2844 test_range_moveend(range, characterW, 3, 3);
2845 test_range_text(range, "wor");
2846 test_range_parent(range, ET_BODY);
2847 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2848 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2849 test_range_move(range, characterW, 3, 3);
2850 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2851 test_range_moveend(range, characterW, -4, -4);
2852 test_range_put_text(range, "abc def ");
2853 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2854 test_range_move(range, wordW, 1, 1);
2855 test_range_movestart(range, characterW, -1, -1);
2856 test_range_text(range, " ");
2857 test_range_move(range, wordW, 1, 1);
2858 test_range_moveend(range, characterW, 3, 3);
2859 test_range_text(range, "def");
2860 test_range_put_text(range, "xyz");
2861 test_range_moveend(range, characterW, 1, 1);
2862 test_range_move(range, wordW, 1, 1);
2863 test_range_moveend(range, characterW, 2, 2);
2864 test_range_text(range, "ab");
2866 IHTMLTxtRange_Release(range);
2869 static void test_txtrange2(IHTMLDocument2 *doc)
2871 IHTMLTxtRange *range;
2873 range = test_create_body_range(doc);
2875 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2876 test_range_move(range, characterW, 5, 5);
2877 test_range_moveend(range, characterW, 1, 1);
2878 test_range_text(range, "2");
2879 test_range_move(range, characterW, -3, -3);
2880 test_range_moveend(range, characterW, 3, 3);
2881 test_range_text(range, "c\r\n\r\n1");
2882 test_range_collapse(range, VARIANT_FALSE);
2883 test_range_moveend(range, characterW, 4, 4);
2884 test_range_text(range, "23");
2885 test_range_moveend(range, characterW, 1, 1);
2886 test_range_text(range, "23\r\n\r\n\r\nd");
2887 test_range_moveend(range, characterW, -1, -1);
2888 test_range_text(range, "23");
2889 test_range_moveend(range, characterW, -1, -1);
2890 test_range_text(range, "23");
2891 test_range_moveend(range, characterW, -2, -2);
2892 test_range_text(range, "2");
2894 IHTMLTxtRange_Release(range);
2897 static void test_compatmode(IHTMLDocument2 *doc)
2899 IHTMLDocument5 *doc5;
2903 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2904 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2908 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2909 IHTMLDocument5_Release(doc5);
2910 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2911 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2912 SysFreeString(mode);
2915 static void test_location(IHTMLDocument2 *doc)
2917 IHTMLLocation *location, *location2;
2918 IHTMLWindow2 *window;
2923 hres = IHTMLDocument2_get_location(doc, &location);
2924 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2926 hres = IHTMLDocument2_get_location(doc, &location2);
2927 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2929 ok(location == location2, "location != location2\n");
2930 IHTMLLocation_Release(location2);
2932 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2933 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2935 hres = IHTMLWindow2_get_location(window, &location2);
2936 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2937 ok(location == location2, "location != location2\n");
2938 IHTMLLocation_Release(location2);
2940 test_ifaces((IUnknown*)location, location_iids);
2941 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2943 hres = IHTMLLocation_get_pathname(location, &str);
2944 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2945 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2947 hres = IHTMLLocation_get_href(location, NULL);
2948 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2950 hres = IHTMLLocation_get_href(location, &str);
2951 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2952 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2954 ref = IHTMLLocation_Release(location);
2955 ok(!ref, "location chould be destroyed here\n");
2958 static void test_navigator(IHTMLDocument2 *doc)
2960 IHTMLWindow2 *window;
2961 IOmNavigator *navigator, *navigator2;
2968 static const WCHAR v40[] = {'4','.','0'};
2970 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2971 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2973 hres = IHTMLWindow2_get_navigator(window, &navigator);
2974 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2975 ok(navigator != NULL, "navigator == NULL\n");
2976 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2978 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2979 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2980 ok(navigator != navigator2, "navigator2 != navihgator\n");
2982 IHTMLWindow2_Release(window);
2983 IOmNavigator_Release(navigator2);
2985 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2986 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2987 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2988 SysFreeString(bstr);
2991 hres = IOmNavigator_get_appName(navigator, &bstr);
2992 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2993 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2994 SysFreeString(bstr);
2997 hres = IOmNavigator_get_platform(navigator, &bstr);
2998 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3000 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3002 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3004 SysFreeString(bstr);
3007 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3008 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3009 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3010 SysFreeString(bstr);
3012 hres = IOmNavigator_toString(navigator, NULL);
3013 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3016 hres = IOmNavigator_toString(navigator, &bstr);
3017 ok(hres == S_OK, "toString failed: %08x\n", hres);
3018 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3019 SysFreeString(bstr);
3022 hres = ObtainUserAgentString(0, buf, &size);
3023 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3026 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3027 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3028 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3029 SysFreeString(bstr);
3031 ref = IOmNavigator_Release(navigator);
3032 ok(!ref, "navigator should be destroyed here\n");
3035 static void test_current_style(IHTMLCurrentStyle *current_style)
3041 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3042 test_ifaces((IUnknown*)current_style, cstyle_iids);
3044 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3045 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3046 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3049 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3050 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3051 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3054 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3055 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3058 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3059 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3060 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3063 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3064 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3065 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3068 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3069 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3070 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3073 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3074 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3075 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3078 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3079 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3080 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3083 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3084 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3085 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3088 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3089 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3090 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3093 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3094 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3095 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3098 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3099 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3100 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3103 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3104 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3105 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3108 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3109 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3110 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3113 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3114 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3117 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3118 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3121 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3122 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3125 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3126 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3129 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3130 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3133 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3134 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3137 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3138 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3139 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3140 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3143 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3144 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3145 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3148 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3149 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3150 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3153 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3154 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3155 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3158 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3159 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3160 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3163 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3164 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3165 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3168 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3169 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3170 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3173 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3174 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3175 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3176 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3179 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3180 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3181 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3182 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3185 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3186 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3187 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3190 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3191 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3192 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3195 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3196 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3197 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3201 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3202 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3203 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3206 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3207 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3208 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3211 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3212 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3213 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3216 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3217 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3218 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3221 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3222 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3223 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3226 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3227 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3228 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3231 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3232 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3233 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3236 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3237 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3238 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3241 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3242 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3243 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3246 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3247 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3248 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3251 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3252 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3253 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3256 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3257 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3258 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3261 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3262 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3263 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3266 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3267 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3268 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3271 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3272 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3273 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3276 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3277 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3278 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3281 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3282 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3283 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3286 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3287 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3288 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3291 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3292 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3293 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3297 static void test_style2(IHTMLStyle2 *style2)
3302 str = (void*)0xdeadbeef;
3303 hres = IHTMLStyle2_get_position(style2, &str);
3304 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3305 ok(!str, "str != NULL\n");
3307 str = a2bstr("absolute");
3308 hres = IHTMLStyle2_put_position(style2, str);
3309 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3313 hres = IHTMLStyle2_get_position(style2, &str);
3314 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3315 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3319 static void test_style3(IHTMLStyle3 *style3)
3324 str = (void*)0xdeadbeef;
3325 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3326 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3327 ok(!str, "str != NULL\n");
3329 str = a2bstr("break-word");
3330 hres = IHTMLStyle3_put_wordWrap(style3, str);
3331 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3335 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3336 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3337 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3341 static void test_style4(IHTMLStyle4 *style4)
3347 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3348 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3351 V_BSTR(&v) = a2bstr("10px");
3352 hres = IHTMLStyle4_put_minHeight(style4, v);
3353 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3356 hres = IHTMLStyle4_get_minHeight(style4, &v);
3357 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3358 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3359 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3361 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3362 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3363 VariantClear(&vdefault);
3366 static void test_default_style(IHTMLStyle *style)
3368 IHTMLStyle2 *style2;
3369 IHTMLStyle3 *style3;
3370 IHTMLStyle4 *style4;
3376 BSTR sOverflowDefault;
3380 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3381 test_ifaces((IUnknown*)style, style_iids);
3383 test_style_csstext(style, NULL);
3385 hres = IHTMLStyle_get_position(style, &str);
3386 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3387 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3390 hres = IHTMLStyle_get_marginRight(style, &v);
3391 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3392 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3393 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3396 hres = IHTMLStyle_get_marginLeft(style, &v);
3397 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3398 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3399 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3401 str = (void*)0xdeadbeef;
3402 hres = IHTMLStyle_get_fontFamily(style, &str);
3403 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3404 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3406 str = (void*)0xdeadbeef;
3407 hres = IHTMLStyle_get_fontWeight(style, &str);
3408 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3409 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3411 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3412 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3414 str = a2bstr("test");
3415 hres = IHTMLStyle_put_fontWeight(style, str);
3416 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3419 str = a2bstr("bold");
3420 hres = IHTMLStyle_put_fontWeight(style, str);
3421 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3424 str = a2bstr("bolder");
3425 hres = IHTMLStyle_put_fontWeight(style, str);
3426 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3429 str = a2bstr("lighter");
3430 hres = IHTMLStyle_put_fontWeight(style, str);
3431 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3434 str = a2bstr("100");
3435 hres = IHTMLStyle_put_fontWeight(style, str);
3436 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3439 str = a2bstr("200");
3440 hres = IHTMLStyle_put_fontWeight(style, str);
3441 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3444 str = a2bstr("300");
3445 hres = IHTMLStyle_put_fontWeight(style, str);
3446 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3449 str = a2bstr("400");
3450 hres = IHTMLStyle_put_fontWeight(style, str);
3451 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3454 str = a2bstr("500");
3455 hres = IHTMLStyle_put_fontWeight(style, str);
3456 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3459 str = a2bstr("600");
3460 hres = IHTMLStyle_put_fontWeight(style, str);
3461 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3464 str = a2bstr("700");
3465 hres = IHTMLStyle_put_fontWeight(style, str);
3466 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3469 str = a2bstr("800");
3470 hres = IHTMLStyle_put_fontWeight(style, str);
3471 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3474 str = a2bstr("900");
3475 hres = IHTMLStyle_put_fontWeight(style, str);
3476 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3479 hres = IHTMLStyle_get_fontWeight(style, &str);
3480 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3481 ok(!strcmp_wa(str, "900"), "str != style900\n");
3484 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3485 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3486 SysFreeString(sDefault);
3489 hres = IHTMLStyle_get_fontVariant(style, NULL);
3490 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3492 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3493 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3495 str = a2bstr("test");
3496 hres = IHTMLStyle_put_fontVariant(style, str);
3497 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3500 str = a2bstr("small-caps");
3501 hres = IHTMLStyle_put_fontVariant(style, str);
3502 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3505 str = a2bstr("normal");
3506 hres = IHTMLStyle_put_fontVariant(style, str);
3507 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3510 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3511 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3512 SysFreeString(sDefault);
3514 str = (void*)0xdeadbeef;
3515 hres = IHTMLStyle_get_display(style, &str);
3516 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3517 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3519 str = (void*)0xdeadbeef;
3520 hres = IHTMLStyle_get_visibility(style, &str);
3521 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3522 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3525 hres = IHTMLStyle_get_fontSize(style, &v);
3526 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3527 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3528 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3531 hres = IHTMLStyle_get_color(style, &v);
3532 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3533 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3534 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3537 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3538 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3539 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3541 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3542 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3543 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3545 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3546 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3547 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3549 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3550 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3553 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3554 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3555 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3557 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3558 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3559 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3561 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3562 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3563 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3565 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3566 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3569 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3570 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3571 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3573 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3574 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3575 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3577 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3578 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3579 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3581 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3582 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3585 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3586 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3587 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3589 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3590 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3591 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3593 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3594 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3595 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3597 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3598 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3601 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3602 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3603 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3605 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3606 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3607 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3609 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3610 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3611 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3613 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3614 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3616 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3617 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3619 str = a2bstr("invalid");
3620 hres = IHTMLStyle_put_textDecoration(style, str);
3621 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3624 str = a2bstr("none");
3625 hres = IHTMLStyle_put_textDecoration(style, str);
3626 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3629 str = a2bstr("underline");
3630 hres = IHTMLStyle_put_textDecoration(style, str);
3631 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3634 str = a2bstr("overline");
3635 hres = IHTMLStyle_put_textDecoration(style, str);
3636 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3639 str = a2bstr("line-through");
3640 hres = IHTMLStyle_put_textDecoration(style, str);
3641 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3644 str = a2bstr("blink");
3645 hres = IHTMLStyle_put_textDecoration(style, str);
3646 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3649 hres = IHTMLStyle_get_textDecoration(style, &str);
3650 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3651 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3654 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3655 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3656 SysFreeString(sDefault);
3658 hres = IHTMLStyle_get_posWidth(style, NULL);
3659 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3661 hres = IHTMLStyle_get_posWidth(style, &f);
3662 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3663 ok(f == 0.0f, "f = %f\n", f);
3665 V_VT(&v) = VT_EMPTY;
3666 hres = IHTMLStyle_get_width(style, &v);
3667 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3668 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3669 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3671 hres = IHTMLStyle_put_posWidth(style, 2.2);
3672 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3674 hres = IHTMLStyle_get_posWidth(style, &f);
3675 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3677 f == 2.2f, /* IE8 */
3681 V_BSTR(&v) = a2bstr("auto");
3682 hres = IHTMLStyle_put_width(style, v);
3683 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3686 V_VT(&v) = VT_EMPTY;
3687 hres = IHTMLStyle_get_width(style, &v);
3688 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3689 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3690 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3694 str = (void*)0xdeadbeef;
3695 hres = IHTMLStyle_get_margin(style, &str);
3696 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3697 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3700 hres = IHTMLStyle_put_margin(style, str);
3701 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3704 hres = IHTMLStyle_get_margin(style, &str);
3705 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3706 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3708 hres = IHTMLStyle_put_margin(style, NULL);
3709 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3712 hres = IHTMLStyle_get_border(style, &str);
3713 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3714 ok(!str || !*str, "str is not empty\n");
3717 str = a2bstr("1px");
3718 hres = IHTMLStyle_put_border(style, str);
3719 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3722 V_VT(&v) = VT_EMPTY;
3723 hres = IHTMLStyle_get_left(style, &v);
3724 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3725 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3726 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3730 hres = IHTMLStyle_get_posLeft(style, NULL);
3731 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3734 hres = IHTMLStyle_get_posLeft(style, &f);
3735 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3736 ok(f == 0.0, "expected 0.0 got %f\n", f);
3738 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3739 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3741 hres = IHTMLStyle_get_posLeft(style, &f);
3742 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3744 f == 4.9f, /* IE8 */
3745 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3747 /* Ensure left is updated correctly. */
3748 V_VT(&v) = VT_EMPTY;
3749 hres = IHTMLStyle_get_left(style, &v);
3750 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3751 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3752 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3753 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3754 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3759 V_BSTR(&v) = a2bstr("3px");
3760 hres = IHTMLStyle_put_left(style, v);
3761 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3764 hres = IHTMLStyle_get_posLeft(style, &f);
3765 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3766 ok(f == 3.0, "expected 3.0 got %f\n", f);
3768 V_VT(&v) = VT_EMPTY;
3769 hres = IHTMLStyle_get_left(style, &v);
3770 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3771 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3772 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3776 hres = IHTMLStyle_put_left(style, v);
3777 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3779 V_VT(&v) = VT_EMPTY;
3780 hres = IHTMLStyle_get_left(style, &v);
3781 ok(hres == S_OK, "get_left 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 V_VT(&v) = VT_EMPTY;
3787 hres = IHTMLStyle_get_top(style, &v);
3788 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3789 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3790 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3794 hres = IHTMLStyle_get_posTop(style, NULL);
3795 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3798 hres = IHTMLStyle_get_posTop(style, &f);
3799 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3800 ok(f == 0.0, "expected 0.0 got %f\n", f);
3802 hres = IHTMLStyle_put_posTop(style, 4.9f);
3803 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3805 hres = IHTMLStyle_get_posTop(style, &f);
3806 ok(hres == S_OK, "get_posTop 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("3px");
3813 hres = IHTMLStyle_put_top(style, v);
3814 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3817 V_VT(&v) = VT_EMPTY;
3818 hres = IHTMLStyle_get_top(style, &v);
3819 ok(hres == S_OK, "get_top 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), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3824 hres = IHTMLStyle_get_posTop(style, &f);
3825 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3826 ok(f == 3.0, "expected 3.0 got %f\n", f);
3829 hres = IHTMLStyle_put_top(style, v);
3830 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3832 V_VT(&v) = VT_EMPTY;
3833 hres = IHTMLStyle_get_top(style, &v);
3834 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3835 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3836 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3839 /* Test posHeight */
3840 hres = IHTMLStyle_get_posHeight(style, NULL);
3841 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3843 V_VT(&v) = VT_EMPTY;
3844 hres = IHTMLStyle_get_height(style, &v);
3845 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3846 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3847 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3851 hres = IHTMLStyle_get_posHeight(style, &f);
3852 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3853 ok(f == 0.0, "expected 0.0 got %f\n", f);
3855 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3856 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3858 hres = IHTMLStyle_get_posHeight(style, &f);
3859 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3861 f == 4.9f, /* IE8 */
3862 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3865 V_BSTR(&v) = a2bstr("64px");
3866 hres = IHTMLStyle_put_height(style, v);
3867 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3870 V_VT(&v) = VT_EMPTY;
3871 hres = IHTMLStyle_get_height(style, &v);
3872 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3873 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3874 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3877 hres = IHTMLStyle_get_posHeight(style, &f);
3878 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3879 ok(f == 64.0, "expected 64.0 got %f\n", f);
3881 str = (void*)0xdeadbeef;
3882 hres = IHTMLStyle_get_cursor(style, &str);
3883 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3884 ok(!str, "get_cursor != NULL\n");
3887 str = a2bstr("default");
3888 hres = IHTMLStyle_put_cursor(style, str);
3889 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3893 hres = IHTMLStyle_get_cursor(style, &str);
3894 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3895 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3898 V_VT(&v) = VT_EMPTY;
3899 hres = IHTMLStyle_get_verticalAlign(style, &v);
3900 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3901 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3902 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3906 V_BSTR(&v) = a2bstr("middle");
3907 hres = IHTMLStyle_put_verticalAlign(style, v);
3908 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3911 V_VT(&v) = VT_EMPTY;
3912 hres = IHTMLStyle_get_verticalAlign(style, &v);
3913 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3914 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3915 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3918 str = (void*)0xdeadbeef;
3919 hres = IHTMLStyle_get_textAlign(style, &str);
3920 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3921 ok(!str, "textAlign != NULL\n");
3923 str = a2bstr("center");
3924 hres = IHTMLStyle_put_textAlign(style, str);
3925 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3929 hres = IHTMLStyle_get_textAlign(style, &str);
3930 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3931 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3934 str = (void*)0xdeadbeef;
3935 hres = IHTMLStyle_get_filter(style, &str);
3936 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3937 ok(!str, "filter != NULL\n");
3939 str = a2bstr("alpha(opacity=100)");
3940 hres = IHTMLStyle_put_filter(style, str);
3941 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3944 V_VT(&v) = VT_EMPTY;
3945 hres = IHTMLStyle_get_zIndex(style, &v);
3946 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3947 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3948 ok(!V_I4(&v), "V_I4(v) != 0\n");
3952 V_BSTR(&v) = a2bstr("1");
3953 hres = IHTMLStyle_put_zIndex(style, v);
3954 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3957 V_VT(&v) = VT_EMPTY;
3958 hres = IHTMLStyle_get_zIndex(style, &v);
3959 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3960 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3961 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3965 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3966 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3968 str = a2bstr("test");
3969 hres = IHTMLStyle_put_fontStyle(style, str);
3970 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3973 str = a2bstr("italic");
3974 hres = IHTMLStyle_put_fontStyle(style, str);
3975 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3978 str = a2bstr("oblique");
3979 hres = IHTMLStyle_put_fontStyle(style, str);
3980 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3983 str = a2bstr("normal");
3984 hres = IHTMLStyle_put_fontStyle(style, str);
3985 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3988 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3989 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3990 SysFreeString(sDefault);
3993 hres = IHTMLStyle_get_overflow(style, NULL);
3994 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3996 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3997 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3999 str = a2bstr("test");
4000 hres = IHTMLStyle_put_overflow(style, str);
4001 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4004 str = a2bstr("visible");
4005 hres = IHTMLStyle_put_overflow(style, str);
4006 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4009 str = a2bstr("scroll");
4010 hres = IHTMLStyle_put_overflow(style, str);
4011 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4014 str = a2bstr("hidden");
4015 hres = IHTMLStyle_put_overflow(style, str);
4016 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4019 str = a2bstr("auto");
4020 hres = IHTMLStyle_put_overflow(style, str);
4021 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4024 hres = IHTMLStyle_get_overflow(style, &str);
4025 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4026 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4030 hres = IHTMLStyle_put_overflow(style, str);
4031 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4034 hres = IHTMLStyle_get_overflow(style, &str);
4035 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4036 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4039 /* restore overflow default */
4040 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4041 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4042 SysFreeString(sOverflowDefault);
4044 /* Attribute Tests*/
4045 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4046 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4048 str = a2bstr("position");
4049 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4050 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4052 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4053 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4054 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4057 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4058 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4061 V_BSTR(&v) = a2bstr("absolute");
4062 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4063 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4066 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4067 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4068 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4069 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4074 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4075 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4080 str = a2bstr("borderLeftStyle");
4081 test_border_styles(style, str);
4084 str = a2bstr("borderbottomstyle");
4085 test_border_styles(style, str);
4088 str = a2bstr("borderrightstyle");
4089 test_border_styles(style, str);
4092 str = a2bstr("bordertopstyle");
4093 test_border_styles(style, str);
4096 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4097 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4099 str = a2bstr("none dotted dashed solid");
4100 hres = IHTMLStyle_put_borderStyle(style, str);
4101 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4104 str = a2bstr("none dotted dashed solid");
4105 hres = IHTMLStyle_get_borderStyle(style, &str);
4106 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4107 ok(!strcmp_wa(str, "none dotted dashed solid"),
4108 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4111 str = a2bstr("double groove ridge inset");
4112 hres = IHTMLStyle_put_borderStyle(style, str);
4113 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4116 str = a2bstr("window-inset outset ridge inset");
4117 hres = IHTMLStyle_put_borderStyle(style, str);
4118 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4121 str = a2bstr("window-inset");
4122 hres = IHTMLStyle_put_borderStyle(style, str);
4123 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4126 str = a2bstr("none none none none none");
4127 hres = IHTMLStyle_put_borderStyle(style, str);
4128 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4131 str = a2bstr("invalid none none none");
4132 hres = IHTMLStyle_put_borderStyle(style, str);
4133 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4136 str = a2bstr("none invalid none none");
4137 hres = IHTMLStyle_put_borderStyle(style, str);
4138 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4141 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4142 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4143 SysFreeString(sDefault);
4145 /* backgoundColor */
4146 hres = IHTMLStyle_get_backgroundColor(style, &v);
4147 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4148 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4149 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4153 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4154 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4157 V_BSTR(&v) = a2bstr("10");
4158 hres = IHTMLStyle_put_paddingLeft(style, v);
4159 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4162 hres = IHTMLStyle_get_paddingLeft(style, &v);
4163 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4164 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4166 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4167 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4169 /* BackgroundRepeat */
4170 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4171 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4173 str = a2bstr("invalid");
4174 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4175 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4178 str = a2bstr("repeat");
4179 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4180 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4183 str = a2bstr("no-repeat");
4184 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4185 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4188 str = a2bstr("repeat-x");
4189 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4190 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4193 str = a2bstr("repeat-y");
4194 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4195 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4198 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4199 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4200 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4203 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4204 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4205 SysFreeString(sDefault);
4208 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4209 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4211 str = a2bstr("red green red blue");
4212 hres = IHTMLStyle_put_borderColor(style, str);
4213 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4216 hres = IHTMLStyle_get_borderColor(style, &str);
4217 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4218 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4221 hres = IHTMLStyle_put_borderColor(style, sDefault);
4222 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4223 SysFreeString(sDefault);
4226 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4227 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4229 str = a2bstr("thick dotted red");
4230 hres = IHTMLStyle_put_borderLeft(style, str);
4231 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4234 /* IHTMLStyle_get_borderLeft appears to have a bug where
4235 it returns the first letter of the color. So we check
4236 each style individually.
4239 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4240 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4241 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4245 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4246 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4247 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4250 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4251 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4252 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4255 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4256 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4257 SysFreeString(sDefault);
4259 /* backgroundPositionX */
4260 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4261 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4264 V_BSTR(&v) = a2bstr("10px");
4265 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4266 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4269 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4270 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4271 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4274 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4275 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4276 VariantClear(&vDefault);
4278 /* backgroundPositionY */
4279 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4280 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4283 V_BSTR(&v) = a2bstr("10px");
4284 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4285 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4288 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4289 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4290 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4293 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4294 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4295 VariantClear(&vDefault);
4297 /* borderTopWidth */
4298 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4299 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4302 V_BSTR(&v) = a2bstr("10px");
4303 hres = IHTMLStyle_put_borderTopWidth(style, v);
4304 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4307 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4308 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4309 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4312 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4313 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4314 VariantClear(&vDefault);
4316 /* borderRightWidth */
4317 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4318 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4321 V_BSTR(&v) = a2bstr("10");
4322 hres = IHTMLStyle_put_borderRightWidth(style, v);
4323 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4326 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4327 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4328 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4331 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4332 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4333 VariantClear(&vDefault);
4335 /* borderBottomWidth */
4336 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4337 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4340 V_BSTR(&v) = a2bstr("10");
4341 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4342 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4345 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4346 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4347 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4350 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4351 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4352 VariantClear(&vDefault);
4354 /* borderLeftWidth */
4355 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4356 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4359 V_BSTR(&v) = a2bstr("10");
4360 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4361 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4364 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4365 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4366 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4369 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4370 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4371 VariantClear(&vDefault);
4374 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4375 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4378 V_BSTR(&v) = a2bstr("10");
4379 hres = IHTMLStyle_put_wordSpacing(style, v);
4380 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4383 hres = IHTMLStyle_get_wordSpacing(style, &v);
4384 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4385 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4386 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4389 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4390 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4391 VariantClear(&vDefault);
4394 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4395 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4398 V_BSTR(&v) = a2bstr("11");
4399 hres = IHTMLStyle_put_letterSpacing(style, v);
4400 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4403 hres = IHTMLStyle_get_letterSpacing(style, &v);
4404 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4405 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4406 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4409 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4410 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4411 VariantClear(&vDefault);
4413 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4414 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4415 if(SUCCEEDED(hres)) {
4416 test_style2(style2);
4417 IHTMLStyle2_Release(style2);
4420 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4421 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4422 if(SUCCEEDED(hres)) {
4423 test_style3(style3);
4424 IHTMLStyle3_Release(style3);
4427 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4428 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4429 if(SUCCEEDED(hres)) {
4430 test_style4(style4);
4431 IHTMLStyle4_Release(style4);
4435 static void test_set_csstext(IHTMLStyle *style)
4440 test_style_set_csstext(style, "background-color: black;");
4442 hres = IHTMLStyle_get_backgroundColor(style, &v);
4443 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4444 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4445 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4449 static void test_default_selection(IHTMLDocument2 *doc)
4451 IHTMLSelectionObject *selection;
4452 IHTMLTxtRange *range;
4457 hres = IHTMLDocument2_get_selection(doc, &selection);
4458 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4460 hres = IHTMLSelectionObject_get_type(selection, &str);
4461 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4462 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4465 hres = IHTMLSelectionObject_createRange(selection, &disp);
4466 IHTMLSelectionObject_Release(selection);
4467 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4469 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4470 IDispatch_Release(disp);
4471 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4473 test_range_text(range, NULL);
4474 IHTMLTxtRange_Release(range);
4477 static void test_doc_elem(IHTMLDocument2 *doc)
4479 IHTMLDocument2 *doc_node, *owner_doc;
4481 IHTMLDocument3 *doc3;
4484 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4485 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4487 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4488 IHTMLDocument3_Release(doc3);
4489 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4491 test_node_name((IUnknown*)elem, "HTML");
4492 test_elem_tag((IUnknown*)elem, "HTML");
4494 doc_node = get_doc_node(doc);
4495 owner_doc = get_owner_doc((IUnknown*)elem);
4496 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4497 IHTMLDocument2_Release(owner_doc);
4499 owner_doc = get_owner_doc((IUnknown*)doc_node);
4500 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4501 IHTMLDocument2_Release(doc_node);
4503 test_elem_client_rect((IUnknown*)elem);
4505 IHTMLElement_Release(elem);
4508 static void test_default_body(IHTMLBodyElement *body)
4514 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4515 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4517 bstr = (void*)0xdeadbeef;
4518 hres = IHTMLBodyElement_get_background(body, &bstr);
4519 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4520 ok(bstr == NULL, "bstr != NULL\n");
4522 l = elem_get_scroll_height((IUnknown*)body);
4523 ok(l != -1, "scrollHeight == -1\n");
4524 l = elem_get_scroll_width((IUnknown*)body);
4525 ok(l != -1, "scrollWidth == -1\n");
4526 l = elem_get_scroll_top((IUnknown*)body);
4527 ok(!l, "scrollTop = %d\n", l);
4528 elem_get_scroll_left((IUnknown*)body);
4530 /* get_text tests */
4531 hres = IHTMLBodyElement_get_text(body, &v);
4532 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4533 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4534 ok(bstr == NULL, "bstr != NULL\n");
4537 /* get_text - Invalid Text */
4539 V_BSTR(&v) = SysAllocString(sTextInvalid);
4540 hres = IHTMLBodyElement_put_text(body, v);
4541 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4545 hres = IHTMLBodyElement_get_text(body, &v);
4546 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4547 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4548 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4551 /* get_text - Valid Text */
4553 V_BSTR(&v) = SysAllocString(sBodyText);
4554 hres = IHTMLBodyElement_put_text(body, v);
4555 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4559 hres = IHTMLBodyElement_get_text(body, &v);
4560 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4561 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4562 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4566 static void test_body_funs(IHTMLBodyElement *body)
4568 static WCHAR sRed[] = {'r','e','d',0};
4573 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4574 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4575 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4577 V_VT(&vbg) = VT_BSTR;
4578 V_BSTR(&vbg) = SysAllocString(sRed);
4579 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4580 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4583 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4584 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4585 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4586 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4589 /* Restore Originial */
4590 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4591 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4592 VariantClear(&vDefaultbg);
4595 static void test_window(IHTMLDocument2 *doc)
4597 IHTMLWindow2 *window, *window2, *self;
4598 IHTMLDocument2 *doc2 = NULL;
4604 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4605 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4606 test_ifaces((IUnknown*)window, window_iids);
4607 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4609 hres = IHTMLWindow2_get_document(window, &doc2);
4610 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4611 ok(doc2 != NULL, "doc2 == NULL\n");
4613 test_ifaces((IUnknown*)doc2, doc_node_iids);
4614 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4616 test_ifaces((IUnknown*)doc, doc_obj_iids);
4617 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4619 unk = (void*)0xdeadbeef;
4620 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4621 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4622 ok(!unk, "unk = %p\n", unk);
4624 IHTMLDocument_Release(doc2);
4626 hres = IHTMLWindow2_get_window(window, &window2);
4627 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4628 ok(window2 != NULL, "window2 == NULL\n");
4630 hres = IHTMLWindow2_get_self(window, &self);
4631 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4632 ok(window2 != NULL, "self == NULL\n");
4634 ok(self == window2, "self != window2\n");
4636 IHTMLWindow2_Release(window2);
4637 IHTMLWindow2_Release(self);
4640 hres = IHTMLDocument2_get_Script(doc, &disp);
4641 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4642 ok(disp == (void*)window, "disp != window\n");
4643 IDispatch_Release(disp);
4645 hres = IHTMLWindow2_toString(window, NULL);
4646 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4649 hres = IHTMLWindow2_toString(window, &str);
4650 ok(hres == S_OK, "toString failed: %08x\n", hres);
4651 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4654 test_window_name(window, NULL);
4655 set_window_name(window, "test");
4656 test_window_length(window, 0);
4658 IHTMLWindow2_Release(window);
4661 static void test_defaults(IHTMLDocument2 *doc)
4663 IHTMLStyleSheetsCollection *stylesheetcol;
4664 IHTMLCurrentStyle *cstyle;
4665 IHTMLBodyElement *body;
4666 IHTMLElement2 *elem2;
4671 IHTMLElementCollection *collection;
4673 hres = IHTMLDocument2_get_body(doc, &elem);
4674 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4676 hres = IHTMLDocument2_get_images(doc, NULL);
4677 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4679 hres = IHTMLDocument2_get_images(doc, &collection);
4680 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4683 test_elem_collection((IUnknown*)collection, NULL, 0);
4684 IHTMLElementCollection_Release(collection);
4687 hres = IHTMLDocument2_get_applets(doc, NULL);
4688 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4690 hres = IHTMLDocument2_get_applets(doc, &collection);
4691 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4694 test_elem_collection((IUnknown*)collection, NULL, 0);
4695 IHTMLElementCollection_Release(collection);
4698 hres = IHTMLDocument2_get_links(doc, NULL);
4699 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4701 hres = IHTMLDocument2_get_links(doc, &collection);
4702 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4705 test_elem_collection((IUnknown*)collection, NULL, 0);
4706 IHTMLElementCollection_Release(collection);
4709 hres = IHTMLDocument2_get_forms(doc, NULL);
4710 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4712 hres = IHTMLDocument2_get_forms(doc, &collection);
4713 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4716 test_elem_collection((IUnknown*)collection, NULL, 0);
4717 IHTMLElementCollection_Release(collection);
4720 hres = IHTMLDocument2_get_anchors(doc, NULL);
4721 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4723 hres = IHTMLDocument2_get_anchors(doc, &collection);
4724 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4727 test_elem_collection((IUnknown*)collection, NULL, 0);
4728 IHTMLElementCollection_Release(collection);
4731 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4732 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4733 test_default_body(body);
4734 test_body_funs(body);
4735 IHTMLBodyElement_Release(body);
4737 hres = IHTMLElement_get_style(elem, &style);
4738 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4740 test_default_style(style);
4742 test_compatmode(doc);
4744 test_navigator(doc);
4746 elem2 = get_elem2_iface((IUnknown*)elem);
4747 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4748 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4749 if(SUCCEEDED(hres)) {
4750 test_current_style(cstyle);
4751 IHTMLCurrentStyle_Release(cstyle);
4753 IHTMLElement2_Release(elem2);
4755 IHTMLElement_Release(elem);
4757 test_set_csstext(style);
4758 IHTMLStyle_Release(style);
4760 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4761 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4764 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4765 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4766 ok(l == 0, "length = %d\n", l);
4768 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4770 test_default_selection(doc);
4771 test_doc_title(doc, "");
4774 static void test_tr_elem(IHTMLElement *elem)
4776 IHTMLElementCollection *col;
4780 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4782 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4783 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4788 hres = IHTMLTableRow_get_cells(row, &col);
4789 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4790 ok(col != NULL, "get_cells returned NULL\n");
4792 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4793 IHTMLElementCollection_Release(col);
4795 IHTMLTable_Release(row);
4798 static void test_table_elem(IHTMLElement *elem)
4800 IHTMLElementCollection *col;
4805 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4806 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4808 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4809 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4814 hres = IHTMLTable_get_rows(table, &col);
4815 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4816 ok(col != NULL, "get_ros returned NULL\n");
4818 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4819 IHTMLElementCollection_Release(col);
4821 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4823 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4824 test_elem_tag((IUnknown*)node, "TABLE");
4825 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4826 IHTMLDOMNode_Release(node);
4828 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4829 test_elem_tag((IUnknown*)node, "TABLE");
4830 test_elem_all((IUnknown*)node, NULL, 0);
4831 IHTMLDOMNode_Release(node);
4833 IHTMLTable_Release(table);
4836 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4846 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4847 SafeArrayAccessData(sa, (void**)&var);
4848 V_VT(var) = VT_BSTR;
4849 V_BSTR(var) = str = a2bstr(text);
4850 SafeArrayUnaccessData(sa);
4853 hres = IHTMLDocument2_writeln(doc, sa);
4855 hres = IHTMLDocument2_write(doc, sa);
4856 ok(hres == S_OK, "write failed: %08x\n", hres);
4859 SafeArrayDestroy(sa);
4862 static void test_frame_doc(IUnknown *frame_elem)
4864 IHTMLDocument2 *window_doc, *elem_doc;
4865 IHTMLWindow2 *content_window;
4867 content_window = get_frame_content_window(frame_elem);
4868 window_doc = get_window_doc(content_window);
4869 IHTMLWindow2_Release(content_window);
4871 elem_doc = get_elem_doc(frame_elem);
4872 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
4874 IHTMLDocument2_Release(elem_doc);
4875 IHTMLDocument2_Release(window_doc);
4878 static void test_iframe_elem(IHTMLElement *elem)
4880 IHTMLDocument2 *content_doc, *owner_doc;
4881 IHTMLElementCollection *col;
4882 IHTMLWindow2 *content_window;
4888 static const elem_type_t all_types[] = {
4896 test_frame_doc((IUnknown*)elem);
4898 content_window = get_frame_content_window((IUnknown*)elem);
4899 test_window_length(content_window, 0);
4901 content_doc = get_window_doc(content_window);
4902 IHTMLWindow2_Release(content_window);
4904 str = a2bstr("text/html");
4905 V_VT(&errv) = VT_ERROR;
4907 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4909 ok(hres == S_OK, "open failed: %08x\n", hres);
4910 ok(disp != NULL, "disp == NULL\n");
4911 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4912 IDispatch_Release(disp);
4914 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4915 doc_write(content_doc, TRUE, "</html>");
4917 hres = IHTMLDocument2_get_all(content_doc, &col);
4918 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4919 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4920 IHTMLElementCollection_Release(col);
4922 hres = IHTMLDocument2_close(content_doc);
4923 ok(hres == S_OK, "close failed: %08x\n", hres);
4925 owner_doc = get_owner_doc((IUnknown*)content_doc);
4926 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4928 IHTMLDocument2_Release(content_doc);
4931 static void test_stylesheet(IDispatch *disp)
4933 IHTMLStyleSheetRulesCollection *col = NULL;
4934 IHTMLStyleSheet *stylesheet;
4937 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4938 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4940 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4941 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4942 ok(col != NULL, "col == NULL\n");
4944 IHTMLStyleSheetRulesCollection_Release(col);
4945 IHTMLStyleSheet_Release(stylesheet);
4948 static void test_stylesheets(IHTMLDocument2 *doc)
4950 IHTMLStyleSheetsCollection *col = NULL;
4955 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4956 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4957 ok(col != NULL, "col == NULL\n");
4959 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4960 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4961 ok(len == 1, "len=%d\n", len);
4967 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4968 ok(hres == S_OK, "item failed: %08x\n", hres);
4969 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4970 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4971 test_stylesheet(V_DISPATCH(&res));
4978 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4979 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4980 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4981 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4984 IHTMLStyleSheetsCollection_Release(col);
4987 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4989 IDispatchEx *dispex;
4991 DISPPARAMS dp = {NULL, NULL, 0, 0};
4999 static const WCHAR w0[] = {'0',0};
5000 static const WCHAR w100[] = {'1','0','0',0};
5002 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5003 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5005 bstr = SysAllocString(w0);
5006 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5007 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5008 SysFreeString(bstr);
5011 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5012 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5013 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5014 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5015 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5016 type = get_node_type((IUnknown*)node);
5017 ok(type == 3, "type=%d\n", type);
5018 IHTMLDOMNode_Release(node);
5021 bstr = SysAllocString(w100);
5022 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5023 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5024 SysFreeString(bstr);
5026 IDispatchEx_Release(dispex);
5031 static void test_elems(IHTMLDocument2 *doc)
5033 IHTMLElementCollection *col;
5034 IHTMLDOMChildrenCollection *child_col;
5035 IHTMLElement *elem, *elem2, *elem3;
5036 IHTMLDOMNode *node, *node2;
5037 IHTMLWindow2 *window;
5041 IHTMLElementCollection *collection;
5042 IHTMLDocument3 *doc3;
5045 static const elem_type_t all_types[] = {
5070 static const elem_type_t item_types[] = {
5076 hres = IHTMLDocument2_get_all(doc, &col);
5077 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5078 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5079 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5080 IHTMLElementCollection_Release(col);
5082 hres = IHTMLDocument2_get_images(doc, &collection);
5083 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5086 static const elem_type_t images_types[] = {ET_IMG};
5087 test_elem_collection((IUnknown*)collection, images_types, 1);
5089 IHTMLElementCollection_Release(collection);
5092 hres = IHTMLDocument2_get_links(doc, &collection);
5093 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5096 static const elem_type_t images_types[] = {ET_A};
5097 test_elem_collection((IUnknown*)collection, images_types, 1);
5099 IHTMLElementCollection_Release(collection);
5102 hres = IHTMLDocument2_get_anchors(doc, &collection);
5103 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5106 static const elem_type_t anchor_types[] = {ET_A};
5107 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5109 IHTMLElementCollection_Release(collection);
5112 elem = get_doc_elem(doc);
5113 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5114 IHTMLElement_Release(elem);
5116 get_elem_by_id(doc, "xxx", FALSE);
5117 elem = get_doc_elem_by_id(doc, "xxx");
5118 ok(!elem, "elem != NULL\n");
5120 elem = get_doc_elem_by_id(doc, "s");
5121 ok(elem != NULL, "elem == NULL\n");
5123 test_elem_type((IUnknown*)elem, ET_SELECT);
5124 test_elem_attr(elem, "xxx", NULL);
5125 test_elem_attr(elem, "id", "s");
5126 test_elem_class((IUnknown*)elem, NULL);
5127 test_elem_set_class((IUnknown*)elem, "cl");
5128 test_elem_set_class((IUnknown*)elem, NULL);
5129 test_elem_tabindex((IUnknown*)elem, 0);
5130 test_elem_set_tabindex((IUnknown*)elem, 1);
5132 node = test_node_get_parent((IUnknown*)elem);
5133 ok(node != NULL, "node == NULL\n");
5134 test_node_name((IUnknown*)node, "BODY");
5135 node2 = test_node_get_parent((IUnknown*)node);
5136 IHTMLDOMNode_Release(node);
5137 ok(node2 != NULL, "node == NULL\n");
5138 test_node_name((IUnknown*)node2, "HTML");
5139 node = test_node_get_parent((IUnknown*)node2);
5140 IHTMLDOMNode_Release(node2);
5141 ok(node != NULL, "node == NULL\n");
5144 test_node_name((IUnknown*)node, "#document");
5145 type = get_node_type((IUnknown*)node);
5146 ok(type == 9, "type=%d, expected 9\n", type);
5147 node2 = test_node_get_parent((IUnknown*)node);
5148 IHTMLDOMNode_Release(node);
5149 ok(node2 == NULL, "node != NULL\n");
5152 elem2 = test_elem_get_parent((IUnknown*)elem);
5153 ok(elem2 != NULL, "elem2 == NULL\n");
5154 test_node_name((IUnknown*)elem2, "BODY");
5155 elem3 = test_elem_get_parent((IUnknown*)elem2);
5156 IHTMLElement_Release(elem2);
5157 ok(elem3 != NULL, "elem3 == NULL\n");
5158 test_node_name((IUnknown*)elem3, "HTML");
5159 elem2 = test_elem_get_parent((IUnknown*)elem3);
5160 IHTMLElement_Release(elem3);
5161 ok(elem2 == NULL, "elem2 != NULL\n");
5163 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5164 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5165 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5167 test_elem_innertext(elem, "opt1opt2");
5169 IHTMLElement_Release(elem);
5172 elem = get_elem_by_id(doc, "s", TRUE);
5174 IHTMLSelectElement *select;
5175 IHTMLDocument2 *doc_node, *elem_doc;
5177 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5178 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5180 test_select_elem(select);
5182 test_elem_title((IUnknown*)select, NULL);
5183 test_elem_set_title((IUnknown*)select, "Title");
5184 test_elem_title((IUnknown*)select, "Title");
5185 test_elem_offset((IUnknown*)select);
5187 node = get_first_child((IUnknown*)select);
5188 ok(node != NULL, "node == NULL\n");
5190 test_elem_type((IUnknown*)node, ET_OPTION);
5191 IHTMLDOMNode_Release(node);
5194 type = get_node_type((IUnknown*)select);
5195 ok(type == 1, "type=%d\n", type);
5197 IHTMLSelectElement_Release(select);
5199 elem_doc = get_elem_doc((IUnknown*)elem);
5201 doc_node = get_doc_node(doc);
5202 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5203 IHTMLDocument2_Release(doc_node);
5204 IHTMLDocument2_Release(elem_doc);
5206 IHTMLElement_Release(elem);
5209 elem = get_elem_by_id(doc, "sc", TRUE);
5211 IHTMLScriptElement *script;
5214 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5215 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5221 hres = IHTMLScriptElement_get_type(script, &type);
5222 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5223 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5224 SysFreeString(type);
5227 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5228 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5230 hres = IHTMLScriptElement_get_defer(script, &vb);
5231 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5232 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5234 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5235 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5238 IHTMLScriptElement_Release(script);
5241 elem = get_elem_by_id(doc, "in", TRUE);
5243 IHTMLInputElement *input;
5245 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5246 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5248 test_elem_id((IUnknown*)elem, "in");
5249 test_elem_put_id((IUnknown*)elem, "newin");
5250 test_input_get_disabled(input, VARIANT_FALSE);
5251 test_input_set_disabled(input, VARIANT_TRUE);
5252 test_input_set_disabled(input, VARIANT_FALSE);
5253 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5254 test_input_get_disabled(input, VARIANT_TRUE);
5255 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5256 test_input_get_disabled(input, VARIANT_FALSE);
5257 test_elem_client_size((IUnknown*)elem);
5259 test_node_get_value_str((IUnknown*)elem, NULL);
5260 test_node_put_value_str((IUnknown*)elem, "test");
5261 test_node_get_value_str((IUnknown*)elem, NULL);
5262 test_input_value((IUnknown*)elem, NULL);
5263 test_input_put_value((IUnknown*)elem, "test");
5264 test_input_value((IUnknown*)elem, NULL);
5265 test_elem_class((IUnknown*)elem, "testclass");
5266 test_elem_tabindex((IUnknown*)elem, 2);
5267 test_elem_set_tabindex((IUnknown*)elem, 3);
5268 test_elem_title((IUnknown*)elem, "test title");
5270 test_input_get_defaultchecked(input, VARIANT_FALSE);
5271 test_input_set_defaultchecked(input, VARIANT_TRUE);
5272 test_input_set_defaultchecked(input, VARIANT_FALSE);
5274 test_input_get_checked(input, VARIANT_FALSE);
5275 test_input_set_checked(input, VARIANT_TRUE);
5276 test_input_set_checked(input, VARIANT_FALSE);
5278 test_input_src(input, NULL);
5279 test_input_set_src(input, "about:blank");
5281 IHTMLInputElement_Release(input);
5282 IHTMLElement_Release(elem);
5285 elem = get_elem_by_id(doc, "imgid", TRUE);
5287 test_img_src((IUnknown*)elem, "");
5288 test_img_set_src((IUnknown*)elem, "about:blank");
5289 test_img_alt((IUnknown*)elem, NULL);
5290 test_img_set_alt((IUnknown*)elem, "alt test");
5291 IHTMLElement_Release(elem);
5294 elem = get_doc_elem_by_id(doc, "tbl");
5295 ok(elem != NULL, "elem == NULL\n");
5297 test_table_elem(elem);
5298 IHTMLElement_Release(elem);
5301 elem = get_doc_elem_by_id(doc, "row2");
5302 ok(elem != NULL, "elem == NULL\n");
5305 IHTMLElement_Release(elem);
5308 elem = get_doc_elem_by_id(doc, "ifr");
5309 ok(elem != NULL, "elem == NULL\n");
5311 test_iframe_elem(elem);
5312 IHTMLElement_Release(elem);
5315 elem = get_elem_by_id(doc, "a", TRUE);
5317 test_anchor_href((IUnknown*)elem, "http://test/");
5318 IHTMLElement_Release(elem);
5321 hres = IHTMLDocument2_get_body(doc, &elem);
5322 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5324 node = get_first_child((IUnknown*)elem);
5325 ok(node != NULL, "node == NULL\n");
5327 test_ifaces((IUnknown*)node, text_iids);
5328 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5330 node2 = get_first_child((IUnknown*)node);
5331 ok(!node2, "node2 != NULL\n");
5333 type = get_node_type((IUnknown*)node);
5334 ok(type == 3, "type=%d\n", type);
5336 test_node_get_value_str((IUnknown*)node, "text test");
5337 test_node_put_value_str((IUnknown*)elem, "test text");
5338 test_node_get_value_str((IUnknown*)node, "text test");
5340 IHTMLDOMNode_Release(node);
5343 child_col = get_child_nodes((IUnknown*)elem);
5344 ok(child_col != NULL, "child_coll == NULL\n");
5348 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5350 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5351 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5352 ok(length, "length=0\n");
5355 node = get_child_item(child_col, 0);
5356 ok(node != NULL, "node == NULL\n");
5358 type = get_node_type((IUnknown*)node);
5359 ok(type == 3, "type=%d\n", type);
5360 node2 = node_get_next((IUnknown*)node);
5361 IHTMLDOMNode_Release(node);
5364 node = get_child_item(child_col, 1);
5365 ok(node != NULL, "node == NULL\n");
5367 type = get_node_type((IUnknown*)node);
5368 ok(type == 8, "type=%d\n", type);
5370 test_elem_id((IUnknown*)node, NULL);
5371 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5372 IHTMLDOMNode_Release(node2);
5373 IHTMLDOMNode_Release(node);
5376 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5377 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5379 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5380 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5382 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5383 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5385 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5386 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5388 test_child_col_disp(child_col);
5390 IHTMLDOMChildrenCollection_Release(child_col);
5393 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5394 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5395 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5397 IHTMLElement_Release(elem);
5399 test_stylesheets(doc);
5400 test_create_option_elem(doc);
5401 test_create_img_elem(doc);
5403 elem = get_doc_elem_by_id(doc, "tbl");
5404 ok(elem != NULL, "elem = NULL\n");
5405 test_elem_set_innertext(elem, "inner text");
5406 IHTMLElement_Release(elem);
5408 test_doc_title(doc, "test");
5409 test_doc_set_title(doc, "test title");
5410 test_doc_title(doc, "test title");
5413 hres = IHTMLDocument2_get_Script(doc, &disp);
5414 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5417 IDispatchEx *dispex;
5418 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5419 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5423 BSTR str = a2bstr("Testing");
5424 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5425 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5426 ok(pid != -1, "pid == -1\n");
5428 IDispatchEx_Release(dispex);
5431 IDispatch_Release(disp);
5433 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5434 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5436 str = a2bstr("img");
5437 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5438 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5442 static const elem_type_t img_types[] = { ET_IMG };
5444 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5445 IHTMLElementCollection_Release(col);
5448 elem = get_doc_elem_by_id(doc, "y");
5449 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5450 test_elem_innerhtml((IUnknown*)elem, "inner html");
5451 test_elem_set_innerhtml((IUnknown*)elem, "");
5452 test_elem_innerhtml((IUnknown*)elem, NULL);
5453 node = node_get_next((IUnknown*)elem);
5454 ok(!node, "node = %p\n", node);
5456 elem2 = get_doc_elem_by_id(doc, "x");
5457 test_elem_tag((IUnknown*)elem2, "A");
5458 node = node_get_next((IUnknown*)elem2);
5459 IHTMLDOMNode_Release(node);
5460 IHTMLElement_Release(elem2);
5461 IHTMLElement_Release(elem);
5463 IHTMLDocument3_Release(doc3);
5465 window = get_doc_window(doc);
5466 test_window_name(window, NULL);
5467 set_window_name(window, "test name");
5468 test_window_length(window, 1);
5469 IHTMLWindow2_Release(window);
5472 static void test_elems2(IHTMLDocument2 *doc)
5474 IHTMLElement *elem, *elem2;
5476 static const elem_type_t outer_types[] = {
5481 elem = get_doc_elem_by_id(doc, "divid");
5483 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5484 elem2 = get_doc_elem_by_id(doc, "innerid");
5485 ok(elem2 != NULL, "elem2 == NULL\n");
5486 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5487 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5488 IHTMLElement_Release(elem2);
5490 elem2 = get_doc_elem_by_id(doc, "aid");
5491 ok(elem2 != NULL, "elem2 == NULL\n");
5492 test_elem_set_outerhtml((IUnknown*)elem2, "");
5493 test_elem_all((IUnknown*)elem, outer_types, 1);
5494 IHTMLElement_Release(elem2);
5496 IHTMLElement_Release(elem);
5499 static void test_create_elems(IHTMLDocument2 *doc)
5501 IHTMLElement *elem, *body, *elem2;
5502 IHTMLDOMNode *node, *node2, *node3, *comment;
5503 IHTMLDocument5 *doc5;
5510 static const elem_type_t types1[] = { ET_TESTG };
5512 elem = test_create_elem(doc, "TEST");
5513 test_elem_tag((IUnknown*)elem, "TEST");
5514 type = get_node_type((IUnknown*)elem);
5515 ok(type == 1, "type=%d\n", type);
5516 test_ifaces((IUnknown*)elem, elem_iids);
5517 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5519 hres = IHTMLDocument2_get_body(doc, &body);
5520 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5521 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5523 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5524 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5525 elem2 = get_elem_iface((IUnknown*)node);
5526 IHTMLElement_Release(elem2);
5528 hres = IHTMLElement_get_all(body, &disp);
5529 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5530 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5531 IDispatch_Release(disp);
5533 test_node_remove_child((IUnknown*)body, node);
5535 hres = IHTMLElement_get_all(body, &disp);
5536 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5537 test_elem_collection((IUnknown*)disp, NULL, 0);
5538 IDispatch_Release(disp);
5539 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5541 IHTMLElement_Release(elem);
5542 IHTMLDOMNode_Release(node);
5544 node = test_create_text(doc, "test");
5545 test_ifaces((IUnknown*)node, text_iids);
5546 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5548 V_VT(&var) = VT_NULL;
5549 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5550 IHTMLDOMNode_Release(node);
5552 node = test_create_text(doc, "insert ");
5554 V_VT(&var) = VT_DISPATCH;
5555 V_DISPATCH(&var) = (IDispatch*)node2;
5556 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5557 IHTMLDOMNode_Release(node);
5558 IHTMLDOMNode_Release(node2);
5559 IHTMLDOMNode_Release(node3);
5561 test_elem_innertext(body, "insert test");
5562 test_elem_innerhtml((IUnknown*)body, "insert test");
5564 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5567 str = a2bstr("testing");
5568 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5570 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5573 type = get_node_type((IUnknown*)comment);
5574 ok(type == 8, "type=%d, expected 8\n", type);
5576 test_node_get_value_str((IUnknown*)comment, "testing");
5578 IHTMLDOMNode_Release(comment);
5581 IHTMLDocument5_Release(doc5);
5584 IHTMLElement_Release(body);
5587 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5589 IOleCommandTarget *cmdtrg;
5592 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5593 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5595 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5596 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5598 IOleCommandTarget_Release(cmdtrg);
5601 static void test_indent(IHTMLDocument2 *doc)
5603 IHTMLElementCollection *col;
5604 IHTMLTxtRange *range;
5607 static const elem_type_t all_types[] = {
5616 static const elem_type_t indent_types[] = {
5627 hres = IHTMLDocument2_get_all(doc, &col);
5628 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5629 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5630 IHTMLElementCollection_Release(col);
5632 range = test_create_body_range(doc);
5633 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5634 IHTMLTxtRange_Release(range);
5636 hres = IHTMLDocument2_get_all(doc, &col);
5637 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5638 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5639 IHTMLElementCollection_Release(col);
5642 static void test_cond_comment(IHTMLDocument2 *doc)
5644 IHTMLElementCollection *col;
5647 static const elem_type_t all_types[] = {
5655 hres = IHTMLDocument2_get_all(doc, &col);
5656 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5657 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5658 IHTMLElementCollection_Release(col);
5661 static void test_frame(IDispatch *disp, const char *exp_id)
5663 IHTMLWindow2 *frame2, *parent, *top;
5664 IHTMLDocument2 *parent_doc, *top_doc;
5665 IHTMLWindow4 *frame;
5666 IHTMLFrameBase *frame_elem;
5669 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5670 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5674 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5675 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5676 IHTMLWindow4_Release(frame);
5680 test_frame_doc((IUnknown*)frame_elem);
5681 test_elem_id((IUnknown*)frame_elem, exp_id);
5682 IHTMLElement_Release(frame_elem);
5684 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5685 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5689 hres = IHTMLWindow2_get_parent(frame2, &parent);
5690 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5692 IHTMLWindow2_Release(frame2);
5696 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5697 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5698 IHTMLWindow2_Release(parent);
5700 IHTMLWindow2_Release(frame2);
5704 test_doc_title(parent_doc, "frameset test");
5705 IHTMLDocument2_Release(parent_doc);
5708 hres = IHTMLWindow2_get_top(frame2, &top);
5709 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5710 IHTMLWindow2_Release(frame2);
5714 hres = IHTMLWindow2_get_document(top, &top_doc);
5715 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5716 IHTMLWindow2_Release(top);
5720 test_doc_title(top_doc, "frameset test");
5721 IHTMLDocument2_Release(top_doc);
5724 static void test_frameset(IHTMLDocument2 *doc)
5726 IHTMLWindow2 *window;
5727 IHTMLFramesCollection2 *frames;
5730 VARIANT index_var, result_var;
5733 window = get_doc_window(doc);
5735 /* test using IHTMLFramesCollection object */
5737 hres = IHTMLWindow2_get_frames(window, &frames);
5738 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5739 IHTMLWindow2_Release(window);
5743 /* test result length */
5744 hres = IHTMLFramesCollection2_get_length(frames, &length);
5745 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5746 ok(length == 2, "IHTMLFramesCollection2_get_length should have been 2, was: %d\n", length);
5748 /* test first frame */
5749 V_VT(&index_var) = VT_I4;
5750 V_I4(&index_var) = 0;
5751 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5752 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5753 if(SUCCEEDED(hres)) {
5754 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5755 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5757 VariantClear(&result_var);
5759 /* test second frame */
5760 V_I4(&index_var) = 1;
5761 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5762 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5763 if(SUCCEEDED(hres)) {
5764 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5765 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5767 VariantClear(&result_var);
5769 /* fail on third frame */
5770 V_I4(&index_var) = 2;
5771 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5772 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5773 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5774 VariantClear(&result_var);
5776 /* string argument (element id lookup) */
5777 V_VT(&index_var) = VT_BSTR;
5778 V_BSTR(&index_var) = a2bstr("fr1");
5779 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5780 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5781 if(SUCCEEDED(hres)) {
5782 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5783 test_frame(V_DISPATCH(&result_var), "fr1");
5785 VariantClear(&result_var);
5786 VariantClear(&index_var);
5788 /* invalid argument */
5789 V_VT(&index_var) = VT_BOOL;
5790 V_BOOL(&index_var) = VARIANT_TRUE;
5791 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5792 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5793 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5794 VariantClear(&result_var);
5796 IHTMLFramesCollection2_Release(frames);
5798 /* test using IHTMLWindow2 inheritance */
5800 /* test result length */
5801 hres = IHTMLWindow2_get_length(window, &length);
5802 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5803 ok(length == 2, "IHTMLWindow2_get_length should have been 2, was: %d\n", length);
5805 /* test first frame */
5806 V_VT(&index_var) = VT_I4;
5807 V_I4(&index_var) = 0;
5808 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5809 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5810 if(SUCCEEDED(hres)) {
5811 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5812 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5814 VariantClear(&result_var);
5816 /* test second frame */
5817 V_I4(&index_var) = 1;
5818 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5819 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5820 if(SUCCEEDED(hres)) {
5821 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5822 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5824 VariantClear(&result_var);
5826 /* fail on third frame */
5827 V_I4(&index_var) = 2;
5828 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5829 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5830 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5831 VariantClear(&result_var);
5833 /* string argument (element id lookup) */
5834 V_VT(&index_var) = VT_BSTR;
5835 V_BSTR(&index_var) = a2bstr("fr2");
5836 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5837 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5838 if(SUCCEEDED(hres)) {
5839 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5840 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5842 VariantClear(&result_var);
5843 VariantClear(&index_var);
5845 /* invalid argument */
5846 V_VT(&index_var) = VT_BOOL;
5847 V_BOOL(&index_var) = VARIANT_TRUE;
5848 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5849 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5850 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5851 VariantClear(&result_var);
5853 /* getElementById with node name attributes */
5854 elem = get_doc_elem_by_id(doc, "nm1");
5855 test_elem_id((IUnknown*)elem, "fr1");
5856 IHTMLElement_Release(elem);
5859 static IHTMLDocument2 *notif_doc;
5860 static BOOL doc_complete;
5862 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5863 REFIID riid, void**ppv)
5865 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5870 ok(0, "unexpected call\n");
5871 return E_NOINTERFACE;
5874 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5879 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5884 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5886 if(dispID == DISPID_READYSTATE){
5890 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5891 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5893 if(!strcmp_wa(state, "complete"))
5894 doc_complete = TRUE;
5896 SysFreeString(state);
5902 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5904 ok(0, "unexpected call\n");
5908 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5909 PropertyNotifySink_QueryInterface,
5910 PropertyNotifySink_AddRef,
5911 PropertyNotifySink_Release,
5912 PropertyNotifySink_OnChanged,
5913 PropertyNotifySink_OnRequestEdit
5916 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5918 static IHTMLDocument2 *create_doc_with_string(const char *str)
5920 IPersistStreamInit *init;
5922 IHTMLDocument2 *doc;
5926 notif_doc = doc = create_document();
5930 doc_complete = FALSE;
5932 mem = GlobalAlloc(0, len);
5933 memcpy(mem, str, len);
5934 CreateStreamOnHGlobal(mem, TRUE, &stream);
5936 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5938 IPersistStreamInit_Load(init, stream);
5939 IPersistStreamInit_Release(init);
5940 IStream_Release(stream);
5945 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5947 IConnectionPointContainer *container;
5948 IConnectionPoint *cp;
5952 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5953 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5955 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5956 IConnectionPointContainer_Release(container);
5957 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5959 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5960 IConnectionPoint_Release(cp);
5961 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5964 typedef void (*domtest_t)(IHTMLDocument2*);
5966 static void run_domtest(const char *str, domtest_t test)
5968 IHTMLDocument2 *doc;
5972 doc = create_doc_with_string(str);
5976 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5978 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5979 TranslateMessage(&msg);
5980 DispatchMessage(&msg);
5985 ref = IHTMLDocument2_Release(doc);
5987 ref == 1, /* Vista */
5995 run_domtest(doc_str1, test_doc_elem);
5996 run_domtest(doc_str1, test_get_set_attr);
5997 run_domtest(range_test_str, test_txtrange);
5998 run_domtest(range_test2_str, test_txtrange2);
5999 if (winetest_interactive || ! is_ie_hardened()) {
6000 run_domtest(elem_test_str, test_elems);
6002 skip("IE running in Enhanced Security Configuration\n");
6004 run_domtest(elem_test2_str, test_elems2);
6005 run_domtest(doc_blank, test_create_elems);
6006 run_domtest(doc_blank, test_defaults);
6007 run_domtest(indent_test_str, test_indent);
6008 run_domtest(cond_comment_str, test_cond_comment);
6009 run_domtest(frameset_str, test_frameset);