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_screen(IHTMLWindow2 *window)
3037 IHTMLScreen *screen, *screen2;
3042 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
3045 hres = IHTMLWindow2_get_screen(window, &screen);
3046 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3047 ok(screen != NULL, "screen == NULL\n");
3050 hres = IHTMLWindow2_get_screen(window, &screen2);
3051 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3052 ok(screen2 != NULL, "screen == NULL\n");
3053 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3054 IHTMLScreen_Release(screen2);
3056 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3058 hdc = CreateICW(displayW, NULL, NULL, NULL);
3060 exl = GetDeviceCaps(hdc, HORZRES);
3062 hres = IHTMLScreen_get_width(screen, &l);
3063 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3064 ok(l == exl, "width = %d, expected %d\n", l, exl);
3066 exl = GetDeviceCaps(hdc, VERTRES);
3068 hres = IHTMLScreen_get_height(screen, &l);
3069 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3070 ok(l == exl, "height = %d, expected %d\n", l, exl);
3072 exl = GetDeviceCaps(hdc, BITSPIXEL);
3074 hres = IHTMLScreen_get_colorDepth(screen, &l);
3075 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3076 ok(l == exl, "height = %d, expected %d\n", l, exl);
3080 IHTMLScreen_Release(screen);
3083 static void test_current_style(IHTMLCurrentStyle *current_style)
3089 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3090 test_ifaces((IUnknown*)current_style, cstyle_iids);
3092 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3093 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3094 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3097 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3098 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3099 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3102 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3103 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3106 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3107 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3108 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3111 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3112 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3113 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3116 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3117 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3118 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3121 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3122 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3123 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3126 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3127 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3128 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3131 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3132 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3133 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3136 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3137 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3138 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3141 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3142 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3143 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3146 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3147 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3148 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3151 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3152 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3153 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3156 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3157 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3158 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3161 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3162 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3165 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3166 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3169 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3170 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3173 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3174 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3177 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3178 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3181 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3182 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3185 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3186 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3187 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3188 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3191 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3192 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3193 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3196 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3197 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3198 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3201 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3202 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3203 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3206 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3207 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3208 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3211 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3212 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3213 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3216 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3217 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3218 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3221 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3222 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3223 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3224 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3227 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3228 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3229 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3230 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3233 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3234 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3235 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3238 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3239 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3240 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3243 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3244 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3245 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3249 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3250 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3251 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3254 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3255 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3256 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3259 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3260 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3261 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3264 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3265 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3266 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3269 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3270 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3271 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3274 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3275 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3276 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3279 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3280 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3281 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3284 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3285 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3286 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3289 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3290 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3291 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3294 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3295 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3296 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3299 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3300 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3301 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3304 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3305 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3306 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3309 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3310 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3311 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3314 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3315 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3316 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3319 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3320 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3321 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3324 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3325 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3326 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3329 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3330 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3331 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3334 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3335 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3336 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3339 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3340 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3341 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3345 static void test_style2(IHTMLStyle2 *style2)
3350 str = (void*)0xdeadbeef;
3351 hres = IHTMLStyle2_get_position(style2, &str);
3352 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3353 ok(!str, "str != NULL\n");
3355 str = a2bstr("absolute");
3356 hres = IHTMLStyle2_put_position(style2, str);
3357 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3361 hres = IHTMLStyle2_get_position(style2, &str);
3362 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3363 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3367 static void test_style3(IHTMLStyle3 *style3)
3372 str = (void*)0xdeadbeef;
3373 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3374 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3375 ok(!str, "str != NULL\n");
3377 str = a2bstr("break-word");
3378 hres = IHTMLStyle3_put_wordWrap(style3, str);
3379 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3383 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3384 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3385 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3389 static void test_style4(IHTMLStyle4 *style4)
3395 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3396 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3399 V_BSTR(&v) = a2bstr("10px");
3400 hres = IHTMLStyle4_put_minHeight(style4, v);
3401 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3404 hres = IHTMLStyle4_get_minHeight(style4, &v);
3405 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3406 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3407 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3409 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3410 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3411 VariantClear(&vdefault);
3414 static void test_default_style(IHTMLStyle *style)
3416 IHTMLStyle2 *style2;
3417 IHTMLStyle3 *style3;
3418 IHTMLStyle4 *style4;
3424 BSTR sOverflowDefault;
3428 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3429 test_ifaces((IUnknown*)style, style_iids);
3431 test_style_csstext(style, NULL);
3433 hres = IHTMLStyle_get_position(style, &str);
3434 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3435 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3438 hres = IHTMLStyle_get_marginRight(style, &v);
3439 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3440 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3441 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3444 hres = IHTMLStyle_get_marginLeft(style, &v);
3445 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3446 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3447 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3449 str = (void*)0xdeadbeef;
3450 hres = IHTMLStyle_get_fontFamily(style, &str);
3451 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3452 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3454 str = (void*)0xdeadbeef;
3455 hres = IHTMLStyle_get_fontWeight(style, &str);
3456 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3457 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3459 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3460 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3462 str = a2bstr("test");
3463 hres = IHTMLStyle_put_fontWeight(style, str);
3464 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3467 str = a2bstr("bold");
3468 hres = IHTMLStyle_put_fontWeight(style, str);
3469 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3472 str = a2bstr("bolder");
3473 hres = IHTMLStyle_put_fontWeight(style, str);
3474 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3477 str = a2bstr("lighter");
3478 hres = IHTMLStyle_put_fontWeight(style, str);
3479 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3482 str = a2bstr("100");
3483 hres = IHTMLStyle_put_fontWeight(style, str);
3484 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3487 str = a2bstr("200");
3488 hres = IHTMLStyle_put_fontWeight(style, str);
3489 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3492 str = a2bstr("300");
3493 hres = IHTMLStyle_put_fontWeight(style, str);
3494 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3497 str = a2bstr("400");
3498 hres = IHTMLStyle_put_fontWeight(style, str);
3499 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3502 str = a2bstr("500");
3503 hres = IHTMLStyle_put_fontWeight(style, str);
3504 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3507 str = a2bstr("600");
3508 hres = IHTMLStyle_put_fontWeight(style, str);
3509 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3512 str = a2bstr("700");
3513 hres = IHTMLStyle_put_fontWeight(style, str);
3514 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3517 str = a2bstr("800");
3518 hres = IHTMLStyle_put_fontWeight(style, str);
3519 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3522 str = a2bstr("900");
3523 hres = IHTMLStyle_put_fontWeight(style, str);
3524 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3527 hres = IHTMLStyle_get_fontWeight(style, &str);
3528 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3529 ok(!strcmp_wa(str, "900"), "str != style900\n");
3532 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3533 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3534 SysFreeString(sDefault);
3537 hres = IHTMLStyle_get_fontVariant(style, NULL);
3538 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3540 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3541 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3543 str = a2bstr("test");
3544 hres = IHTMLStyle_put_fontVariant(style, str);
3545 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3548 str = a2bstr("small-caps");
3549 hres = IHTMLStyle_put_fontVariant(style, str);
3550 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3553 str = a2bstr("normal");
3554 hres = IHTMLStyle_put_fontVariant(style, str);
3555 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3558 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3559 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3560 SysFreeString(sDefault);
3562 str = (void*)0xdeadbeef;
3563 hres = IHTMLStyle_get_display(style, &str);
3564 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3565 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3567 str = (void*)0xdeadbeef;
3568 hres = IHTMLStyle_get_visibility(style, &str);
3569 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3570 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3573 hres = IHTMLStyle_get_fontSize(style, &v);
3574 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3575 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3576 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3579 hres = IHTMLStyle_get_color(style, &v);
3580 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3581 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3582 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3585 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3586 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3587 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3589 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3590 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3591 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3593 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3594 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3595 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3597 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3598 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3601 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3602 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3603 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3605 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3606 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3607 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3609 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3610 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3611 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3613 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3614 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3617 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3618 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3619 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3621 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3622 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3623 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3625 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3626 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3627 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3629 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3630 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3633 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3634 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3635 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3637 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3638 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3639 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3641 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3642 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3643 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3645 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3646 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3649 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3650 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3651 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3653 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3654 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3655 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3657 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3658 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3659 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3661 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3662 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3664 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3665 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3667 str = a2bstr("invalid");
3668 hres = IHTMLStyle_put_textDecoration(style, str);
3669 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3672 str = a2bstr("none");
3673 hres = IHTMLStyle_put_textDecoration(style, str);
3674 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3677 str = a2bstr("underline");
3678 hres = IHTMLStyle_put_textDecoration(style, str);
3679 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3682 str = a2bstr("overline");
3683 hres = IHTMLStyle_put_textDecoration(style, str);
3684 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3687 str = a2bstr("line-through");
3688 hres = IHTMLStyle_put_textDecoration(style, str);
3689 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3692 str = a2bstr("blink");
3693 hres = IHTMLStyle_put_textDecoration(style, str);
3694 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3697 hres = IHTMLStyle_get_textDecoration(style, &str);
3698 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3699 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3702 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3703 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3704 SysFreeString(sDefault);
3706 hres = IHTMLStyle_get_posWidth(style, NULL);
3707 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3709 hres = IHTMLStyle_get_posWidth(style, &f);
3710 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3711 ok(f == 0.0f, "f = %f\n", f);
3713 V_VT(&v) = VT_EMPTY;
3714 hres = IHTMLStyle_get_width(style, &v);
3715 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3716 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3717 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3719 hres = IHTMLStyle_put_posWidth(style, 2.2);
3720 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3722 hres = IHTMLStyle_get_posWidth(style, &f);
3723 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3725 f == 2.2f, /* IE8 */
3729 V_BSTR(&v) = a2bstr("auto");
3730 hres = IHTMLStyle_put_width(style, v);
3731 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3734 V_VT(&v) = VT_EMPTY;
3735 hres = IHTMLStyle_get_width(style, &v);
3736 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3737 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3738 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3742 str = (void*)0xdeadbeef;
3743 hres = IHTMLStyle_get_margin(style, &str);
3744 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3745 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3748 hres = IHTMLStyle_put_margin(style, str);
3749 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3752 hres = IHTMLStyle_get_margin(style, &str);
3753 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3754 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3756 hres = IHTMLStyle_put_margin(style, NULL);
3757 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3760 hres = IHTMLStyle_get_border(style, &str);
3761 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3762 ok(!str || !*str, "str is not empty\n");
3765 str = a2bstr("1px");
3766 hres = IHTMLStyle_put_border(style, str);
3767 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3770 V_VT(&v) = VT_EMPTY;
3771 hres = IHTMLStyle_get_left(style, &v);
3772 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3773 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3774 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3778 hres = IHTMLStyle_get_posLeft(style, NULL);
3779 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3782 hres = IHTMLStyle_get_posLeft(style, &f);
3783 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3784 ok(f == 0.0, "expected 0.0 got %f\n", f);
3786 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3787 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3789 hres = IHTMLStyle_get_posLeft(style, &f);
3790 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3792 f == 4.9f, /* IE8 */
3793 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3795 /* Ensure left is updated correctly. */
3796 V_VT(&v) = VT_EMPTY;
3797 hres = IHTMLStyle_get_left(style, &v);
3798 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3799 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3800 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3801 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3802 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3807 V_BSTR(&v) = a2bstr("3px");
3808 hres = IHTMLStyle_put_left(style, v);
3809 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3812 hres = IHTMLStyle_get_posLeft(style, &f);
3813 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3814 ok(f == 3.0, "expected 3.0 got %f\n", f);
3816 V_VT(&v) = VT_EMPTY;
3817 hres = IHTMLStyle_get_left(style, &v);
3818 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3819 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3820 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3824 hres = IHTMLStyle_put_left(style, v);
3825 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3827 V_VT(&v) = VT_EMPTY;
3828 hres = IHTMLStyle_get_left(style, &v);
3829 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3830 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3831 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3834 V_VT(&v) = VT_EMPTY;
3835 hres = IHTMLStyle_get_top(style, &v);
3836 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3837 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3838 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3842 hres = IHTMLStyle_get_posTop(style, NULL);
3843 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3846 hres = IHTMLStyle_get_posTop(style, &f);
3847 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3848 ok(f == 0.0, "expected 0.0 got %f\n", f);
3850 hres = IHTMLStyle_put_posTop(style, 4.9f);
3851 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3853 hres = IHTMLStyle_get_posTop(style, &f);
3854 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3856 f == 4.9f, /* IE8 */
3857 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3860 V_BSTR(&v) = a2bstr("3px");
3861 hres = IHTMLStyle_put_top(style, v);
3862 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3865 V_VT(&v) = VT_EMPTY;
3866 hres = IHTMLStyle_get_top(style, &v);
3867 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3868 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3869 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3872 hres = IHTMLStyle_get_posTop(style, &f);
3873 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3874 ok(f == 3.0, "expected 3.0 got %f\n", f);
3877 hres = IHTMLStyle_put_top(style, v);
3878 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3880 V_VT(&v) = VT_EMPTY;
3881 hres = IHTMLStyle_get_top(style, &v);
3882 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3883 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3884 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3887 /* Test posHeight */
3888 hres = IHTMLStyle_get_posHeight(style, NULL);
3889 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3891 V_VT(&v) = VT_EMPTY;
3892 hres = IHTMLStyle_get_height(style, &v);
3893 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3894 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3895 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3899 hres = IHTMLStyle_get_posHeight(style, &f);
3900 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3901 ok(f == 0.0, "expected 0.0 got %f\n", f);
3903 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3904 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3906 hres = IHTMLStyle_get_posHeight(style, &f);
3907 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3909 f == 4.9f, /* IE8 */
3910 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3913 V_BSTR(&v) = a2bstr("64px");
3914 hres = IHTMLStyle_put_height(style, v);
3915 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3918 V_VT(&v) = VT_EMPTY;
3919 hres = IHTMLStyle_get_height(style, &v);
3920 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3921 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3922 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3925 hres = IHTMLStyle_get_posHeight(style, &f);
3926 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3927 ok(f == 64.0, "expected 64.0 got %f\n", f);
3929 str = (void*)0xdeadbeef;
3930 hres = IHTMLStyle_get_cursor(style, &str);
3931 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3932 ok(!str, "get_cursor != NULL\n");
3935 str = a2bstr("default");
3936 hres = IHTMLStyle_put_cursor(style, str);
3937 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3941 hres = IHTMLStyle_get_cursor(style, &str);
3942 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3943 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3946 V_VT(&v) = VT_EMPTY;
3947 hres = IHTMLStyle_get_verticalAlign(style, &v);
3948 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3949 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3950 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3954 V_BSTR(&v) = a2bstr("middle");
3955 hres = IHTMLStyle_put_verticalAlign(style, v);
3956 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3959 V_VT(&v) = VT_EMPTY;
3960 hres = IHTMLStyle_get_verticalAlign(style, &v);
3961 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3962 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3963 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3966 str = (void*)0xdeadbeef;
3967 hres = IHTMLStyle_get_textAlign(style, &str);
3968 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3969 ok(!str, "textAlign != NULL\n");
3971 str = a2bstr("center");
3972 hres = IHTMLStyle_put_textAlign(style, str);
3973 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3977 hres = IHTMLStyle_get_textAlign(style, &str);
3978 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3979 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3982 str = (void*)0xdeadbeef;
3983 hres = IHTMLStyle_get_filter(style, &str);
3984 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3985 ok(!str, "filter != NULL\n");
3987 str = a2bstr("alpha(opacity=100)");
3988 hres = IHTMLStyle_put_filter(style, str);
3989 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3992 V_VT(&v) = VT_EMPTY;
3993 hres = IHTMLStyle_get_zIndex(style, &v);
3994 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3995 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3996 ok(!V_I4(&v), "V_I4(v) != 0\n");
4000 V_BSTR(&v) = a2bstr("1");
4001 hres = IHTMLStyle_put_zIndex(style, v);
4002 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4005 V_VT(&v) = VT_EMPTY;
4006 hres = IHTMLStyle_get_zIndex(style, &v);
4007 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4008 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4009 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4013 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4014 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4016 str = a2bstr("test");
4017 hres = IHTMLStyle_put_fontStyle(style, str);
4018 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4021 str = a2bstr("italic");
4022 hres = IHTMLStyle_put_fontStyle(style, str);
4023 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4026 str = a2bstr("oblique");
4027 hres = IHTMLStyle_put_fontStyle(style, str);
4028 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4031 str = a2bstr("normal");
4032 hres = IHTMLStyle_put_fontStyle(style, str);
4033 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4036 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4037 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4038 SysFreeString(sDefault);
4041 hres = IHTMLStyle_get_overflow(style, NULL);
4042 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4044 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4045 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4047 str = a2bstr("test");
4048 hres = IHTMLStyle_put_overflow(style, str);
4049 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4052 str = a2bstr("visible");
4053 hres = IHTMLStyle_put_overflow(style, str);
4054 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4057 str = a2bstr("scroll");
4058 hres = IHTMLStyle_put_overflow(style, str);
4059 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4062 str = a2bstr("hidden");
4063 hres = IHTMLStyle_put_overflow(style, str);
4064 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4067 str = a2bstr("auto");
4068 hres = IHTMLStyle_put_overflow(style, str);
4069 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4072 hres = IHTMLStyle_get_overflow(style, &str);
4073 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4074 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4078 hres = IHTMLStyle_put_overflow(style, str);
4079 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4082 hres = IHTMLStyle_get_overflow(style, &str);
4083 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4084 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4087 /* restore overflow default */
4088 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4089 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4090 SysFreeString(sOverflowDefault);
4092 /* Attribute Tests*/
4093 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4094 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4096 str = a2bstr("position");
4097 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4098 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4100 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4101 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4102 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4105 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4106 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4109 V_BSTR(&v) = a2bstr("absolute");
4110 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4111 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4114 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4115 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4116 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4117 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4122 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4123 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4128 str = a2bstr("borderLeftStyle");
4129 test_border_styles(style, str);
4132 str = a2bstr("borderbottomstyle");
4133 test_border_styles(style, str);
4136 str = a2bstr("borderrightstyle");
4137 test_border_styles(style, str);
4140 str = a2bstr("bordertopstyle");
4141 test_border_styles(style, str);
4144 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4145 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4147 str = a2bstr("none dotted dashed solid");
4148 hres = IHTMLStyle_put_borderStyle(style, str);
4149 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4152 str = a2bstr("none dotted dashed solid");
4153 hres = IHTMLStyle_get_borderStyle(style, &str);
4154 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4155 ok(!strcmp_wa(str, "none dotted dashed solid"),
4156 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4159 str = a2bstr("double groove ridge inset");
4160 hres = IHTMLStyle_put_borderStyle(style, str);
4161 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4164 str = a2bstr("window-inset outset ridge inset");
4165 hres = IHTMLStyle_put_borderStyle(style, str);
4166 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4169 str = a2bstr("window-inset");
4170 hres = IHTMLStyle_put_borderStyle(style, str);
4171 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4174 str = a2bstr("none none none none none");
4175 hres = IHTMLStyle_put_borderStyle(style, str);
4176 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4179 str = a2bstr("invalid none none none");
4180 hres = IHTMLStyle_put_borderStyle(style, str);
4181 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4184 str = a2bstr("none invalid none none");
4185 hres = IHTMLStyle_put_borderStyle(style, str);
4186 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4189 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4190 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4191 SysFreeString(sDefault);
4193 /* backgoundColor */
4194 hres = IHTMLStyle_get_backgroundColor(style, &v);
4195 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4196 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4197 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4201 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4202 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4205 V_BSTR(&v) = a2bstr("10");
4206 hres = IHTMLStyle_put_paddingLeft(style, v);
4207 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4210 hres = IHTMLStyle_get_paddingLeft(style, &v);
4211 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4212 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4214 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4215 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4217 /* BackgroundRepeat */
4218 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4219 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4221 str = a2bstr("invalid");
4222 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4223 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4226 str = a2bstr("repeat");
4227 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4228 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4231 str = a2bstr("no-repeat");
4232 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4233 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4236 str = a2bstr("repeat-x");
4237 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4238 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4241 str = a2bstr("repeat-y");
4242 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4243 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4246 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4247 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4248 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4251 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4252 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4253 SysFreeString(sDefault);
4256 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4257 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4259 str = a2bstr("red green red blue");
4260 hres = IHTMLStyle_put_borderColor(style, str);
4261 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4264 hres = IHTMLStyle_get_borderColor(style, &str);
4265 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4266 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4269 hres = IHTMLStyle_put_borderColor(style, sDefault);
4270 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4271 SysFreeString(sDefault);
4274 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4275 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4277 str = a2bstr("thick dotted red");
4278 hres = IHTMLStyle_put_borderLeft(style, str);
4279 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4282 /* IHTMLStyle_get_borderLeft appears to have a bug where
4283 it returns the first letter of the color. So we check
4284 each style individually.
4287 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4288 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4289 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4293 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4294 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4295 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4298 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4299 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4300 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4303 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4304 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4305 SysFreeString(sDefault);
4307 /* backgroundPositionX */
4308 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4309 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4312 V_BSTR(&v) = a2bstr("10px");
4313 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4314 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4317 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4318 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4319 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4322 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4323 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4324 VariantClear(&vDefault);
4326 /* backgroundPositionY */
4327 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4328 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4331 V_BSTR(&v) = a2bstr("10px");
4332 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4333 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4336 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4337 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4338 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4341 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4342 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4343 VariantClear(&vDefault);
4345 /* borderTopWidth */
4346 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4347 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4350 V_BSTR(&v) = a2bstr("10px");
4351 hres = IHTMLStyle_put_borderTopWidth(style, v);
4352 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4355 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4356 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4357 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4360 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4361 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4362 VariantClear(&vDefault);
4364 /* borderRightWidth */
4365 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4366 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4369 V_BSTR(&v) = a2bstr("10");
4370 hres = IHTMLStyle_put_borderRightWidth(style, v);
4371 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4374 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4375 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4376 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4379 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4380 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4381 VariantClear(&vDefault);
4383 /* borderBottomWidth */
4384 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4385 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4388 V_BSTR(&v) = a2bstr("10");
4389 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4390 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4393 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4394 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4395 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4398 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4399 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4400 VariantClear(&vDefault);
4402 /* borderLeftWidth */
4403 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4404 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4407 V_BSTR(&v) = a2bstr("10");
4408 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4409 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4412 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4413 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4414 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4417 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4418 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4419 VariantClear(&vDefault);
4422 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4423 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4426 V_BSTR(&v) = a2bstr("10");
4427 hres = IHTMLStyle_put_wordSpacing(style, v);
4428 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4431 hres = IHTMLStyle_get_wordSpacing(style, &v);
4432 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4433 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4434 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4437 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4438 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4439 VariantClear(&vDefault);
4442 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4443 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4446 V_BSTR(&v) = a2bstr("11");
4447 hres = IHTMLStyle_put_letterSpacing(style, v);
4448 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4451 hres = IHTMLStyle_get_letterSpacing(style, &v);
4452 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4453 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4454 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4457 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4458 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4459 VariantClear(&vDefault);
4461 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4462 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4463 if(SUCCEEDED(hres)) {
4464 test_style2(style2);
4465 IHTMLStyle2_Release(style2);
4468 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4469 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4470 if(SUCCEEDED(hres)) {
4471 test_style3(style3);
4472 IHTMLStyle3_Release(style3);
4475 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4476 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4477 if(SUCCEEDED(hres)) {
4478 test_style4(style4);
4479 IHTMLStyle4_Release(style4);
4483 static void test_set_csstext(IHTMLStyle *style)
4488 test_style_set_csstext(style, "background-color: black;");
4490 hres = IHTMLStyle_get_backgroundColor(style, &v);
4491 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4492 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4493 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4497 static void test_default_selection(IHTMLDocument2 *doc)
4499 IHTMLSelectionObject *selection;
4500 IHTMLTxtRange *range;
4505 hres = IHTMLDocument2_get_selection(doc, &selection);
4506 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4508 hres = IHTMLSelectionObject_get_type(selection, &str);
4509 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4510 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4513 hres = IHTMLSelectionObject_createRange(selection, &disp);
4514 IHTMLSelectionObject_Release(selection);
4515 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4517 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4518 IDispatch_Release(disp);
4519 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4521 test_range_text(range, NULL);
4522 IHTMLTxtRange_Release(range);
4525 static void test_doc_elem(IHTMLDocument2 *doc)
4527 IHTMLDocument2 *doc_node, *owner_doc;
4529 IHTMLDocument3 *doc3;
4532 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4533 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4535 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4536 IHTMLDocument3_Release(doc3);
4537 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4539 test_node_name((IUnknown*)elem, "HTML");
4540 test_elem_tag((IUnknown*)elem, "HTML");
4542 doc_node = get_doc_node(doc);
4543 owner_doc = get_owner_doc((IUnknown*)elem);
4544 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4545 IHTMLDocument2_Release(owner_doc);
4547 owner_doc = get_owner_doc((IUnknown*)doc_node);
4548 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4549 IHTMLDocument2_Release(doc_node);
4551 test_elem_client_rect((IUnknown*)elem);
4553 IHTMLElement_Release(elem);
4556 static void test_default_body(IHTMLBodyElement *body)
4562 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4563 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4565 bstr = (void*)0xdeadbeef;
4566 hres = IHTMLBodyElement_get_background(body, &bstr);
4567 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4568 ok(bstr == NULL, "bstr != NULL\n");
4570 l = elem_get_scroll_height((IUnknown*)body);
4571 ok(l != -1, "scrollHeight == -1\n");
4572 l = elem_get_scroll_width((IUnknown*)body);
4573 ok(l != -1, "scrollWidth == -1\n");
4574 l = elem_get_scroll_top((IUnknown*)body);
4575 ok(!l, "scrollTop = %d\n", l);
4576 elem_get_scroll_left((IUnknown*)body);
4578 /* get_text tests */
4579 hres = IHTMLBodyElement_get_text(body, &v);
4580 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4581 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4582 ok(bstr == NULL, "bstr != NULL\n");
4585 /* get_text - Invalid Text */
4587 V_BSTR(&v) = SysAllocString(sTextInvalid);
4588 hres = IHTMLBodyElement_put_text(body, v);
4589 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4593 hres = IHTMLBodyElement_get_text(body, &v);
4594 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4595 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4596 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4599 /* get_text - Valid Text */
4601 V_BSTR(&v) = SysAllocString(sBodyText);
4602 hres = IHTMLBodyElement_put_text(body, v);
4603 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4607 hres = IHTMLBodyElement_get_text(body, &v);
4608 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4609 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4610 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4614 static void test_body_funs(IHTMLBodyElement *body)
4616 static WCHAR sRed[] = {'r','e','d',0};
4621 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4622 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4623 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4625 V_VT(&vbg) = VT_BSTR;
4626 V_BSTR(&vbg) = SysAllocString(sRed);
4627 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4628 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4631 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4632 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4633 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4634 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4637 /* Restore Originial */
4638 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4639 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4640 VariantClear(&vDefaultbg);
4643 static void test_window(IHTMLDocument2 *doc)
4645 IHTMLWindow2 *window, *window2, *self;
4646 IHTMLDocument2 *doc2 = NULL;
4652 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4653 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4654 test_ifaces((IUnknown*)window, window_iids);
4655 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4657 hres = IHTMLWindow2_get_document(window, &doc2);
4658 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4659 ok(doc2 != NULL, "doc2 == NULL\n");
4661 test_ifaces((IUnknown*)doc2, doc_node_iids);
4662 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4664 test_ifaces((IUnknown*)doc, doc_obj_iids);
4665 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4667 unk = (void*)0xdeadbeef;
4668 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4669 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4670 ok(!unk, "unk = %p\n", unk);
4672 IHTMLDocument_Release(doc2);
4674 hres = IHTMLWindow2_get_window(window, &window2);
4675 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4676 ok(window2 != NULL, "window2 == NULL\n");
4678 hres = IHTMLWindow2_get_self(window, &self);
4679 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4680 ok(window2 != NULL, "self == NULL\n");
4682 ok(self == window2, "self != window2\n");
4684 IHTMLWindow2_Release(window2);
4685 IHTMLWindow2_Release(self);
4688 hres = IHTMLDocument2_get_Script(doc, &disp);
4689 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4690 ok(disp == (void*)window, "disp != window\n");
4691 IDispatch_Release(disp);
4693 hres = IHTMLWindow2_toString(window, NULL);
4694 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4697 hres = IHTMLWindow2_toString(window, &str);
4698 ok(hres == S_OK, "toString failed: %08x\n", hres);
4699 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4702 test_window_name(window, NULL);
4703 set_window_name(window, "test");
4704 test_window_length(window, 0);
4705 test_screen(window);
4707 IHTMLWindow2_Release(window);
4710 static void test_defaults(IHTMLDocument2 *doc)
4712 IHTMLStyleSheetsCollection *stylesheetcol;
4713 IHTMLCurrentStyle *cstyle;
4714 IHTMLBodyElement *body;
4715 IHTMLElement2 *elem2;
4720 IHTMLElementCollection *collection;
4722 hres = IHTMLDocument2_get_body(doc, &elem);
4723 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4725 hres = IHTMLDocument2_get_images(doc, NULL);
4726 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4728 hres = IHTMLDocument2_get_images(doc, &collection);
4729 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4732 test_elem_collection((IUnknown*)collection, NULL, 0);
4733 IHTMLElementCollection_Release(collection);
4736 hres = IHTMLDocument2_get_applets(doc, NULL);
4737 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4739 hres = IHTMLDocument2_get_applets(doc, &collection);
4740 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4743 test_elem_collection((IUnknown*)collection, NULL, 0);
4744 IHTMLElementCollection_Release(collection);
4747 hres = IHTMLDocument2_get_links(doc, NULL);
4748 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4750 hres = IHTMLDocument2_get_links(doc, &collection);
4751 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4754 test_elem_collection((IUnknown*)collection, NULL, 0);
4755 IHTMLElementCollection_Release(collection);
4758 hres = IHTMLDocument2_get_forms(doc, NULL);
4759 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4761 hres = IHTMLDocument2_get_forms(doc, &collection);
4762 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4765 test_elem_collection((IUnknown*)collection, NULL, 0);
4766 IHTMLElementCollection_Release(collection);
4769 hres = IHTMLDocument2_get_anchors(doc, NULL);
4770 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4772 hres = IHTMLDocument2_get_anchors(doc, &collection);
4773 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4776 test_elem_collection((IUnknown*)collection, NULL, 0);
4777 IHTMLElementCollection_Release(collection);
4780 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4781 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4782 test_default_body(body);
4783 test_body_funs(body);
4784 IHTMLBodyElement_Release(body);
4786 hres = IHTMLElement_get_style(elem, &style);
4787 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4789 test_default_style(style);
4791 test_compatmode(doc);
4793 test_navigator(doc);
4795 elem2 = get_elem2_iface((IUnknown*)elem);
4796 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4797 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4798 if(SUCCEEDED(hres)) {
4799 test_current_style(cstyle);
4800 IHTMLCurrentStyle_Release(cstyle);
4802 IHTMLElement2_Release(elem2);
4804 IHTMLElement_Release(elem);
4806 test_set_csstext(style);
4807 IHTMLStyle_Release(style);
4809 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4810 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4813 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4814 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4815 ok(l == 0, "length = %d\n", l);
4817 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4819 test_default_selection(doc);
4820 test_doc_title(doc, "");
4823 static void test_tr_elem(IHTMLElement *elem)
4825 IHTMLElementCollection *col;
4829 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4831 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4832 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4837 hres = IHTMLTableRow_get_cells(row, &col);
4838 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4839 ok(col != NULL, "get_cells returned NULL\n");
4841 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4842 IHTMLElementCollection_Release(col);
4844 IHTMLTable_Release(row);
4847 static void test_table_elem(IHTMLElement *elem)
4849 IHTMLElementCollection *col;
4854 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4855 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4857 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4858 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4863 hres = IHTMLTable_get_rows(table, &col);
4864 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4865 ok(col != NULL, "get_ros returned NULL\n");
4867 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4868 IHTMLElementCollection_Release(col);
4870 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4872 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4873 test_elem_tag((IUnknown*)node, "TABLE");
4874 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4875 IHTMLDOMNode_Release(node);
4877 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4878 test_elem_tag((IUnknown*)node, "TABLE");
4879 test_elem_all((IUnknown*)node, NULL, 0);
4880 IHTMLDOMNode_Release(node);
4882 IHTMLTable_Release(table);
4885 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4895 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4896 SafeArrayAccessData(sa, (void**)&var);
4897 V_VT(var) = VT_BSTR;
4898 V_BSTR(var) = str = a2bstr(text);
4899 SafeArrayUnaccessData(sa);
4902 hres = IHTMLDocument2_writeln(doc, sa);
4904 hres = IHTMLDocument2_write(doc, sa);
4905 ok(hres == S_OK, "write failed: %08x\n", hres);
4908 SafeArrayDestroy(sa);
4911 static void test_frame_doc(IUnknown *frame_elem)
4913 IHTMLDocument2 *window_doc, *elem_doc;
4914 IHTMLWindow2 *content_window;
4916 content_window = get_frame_content_window(frame_elem);
4917 window_doc = get_window_doc(content_window);
4918 IHTMLWindow2_Release(content_window);
4920 elem_doc = get_elem_doc(frame_elem);
4921 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
4923 IHTMLDocument2_Release(elem_doc);
4924 IHTMLDocument2_Release(window_doc);
4927 static void test_iframe_elem(IHTMLElement *elem)
4929 IHTMLDocument2 *content_doc, *owner_doc;
4930 IHTMLElementCollection *col;
4931 IHTMLWindow2 *content_window;
4937 static const elem_type_t all_types[] = {
4945 test_frame_doc((IUnknown*)elem);
4947 content_window = get_frame_content_window((IUnknown*)elem);
4948 test_window_length(content_window, 0);
4950 content_doc = get_window_doc(content_window);
4951 IHTMLWindow2_Release(content_window);
4953 str = a2bstr("text/html");
4954 V_VT(&errv) = VT_ERROR;
4956 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4958 ok(hres == S_OK, "open failed: %08x\n", hres);
4959 ok(disp != NULL, "disp == NULL\n");
4960 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4961 IDispatch_Release(disp);
4963 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4964 doc_write(content_doc, TRUE, "</html>");
4966 hres = IHTMLDocument2_get_all(content_doc, &col);
4967 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4968 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4969 IHTMLElementCollection_Release(col);
4971 hres = IHTMLDocument2_close(content_doc);
4972 ok(hres == S_OK, "close failed: %08x\n", hres);
4974 owner_doc = get_owner_doc((IUnknown*)content_doc);
4975 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4977 IHTMLDocument2_Release(content_doc);
4980 static void test_stylesheet(IDispatch *disp)
4982 IHTMLStyleSheetRulesCollection *col = NULL;
4983 IHTMLStyleSheet *stylesheet;
4986 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4987 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4989 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4990 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4991 ok(col != NULL, "col == NULL\n");
4993 IHTMLStyleSheetRulesCollection_Release(col);
4994 IHTMLStyleSheet_Release(stylesheet);
4997 static void test_stylesheets(IHTMLDocument2 *doc)
4999 IHTMLStyleSheetsCollection *col = NULL;
5004 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5005 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5006 ok(col != NULL, "col == NULL\n");
5008 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5009 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5010 ok(len == 1, "len=%d\n", len);
5016 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5017 ok(hres == S_OK, "item failed: %08x\n", hres);
5018 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5019 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5020 test_stylesheet(V_DISPATCH(&res));
5027 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5028 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5029 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5030 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5033 IHTMLStyleSheetsCollection_Release(col);
5036 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5038 IDispatchEx *dispex;
5040 DISPPARAMS dp = {NULL, NULL, 0, 0};
5048 static const WCHAR w0[] = {'0',0};
5049 static const WCHAR w100[] = {'1','0','0',0};
5051 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5052 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5054 bstr = SysAllocString(w0);
5055 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5056 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5057 SysFreeString(bstr);
5060 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5061 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5062 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5063 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5064 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5065 type = get_node_type((IUnknown*)node);
5066 ok(type == 3, "type=%d\n", type);
5067 IHTMLDOMNode_Release(node);
5070 bstr = SysAllocString(w100);
5071 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5072 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5073 SysFreeString(bstr);
5075 IDispatchEx_Release(dispex);
5080 static void test_elems(IHTMLDocument2 *doc)
5082 IHTMLElementCollection *col;
5083 IHTMLDOMChildrenCollection *child_col;
5084 IHTMLElement *elem, *elem2, *elem3;
5085 IHTMLDOMNode *node, *node2;
5086 IHTMLWindow2 *window;
5090 IHTMLElementCollection *collection;
5091 IHTMLDocument3 *doc3;
5094 static const elem_type_t all_types[] = {
5119 static const elem_type_t item_types[] = {
5125 hres = IHTMLDocument2_get_all(doc, &col);
5126 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5127 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5128 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5129 IHTMLElementCollection_Release(col);
5131 hres = IHTMLDocument2_get_images(doc, &collection);
5132 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5135 static const elem_type_t images_types[] = {ET_IMG};
5136 test_elem_collection((IUnknown*)collection, images_types, 1);
5138 IHTMLElementCollection_Release(collection);
5141 hres = IHTMLDocument2_get_links(doc, &collection);
5142 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5145 static const elem_type_t images_types[] = {ET_A};
5146 test_elem_collection((IUnknown*)collection, images_types, 1);
5148 IHTMLElementCollection_Release(collection);
5151 hres = IHTMLDocument2_get_anchors(doc, &collection);
5152 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5155 static const elem_type_t anchor_types[] = {ET_A};
5156 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5158 IHTMLElementCollection_Release(collection);
5161 elem = get_doc_elem(doc);
5162 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5163 IHTMLElement_Release(elem);
5165 get_elem_by_id(doc, "xxx", FALSE);
5166 elem = get_doc_elem_by_id(doc, "xxx");
5167 ok(!elem, "elem != NULL\n");
5169 elem = get_doc_elem_by_id(doc, "s");
5170 ok(elem != NULL, "elem == NULL\n");
5172 test_elem_type((IUnknown*)elem, ET_SELECT);
5173 test_elem_attr(elem, "xxx", NULL);
5174 test_elem_attr(elem, "id", "s");
5175 test_elem_class((IUnknown*)elem, NULL);
5176 test_elem_set_class((IUnknown*)elem, "cl");
5177 test_elem_set_class((IUnknown*)elem, NULL);
5178 test_elem_tabindex((IUnknown*)elem, 0);
5179 test_elem_set_tabindex((IUnknown*)elem, 1);
5181 node = test_node_get_parent((IUnknown*)elem);
5182 ok(node != NULL, "node == NULL\n");
5183 test_node_name((IUnknown*)node, "BODY");
5184 node2 = test_node_get_parent((IUnknown*)node);
5185 IHTMLDOMNode_Release(node);
5186 ok(node2 != NULL, "node == NULL\n");
5187 test_node_name((IUnknown*)node2, "HTML");
5188 node = test_node_get_parent((IUnknown*)node2);
5189 IHTMLDOMNode_Release(node2);
5190 ok(node != NULL, "node == NULL\n");
5193 test_node_name((IUnknown*)node, "#document");
5194 type = get_node_type((IUnknown*)node);
5195 ok(type == 9, "type=%d, expected 9\n", type);
5196 node2 = test_node_get_parent((IUnknown*)node);
5197 IHTMLDOMNode_Release(node);
5198 ok(node2 == NULL, "node != NULL\n");
5201 elem2 = test_elem_get_parent((IUnknown*)elem);
5202 ok(elem2 != NULL, "elem2 == NULL\n");
5203 test_node_name((IUnknown*)elem2, "BODY");
5204 elem3 = test_elem_get_parent((IUnknown*)elem2);
5205 IHTMLElement_Release(elem2);
5206 ok(elem3 != NULL, "elem3 == NULL\n");
5207 test_node_name((IUnknown*)elem3, "HTML");
5208 elem2 = test_elem_get_parent((IUnknown*)elem3);
5209 IHTMLElement_Release(elem3);
5210 ok(elem2 == NULL, "elem2 != NULL\n");
5212 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5213 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5214 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5216 test_elem_innertext(elem, "opt1opt2");
5218 IHTMLElement_Release(elem);
5221 elem = get_elem_by_id(doc, "s", TRUE);
5223 IHTMLSelectElement *select;
5224 IHTMLDocument2 *doc_node, *elem_doc;
5226 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5227 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5229 test_select_elem(select);
5231 test_elem_title((IUnknown*)select, NULL);
5232 test_elem_set_title((IUnknown*)select, "Title");
5233 test_elem_title((IUnknown*)select, "Title");
5234 test_elem_offset((IUnknown*)select);
5236 node = get_first_child((IUnknown*)select);
5237 ok(node != NULL, "node == NULL\n");
5239 test_elem_type((IUnknown*)node, ET_OPTION);
5240 IHTMLDOMNode_Release(node);
5243 type = get_node_type((IUnknown*)select);
5244 ok(type == 1, "type=%d\n", type);
5246 IHTMLSelectElement_Release(select);
5248 elem_doc = get_elem_doc((IUnknown*)elem);
5250 doc_node = get_doc_node(doc);
5251 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5252 IHTMLDocument2_Release(doc_node);
5253 IHTMLDocument2_Release(elem_doc);
5255 IHTMLElement_Release(elem);
5258 elem = get_elem_by_id(doc, "sc", TRUE);
5260 IHTMLScriptElement *script;
5263 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5264 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5270 hres = IHTMLScriptElement_get_type(script, &type);
5271 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5272 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5273 SysFreeString(type);
5276 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5277 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5279 hres = IHTMLScriptElement_get_defer(script, &vb);
5280 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5281 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5283 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5284 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5287 IHTMLScriptElement_Release(script);
5290 elem = get_elem_by_id(doc, "in", TRUE);
5292 IHTMLInputElement *input;
5294 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5295 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5297 test_elem_id((IUnknown*)elem, "in");
5298 test_elem_put_id((IUnknown*)elem, "newin");
5299 test_input_get_disabled(input, VARIANT_FALSE);
5300 test_input_set_disabled(input, VARIANT_TRUE);
5301 test_input_set_disabled(input, VARIANT_FALSE);
5302 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5303 test_input_get_disabled(input, VARIANT_TRUE);
5304 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5305 test_input_get_disabled(input, VARIANT_FALSE);
5306 test_elem_client_size((IUnknown*)elem);
5308 test_node_get_value_str((IUnknown*)elem, NULL);
5309 test_node_put_value_str((IUnknown*)elem, "test");
5310 test_node_get_value_str((IUnknown*)elem, NULL);
5311 test_input_value((IUnknown*)elem, NULL);
5312 test_input_put_value((IUnknown*)elem, "test");
5313 test_input_value((IUnknown*)elem, NULL);
5314 test_elem_class((IUnknown*)elem, "testclass");
5315 test_elem_tabindex((IUnknown*)elem, 2);
5316 test_elem_set_tabindex((IUnknown*)elem, 3);
5317 test_elem_title((IUnknown*)elem, "test title");
5319 test_input_get_defaultchecked(input, VARIANT_FALSE);
5320 test_input_set_defaultchecked(input, VARIANT_TRUE);
5321 test_input_set_defaultchecked(input, VARIANT_FALSE);
5323 test_input_get_checked(input, VARIANT_FALSE);
5324 test_input_set_checked(input, VARIANT_TRUE);
5325 test_input_set_checked(input, VARIANT_FALSE);
5327 test_input_src(input, NULL);
5328 test_input_set_src(input, "about:blank");
5330 IHTMLInputElement_Release(input);
5331 IHTMLElement_Release(elem);
5334 elem = get_elem_by_id(doc, "imgid", TRUE);
5336 test_img_src((IUnknown*)elem, "");
5337 test_img_set_src((IUnknown*)elem, "about:blank");
5338 test_img_alt((IUnknown*)elem, NULL);
5339 test_img_set_alt((IUnknown*)elem, "alt test");
5340 IHTMLElement_Release(elem);
5343 elem = get_doc_elem_by_id(doc, "tbl");
5344 ok(elem != NULL, "elem == NULL\n");
5346 test_table_elem(elem);
5347 IHTMLElement_Release(elem);
5350 elem = get_doc_elem_by_id(doc, "row2");
5351 ok(elem != NULL, "elem == NULL\n");
5354 IHTMLElement_Release(elem);
5357 elem = get_doc_elem_by_id(doc, "ifr");
5358 ok(elem != NULL, "elem == NULL\n");
5360 test_iframe_elem(elem);
5361 IHTMLElement_Release(elem);
5364 elem = get_elem_by_id(doc, "a", TRUE);
5366 test_anchor_href((IUnknown*)elem, "http://test/");
5367 IHTMLElement_Release(elem);
5370 hres = IHTMLDocument2_get_body(doc, &elem);
5371 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5373 node = get_first_child((IUnknown*)elem);
5374 ok(node != NULL, "node == NULL\n");
5376 test_ifaces((IUnknown*)node, text_iids);
5377 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5379 node2 = get_first_child((IUnknown*)node);
5380 ok(!node2, "node2 != NULL\n");
5382 type = get_node_type((IUnknown*)node);
5383 ok(type == 3, "type=%d\n", type);
5385 test_node_get_value_str((IUnknown*)node, "text test");
5386 test_node_put_value_str((IUnknown*)elem, "test text");
5387 test_node_get_value_str((IUnknown*)node, "text test");
5389 IHTMLDOMNode_Release(node);
5392 child_col = get_child_nodes((IUnknown*)elem);
5393 ok(child_col != NULL, "child_coll == NULL\n");
5397 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5399 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5400 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5401 ok(length, "length=0\n");
5404 node = get_child_item(child_col, 0);
5405 ok(node != NULL, "node == NULL\n");
5407 type = get_node_type((IUnknown*)node);
5408 ok(type == 3, "type=%d\n", type);
5409 node2 = node_get_next((IUnknown*)node);
5410 IHTMLDOMNode_Release(node);
5413 node = get_child_item(child_col, 1);
5414 ok(node != NULL, "node == NULL\n");
5416 type = get_node_type((IUnknown*)node);
5417 ok(type == 8, "type=%d\n", type);
5419 test_elem_id((IUnknown*)node, NULL);
5420 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5421 IHTMLDOMNode_Release(node2);
5422 IHTMLDOMNode_Release(node);
5425 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5426 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5428 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5429 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5431 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5432 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5434 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5435 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5437 test_child_col_disp(child_col);
5439 IHTMLDOMChildrenCollection_Release(child_col);
5442 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5443 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5444 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5446 IHTMLElement_Release(elem);
5448 test_stylesheets(doc);
5449 test_create_option_elem(doc);
5450 test_create_img_elem(doc);
5452 elem = get_doc_elem_by_id(doc, "tbl");
5453 ok(elem != NULL, "elem = NULL\n");
5454 test_elem_set_innertext(elem, "inner text");
5455 IHTMLElement_Release(elem);
5457 test_doc_title(doc, "test");
5458 test_doc_set_title(doc, "test title");
5459 test_doc_title(doc, "test title");
5462 hres = IHTMLDocument2_get_Script(doc, &disp);
5463 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5466 IDispatchEx *dispex;
5467 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5468 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5472 BSTR str = a2bstr("Testing");
5473 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5474 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5475 ok(pid != -1, "pid == -1\n");
5477 IDispatchEx_Release(dispex);
5480 IDispatch_Release(disp);
5482 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5483 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5485 str = a2bstr("img");
5486 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5487 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5491 static const elem_type_t img_types[] = { ET_IMG };
5493 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5494 IHTMLElementCollection_Release(col);
5497 elem = get_doc_elem_by_id(doc, "y");
5498 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5499 test_elem_innerhtml((IUnknown*)elem, "inner html");
5500 test_elem_set_innerhtml((IUnknown*)elem, "");
5501 test_elem_innerhtml((IUnknown*)elem, NULL);
5502 node = node_get_next((IUnknown*)elem);
5503 ok(!node, "node = %p\n", node);
5505 elem2 = get_doc_elem_by_id(doc, "x");
5506 test_elem_tag((IUnknown*)elem2, "A");
5507 node = node_get_next((IUnknown*)elem2);
5508 IHTMLDOMNode_Release(node);
5509 IHTMLElement_Release(elem2);
5510 IHTMLElement_Release(elem);
5512 IHTMLDocument3_Release(doc3);
5514 window = get_doc_window(doc);
5515 test_window_name(window, NULL);
5516 set_window_name(window, "test name");
5517 test_window_length(window, 1);
5518 IHTMLWindow2_Release(window);
5521 static void test_elems2(IHTMLDocument2 *doc)
5523 IHTMLElement *elem, *elem2;
5525 static const elem_type_t outer_types[] = {
5530 elem = get_doc_elem_by_id(doc, "divid");
5532 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5533 elem2 = get_doc_elem_by_id(doc, "innerid");
5534 ok(elem2 != NULL, "elem2 == NULL\n");
5535 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5536 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5537 IHTMLElement_Release(elem2);
5539 elem2 = get_doc_elem_by_id(doc, "aid");
5540 ok(elem2 != NULL, "elem2 == NULL\n");
5541 test_elem_set_outerhtml((IUnknown*)elem2, "");
5542 test_elem_all((IUnknown*)elem, outer_types, 1);
5543 IHTMLElement_Release(elem2);
5545 IHTMLElement_Release(elem);
5548 static void test_create_elems(IHTMLDocument2 *doc)
5550 IHTMLElement *elem, *body, *elem2;
5551 IHTMLDOMNode *node, *node2, *node3, *comment;
5552 IHTMLDocument5 *doc5;
5559 static const elem_type_t types1[] = { ET_TESTG };
5561 elem = test_create_elem(doc, "TEST");
5562 test_elem_tag((IUnknown*)elem, "TEST");
5563 type = get_node_type((IUnknown*)elem);
5564 ok(type == 1, "type=%d\n", type);
5565 test_ifaces((IUnknown*)elem, elem_iids);
5566 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5568 hres = IHTMLDocument2_get_body(doc, &body);
5569 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5570 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5572 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5573 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5574 elem2 = get_elem_iface((IUnknown*)node);
5575 IHTMLElement_Release(elem2);
5577 hres = IHTMLElement_get_all(body, &disp);
5578 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5579 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5580 IDispatch_Release(disp);
5582 test_node_remove_child((IUnknown*)body, node);
5584 hres = IHTMLElement_get_all(body, &disp);
5585 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5586 test_elem_collection((IUnknown*)disp, NULL, 0);
5587 IDispatch_Release(disp);
5588 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5590 IHTMLElement_Release(elem);
5591 IHTMLDOMNode_Release(node);
5593 node = test_create_text(doc, "test");
5594 test_ifaces((IUnknown*)node, text_iids);
5595 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5597 V_VT(&var) = VT_NULL;
5598 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5599 IHTMLDOMNode_Release(node);
5601 node = test_create_text(doc, "insert ");
5603 V_VT(&var) = VT_DISPATCH;
5604 V_DISPATCH(&var) = (IDispatch*)node2;
5605 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5606 IHTMLDOMNode_Release(node);
5607 IHTMLDOMNode_Release(node2);
5608 IHTMLDOMNode_Release(node3);
5610 test_elem_innertext(body, "insert test");
5611 test_elem_innerhtml((IUnknown*)body, "insert test");
5613 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5616 str = a2bstr("testing");
5617 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5619 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5622 type = get_node_type((IUnknown*)comment);
5623 ok(type == 8, "type=%d, expected 8\n", type);
5625 test_node_get_value_str((IUnknown*)comment, "testing");
5627 IHTMLDOMNode_Release(comment);
5630 IHTMLDocument5_Release(doc5);
5633 IHTMLElement_Release(body);
5636 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5638 IOleCommandTarget *cmdtrg;
5641 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5642 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5644 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5645 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5647 IOleCommandTarget_Release(cmdtrg);
5650 static void test_indent(IHTMLDocument2 *doc)
5652 IHTMLElementCollection *col;
5653 IHTMLTxtRange *range;
5656 static const elem_type_t all_types[] = {
5665 static const elem_type_t indent_types[] = {
5676 hres = IHTMLDocument2_get_all(doc, &col);
5677 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5678 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5679 IHTMLElementCollection_Release(col);
5681 range = test_create_body_range(doc);
5682 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5683 IHTMLTxtRange_Release(range);
5685 hres = IHTMLDocument2_get_all(doc, &col);
5686 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5687 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5688 IHTMLElementCollection_Release(col);
5691 static void test_cond_comment(IHTMLDocument2 *doc)
5693 IHTMLElementCollection *col;
5696 static const elem_type_t all_types[] = {
5704 hres = IHTMLDocument2_get_all(doc, &col);
5705 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5706 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5707 IHTMLElementCollection_Release(col);
5710 static void test_frame(IDispatch *disp, const char *exp_id)
5712 IHTMLWindow2 *frame2, *parent, *top;
5713 IHTMLDocument2 *parent_doc, *top_doc;
5714 IHTMLWindow4 *frame;
5715 IHTMLFrameBase *frame_elem;
5718 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5719 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5723 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5724 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5725 IHTMLWindow4_Release(frame);
5729 test_frame_doc((IUnknown*)frame_elem);
5730 test_elem_id((IUnknown*)frame_elem, exp_id);
5731 IHTMLElement_Release(frame_elem);
5733 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5734 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5738 hres = IHTMLWindow2_get_parent(frame2, &parent);
5739 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5741 IHTMLWindow2_Release(frame2);
5745 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5746 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5747 IHTMLWindow2_Release(parent);
5749 IHTMLWindow2_Release(frame2);
5753 test_doc_title(parent_doc, "frameset test");
5754 IHTMLDocument2_Release(parent_doc);
5757 hres = IHTMLWindow2_get_top(frame2, &top);
5758 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5759 IHTMLWindow2_Release(frame2);
5763 hres = IHTMLWindow2_get_document(top, &top_doc);
5764 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5765 IHTMLWindow2_Release(top);
5769 test_doc_title(top_doc, "frameset test");
5770 IHTMLDocument2_Release(top_doc);
5773 static void test_frameset(IHTMLDocument2 *doc)
5775 IHTMLWindow2 *window;
5776 IHTMLFramesCollection2 *frames;
5779 VARIANT index_var, result_var;
5782 window = get_doc_window(doc);
5784 /* test using IHTMLFramesCollection object */
5786 hres = IHTMLWindow2_get_frames(window, &frames);
5787 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5788 IHTMLWindow2_Release(window);
5792 /* test result length */
5793 hres = IHTMLFramesCollection2_get_length(frames, &length);
5794 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5795 ok(length == 2, "IHTMLFramesCollection2_get_length should have been 2, was: %d\n", length);
5797 /* test first frame */
5798 V_VT(&index_var) = VT_I4;
5799 V_I4(&index_var) = 0;
5800 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5801 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5802 if(SUCCEEDED(hres)) {
5803 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5804 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5806 VariantClear(&result_var);
5808 /* test second frame */
5809 V_I4(&index_var) = 1;
5810 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5811 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5812 if(SUCCEEDED(hres)) {
5813 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5814 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5816 VariantClear(&result_var);
5818 /* fail on third frame */
5819 V_I4(&index_var) = 2;
5820 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5821 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5822 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5823 VariantClear(&result_var);
5825 /* string argument (element id lookup) */
5826 V_VT(&index_var) = VT_BSTR;
5827 V_BSTR(&index_var) = a2bstr("fr1");
5828 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5829 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5830 if(SUCCEEDED(hres)) {
5831 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5832 test_frame(V_DISPATCH(&result_var), "fr1");
5834 VariantClear(&result_var);
5835 VariantClear(&index_var);
5837 /* invalid argument */
5838 V_VT(&index_var) = VT_BOOL;
5839 V_BOOL(&index_var) = VARIANT_TRUE;
5840 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5841 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5842 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5843 VariantClear(&result_var);
5845 IHTMLFramesCollection2_Release(frames);
5847 /* test using IHTMLWindow2 inheritance */
5849 /* test result length */
5850 hres = IHTMLWindow2_get_length(window, &length);
5851 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5852 ok(length == 2, "IHTMLWindow2_get_length should have been 2, was: %d\n", length);
5854 /* test first frame */
5855 V_VT(&index_var) = VT_I4;
5856 V_I4(&index_var) = 0;
5857 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5858 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5859 if(SUCCEEDED(hres)) {
5860 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5861 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5863 VariantClear(&result_var);
5865 /* test second frame */
5866 V_I4(&index_var) = 1;
5867 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5868 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5869 if(SUCCEEDED(hres)) {
5870 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5871 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5873 VariantClear(&result_var);
5875 /* fail on third frame */
5876 V_I4(&index_var) = 2;
5877 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5878 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5879 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5880 VariantClear(&result_var);
5882 /* string argument (element id lookup) */
5883 V_VT(&index_var) = VT_BSTR;
5884 V_BSTR(&index_var) = a2bstr("fr2");
5885 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5886 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5887 if(SUCCEEDED(hres)) {
5888 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5889 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5891 VariantClear(&result_var);
5892 VariantClear(&index_var);
5894 /* invalid argument */
5895 V_VT(&index_var) = VT_BOOL;
5896 V_BOOL(&index_var) = VARIANT_TRUE;
5897 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5898 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5899 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5900 VariantClear(&result_var);
5902 /* getElementById with node name attributes */
5903 elem = get_doc_elem_by_id(doc, "nm1");
5904 test_elem_id((IUnknown*)elem, "fr1");
5905 IHTMLElement_Release(elem);
5908 static IHTMLDocument2 *notif_doc;
5909 static BOOL doc_complete;
5911 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5912 REFIID riid, void**ppv)
5914 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5919 ok(0, "unexpected call\n");
5920 return E_NOINTERFACE;
5923 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5928 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5933 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5935 if(dispID == DISPID_READYSTATE){
5939 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5940 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5942 if(!strcmp_wa(state, "complete"))
5943 doc_complete = TRUE;
5945 SysFreeString(state);
5951 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5953 ok(0, "unexpected call\n");
5957 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5958 PropertyNotifySink_QueryInterface,
5959 PropertyNotifySink_AddRef,
5960 PropertyNotifySink_Release,
5961 PropertyNotifySink_OnChanged,
5962 PropertyNotifySink_OnRequestEdit
5965 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5967 static IHTMLDocument2 *create_doc_with_string(const char *str)
5969 IPersistStreamInit *init;
5971 IHTMLDocument2 *doc;
5975 notif_doc = doc = create_document();
5979 doc_complete = FALSE;
5981 mem = GlobalAlloc(0, len);
5982 memcpy(mem, str, len);
5983 CreateStreamOnHGlobal(mem, TRUE, &stream);
5985 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5987 IPersistStreamInit_Load(init, stream);
5988 IPersistStreamInit_Release(init);
5989 IStream_Release(stream);
5994 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5996 IConnectionPointContainer *container;
5997 IConnectionPoint *cp;
6001 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6002 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6004 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6005 IConnectionPointContainer_Release(container);
6006 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6008 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6009 IConnectionPoint_Release(cp);
6010 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6013 typedef void (*domtest_t)(IHTMLDocument2*);
6015 static void run_domtest(const char *str, domtest_t test)
6017 IHTMLDocument2 *doc;
6021 doc = create_doc_with_string(str);
6025 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6027 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6028 TranslateMessage(&msg);
6029 DispatchMessage(&msg);
6034 ref = IHTMLDocument2_Release(doc);
6036 ref == 1, /* Vista */
6044 run_domtest(doc_str1, test_doc_elem);
6045 run_domtest(doc_str1, test_get_set_attr);
6046 run_domtest(range_test_str, test_txtrange);
6047 run_domtest(range_test2_str, test_txtrange2);
6048 if (winetest_interactive || ! is_ie_hardened()) {
6049 run_domtest(elem_test_str, test_elems);
6051 skip("IE running in Enhanced Security Configuration\n");
6053 run_domtest(elem_test2_str, test_elems2);
6054 run_domtest(doc_blank, test_create_elems);
6055 run_domtest(doc_blank, test_defaults);
6056 run_domtest(indent_test_str, test_indent);
6057 run_domtest(cond_comment_str, test_cond_comment);
6058 run_domtest(frameset_str, test_frameset);