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>"
54 "<form id=\"frm\"></form>"
56 static const char elem_test2_str[] =
57 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
58 "<body><div id=\"divid\"></div></body>"
61 static const char indent_test_str[] =
62 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
63 static const char cond_comment_str[] =
64 "<html><head><title>test</title></head><body>"
65 "<!--[if gte IE 4]> <br> <![endif]-->"
67 static const char frameset_str[] =
68 "<html><head><title>frameset test</title></head><frameset rows=\"28, *\">"
69 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
72 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
73 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
74 static WCHAR wordW[] = {'w','o','r','d',0};
104 static const IID * const none_iids[] = {
109 static const IID * const doc_node_iids[] = {
118 &IID_IConnectionPointContainer,
119 &IID_IInternetHostSecurityManager,
123 static const IID * const doc_obj_iids[] = {
130 &IID_IConnectionPointContainer,
135 static const IID * const elem_iids[] = {
142 &IID_IConnectionPointContainer,
146 static const IID * const body_iids[] = {
152 &IID_IHTMLTextContainer,
153 &IID_IHTMLBodyElement,
155 &IID_IConnectionPointContainer,
159 static const IID * const anchor_iids[] = {
165 &IID_IHTMLAnchorElement,
167 &IID_IConnectionPointContainer,
171 static const IID * const input_iids[] = {
177 &IID_IHTMLInputElement,
178 &IID_IHTMLInputTextElement,
180 &IID_IConnectionPointContainer,
184 static const IID * const select_iids[] = {
190 &IID_IHTMLSelectElement,
192 &IID_IConnectionPointContainer,
196 static const IID * const textarea_iids[] = {
202 &IID_IHTMLTextAreaElement,
204 &IID_IConnectionPointContainer,
208 static const IID * const option_iids[] = {
214 &IID_IHTMLOptionElement,
216 &IID_IConnectionPointContainer,
220 static const IID * const table_iids[] = {
228 &IID_IConnectionPointContainer,
232 static const IID * const script_iids[] = {
238 &IID_IHTMLScriptElement,
240 &IID_IConnectionPointContainer,
244 static const IID * const text_iids[] = {
247 &IID_IHTMLDOMTextNode,
251 static const IID * const location_iids[] = {
257 static const IID * const window_iids[] = {
265 static const IID * const comment_iids[] = {
271 &IID_IHTMLCommentElement,
273 &IID_IConnectionPointContainer,
277 static const IID * const img_iids[] = {
284 &IID_IHTMLImgElement,
285 &IID_IConnectionPointContainer,
289 static const IID * const tr_iids[] = {
297 &IID_IConnectionPointContainer,
301 static const IID * const td_iids[] = {
308 &IID_IConnectionPointContainer,
312 static const IID * const iframe_iids[] = {
319 &IID_IHTMLFrameBase2,
321 &IID_IConnectionPointContainer,
325 static const IID * const form_iids[] = {
331 &IID_IHTMLFormElement,
333 &IID_IConnectionPointContainer,
337 static const IID * const generic_iids[] = {
343 &IID_IHTMLGenericElement,
345 &IID_IConnectionPointContainer,
349 static const IID * const style_iids[] = {
360 static const IID * const cstyle_iids[] = {
364 &IID_IHTMLCurrentStyle,
368 static const IID * const img_factory_iids[] = {
372 &IID_IHTMLImageElementFactory,
382 static const elem_type_info_t elem_type_infos[] = {
383 {"", none_iids, NULL},
384 {"HTML", elem_iids, NULL},
385 {"HEAD", elem_iids, NULL},
386 {"TITLE", elem_iids, NULL},
387 {"BODY", body_iids, &DIID_DispHTMLBody},
388 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
389 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
390 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
391 {"TEXTAREA", textarea_iids, NULL},
392 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
393 {"STYLE", elem_iids, NULL},
394 {"BLOCKQUOTE",elem_iids, NULL},
395 {"P", elem_iids, NULL},
396 {"BR", elem_iids, NULL},
397 {"TABLE", table_iids, &DIID_DispHTMLTable},
398 {"TBODY", elem_iids, NULL},
399 {"SCRIPT", script_iids, NULL},
400 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
401 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
402 {"!", comment_iids, &DIID_DispHTMLCommentElement},
403 {"IMG", img_iids, &DIID_DispHTMLImg},
404 {"TR", tr_iids, &DIID_DispHTMLTableRow},
405 {"TD", td_iids, NULL},
406 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
407 {"FORM", form_iids, &DIID_DispHTMLFormElement}
410 static const char *dbgstr_guid(REFIID riid)
414 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
415 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
416 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
417 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
422 static int strcmp_wa(LPCWSTR strw, const char *stra)
425 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
426 return lstrcmpA(stra, buf);
429 static BSTR a2bstr(const char *str)
434 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
435 ret = SysAllocStringLen(NULL, len);
436 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
441 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
443 IUnknown *unk1, *unk2;
448 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
449 IUnknown_Release(unk1);
450 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
451 IUnknown_Release(unk2);
456 static IHTMLDocument2 *create_document(void)
459 IHTMLDocument5 *doc5;
462 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
463 &IID_IHTMLDocument2, (void**)&doc);
464 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
468 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
470 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
471 IHTMLDocument2_Release(doc);
475 IHTMLDocument5_Release(doc5);
479 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
480 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
482 const IID * const *piid;
486 for(piid = iids; *piid; piid++) {
487 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
488 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
490 IUnknown_Release(unk);
494 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
495 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
503 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
504 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
509 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
510 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
511 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
513 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
514 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
516 if(SUCCEEDED(hres)) {
519 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
520 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
522 *iid = type_attr->guid;
526 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
527 ITypeInfo_Release(typeinfo);
530 IDispatchEx_Release(dispex);
534 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
535 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
537 DISPPARAMS dp = {NULL,NULL,0,0};
543 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
544 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
548 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
549 IDispatchEx_Release(dispex);
550 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
552 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
553 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
557 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
558 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
562 if(_test_get_dispid(line, unk, &iid))
563 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
566 _test_disp_value(line, unk, val);
569 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
570 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
574 if(_test_get_dispid(line, unk, &iid))
575 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
576 "unexpected guid %s\n", dbgstr_guid(&iid));
579 _test_disp_value(line, unk, val);
582 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
583 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
588 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
589 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
593 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
594 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
599 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
600 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
604 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
605 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
610 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
611 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
615 #define get_node_iface(u) _get_node_iface(__LINE__,u)
616 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
621 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
622 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
626 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
627 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
632 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
633 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
637 #define get_img_iface(u) _get_img_iface(__LINE__,u)
638 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
640 IHTMLImgElement *img;
643 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
644 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
648 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
649 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
651 IHTMLAnchorElement *anchor;
654 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
655 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
659 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
660 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
662 IHTMLDOMNode *node = _get_node_iface(line, unk);
666 hres = IHTMLDOMNode_get_nodeName(node, &name);
667 IHTMLDOMNode_Release(node);
668 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
669 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
674 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
675 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
677 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
678 IDispatch *disp = (void*)0xdeadbeef;
679 IHTMLDocument2 *doc = NULL;
682 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
683 IHTMLDOMNode2_Release(node);
684 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
687 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
688 IDispatch_Release(disp);
689 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
695 #define get_doc_window(d) _get_doc_window(__LINE__,d)
696 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
698 IHTMLWindow2 *window;
702 hres = IHTMLDocument2_get_parentWindow(doc, &window);
703 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
704 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
709 #define clone_node(n,d) _clone_node(__LINE__,n,d)
710 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
712 IHTMLDOMNode *node = _get_node_iface(line, unk);
713 IHTMLDOMNode *ret = NULL;
716 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
717 IHTMLDOMNode_Release(node);
718 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
719 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
725 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
726 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
728 IHTMLElement *elem = _get_elem_iface(line, unk);
732 hres = IHTMLElement_get_tagName(elem, &tag);
733 IHTMLElement_Release(elem);
734 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
735 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
740 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
741 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
743 _test_elem_tag(line, unk, elem_type_infos[type].tag);
744 _test_ifaces(line, unk, elem_type_infos[type].iids);
746 if(elem_type_infos[type].dispiid && type != ET_A)
747 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
750 #define get_node_type(n) _get_node_type(__LINE__,n)
751 static LONG _get_node_type(unsigned line, IUnknown *unk)
753 IHTMLDOMNode *node = _get_node_iface(line, unk);
757 hres = IHTMLDOMNode_get_nodeType(node, &type);
758 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
760 IHTMLDOMNode_Release(node);
765 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
766 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
768 IHTMLDOMNode *node = _get_node_iface(line, unk);
769 IHTMLDOMChildrenCollection *col = NULL;
773 hres = IHTMLDOMNode_get_childNodes(node, &disp);
774 IHTMLDOMNode_Release(node);
775 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
779 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
780 IDispatch_Release(disp);
781 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
786 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
787 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
789 IHTMLDOMNode *node = NULL;
793 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
794 ok(hres == S_OK, "item failed: %08x\n", hres);
796 node = _get_node_iface(line, (IUnknown*)disp);
797 IDispatch_Release(disp);
802 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
803 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
812 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
814 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
817 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
818 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
820 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
823 VariantClear(&value);
826 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
827 static void _test_elem_offset(unsigned line, IUnknown *unk)
829 IHTMLElement *elem = _get_elem_iface(line, unk);
833 hres = IHTMLElement_get_offsetTop(elem, &l);
834 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
836 hres = IHTMLElement_get_offsetHeight(elem, &l);
837 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
839 hres = IHTMLElement_get_offsetWidth(elem, &l);
840 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
842 IHTMLElement_Release(elem);
845 #define get_doc_node(d) _get_doc_node(__LINE__,d)
846 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
848 IHTMLWindow2 *window;
852 hres = IHTMLDocument2_get_parentWindow(doc, &window);
853 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
855 hres = IHTMLWindow2_get_document(window, &ret);
856 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
857 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
862 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
863 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
868 hres = IHTMLWindow2_get_name(window, &name);
869 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
871 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
873 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
876 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
877 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
883 hres = IHTMLWindow2_put_name(window, str);
885 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
887 _test_window_name(line, window, name);
890 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
891 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
896 hres = IHTMLWindow2_get_length(window, &length);
897 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
898 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
901 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
902 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
904 IHTMLFrameBase2 *base2;
905 IHTMLWindow2 *window;
908 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
909 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
912 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
913 IHTMLFrameBase2_Release(base2);
914 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
915 ok(window != NULL, "contentWindow = NULL\n");
920 static void test_get_set_attr(IHTMLDocument2 *doc)
923 IHTMLDocument3 *doc3;
928 /* grab an element to test with */
929 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
930 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
932 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
933 IHTMLDocument3_Release(doc3);
934 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
936 /* get a non-present attribute */
937 bstr = a2bstr("notAnAttribute");
938 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
939 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
940 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
944 /* get a present attribute */
945 bstr = a2bstr("scrollHeight");
946 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
947 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
948 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
952 /* create a new BSTR attribute */
953 bstr = a2bstr("newAttribute");
955 V_VT(&val) = VT_BSTR;
956 V_BSTR(&val) = a2bstr("the value");
957 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
958 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
961 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
962 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
963 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
964 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)));
967 /* overwrite the attribute with a BOOL */
968 V_VT(&val) = VT_BOOL;
969 V_BOOL(&val) = VARIANT_TRUE;
970 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
971 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
974 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
975 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
976 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
977 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
982 /* case-insensitive */
983 bstr = a2bstr("newattribute");
984 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
985 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
986 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
987 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
991 IHTMLElement_Release(elem);
994 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
995 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
998 IHTMLDocument3 *doc3;
1001 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1002 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1003 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1004 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1005 IHTMLDocument3_Release(doc3);
1010 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1011 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1013 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1017 hres = IHTMLAnchorElement_get_href(anchor, &str);
1018 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1019 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1022 _test_disp_value(line, unk, exhref);
1025 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1026 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1031 hres = IHTMLOptionElement_get_text(option, &bstr);
1032 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1033 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1034 SysFreeString(bstr);
1037 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1038 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1043 bstr = a2bstr(text);
1044 hres = IHTMLOptionElement_put_text(option, bstr);
1045 SysFreeString(bstr);
1046 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1048 _test_option_text(line, option, text);
1051 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1052 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1057 hres = IHTMLOptionElement_get_value(option, &bstr);
1058 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1059 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1060 SysFreeString(bstr);
1063 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1064 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1069 bstr = a2bstr(value);
1070 hres = IHTMLOptionElement_put_value(option, bstr);
1071 SysFreeString(bstr);
1072 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1074 _test_option_value(line, option, value);
1077 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1078 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1079 const char *txt, const char *val)
1081 IHTMLOptionElementFactory *factory;
1082 IHTMLOptionElement *option;
1083 IHTMLWindow2 *window;
1084 VARIANT text, value, empty;
1087 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1088 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1090 hres = IHTMLWindow2_get_Option(window, &factory);
1091 IHTMLWindow2_Release(window);
1092 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1094 V_VT(&text) = VT_BSTR;
1095 V_BSTR(&text) = a2bstr(txt);
1096 V_VT(&value) = VT_BSTR;
1097 V_BSTR(&value) = a2bstr(val);
1098 V_VT(&empty) = VT_EMPTY;
1100 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1101 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1103 IHTMLOptionElementFactory_Release(factory);
1104 VariantClear(&text);
1105 VariantClear(&value);
1107 _test_option_text(line, option, txt);
1108 _test_option_value(line, option, val);
1113 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1114 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1119 hres = IHTMLImgElement_get_width(img, &found);
1120 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1121 todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1124 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1125 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1129 hres = IHTMLImgElement_put_width(img, width);
1130 todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres);
1132 _test_img_width(line, img, width);
1135 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1136 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1141 hres = IHTMLImgElement_get_height(img, &found);
1142 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1143 todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1146 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1147 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1151 hres = IHTMLImgElement_put_height(img, height);
1152 todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres);
1154 _test_img_height(line, img, height);
1157 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1158 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1159 LONG wdth, LONG hght)
1161 IHTMLImageElementFactory *factory;
1162 IHTMLImgElement *img;
1163 IHTMLWindow2 *window;
1164 VARIANT width, height;
1168 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1169 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1171 hres = IHTMLWindow2_get_Image(window, &factory);
1172 IHTMLWindow2_Release(window);
1173 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1175 test_ifaces((IUnknown*)factory, img_factory_iids);
1176 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1179 snprintf(buf, 16, "%d", wdth);
1180 V_VT(&width) = VT_BSTR;
1181 V_BSTR(&width) = a2bstr(buf);
1183 V_VT(&width) = VT_EMPTY;
1188 snprintf(buf, 16, "%d", hght);
1189 V_VT(&height) = VT_BSTR;
1190 V_BSTR(&height) = a2bstr(buf);
1192 V_VT(&height) = VT_EMPTY;
1196 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1197 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1199 IHTMLImageElementFactory_Release(factory);
1200 VariantClear(&width);
1201 VariantClear(&height);
1203 if(SUCCEEDED(hres)) {
1204 _test_img_width(line, img, wdth);
1205 _test_img_height(line, img, hght);
1212 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1213 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1215 LONG len = 0xdeadbeef;
1218 hres = IHTMLSelectElement_get_length(select, &len);
1219 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1220 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1223 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1224 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1226 LONG idx = 0xdeadbeef;
1229 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1230 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1231 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1234 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1235 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1239 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1240 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1241 _test_select_selidx(line, select, index);
1244 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1245 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1250 hres = IHTMLSelectElement_get_value(select, &val);
1251 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1253 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1255 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1258 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1259 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1265 hres = IHTMLSelectElement_put_value(select, bstr);
1266 SysFreeString(bstr);
1267 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1270 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1271 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1276 hres = IHTMLSelectElement_get_type(select, &type);
1277 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1278 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1281 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1282 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1287 hres = IHTMLTxtRange_get_text(range, &text);
1288 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1291 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1292 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1294 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1297 SysFreeString(text);
1301 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1302 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1306 hres = IHTMLTxtRange_collapse(range, b);
1307 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1308 _test_range_text(line, range, NULL);
1311 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1312 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1313 VARIANT_BOOL exb, const char *extext)
1315 VARIANT_BOOL b = 0xe0e0;
1318 hres = IHTMLTxtRange_expand(range, unit, &b);
1319 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1320 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1321 _test_range_text(line, range, extext);
1324 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1325 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1327 LONG c = 0xdeadbeef;
1330 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1331 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1332 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1333 _test_range_text(line, range, NULL);
1336 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1337 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1338 LPWSTR unit, LONG cnt, LONG excnt)
1340 LONG c = 0xdeadbeef;
1343 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1344 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1345 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1348 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1349 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1351 LONG c = 0xdeadbeef;
1354 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1355 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1356 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1359 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1360 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1363 BSTR bstr = a2bstr(text);
1365 hres = IHTMLTxtRange_put_text(range, bstr);
1366 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1367 SysFreeString(bstr);
1368 _test_range_text(line, range, NULL);
1371 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1372 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1378 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1379 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1380 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1383 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1384 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1390 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1391 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1392 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1395 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1396 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1397 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1400 test_range_inrange(range1, range2, VARIANT_TRUE);
1401 test_range_inrange(range2, range1, VARIANT_TRUE);
1405 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1406 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1411 hres = IHTMLTxtRange_parentElement(range, &elem);
1412 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1414 _test_elem_type(line, (IUnknown*)elem, type);
1416 IHTMLElement_Release(elem);
1419 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1420 static void _test_elem_collection(unsigned line, IUnknown *unk,
1421 const elem_type_t *elem_types, LONG exlen)
1423 IHTMLElementCollection *col;
1426 VARIANT name, index;
1427 IDispatch *disp, *disp2;
1430 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1431 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1433 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1435 hres = IHTMLElementCollection_get_length(col, &len);
1436 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1437 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1442 V_VT(&index) = VT_EMPTY;
1444 for(i=0; i<len; i++) {
1445 V_VT(&name) = VT_I4;
1447 disp = (void*)0xdeadbeef;
1448 hres = IHTMLElementCollection_item(col, name, index, &disp);
1449 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1450 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1451 if(FAILED(hres) || !disp)
1454 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1457 V_VT(&name) = VT_UINT;
1459 disp2 = (void*)0xdeadbeef;
1460 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1461 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1462 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1464 IDispatch_Release(disp2);
1467 IDispatch_Release(disp);
1470 V_VT(&name) = VT_I4;
1472 disp = (void*)0xdeadbeef;
1473 hres = IHTMLElementCollection_item(col, name, index, &disp);
1474 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1475 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1477 V_VT(&name) = VT_I4;
1479 disp = (void*)0xdeadbeef;
1480 hres = IHTMLElementCollection_item(col, name, index, &disp);
1481 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1482 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1484 IHTMLElementCollection_Release(col);
1487 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1488 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1490 IHTMLElement *elem = _get_elem_iface(line, unk);
1494 hres = IHTMLElement_get_all(elem, &disp);
1495 IHTMLElement_Release(elem);
1496 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1498 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1499 IDispatch_Release(disp);
1502 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1503 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1505 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1506 IHTMLElementCollection *col = NULL;
1507 elem_type_t *types = NULL;
1512 tmp = a2bstr(elem_type_infos[type].tag);
1513 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1515 IHTMLElement2_Release(elem);
1516 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1517 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1520 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1521 for(i=0; i<exlen; i++)
1525 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1527 HeapFree(GetProcessHeap(), 0, types);
1530 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1531 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1536 hres = IHTMLElement_get_innerText(elem, &text);
1537 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1538 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1539 wine_dbgstr_w(text), extext);
1540 SysFreeString(text);
1543 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1544 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1546 IHTMLDOMChildrenCollection *col;
1551 hres = IHTMLElement_put_innerText(elem, str);
1552 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1555 _test_elem_innertext(line, elem, text);
1558 col = _get_child_nodes(line, (IUnknown*)elem);
1559 ok(col != NULL, "col == NULL\n");
1561 LONG length = 0, type;
1564 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1565 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1566 ok(length == 1, "length = %d\n", length);
1568 node = _get_child_item(line, col, 0);
1569 ok(node != NULL, "node == NULL\n");
1571 type = _get_node_type(line, (IUnknown*)node);
1572 ok(type == 3, "type=%d\n", type);
1573 IHTMLDOMNode_Release(node);
1576 IHTMLDOMChildrenCollection_Release(col);
1581 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1582 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1584 IHTMLElement *elem = _get_elem_iface(line, unk);
1588 hres = IHTMLElement_get_innerHTML(elem, &html);
1589 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1591 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1593 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1595 IHTMLElement_Release(elem);
1596 SysFreeString(html);
1599 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1600 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1602 IHTMLElement *elem = _get_elem_iface(line, unk);
1606 html = a2bstr(inner_html);
1607 hres = IHTMLElement_put_innerHTML(elem, html);
1608 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1610 IHTMLElement_Release(elem);
1611 SysFreeString(html);
1614 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1615 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1617 IHTMLElement *elem = _get_elem_iface(line, unk);
1621 html = a2bstr(outer_html);
1622 hres = IHTMLElement_put_outerHTML(elem, html);
1623 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1625 IHTMLElement_Release(elem);
1626 SysFreeString(html);
1629 #define get_first_child(n) _get_first_child(__LINE__,n)
1630 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1632 IHTMLDOMNode *node = _get_node_iface(line, unk);
1633 IHTMLDOMNode *child = NULL;
1636 hres = IHTMLDOMNode_get_firstChild(node, &child);
1637 IHTMLDOMNode_Release(node);
1638 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1643 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1644 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1646 IHTMLDOMNode *node = _get_node_iface(line, unk);
1647 VARIANT_BOOL b = 0xdead;
1650 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1651 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1652 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1654 IHTMLDOMNode_Release(node);
1657 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1658 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1660 IHTMLDOMNode *node = _get_node_iface(line, unk);
1661 IHTMLDOMNode *parent;
1664 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1665 IHTMLDOMNode_Release(node);
1666 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1671 #define node_get_next(u) _node_get_next(__LINE__,u)
1672 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1674 IHTMLDOMNode *node = _get_node_iface(line, unk);
1678 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1679 IHTMLDOMNode_Release(node);
1680 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1685 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1686 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1688 IHTMLElement *elem = _get_elem_iface(line, unk);
1689 IHTMLElement *parent;
1692 hres = IHTMLElement_get_parentElement(elem, &parent);
1693 IHTMLElement_Release(elem);
1694 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1699 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1700 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1702 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1703 VARIANT_BOOL disabled = 100;
1707 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1708 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1709 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1710 IHTMLElement3_Release(elem3);
1713 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1714 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1716 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1720 hres = IHTMLElement3_put_disabled(elem3, b);
1721 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1723 IHTMLElement3_Release(elem3);
1724 _test_elem3_get_disabled(line, unk, b);
1727 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1728 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1730 VARIANT_BOOL disabled = 100;
1733 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1734 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1735 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1737 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1740 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1741 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1745 hres = IHTMLSelectElement_put_disabled(select, b);
1746 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1748 _test_select_get_disabled(line, select, b);
1751 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1752 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1754 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1755 IHTMLTextContainer *txtcont;
1756 LONG l = -1, l2 = -1;
1759 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1760 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1761 IHTMLElement2_Release(elem);
1763 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1764 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1766 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1767 IHTMLTextContainer_Release(txtcont);
1768 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1769 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1774 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1775 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1777 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1778 IHTMLTextContainer *txtcont;
1779 LONG l = -1, l2 = -1;
1782 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1783 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1784 IHTMLElement2_Release(elem);
1786 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1787 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1789 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1790 IHTMLTextContainer_Release(txtcont);
1791 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1792 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1797 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1798 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1800 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1801 IHTMLTextContainer *txtcont;
1802 LONG l = -1, l2 = -1;
1805 hres = IHTMLElement2_get_scrollTop(elem, &l);
1806 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1807 IHTMLElement2_Release(elem);
1809 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1810 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1812 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1813 IHTMLTextContainer_Release(txtcont);
1814 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1815 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1820 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1821 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1823 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1824 IHTMLTextContainer *txtcont;
1825 LONG l = -1, l2 = -1;
1828 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1829 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1831 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1832 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1833 IHTMLElement2_Release(elem);
1835 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1836 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1838 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1839 IHTMLTextContainer_Release(txtcont);
1840 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1841 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1844 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1845 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1847 IHTMLImgElement *img = _get_img_iface(line, unk);
1851 hres = IHTMLImgElement_get_src(img, &src);
1852 IHTMLImgElement_Release(img);
1853 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1854 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1858 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1859 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1861 IHTMLImgElement *img = _get_img_iface(line, unk);
1866 hres = IHTMLImgElement_put_src(img, tmp);
1867 IHTMLImgElement_Release(img);
1869 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1871 _test_img_src(line, unk, src);
1874 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1875 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1877 IHTMLImgElement *img = _get_img_iface(line, unk);
1881 hres = IHTMLImgElement_get_alt(img, &alt);
1882 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1884 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1886 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1890 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1891 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1893 IHTMLImgElement *img = _get_img_iface(line, unk);
1898 hres = IHTMLImgElement_put_alt(img, tmp);
1899 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1902 _test_img_alt(line, unk, alt);
1905 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1906 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1908 VARIANT_BOOL disabled = 100;
1911 hres = IHTMLInputElement_get_disabled(input, &disabled);
1912 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1913 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1915 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1918 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1919 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1923 hres = IHTMLInputElement_put_disabled(input, b);
1924 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1926 _test_input_get_disabled(line, input, b);
1929 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1930 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1932 VARIANT_BOOL checked = 100;
1935 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1936 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1937 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1940 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1941 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1945 hres = IHTMLInputElement_put_defaultChecked(input, b);
1946 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1948 _test_input_get_defaultchecked(line, input, b);
1951 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1952 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1954 VARIANT_BOOL checked = 100;
1957 hres = IHTMLInputElement_get_checked(input, &checked);
1958 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1959 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1962 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1963 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1967 hres = IHTMLInputElement_put_checked(input, b);
1968 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1970 _test_input_get_checked(line, input, b);
1973 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1974 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1976 IHTMLInputElement *input;
1980 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1981 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1985 hres = IHTMLInputElement_get_value(input, &bstr);
1986 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1988 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1990 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1991 SysFreeString(bstr);
1992 IHTMLInputElement_Release(input);
1995 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1996 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1998 IHTMLInputElement *input;
2002 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2003 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2008 hres = IHTMLInputElement_get_value(input, &bstr);
2009 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2010 SysFreeString(bstr);
2011 IHTMLInputElement_Release(input);
2014 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2015 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2020 hres = IHTMLInputElement_get_src(input, &src);
2021 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2023 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2025 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2029 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2030 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2036 hres = IHTMLInputElement_put_src(input, tmp);
2038 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2040 _test_input_src(line, input, src);
2043 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2044 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2046 IHTMLElement *elem = _get_elem_iface(line, unk);
2047 BSTR class = (void*)0xdeadbeef;
2050 hres = IHTMLElement_get_className(elem, &class);
2051 IHTMLElement_Release(elem);
2052 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2054 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2056 ok_(__FILE__,line) (!class, "class != NULL\n");
2057 SysFreeString(class);
2060 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2061 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2063 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2067 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2068 IHTMLElement2_Release(elem2);
2069 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2070 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2073 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2074 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2076 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2079 hres = IHTMLElement2_put_tabIndex(elem2, index);
2080 IHTMLElement2_Release(elem2);
2081 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2083 _test_elem_tabindex(line, unk, index);
2086 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2087 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2089 IHTMLElement *elem = _get_elem_iface(line, unk);
2093 tmp = class ? a2bstr(class) : NULL;
2094 hres = IHTMLElement_put_className(elem, tmp);
2095 IHTMLElement_Release(elem);
2096 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2099 _test_elem_class(line, unk, class);
2102 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2103 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2105 IHTMLElement *elem = _get_elem_iface(line, unk);
2106 BSTR id = (void*)0xdeadbeef;
2109 hres = IHTMLElement_get_id(elem, &id);
2110 IHTMLElement_Release(elem);
2111 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2114 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2116 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2121 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2122 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2124 IHTMLElement *elem = _get_elem_iface(line, unk);
2125 BSTR tmp = a2bstr(new_id);
2128 hres = IHTMLElement_put_id(elem, tmp);
2129 IHTMLElement_Release(elem);
2131 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2133 _test_elem_id(line, unk, new_id);
2136 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2137 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2139 IHTMLElement *elem = _get_elem_iface(line, unk);
2143 hres = IHTMLElement_get_title(elem, &title);
2144 IHTMLElement_Release(elem);
2145 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2147 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2149 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2151 SysFreeString(title);
2154 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2155 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2157 IHTMLElement *elem = _get_elem_iface(line, unk);
2161 tmp = a2bstr(title);
2162 hres = IHTMLElement_put_title(elem, tmp);
2163 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2165 IHTMLElement_Release(elem);
2169 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2170 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2172 IHTMLDOMNode *node = _get_node_iface(line, unk);
2176 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2177 IHTMLDOMNode_Release(node);
2178 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2181 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2182 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2184 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2190 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2191 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2193 IHTMLDOMNode *node = _get_node_iface(line, unk);
2197 V_VT(&var) = VT_BSTR;
2198 V_BSTR(&var) = a2bstr(val);
2200 hres = IHTMLDOMNode_put_nodeValue(node, var);
2201 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2202 IHTMLDOMNode_Release(node);
2206 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2207 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2209 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2213 hres = IHTMLElement2_get_clientWidth(elem, &l);
2214 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2215 hres = IHTMLElement2_get_clientHeight(elem, &l);
2216 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2218 IHTMLElement2_Release(elem);
2221 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2222 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2224 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2228 hres = IHTMLElement2_get_clientLeft(elem, &l);
2229 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2230 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2232 hres = IHTMLElement2_get_clientTop(elem, &l);
2233 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2234 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2236 IHTMLElement2_Release(elem);
2239 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2240 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2242 IHTMLElement *elem = _get_elem_iface(line, unk);
2243 IHTMLDocument2 *doc;
2248 hres = IHTMLElement_get_document(elem, &disp);
2249 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2250 ok(disp != NULL, "disp == NULL\n");
2252 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2253 IDispatch_Release(disp);
2254 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2259 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2260 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2262 IHTMLDocument2 *doc;
2266 hres = IHTMLWindow2_get_document(window, &doc);
2267 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2268 ok(doc != NULL, "disp == NULL\n");
2273 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2274 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2276 IHTMLElement *elem = NULL;
2281 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2282 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2283 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2288 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2289 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2291 IHTMLDocument3 *doc3;
2292 IHTMLDOMNode *node = NULL;
2296 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2297 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2300 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2301 IHTMLDocument3_Release(doc3);
2302 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2303 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2308 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2309 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2311 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2312 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2313 IHTMLDOMNode *new_child = NULL;
2316 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2317 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2318 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2319 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2321 IHTMLDOMNode_Release(node);
2322 IHTMLDOMNode_Release(child);
2327 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2328 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2330 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2331 IHTMLDOMNode *new_child = NULL;
2334 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2335 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2336 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2337 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2339 IHTMLDOMNode_Release(node);
2344 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2345 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2347 IHTMLDOMNode *node = _get_node_iface(line, unk);
2348 IHTMLDOMNode *new_node = NULL;
2351 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2352 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2353 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2354 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2356 IHTMLDOMNode_Release(node);
2357 IHTMLDOMNode_Release(new_node);
2360 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2361 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2366 hres = IHTMLDocument2_get_title(doc, &title);
2367 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2368 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2369 SysFreeString(title);
2372 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2373 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2378 tmp = a2bstr(title);
2379 hres = IHTMLDocument2_put_title(doc, tmp);
2380 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2384 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2385 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2390 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2391 LOCALE_USER_DEFAULT, &dispid);
2392 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2395 DISPPARAMS params = {NULL,NULL,0,0};
2396 DISPID dispidNamed = DISPID_PROPERTYPUT;
2401 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2402 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2403 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2406 params.cNamedArgs = 1;
2407 params.rgdispidNamedArgs = &dispidNamed;
2408 V_VT(&arg) = VT_BSTR;
2409 V_BSTR(&arg) = a2bstr("none");
2410 params.rgvarg = &arg;
2411 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2412 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2413 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2416 V_VT(&arg) = VT_BSTR;
2417 V_BSTR(&arg) = a2bstr("dotted");
2418 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2419 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2420 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2423 V_VT(&arg) = VT_BSTR;
2424 V_BSTR(&arg) = a2bstr("dashed");
2425 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2426 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2427 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2430 V_VT(&arg) = VT_BSTR;
2431 V_BSTR(&arg) = a2bstr("solid");
2432 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2433 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2434 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2437 V_VT(&arg) = VT_BSTR;
2438 V_BSTR(&arg) = a2bstr("double");
2439 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2440 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2441 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2444 V_VT(&arg) = VT_BSTR;
2445 V_BSTR(&arg) = a2bstr("groove");
2446 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2447 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2448 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2451 V_VT(&arg) = VT_BSTR;
2452 V_BSTR(&arg) = a2bstr("ridge");
2453 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2454 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2455 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2458 V_VT(&arg) = VT_BSTR;
2459 V_BSTR(&arg) = a2bstr("inset");
2460 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2461 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2462 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2465 V_VT(&arg) = VT_BSTR;
2466 V_BSTR(&arg) = a2bstr("outset");
2467 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2468 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2469 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2472 V_VT(&arg) = VT_BSTR;
2473 V_BSTR(&arg) = a2bstr("invalid");
2474 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2475 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2476 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2479 params.rgvarg = &vDefault;
2480 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2481 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2482 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2486 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2487 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2489 BSTR text = (void*)0xdeadbeef;
2492 hres = IHTMLStyle_get_cssText(style, &text);
2493 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2495 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2497 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2499 SysFreeString(text);
2502 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2503 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2509 hres = IHTMLStyle_put_cssText(style, tmp);
2510 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2514 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2515 const elem_type_t *elem_types, LONG len)
2518 VARIANT name, index;
2522 V_VT(&index) = VT_EMPTY;
2523 V_VT(&name) = VT_BSTR;
2524 V_BSTR(&name) = a2bstr(n);
2526 hres = IHTMLElementCollection_item(col, name, index, &disp);
2527 ok(hres == S_OK, "item failed: %08x\n", hres);
2529 test_elem_collection((IUnknown*)disp, elem_types, len);
2530 IDispatch_Release(disp);
2531 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2535 V_VT(&index) = VT_I4;
2537 for(i=0; i<len; i++) {
2539 disp = (void*)0xdeadbeef;
2540 hres = IHTMLElementCollection_item(col, name, index, &disp);
2541 ok(hres == S_OK, "item failed: %08x\n", hres);
2542 ok(disp != NULL, "disp == NULL\n");
2543 if(FAILED(hres) || !disp)
2546 test_elem_type((IUnknown*)disp, elem_types[i]);
2548 IDispatch_Release(disp);
2552 disp = (void*)0xdeadbeef;
2553 hres = IHTMLElementCollection_item(col, name, index, &disp);
2554 ok(hres == S_OK, "item failed: %08x\n", hres);
2555 ok(disp == NULL, "disp != NULL\n");
2558 disp = (void*)0xdeadbeef;
2559 hres = IHTMLElementCollection_item(col, name, index, &disp);
2560 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2561 ok(disp == NULL, "disp != NULL\n");
2564 SysFreeString(V_BSTR(&name));
2567 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2569 IHTMLElementCollection *col;
2571 IDispatch *disp = (void*)0xdeadbeef;
2572 VARIANT name, index;
2575 hres = IHTMLDocument2_get_all(doc, &col);
2576 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2577 ok(col != NULL, "col == NULL\n");
2578 if(FAILED(hres) || !col)
2581 V_VT(&index) = VT_EMPTY;
2582 V_VT(&name) = VT_BSTR;
2583 V_BSTR(&name) = a2bstr(id);
2585 hres = IHTMLElementCollection_item(col, name, index, &disp);
2586 IHTMLElementCollection_Release(col);
2587 SysFreeString(V_BSTR(&name));
2588 ok(hres == S_OK, "item failed: %08x\n", hres);
2589 if(!expect_success) {
2590 ok(disp == NULL, "disp != NULL\n");
2594 ok(disp != NULL, "disp == NULL\n");
2598 elem = get_elem_iface((IUnknown*)disp);
2599 IDispatch_Release(disp);
2604 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2606 IHTMLDocument3 *doc3;
2611 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2612 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2615 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2617 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2619 IHTMLDocument3_Release(doc3);
2624 static void test_select_elem(IHTMLSelectElement *select)
2626 test_select_type(select, "select-one");
2627 test_select_length(select, 2);
2628 test_select_selidx(select, 0);
2629 test_select_put_selidx(select, 1);
2631 test_select_set_value(select, "val1");
2632 test_select_value(select, "val1");
2634 test_select_get_disabled(select, VARIANT_FALSE);
2635 test_select_set_disabled(select, VARIANT_TRUE);
2636 test_select_set_disabled(select, VARIANT_FALSE);
2639 static void test_create_option_elem(IHTMLDocument2 *doc)
2641 IHTMLOptionElement *option;
2643 option = create_option_elem(doc, "test text", "test value");
2645 test_option_put_text(option, "new text");
2646 test_option_put_value(option, "new value");
2648 IHTMLOptionElement_Release(option);
2651 static void test_create_img_elem(IHTMLDocument2 *doc)
2653 IHTMLImgElement *img;
2655 img = create_img_elem(doc, 10, 15);
2658 test_img_put_width(img, 5);
2659 test_img_put_height(img, 20);
2661 IHTMLImgElement_Release(img);
2665 img = create_img_elem(doc, -1, -1);
2668 test_img_put_width(img, 5);
2669 test_img_put_height(img, 20);
2671 IHTMLImgElement_Release(img);
2675 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2677 IHTMLBodyElement *body;
2678 IHTMLTxtRange *range;
2682 hres = IHTMLDocument2_get_body(doc, &elem);
2683 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2685 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2686 IHTMLElement_Release(elem);
2688 hres = IHTMLBodyElement_createTextRange(body, &range);
2689 IHTMLBodyElement_Release(body);
2690 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2695 static void test_txtrange(IHTMLDocument2 *doc)
2697 IHTMLTxtRange *body_range, *range, *range2;
2698 IHTMLSelectionObject *selection;
2699 IDispatch *disp_range;
2702 body_range = test_create_body_range(doc);
2704 test_range_text(body_range, "test abc 123\r\nit's text");
2706 hres = IHTMLTxtRange_duplicate(body_range, &range);
2707 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2709 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2710 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2711 test_range_isequal(range, range2, VARIANT_TRUE);
2713 test_range_text(range, "test abc 123\r\nit's text");
2714 test_range_text(body_range, "test abc 123\r\nit's text");
2716 test_range_collapse(range, TRUE);
2717 test_range_isequal(range, range2, VARIANT_FALSE);
2718 test_range_inrange(range, range2, VARIANT_FALSE);
2719 test_range_inrange(range2, range, VARIANT_TRUE);
2720 IHTMLTxtRange_Release(range2);
2722 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2723 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2724 test_range_move(range, characterW, 2, 2);
2725 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2727 test_range_collapse(range, FALSE);
2728 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2730 test_range_collapse(range, FALSE);
2731 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2732 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2733 test_range_move(range, characterW, 2, 2);
2734 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2735 test_range_moveend(range, characterW, -5, -5);
2736 test_range_text(range, NULL);
2737 test_range_moveend(range, characterW, 3, 3);
2738 test_range_text(range, "c 1");
2739 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2740 test_range_collapse(range, TRUE);
2741 test_range_move(range, characterW, 4, 4);
2742 test_range_moveend(range, characterW, 1, 1);
2743 test_range_text(range, " ");
2744 test_range_move(range, wordW, 1, 1);
2745 test_range_moveend(range, characterW, 2, 2);
2746 test_range_text(range, "ab");
2748 IHTMLTxtRange_Release(range);
2750 hres = IHTMLTxtRange_duplicate(body_range, &range);
2751 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2753 test_range_text(range, "test abc 123\r\nit's text");
2754 test_range_move(range, characterW, 3, 3);
2755 test_range_moveend(range, characterW, 1, 1);
2756 test_range_text(range, "t");
2757 test_range_moveend(range, characterW, 3, 3);
2758 test_range_text(range, "t ab");
2759 test_range_moveend(range, characterW, -2, -2);
2760 test_range_text(range, "t ");
2761 test_range_move(range, characterW, 6, 6);
2762 test_range_moveend(range, characterW, 3, 3);
2763 test_range_text(range, "123");
2764 test_range_moveend(range, characterW, 2, 2);
2765 test_range_text(range, "123\r\ni");
2767 IHTMLTxtRange_Release(range);
2769 hres = IHTMLTxtRange_duplicate(body_range, &range);
2770 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2772 test_range_move(range, wordW, 1, 1);
2773 test_range_moveend(range, characterW, 2, 2);
2774 test_range_text(range, "ab");
2776 test_range_move(range, characterW, -2, -2);
2777 test_range_moveend(range, characterW, 2, 2);
2778 test_range_text(range, "t ");
2780 test_range_move(range, wordW, 3, 3);
2781 test_range_move(range, wordW, -2, -2);
2782 test_range_moveend(range, characterW, 2, 2);
2783 test_range_text(range, "ab");
2785 test_range_move(range, characterW, -6, -5);
2786 test_range_moveend(range, characterW, -1, 0);
2787 test_range_moveend(range, characterW, -6, 0);
2788 test_range_move(range, characterW, 2, 2);
2789 test_range_moveend(range, characterW, 2, 2);
2790 test_range_text(range, "st");
2791 test_range_moveend(range, characterW, -6, -4);
2792 test_range_moveend(range, characterW, 2, 2);
2794 IHTMLTxtRange_Release(range);
2796 hres = IHTMLTxtRange_duplicate(body_range, &range);
2797 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2799 test_range_move(range, wordW, 2, 2);
2800 test_range_moveend(range, characterW, 2, 2);
2801 test_range_text(range, "12");
2803 test_range_move(range, characterW, 15, 14);
2804 test_range_move(range, characterW, -2, -2);
2805 test_range_moveend(range, characterW, 3, 2);
2806 test_range_text(range, "t");
2807 test_range_moveend(range, characterW, -1, -1);
2808 test_range_text(range, "t");
2809 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2810 test_range_move(range, characterW, -2, -2);
2811 test_range_moveend(range, characterW, 2, 2);
2812 test_range_text(range, "s ");
2813 test_range_move(range, characterW, 100, 7);
2814 test_range_move(range, wordW, 1, 0);
2815 test_range_move(range, characterW, -2, -2);
2816 test_range_moveend(range, characterW, 3, 2);
2817 test_range_text(range, "t");
2819 IHTMLTxtRange_Release(range);
2821 hres = IHTMLTxtRange_duplicate(body_range, &range);
2822 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2824 test_range_collapse(range, TRUE);
2825 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2826 test_range_put_text(range, "word");
2827 test_range_text(body_range, "wordabc 123\r\nit's text");
2828 test_range_text(range, NULL);
2829 test_range_moveend(range, characterW, 3, 3);
2830 test_range_text(range, "abc");
2831 test_range_movestart(range, characterW, -2, -2);
2832 test_range_text(range, "rdabc");
2833 test_range_movestart(range, characterW, 3, 3);
2834 test_range_text(range, "bc");
2835 test_range_movestart(range, characterW, 4, 4);
2836 test_range_text(range, NULL);
2837 test_range_movestart(range, characterW, -3, -3);
2838 test_range_text(range, "c 1");
2839 test_range_movestart(range, characterW, -7, -6);
2840 test_range_text(range, "wordabc 1");
2841 test_range_movestart(range, characterW, 100, 22);
2842 test_range_text(range, NULL);
2844 IHTMLTxtRange_Release(range);
2845 IHTMLTxtRange_Release(body_range);
2847 hres = IHTMLDocument2_get_selection(doc, &selection);
2848 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2850 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2851 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2852 IHTMLSelectionObject_Release(selection);
2854 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2855 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2856 IDispatch_Release(disp_range);
2858 test_range_text(range, NULL);
2859 test_range_moveend(range, characterW, 3, 3);
2860 test_range_text(range, "wor");
2861 test_range_parent(range, ET_BODY);
2862 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2863 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2864 test_range_move(range, characterW, 3, 3);
2865 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2866 test_range_moveend(range, characterW, -4, -4);
2867 test_range_put_text(range, "abc def ");
2868 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2869 test_range_move(range, wordW, 1, 1);
2870 test_range_movestart(range, characterW, -1, -1);
2871 test_range_text(range, " ");
2872 test_range_move(range, wordW, 1, 1);
2873 test_range_moveend(range, characterW, 3, 3);
2874 test_range_text(range, "def");
2875 test_range_put_text(range, "xyz");
2876 test_range_moveend(range, characterW, 1, 1);
2877 test_range_move(range, wordW, 1, 1);
2878 test_range_moveend(range, characterW, 2, 2);
2879 test_range_text(range, "ab");
2881 IHTMLTxtRange_Release(range);
2884 static void test_txtrange2(IHTMLDocument2 *doc)
2886 IHTMLTxtRange *range;
2888 range = test_create_body_range(doc);
2890 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2891 test_range_move(range, characterW, 5, 5);
2892 test_range_moveend(range, characterW, 1, 1);
2893 test_range_text(range, "2");
2894 test_range_move(range, characterW, -3, -3);
2895 test_range_moveend(range, characterW, 3, 3);
2896 test_range_text(range, "c\r\n\r\n1");
2897 test_range_collapse(range, VARIANT_FALSE);
2898 test_range_moveend(range, characterW, 4, 4);
2899 test_range_text(range, "23");
2900 test_range_moveend(range, characterW, 1, 1);
2901 test_range_text(range, "23\r\n\r\n\r\nd");
2902 test_range_moveend(range, characterW, -1, -1);
2903 test_range_text(range, "23");
2904 test_range_moveend(range, characterW, -1, -1);
2905 test_range_text(range, "23");
2906 test_range_moveend(range, characterW, -2, -2);
2907 test_range_text(range, "2");
2909 IHTMLTxtRange_Release(range);
2912 static void test_compatmode(IHTMLDocument2 *doc)
2914 IHTMLDocument5 *doc5;
2918 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2919 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2923 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2924 IHTMLDocument5_Release(doc5);
2925 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2926 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2927 SysFreeString(mode);
2930 static void test_location(IHTMLDocument2 *doc)
2932 IHTMLLocation *location, *location2;
2933 IHTMLWindow2 *window;
2938 hres = IHTMLDocument2_get_location(doc, &location);
2939 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2941 hres = IHTMLDocument2_get_location(doc, &location2);
2942 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2944 ok(location == location2, "location != location2\n");
2945 IHTMLLocation_Release(location2);
2947 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2948 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2950 hres = IHTMLWindow2_get_location(window, &location2);
2951 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2952 ok(location == location2, "location != location2\n");
2953 IHTMLLocation_Release(location2);
2955 test_ifaces((IUnknown*)location, location_iids);
2956 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2958 hres = IHTMLLocation_get_pathname(location, &str);
2959 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2960 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2962 hres = IHTMLLocation_get_href(location, NULL);
2963 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2965 hres = IHTMLLocation_get_href(location, &str);
2966 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2967 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2969 ref = IHTMLLocation_Release(location);
2970 ok(!ref, "location chould be destroyed here\n");
2973 static void test_navigator(IHTMLDocument2 *doc)
2975 IHTMLWindow2 *window;
2976 IOmNavigator *navigator, *navigator2;
2983 static const WCHAR v40[] = {'4','.','0'};
2985 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2986 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2988 hres = IHTMLWindow2_get_navigator(window, &navigator);
2989 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2990 ok(navigator != NULL, "navigator == NULL\n");
2991 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2993 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2994 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2995 ok(navigator != navigator2, "navigator2 != navihgator\n");
2997 IHTMLWindow2_Release(window);
2998 IOmNavigator_Release(navigator2);
3000 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3001 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3002 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3003 SysFreeString(bstr);
3006 hres = IOmNavigator_get_appName(navigator, &bstr);
3007 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3008 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3009 SysFreeString(bstr);
3012 hres = IOmNavigator_get_platform(navigator, &bstr);
3013 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3015 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3017 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3019 SysFreeString(bstr);
3022 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3023 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3024 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3025 SysFreeString(bstr);
3027 hres = IOmNavigator_toString(navigator, NULL);
3028 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3031 hres = IOmNavigator_toString(navigator, &bstr);
3032 ok(hres == S_OK, "toString failed: %08x\n", hres);
3033 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3034 SysFreeString(bstr);
3037 hres = ObtainUserAgentString(0, buf, &size);
3038 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3041 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3042 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3043 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3044 SysFreeString(bstr);
3046 ref = IOmNavigator_Release(navigator);
3047 ok(!ref, "navigator should be destroyed here\n");
3050 static void test_screen(IHTMLWindow2 *window)
3052 IHTMLScreen *screen, *screen2;
3057 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
3060 hres = IHTMLWindow2_get_screen(window, &screen);
3061 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3062 ok(screen != NULL, "screen == NULL\n");
3065 hres = IHTMLWindow2_get_screen(window, &screen2);
3066 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3067 ok(screen2 != NULL, "screen == NULL\n");
3068 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3069 IHTMLScreen_Release(screen2);
3071 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3073 hdc = CreateICW(displayW, NULL, NULL, NULL);
3075 exl = GetDeviceCaps(hdc, HORZRES);
3077 hres = IHTMLScreen_get_width(screen, &l);
3078 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3079 ok(l == exl, "width = %d, expected %d\n", l, exl);
3081 exl = GetDeviceCaps(hdc, VERTRES);
3083 hres = IHTMLScreen_get_height(screen, &l);
3084 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3085 ok(l == exl, "height = %d, expected %d\n", l, exl);
3087 exl = GetDeviceCaps(hdc, BITSPIXEL);
3089 hres = IHTMLScreen_get_colorDepth(screen, &l);
3090 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3091 ok(l == exl, "height = %d, expected %d\n", l, exl);
3095 IHTMLScreen_Release(screen);
3098 static void test_current_style(IHTMLCurrentStyle *current_style)
3104 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3105 test_ifaces((IUnknown*)current_style, cstyle_iids);
3107 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3108 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3109 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3112 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3113 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3114 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3117 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3118 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3121 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3122 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3123 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3126 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3127 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3128 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3131 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3132 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3133 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3136 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3137 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3138 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3141 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3142 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3143 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3146 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3147 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3148 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3151 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3152 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3153 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3156 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3157 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3158 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3161 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3162 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3163 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3166 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3167 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3168 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3171 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3172 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3173 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3176 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3177 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3180 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3181 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3184 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3185 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3188 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3189 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3192 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3193 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3196 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3197 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3200 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3201 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3202 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3203 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3206 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3207 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3208 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3211 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3212 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3213 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3216 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3217 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3218 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3221 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3222 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3223 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3226 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3227 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3228 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3231 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3232 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3233 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3236 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3237 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3238 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3239 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3242 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3243 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3244 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3245 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3248 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3249 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3250 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3253 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3254 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3255 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3258 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3259 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3260 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3264 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3265 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3266 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3269 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3270 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3271 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3274 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3275 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3276 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3279 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3280 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3281 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3284 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3285 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3286 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3289 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3290 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3291 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3294 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3295 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3296 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3299 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3300 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3301 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3304 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3305 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3306 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3309 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3310 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3311 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3314 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3315 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3316 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3319 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3320 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3321 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3324 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3325 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3326 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3329 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3330 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3331 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3334 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3335 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3336 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3339 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3340 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3341 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3344 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3345 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3346 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3349 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3350 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3351 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3354 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3355 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3356 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3360 static void test_style2(IHTMLStyle2 *style2)
3365 str = (void*)0xdeadbeef;
3366 hres = IHTMLStyle2_get_position(style2, &str);
3367 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3368 ok(!str, "str != NULL\n");
3370 str = a2bstr("absolute");
3371 hres = IHTMLStyle2_put_position(style2, str);
3372 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3376 hres = IHTMLStyle2_get_position(style2, &str);
3377 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3378 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3382 static void test_style3(IHTMLStyle3 *style3)
3387 str = (void*)0xdeadbeef;
3388 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3389 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3390 ok(!str, "str != NULL\n");
3392 str = a2bstr("break-word");
3393 hres = IHTMLStyle3_put_wordWrap(style3, str);
3394 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3398 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3399 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3400 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3404 static void test_style4(IHTMLStyle4 *style4)
3410 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3411 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3414 V_BSTR(&v) = a2bstr("10px");
3415 hres = IHTMLStyle4_put_minHeight(style4, v);
3416 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3419 hres = IHTMLStyle4_get_minHeight(style4, &v);
3420 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3421 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3422 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3424 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3425 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3426 VariantClear(&vdefault);
3429 static void test_default_style(IHTMLStyle *style)
3431 IHTMLStyle2 *style2;
3432 IHTMLStyle3 *style3;
3433 IHTMLStyle4 *style4;
3439 BSTR sOverflowDefault;
3443 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3444 test_ifaces((IUnknown*)style, style_iids);
3446 test_style_csstext(style, NULL);
3448 hres = IHTMLStyle_get_position(style, &str);
3449 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3450 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3453 hres = IHTMLStyle_get_marginRight(style, &v);
3454 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3455 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3456 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3459 hres = IHTMLStyle_get_marginLeft(style, &v);
3460 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3461 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3462 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3464 str = (void*)0xdeadbeef;
3465 hres = IHTMLStyle_get_fontFamily(style, &str);
3466 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3467 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3469 str = (void*)0xdeadbeef;
3470 hres = IHTMLStyle_get_fontWeight(style, &str);
3471 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3472 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3474 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3475 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3477 str = a2bstr("test");
3478 hres = IHTMLStyle_put_fontWeight(style, str);
3479 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3482 str = a2bstr("bold");
3483 hres = IHTMLStyle_put_fontWeight(style, str);
3484 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3487 str = a2bstr("bolder");
3488 hres = IHTMLStyle_put_fontWeight(style, str);
3489 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3492 str = a2bstr("lighter");
3493 hres = IHTMLStyle_put_fontWeight(style, str);
3494 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3497 str = a2bstr("100");
3498 hres = IHTMLStyle_put_fontWeight(style, str);
3499 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3502 str = a2bstr("200");
3503 hres = IHTMLStyle_put_fontWeight(style, str);
3504 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3507 str = a2bstr("300");
3508 hres = IHTMLStyle_put_fontWeight(style, str);
3509 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3512 str = a2bstr("400");
3513 hres = IHTMLStyle_put_fontWeight(style, str);
3514 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3517 str = a2bstr("500");
3518 hres = IHTMLStyle_put_fontWeight(style, str);
3519 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3522 str = a2bstr("600");
3523 hres = IHTMLStyle_put_fontWeight(style, str);
3524 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3527 str = a2bstr("700");
3528 hres = IHTMLStyle_put_fontWeight(style, str);
3529 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3532 str = a2bstr("800");
3533 hres = IHTMLStyle_put_fontWeight(style, str);
3534 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3537 str = a2bstr("900");
3538 hres = IHTMLStyle_put_fontWeight(style, str);
3539 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3542 hres = IHTMLStyle_get_fontWeight(style, &str);
3543 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3544 ok(!strcmp_wa(str, "900"), "str != style900\n");
3547 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3548 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3549 SysFreeString(sDefault);
3552 hres = IHTMLStyle_get_fontVariant(style, NULL);
3553 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3555 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3556 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3558 str = a2bstr("test");
3559 hres = IHTMLStyle_put_fontVariant(style, str);
3560 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3563 str = a2bstr("small-caps");
3564 hres = IHTMLStyle_put_fontVariant(style, str);
3565 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3568 str = a2bstr("normal");
3569 hres = IHTMLStyle_put_fontVariant(style, str);
3570 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3573 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3574 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3575 SysFreeString(sDefault);
3577 str = (void*)0xdeadbeef;
3578 hres = IHTMLStyle_get_display(style, &str);
3579 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3580 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3582 str = (void*)0xdeadbeef;
3583 hres = IHTMLStyle_get_visibility(style, &str);
3584 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3585 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3588 hres = IHTMLStyle_get_fontSize(style, &v);
3589 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3590 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3591 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3594 hres = IHTMLStyle_get_color(style, &v);
3595 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3596 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3597 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3600 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3601 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3602 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3604 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3605 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3606 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3608 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3609 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3610 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3612 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3613 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3616 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3617 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3618 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3620 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3621 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3622 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3624 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3625 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3626 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3628 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3629 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3632 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3633 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3634 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3636 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3637 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3638 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3640 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3641 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3642 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3644 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3645 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3648 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3649 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3650 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3652 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3653 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3654 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3656 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3657 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3658 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3660 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3661 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3664 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3665 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3666 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3668 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3669 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3670 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3672 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3673 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3674 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3676 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3677 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3679 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3680 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3682 str = a2bstr("invalid");
3683 hres = IHTMLStyle_put_textDecoration(style, str);
3684 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3687 str = a2bstr("none");
3688 hres = IHTMLStyle_put_textDecoration(style, str);
3689 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3692 str = a2bstr("underline");
3693 hres = IHTMLStyle_put_textDecoration(style, str);
3694 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3697 str = a2bstr("overline");
3698 hres = IHTMLStyle_put_textDecoration(style, str);
3699 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3702 str = a2bstr("line-through");
3703 hres = IHTMLStyle_put_textDecoration(style, str);
3704 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3707 str = a2bstr("blink");
3708 hres = IHTMLStyle_put_textDecoration(style, str);
3709 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3712 hres = IHTMLStyle_get_textDecoration(style, &str);
3713 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3714 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3717 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3718 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3719 SysFreeString(sDefault);
3721 hres = IHTMLStyle_get_posWidth(style, NULL);
3722 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3724 hres = IHTMLStyle_get_posWidth(style, &f);
3725 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3726 ok(f == 0.0f, "f = %f\n", f);
3728 V_VT(&v) = VT_EMPTY;
3729 hres = IHTMLStyle_get_width(style, &v);
3730 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3731 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3732 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3734 hres = IHTMLStyle_put_posWidth(style, 2.2);
3735 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3737 hres = IHTMLStyle_get_posWidth(style, &f);
3738 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3740 f == 2.2f, /* IE8 */
3744 V_BSTR(&v) = a2bstr("auto");
3745 hres = IHTMLStyle_put_width(style, v);
3746 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3749 V_VT(&v) = VT_EMPTY;
3750 hres = IHTMLStyle_get_width(style, &v);
3751 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3752 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3753 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3757 str = (void*)0xdeadbeef;
3758 hres = IHTMLStyle_get_margin(style, &str);
3759 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3760 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3763 hres = IHTMLStyle_put_margin(style, str);
3764 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3767 hres = IHTMLStyle_get_margin(style, &str);
3768 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3769 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3771 hres = IHTMLStyle_put_margin(style, NULL);
3772 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3775 hres = IHTMLStyle_get_border(style, &str);
3776 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3777 ok(!str || !*str, "str is not empty\n");
3780 str = a2bstr("1px");
3781 hres = IHTMLStyle_put_border(style, str);
3782 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3785 V_VT(&v) = VT_EMPTY;
3786 hres = IHTMLStyle_get_left(style, &v);
3787 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3788 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3789 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3793 hres = IHTMLStyle_get_posLeft(style, NULL);
3794 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3797 hres = IHTMLStyle_get_posLeft(style, &f);
3798 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3799 ok(f == 0.0, "expected 0.0 got %f\n", f);
3801 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3802 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3804 hres = IHTMLStyle_get_posLeft(style, &f);
3805 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3807 f == 4.9f, /* IE8 */
3808 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3810 /* Ensure left is updated correctly. */
3811 V_VT(&v) = VT_EMPTY;
3812 hres = IHTMLStyle_get_left(style, &v);
3813 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3814 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3815 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3816 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3817 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3822 V_BSTR(&v) = a2bstr("3px");
3823 hres = IHTMLStyle_put_left(style, v);
3824 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3827 hres = IHTMLStyle_get_posLeft(style, &f);
3828 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3829 ok(f == 3.0, "expected 3.0 got %f\n", f);
3831 V_VT(&v) = VT_EMPTY;
3832 hres = IHTMLStyle_get_left(style, &v);
3833 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3834 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3835 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3839 hres = IHTMLStyle_put_left(style, v);
3840 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3842 V_VT(&v) = VT_EMPTY;
3843 hres = IHTMLStyle_get_left(style, &v);
3844 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3845 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3846 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3849 V_VT(&v) = VT_EMPTY;
3850 hres = IHTMLStyle_get_top(style, &v);
3851 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3852 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3853 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3857 hres = IHTMLStyle_get_posTop(style, NULL);
3858 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3861 hres = IHTMLStyle_get_posTop(style, &f);
3862 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3863 ok(f == 0.0, "expected 0.0 got %f\n", f);
3865 hres = IHTMLStyle_put_posTop(style, 4.9f);
3866 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3868 hres = IHTMLStyle_get_posTop(style, &f);
3869 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3871 f == 4.9f, /* IE8 */
3872 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3875 V_BSTR(&v) = a2bstr("3px");
3876 hres = IHTMLStyle_put_top(style, v);
3877 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(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3887 hres = IHTMLStyle_get_posTop(style, &f);
3888 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3889 ok(f == 3.0, "expected 3.0 got %f\n", f);
3892 hres = IHTMLStyle_put_top(style, v);
3893 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3895 V_VT(&v) = VT_EMPTY;
3896 hres = IHTMLStyle_get_top(style, &v);
3897 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3898 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3899 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3902 /* Test posHeight */
3903 hres = IHTMLStyle_get_posHeight(style, NULL);
3904 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3906 V_VT(&v) = VT_EMPTY;
3907 hres = IHTMLStyle_get_height(style, &v);
3908 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3909 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3910 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3914 hres = IHTMLStyle_get_posHeight(style, &f);
3915 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3916 ok(f == 0.0, "expected 0.0 got %f\n", f);
3918 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3919 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3921 hres = IHTMLStyle_get_posHeight(style, &f);
3922 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3924 f == 4.9f, /* IE8 */
3925 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3928 V_BSTR(&v) = a2bstr("64px");
3929 hres = IHTMLStyle_put_height(style, v);
3930 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3933 V_VT(&v) = VT_EMPTY;
3934 hres = IHTMLStyle_get_height(style, &v);
3935 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3936 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3937 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3940 hres = IHTMLStyle_get_posHeight(style, &f);
3941 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3942 ok(f == 64.0, "expected 64.0 got %f\n", f);
3944 str = (void*)0xdeadbeef;
3945 hres = IHTMLStyle_get_cursor(style, &str);
3946 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3947 ok(!str, "get_cursor != NULL\n");
3950 str = a2bstr("default");
3951 hres = IHTMLStyle_put_cursor(style, str);
3952 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3956 hres = IHTMLStyle_get_cursor(style, &str);
3957 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3958 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3961 V_VT(&v) = VT_EMPTY;
3962 hres = IHTMLStyle_get_verticalAlign(style, &v);
3963 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3964 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3965 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3969 V_BSTR(&v) = a2bstr("middle");
3970 hres = IHTMLStyle_put_verticalAlign(style, v);
3971 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3974 V_VT(&v) = VT_EMPTY;
3975 hres = IHTMLStyle_get_verticalAlign(style, &v);
3976 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3977 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3978 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3981 str = (void*)0xdeadbeef;
3982 hres = IHTMLStyle_get_textAlign(style, &str);
3983 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3984 ok(!str, "textAlign != NULL\n");
3986 str = a2bstr("center");
3987 hres = IHTMLStyle_put_textAlign(style, str);
3988 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3992 hres = IHTMLStyle_get_textAlign(style, &str);
3993 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3994 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3997 str = (void*)0xdeadbeef;
3998 hres = IHTMLStyle_get_filter(style, &str);
3999 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4000 ok(!str, "filter != NULL\n");
4002 str = a2bstr("alpha(opacity=100)");
4003 hres = IHTMLStyle_put_filter(style, str);
4004 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4007 V_VT(&v) = VT_EMPTY;
4008 hres = IHTMLStyle_get_zIndex(style, &v);
4009 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4010 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4011 ok(!V_I4(&v), "V_I4(v) != 0\n");
4015 V_BSTR(&v) = a2bstr("1");
4016 hres = IHTMLStyle_put_zIndex(style, v);
4017 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4020 V_VT(&v) = VT_EMPTY;
4021 hres = IHTMLStyle_get_zIndex(style, &v);
4022 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4023 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4024 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4028 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4029 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4031 str = a2bstr("test");
4032 hres = IHTMLStyle_put_fontStyle(style, str);
4033 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4036 str = a2bstr("italic");
4037 hres = IHTMLStyle_put_fontStyle(style, str);
4038 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4041 str = a2bstr("oblique");
4042 hres = IHTMLStyle_put_fontStyle(style, str);
4043 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4046 str = a2bstr("normal");
4047 hres = IHTMLStyle_put_fontStyle(style, str);
4048 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4051 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4052 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4053 SysFreeString(sDefault);
4056 hres = IHTMLStyle_get_overflow(style, NULL);
4057 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4059 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4060 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4062 str = a2bstr("test");
4063 hres = IHTMLStyle_put_overflow(style, str);
4064 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4067 str = a2bstr("visible");
4068 hres = IHTMLStyle_put_overflow(style, str);
4069 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4072 str = a2bstr("scroll");
4073 hres = IHTMLStyle_put_overflow(style, str);
4074 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4077 str = a2bstr("hidden");
4078 hres = IHTMLStyle_put_overflow(style, str);
4079 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4082 str = a2bstr("auto");
4083 hres = IHTMLStyle_put_overflow(style, str);
4084 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4087 hres = IHTMLStyle_get_overflow(style, &str);
4088 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4089 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4093 hres = IHTMLStyle_put_overflow(style, str);
4094 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4097 hres = IHTMLStyle_get_overflow(style, &str);
4098 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4099 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4102 /* restore overflow default */
4103 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4104 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4105 SysFreeString(sOverflowDefault);
4107 /* Attribute Tests*/
4108 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4109 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4111 str = a2bstr("position");
4112 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4113 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4115 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4116 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4117 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4120 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4121 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4124 V_BSTR(&v) = a2bstr("absolute");
4125 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4126 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4129 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4130 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4131 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4132 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4137 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4138 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4143 str = a2bstr("borderLeftStyle");
4144 test_border_styles(style, str);
4147 str = a2bstr("borderbottomstyle");
4148 test_border_styles(style, str);
4151 str = a2bstr("borderrightstyle");
4152 test_border_styles(style, str);
4155 str = a2bstr("bordertopstyle");
4156 test_border_styles(style, str);
4159 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4160 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4162 str = a2bstr("none dotted dashed solid");
4163 hres = IHTMLStyle_put_borderStyle(style, str);
4164 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4167 str = a2bstr("none dotted dashed solid");
4168 hres = IHTMLStyle_get_borderStyle(style, &str);
4169 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4170 ok(!strcmp_wa(str, "none dotted dashed solid"),
4171 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4174 str = a2bstr("double groove ridge inset");
4175 hres = IHTMLStyle_put_borderStyle(style, str);
4176 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4179 str = a2bstr("window-inset outset ridge inset");
4180 hres = IHTMLStyle_put_borderStyle(style, str);
4181 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4184 str = a2bstr("window-inset");
4185 hres = IHTMLStyle_put_borderStyle(style, str);
4186 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4189 str = a2bstr("none none none none none");
4190 hres = IHTMLStyle_put_borderStyle(style, str);
4191 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4194 str = a2bstr("invalid none none none");
4195 hres = IHTMLStyle_put_borderStyle(style, str);
4196 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4199 str = a2bstr("none invalid none none");
4200 hres = IHTMLStyle_put_borderStyle(style, str);
4201 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4204 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4205 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4206 SysFreeString(sDefault);
4208 /* backgoundColor */
4209 hres = IHTMLStyle_get_backgroundColor(style, &v);
4210 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4211 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4212 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4216 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4217 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4220 V_BSTR(&v) = a2bstr("10");
4221 hres = IHTMLStyle_put_paddingLeft(style, v);
4222 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4225 hres = IHTMLStyle_get_paddingLeft(style, &v);
4226 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4227 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4229 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4230 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4232 /* BackgroundRepeat */
4233 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4234 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4236 str = a2bstr("invalid");
4237 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4238 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4241 str = a2bstr("repeat");
4242 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4243 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4246 str = a2bstr("no-repeat");
4247 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4248 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4251 str = a2bstr("repeat-x");
4252 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4253 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4256 str = a2bstr("repeat-y");
4257 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4258 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4261 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4262 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4263 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4266 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4267 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4268 SysFreeString(sDefault);
4271 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4272 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4274 str = a2bstr("red green red blue");
4275 hres = IHTMLStyle_put_borderColor(style, str);
4276 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4279 hres = IHTMLStyle_get_borderColor(style, &str);
4280 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4281 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4284 hres = IHTMLStyle_put_borderColor(style, sDefault);
4285 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4286 SysFreeString(sDefault);
4289 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4290 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4292 str = a2bstr("thick dotted red");
4293 hres = IHTMLStyle_put_borderLeft(style, str);
4294 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4297 /* IHTMLStyle_get_borderLeft appears to have a bug where
4298 it returns the first letter of the color. So we check
4299 each style individually.
4302 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4303 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4304 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4308 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4309 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4310 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4313 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4314 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4315 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4318 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4319 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4320 SysFreeString(sDefault);
4322 /* backgroundPositionX */
4323 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4324 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4327 V_BSTR(&v) = a2bstr("10px");
4328 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4329 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4332 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4333 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4334 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4337 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4338 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4339 VariantClear(&vDefault);
4341 /* backgroundPositionY */
4342 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4343 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4346 V_BSTR(&v) = a2bstr("10px");
4347 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4348 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4351 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4352 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4353 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4356 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4357 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4358 VariantClear(&vDefault);
4360 /* borderTopWidth */
4361 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4362 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4365 V_BSTR(&v) = a2bstr("10px");
4366 hres = IHTMLStyle_put_borderTopWidth(style, v);
4367 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4370 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4371 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4372 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4375 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4376 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4377 VariantClear(&vDefault);
4379 /* borderRightWidth */
4380 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4381 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4384 V_BSTR(&v) = a2bstr("10");
4385 hres = IHTMLStyle_put_borderRightWidth(style, v);
4386 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4389 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4390 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4391 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4394 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4395 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4396 VariantClear(&vDefault);
4398 /* borderBottomWidth */
4399 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4400 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4403 V_BSTR(&v) = a2bstr("10");
4404 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4405 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4408 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4409 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4410 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4413 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4414 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4415 VariantClear(&vDefault);
4417 /* borderLeftWidth */
4418 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4419 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4422 V_BSTR(&v) = a2bstr("10");
4423 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4424 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4427 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4428 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4429 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4432 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4433 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4434 VariantClear(&vDefault);
4437 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4438 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4441 V_BSTR(&v) = a2bstr("10");
4442 hres = IHTMLStyle_put_wordSpacing(style, v);
4443 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4446 hres = IHTMLStyle_get_wordSpacing(style, &v);
4447 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4448 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4449 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4452 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4453 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4454 VariantClear(&vDefault);
4457 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4458 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4461 V_BSTR(&v) = a2bstr("11");
4462 hres = IHTMLStyle_put_letterSpacing(style, v);
4463 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4466 hres = IHTMLStyle_get_letterSpacing(style, &v);
4467 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4468 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4469 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4472 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4473 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4474 VariantClear(&vDefault);
4476 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4477 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4478 if(SUCCEEDED(hres)) {
4479 test_style2(style2);
4480 IHTMLStyle2_Release(style2);
4483 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4484 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4485 if(SUCCEEDED(hres)) {
4486 test_style3(style3);
4487 IHTMLStyle3_Release(style3);
4490 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4491 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4492 if(SUCCEEDED(hres)) {
4493 test_style4(style4);
4494 IHTMLStyle4_Release(style4);
4498 static void test_set_csstext(IHTMLStyle *style)
4503 test_style_set_csstext(style, "background-color: black;");
4505 hres = IHTMLStyle_get_backgroundColor(style, &v);
4506 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4507 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4508 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4512 static void test_default_selection(IHTMLDocument2 *doc)
4514 IHTMLSelectionObject *selection;
4515 IHTMLTxtRange *range;
4520 hres = IHTMLDocument2_get_selection(doc, &selection);
4521 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4523 hres = IHTMLSelectionObject_get_type(selection, &str);
4524 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4525 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4528 hres = IHTMLSelectionObject_createRange(selection, &disp);
4529 IHTMLSelectionObject_Release(selection);
4530 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4532 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4533 IDispatch_Release(disp);
4534 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4536 test_range_text(range, NULL);
4537 IHTMLTxtRange_Release(range);
4540 static void test_doc_elem(IHTMLDocument2 *doc)
4542 IHTMLDocument2 *doc_node, *owner_doc;
4544 IHTMLDocument3 *doc3;
4547 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4548 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4550 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4551 IHTMLDocument3_Release(doc3);
4552 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4554 test_node_name((IUnknown*)elem, "HTML");
4555 test_elem_tag((IUnknown*)elem, "HTML");
4557 doc_node = get_doc_node(doc);
4558 owner_doc = get_owner_doc((IUnknown*)elem);
4559 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4560 IHTMLDocument2_Release(owner_doc);
4562 owner_doc = get_owner_doc((IUnknown*)doc_node);
4563 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4564 IHTMLDocument2_Release(doc_node);
4566 test_elem_client_rect((IUnknown*)elem);
4568 IHTMLElement_Release(elem);
4571 static void test_default_body(IHTMLBodyElement *body)
4577 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4578 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4580 bstr = (void*)0xdeadbeef;
4581 hres = IHTMLBodyElement_get_background(body, &bstr);
4582 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4583 ok(bstr == NULL, "bstr != NULL\n");
4585 l = elem_get_scroll_height((IUnknown*)body);
4586 ok(l != -1, "scrollHeight == -1\n");
4587 l = elem_get_scroll_width((IUnknown*)body);
4588 ok(l != -1, "scrollWidth == -1\n");
4589 l = elem_get_scroll_top((IUnknown*)body);
4590 ok(!l, "scrollTop = %d\n", l);
4591 elem_get_scroll_left((IUnknown*)body);
4593 /* get_text tests */
4594 hres = IHTMLBodyElement_get_text(body, &v);
4595 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4596 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4597 ok(bstr == NULL, "bstr != NULL\n");
4600 /* get_text - Invalid Text */
4602 V_BSTR(&v) = SysAllocString(sTextInvalid);
4603 hres = IHTMLBodyElement_put_text(body, v);
4604 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4608 hres = IHTMLBodyElement_get_text(body, &v);
4609 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4610 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4611 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4614 /* get_text - Valid Text */
4616 V_BSTR(&v) = SysAllocString(sBodyText);
4617 hres = IHTMLBodyElement_put_text(body, v);
4618 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4622 hres = IHTMLBodyElement_get_text(body, &v);
4623 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4624 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4625 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4629 static void test_body_funs(IHTMLBodyElement *body)
4631 static WCHAR sRed[] = {'r','e','d',0};
4636 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4637 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4638 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4640 V_VT(&vbg) = VT_BSTR;
4641 V_BSTR(&vbg) = SysAllocString(sRed);
4642 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4643 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4646 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4647 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4648 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4649 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4652 /* Restore Originial */
4653 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4654 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4655 VariantClear(&vDefaultbg);
4658 static void test_window(IHTMLDocument2 *doc)
4660 IHTMLWindow2 *window, *window2, *self;
4661 IHTMLDocument2 *doc2 = NULL;
4667 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4668 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4669 test_ifaces((IUnknown*)window, window_iids);
4670 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4672 hres = IHTMLWindow2_get_document(window, &doc2);
4673 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4674 ok(doc2 != NULL, "doc2 == NULL\n");
4676 test_ifaces((IUnknown*)doc2, doc_node_iids);
4677 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4679 test_ifaces((IUnknown*)doc, doc_obj_iids);
4680 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4682 unk = (void*)0xdeadbeef;
4683 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4684 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4685 ok(!unk, "unk = %p\n", unk);
4687 IHTMLDocument_Release(doc2);
4689 hres = IHTMLWindow2_get_window(window, &window2);
4690 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4691 ok(window2 != NULL, "window2 == NULL\n");
4693 hres = IHTMLWindow2_get_self(window, &self);
4694 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4695 ok(window2 != NULL, "self == NULL\n");
4697 ok(self == window2, "self != window2\n");
4699 IHTMLWindow2_Release(window2);
4700 IHTMLWindow2_Release(self);
4703 hres = IHTMLDocument2_get_Script(doc, &disp);
4704 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4705 ok(disp == (void*)window, "disp != window\n");
4706 IDispatch_Release(disp);
4708 hres = IHTMLWindow2_toString(window, NULL);
4709 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4712 hres = IHTMLWindow2_toString(window, &str);
4713 ok(hres == S_OK, "toString failed: %08x\n", hres);
4714 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4717 test_window_name(window, NULL);
4718 set_window_name(window, "test");
4719 test_window_length(window, 0);
4720 test_screen(window);
4722 IHTMLWindow2_Release(window);
4725 static void test_defaults(IHTMLDocument2 *doc)
4727 IHTMLStyleSheetsCollection *stylesheetcol;
4728 IHTMLCurrentStyle *cstyle;
4729 IHTMLBodyElement *body;
4730 IHTMLElement2 *elem2;
4735 IHTMLElementCollection *collection;
4737 hres = IHTMLDocument2_get_body(doc, &elem);
4738 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4740 hres = IHTMLDocument2_get_images(doc, NULL);
4741 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4743 hres = IHTMLDocument2_get_images(doc, &collection);
4744 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4747 test_elem_collection((IUnknown*)collection, NULL, 0);
4748 IHTMLElementCollection_Release(collection);
4751 hres = IHTMLDocument2_get_applets(doc, NULL);
4752 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4754 hres = IHTMLDocument2_get_applets(doc, &collection);
4755 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4758 test_elem_collection((IUnknown*)collection, NULL, 0);
4759 IHTMLElementCollection_Release(collection);
4762 hres = IHTMLDocument2_get_links(doc, NULL);
4763 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4765 hres = IHTMLDocument2_get_links(doc, &collection);
4766 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4769 test_elem_collection((IUnknown*)collection, NULL, 0);
4770 IHTMLElementCollection_Release(collection);
4773 hres = IHTMLDocument2_get_forms(doc, NULL);
4774 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4776 hres = IHTMLDocument2_get_forms(doc, &collection);
4777 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4780 test_elem_collection((IUnknown*)collection, NULL, 0);
4781 IHTMLElementCollection_Release(collection);
4784 hres = IHTMLDocument2_get_anchors(doc, NULL);
4785 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4787 hres = IHTMLDocument2_get_anchors(doc, &collection);
4788 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4791 test_elem_collection((IUnknown*)collection, NULL, 0);
4792 IHTMLElementCollection_Release(collection);
4795 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4796 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4797 test_default_body(body);
4798 test_body_funs(body);
4799 IHTMLBodyElement_Release(body);
4801 hres = IHTMLElement_get_style(elem, &style);
4802 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4804 test_default_style(style);
4806 test_compatmode(doc);
4808 test_navigator(doc);
4810 elem2 = get_elem2_iface((IUnknown*)elem);
4811 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4812 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4813 if(SUCCEEDED(hres)) {
4814 test_current_style(cstyle);
4815 IHTMLCurrentStyle_Release(cstyle);
4817 IHTMLElement2_Release(elem2);
4819 IHTMLElement_Release(elem);
4821 test_set_csstext(style);
4822 IHTMLStyle_Release(style);
4824 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4825 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4828 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4829 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4830 ok(l == 0, "length = %d\n", l);
4832 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4834 test_default_selection(doc);
4835 test_doc_title(doc, "");
4838 static void test_tr_elem(IHTMLElement *elem)
4840 IHTMLElementCollection *col;
4844 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4846 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4847 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4852 hres = IHTMLTableRow_get_cells(row, &col);
4853 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4854 ok(col != NULL, "get_cells returned NULL\n");
4856 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4857 IHTMLElementCollection_Release(col);
4859 IHTMLTable_Release(row);
4862 static void test_table_elem(IHTMLElement *elem)
4864 IHTMLElementCollection *col;
4869 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4870 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4872 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4873 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4878 hres = IHTMLTable_get_rows(table, &col);
4879 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4880 ok(col != NULL, "get_ros returned NULL\n");
4882 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4883 IHTMLElementCollection_Release(col);
4885 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4887 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4888 test_elem_tag((IUnknown*)node, "TABLE");
4889 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4890 IHTMLDOMNode_Release(node);
4892 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4893 test_elem_tag((IUnknown*)node, "TABLE");
4894 test_elem_all((IUnknown*)node, NULL, 0);
4895 IHTMLDOMNode_Release(node);
4897 IHTMLTable_Release(table);
4900 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4910 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4911 SafeArrayAccessData(sa, (void**)&var);
4912 V_VT(var) = VT_BSTR;
4913 V_BSTR(var) = str = a2bstr(text);
4914 SafeArrayUnaccessData(sa);
4917 hres = IHTMLDocument2_writeln(doc, sa);
4919 hres = IHTMLDocument2_write(doc, sa);
4920 ok(hres == S_OK, "write failed: %08x\n", hres);
4923 SafeArrayDestroy(sa);
4926 static void test_frame_doc(IUnknown *frame_elem)
4928 IHTMLDocument2 *window_doc, *elem_doc;
4929 IHTMLWindow2 *content_window;
4931 content_window = get_frame_content_window(frame_elem);
4932 window_doc = get_window_doc(content_window);
4933 IHTMLWindow2_Release(content_window);
4935 elem_doc = get_elem_doc(frame_elem);
4936 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
4938 IHTMLDocument2_Release(elem_doc);
4939 IHTMLDocument2_Release(window_doc);
4942 static void test_iframe_elem(IHTMLElement *elem)
4944 IHTMLDocument2 *content_doc, *owner_doc;
4945 IHTMLElementCollection *col;
4946 IHTMLWindow2 *content_window;
4952 static const elem_type_t all_types[] = {
4960 test_frame_doc((IUnknown*)elem);
4962 content_window = get_frame_content_window((IUnknown*)elem);
4963 test_window_length(content_window, 0);
4965 content_doc = get_window_doc(content_window);
4966 IHTMLWindow2_Release(content_window);
4968 str = a2bstr("text/html");
4969 V_VT(&errv) = VT_ERROR;
4971 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4973 ok(hres == S_OK, "open failed: %08x\n", hres);
4974 ok(disp != NULL, "disp == NULL\n");
4975 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4976 IDispatch_Release(disp);
4978 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4979 doc_write(content_doc, TRUE, "</html>");
4981 hres = IHTMLDocument2_get_all(content_doc, &col);
4982 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4983 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4984 IHTMLElementCollection_Release(col);
4986 hres = IHTMLDocument2_close(content_doc);
4987 ok(hres == S_OK, "close failed: %08x\n", hres);
4989 owner_doc = get_owner_doc((IUnknown*)content_doc);
4990 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4992 IHTMLDocument2_Release(content_doc);
4995 static void test_stylesheet(IDispatch *disp)
4997 IHTMLStyleSheetRulesCollection *col = NULL;
4998 IHTMLStyleSheet *stylesheet;
5001 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
5002 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
5004 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
5005 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
5006 ok(col != NULL, "col == NULL\n");
5008 IHTMLStyleSheetRulesCollection_Release(col);
5009 IHTMLStyleSheet_Release(stylesheet);
5012 static void test_stylesheets(IHTMLDocument2 *doc)
5014 IHTMLStyleSheetsCollection *col = NULL;
5019 hres = IHTMLDocument2_get_styleSheets(doc, &col);
5020 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5021 ok(col != NULL, "col == NULL\n");
5023 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
5024 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5025 ok(len == 1, "len=%d\n", len);
5031 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5032 ok(hres == S_OK, "item failed: %08x\n", hres);
5033 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
5034 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5035 test_stylesheet(V_DISPATCH(&res));
5042 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
5043 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5044 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
5045 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
5048 IHTMLStyleSheetsCollection_Release(col);
5051 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
5053 IDispatchEx *dispex;
5055 DISPPARAMS dp = {NULL, NULL, 0, 0};
5063 static const WCHAR w0[] = {'0',0};
5064 static const WCHAR w100[] = {'1','0','0',0};
5066 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
5067 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
5069 bstr = SysAllocString(w0);
5070 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5071 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5072 SysFreeString(bstr);
5075 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
5076 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
5077 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
5078 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
5079 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
5080 type = get_node_type((IUnknown*)node);
5081 ok(type == 3, "type=%d\n", type);
5082 IHTMLDOMNode_Release(node);
5085 bstr = SysAllocString(w100);
5086 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
5087 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
5088 SysFreeString(bstr);
5090 IDispatchEx_Release(dispex);
5095 static void test_elems(IHTMLDocument2 *doc)
5097 IHTMLElementCollection *col;
5098 IHTMLDOMChildrenCollection *child_col;
5099 IHTMLElement *elem, *elem2, *elem3;
5100 IHTMLDOMNode *node, *node2;
5101 IHTMLWindow2 *window;
5105 IHTMLElementCollection *collection;
5106 IHTMLDocument3 *doc3;
5109 static const elem_type_t all_types[] = {
5135 static const elem_type_t item_types[] = {
5141 hres = IHTMLDocument2_get_all(doc, &col);
5142 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5143 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5144 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5145 IHTMLElementCollection_Release(col);
5147 hres = IHTMLDocument2_get_images(doc, &collection);
5148 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5151 static const elem_type_t images_types[] = {ET_IMG};
5152 test_elem_collection((IUnknown*)collection, images_types, 1);
5154 IHTMLElementCollection_Release(collection);
5157 hres = IHTMLDocument2_get_links(doc, &collection);
5158 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5161 static const elem_type_t images_types[] = {ET_A};
5162 test_elem_collection((IUnknown*)collection, images_types, 1);
5164 IHTMLElementCollection_Release(collection);
5167 hres = IHTMLDocument2_get_anchors(doc, &collection);
5168 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5171 static const elem_type_t anchor_types[] = {ET_A};
5172 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5174 IHTMLElementCollection_Release(collection);
5177 elem = get_doc_elem(doc);
5178 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5179 IHTMLElement_Release(elem);
5181 get_elem_by_id(doc, "xxx", FALSE);
5182 elem = get_doc_elem_by_id(doc, "xxx");
5183 ok(!elem, "elem != NULL\n");
5185 elem = get_doc_elem_by_id(doc, "s");
5186 ok(elem != NULL, "elem == NULL\n");
5188 test_elem_type((IUnknown*)elem, ET_SELECT);
5189 test_elem_attr(elem, "xxx", NULL);
5190 test_elem_attr(elem, "id", "s");
5191 test_elem_class((IUnknown*)elem, NULL);
5192 test_elem_set_class((IUnknown*)elem, "cl");
5193 test_elem_set_class((IUnknown*)elem, NULL);
5194 test_elem_tabindex((IUnknown*)elem, 0);
5195 test_elem_set_tabindex((IUnknown*)elem, 1);
5197 node = test_node_get_parent((IUnknown*)elem);
5198 ok(node != NULL, "node == NULL\n");
5199 test_node_name((IUnknown*)node, "BODY");
5200 node2 = test_node_get_parent((IUnknown*)node);
5201 IHTMLDOMNode_Release(node);
5202 ok(node2 != NULL, "node == NULL\n");
5203 test_node_name((IUnknown*)node2, "HTML");
5204 node = test_node_get_parent((IUnknown*)node2);
5205 IHTMLDOMNode_Release(node2);
5206 ok(node != NULL, "node == NULL\n");
5209 test_node_name((IUnknown*)node, "#document");
5210 type = get_node_type((IUnknown*)node);
5211 ok(type == 9, "type=%d, expected 9\n", type);
5212 node2 = test_node_get_parent((IUnknown*)node);
5213 IHTMLDOMNode_Release(node);
5214 ok(node2 == NULL, "node != NULL\n");
5217 elem2 = test_elem_get_parent((IUnknown*)elem);
5218 ok(elem2 != NULL, "elem2 == NULL\n");
5219 test_node_name((IUnknown*)elem2, "BODY");
5220 elem3 = test_elem_get_parent((IUnknown*)elem2);
5221 IHTMLElement_Release(elem2);
5222 ok(elem3 != NULL, "elem3 == NULL\n");
5223 test_node_name((IUnknown*)elem3, "HTML");
5224 elem2 = test_elem_get_parent((IUnknown*)elem3);
5225 IHTMLElement_Release(elem3);
5226 ok(elem2 == NULL, "elem2 != NULL\n");
5228 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5229 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5230 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5232 test_elem_innertext(elem, "opt1opt2");
5234 IHTMLElement_Release(elem);
5237 elem = get_elem_by_id(doc, "s", TRUE);
5239 IHTMLSelectElement *select;
5240 IHTMLDocument2 *doc_node, *elem_doc;
5242 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5243 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5245 test_select_elem(select);
5247 test_elem_title((IUnknown*)select, NULL);
5248 test_elem_set_title((IUnknown*)select, "Title");
5249 test_elem_title((IUnknown*)select, "Title");
5250 test_elem_offset((IUnknown*)select);
5252 node = get_first_child((IUnknown*)select);
5253 ok(node != NULL, "node == NULL\n");
5255 test_elem_type((IUnknown*)node, ET_OPTION);
5256 IHTMLDOMNode_Release(node);
5259 type = get_node_type((IUnknown*)select);
5260 ok(type == 1, "type=%d\n", type);
5262 IHTMLSelectElement_Release(select);
5264 elem_doc = get_elem_doc((IUnknown*)elem);
5266 doc_node = get_doc_node(doc);
5267 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
5268 IHTMLDocument2_Release(doc_node);
5269 IHTMLDocument2_Release(elem_doc);
5271 IHTMLElement_Release(elem);
5274 elem = get_elem_by_id(doc, "sc", TRUE);
5276 IHTMLScriptElement *script;
5279 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5280 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5286 hres = IHTMLScriptElement_get_type(script, &type);
5287 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5288 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5289 SysFreeString(type);
5292 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5293 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5295 hres = IHTMLScriptElement_get_defer(script, &vb);
5296 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5297 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5299 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5300 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5303 IHTMLScriptElement_Release(script);
5306 elem = get_elem_by_id(doc, "in", TRUE);
5308 IHTMLInputElement *input;
5310 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5311 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5313 test_elem_id((IUnknown*)elem, "in");
5314 test_elem_put_id((IUnknown*)elem, "newin");
5315 test_input_get_disabled(input, VARIANT_FALSE);
5316 test_input_set_disabled(input, VARIANT_TRUE);
5317 test_input_set_disabled(input, VARIANT_FALSE);
5318 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5319 test_input_get_disabled(input, VARIANT_TRUE);
5320 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5321 test_input_get_disabled(input, VARIANT_FALSE);
5322 test_elem_client_size((IUnknown*)elem);
5324 test_node_get_value_str((IUnknown*)elem, NULL);
5325 test_node_put_value_str((IUnknown*)elem, "test");
5326 test_node_get_value_str((IUnknown*)elem, NULL);
5327 test_input_value((IUnknown*)elem, NULL);
5328 test_input_put_value((IUnknown*)elem, "test");
5329 test_input_value((IUnknown*)elem, NULL);
5330 test_elem_class((IUnknown*)elem, "testclass");
5331 test_elem_tabindex((IUnknown*)elem, 2);
5332 test_elem_set_tabindex((IUnknown*)elem, 3);
5333 test_elem_title((IUnknown*)elem, "test title");
5335 test_input_get_defaultchecked(input, VARIANT_FALSE);
5336 test_input_set_defaultchecked(input, VARIANT_TRUE);
5337 test_input_set_defaultchecked(input, VARIANT_FALSE);
5339 test_input_get_checked(input, VARIANT_FALSE);
5340 test_input_set_checked(input, VARIANT_TRUE);
5341 test_input_set_checked(input, VARIANT_FALSE);
5343 test_input_src(input, NULL);
5344 test_input_set_src(input, "about:blank");
5346 IHTMLInputElement_Release(input);
5347 IHTMLElement_Release(elem);
5350 elem = get_elem_by_id(doc, "imgid", TRUE);
5352 test_img_src((IUnknown*)elem, "");
5353 test_img_set_src((IUnknown*)elem, "about:blank");
5354 test_img_alt((IUnknown*)elem, NULL);
5355 test_img_set_alt((IUnknown*)elem, "alt test");
5356 IHTMLElement_Release(elem);
5359 elem = get_doc_elem_by_id(doc, "tbl");
5360 ok(elem != NULL, "elem == NULL\n");
5362 test_table_elem(elem);
5363 IHTMLElement_Release(elem);
5366 elem = get_doc_elem_by_id(doc, "row2");
5367 ok(elem != NULL, "elem == NULL\n");
5370 IHTMLElement_Release(elem);
5373 elem = get_doc_elem_by_id(doc, "ifr");
5374 ok(elem != NULL, "elem == NULL\n");
5376 test_iframe_elem(elem);
5377 IHTMLElement_Release(elem);
5380 elem = get_elem_by_id(doc, "a", TRUE);
5382 test_anchor_href((IUnknown*)elem, "http://test/");
5383 IHTMLElement_Release(elem);
5386 hres = IHTMLDocument2_get_body(doc, &elem);
5387 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5389 node = get_first_child((IUnknown*)elem);
5390 ok(node != NULL, "node == NULL\n");
5392 test_ifaces((IUnknown*)node, text_iids);
5393 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5395 node2 = get_first_child((IUnknown*)node);
5396 ok(!node2, "node2 != NULL\n");
5398 type = get_node_type((IUnknown*)node);
5399 ok(type == 3, "type=%d\n", type);
5401 test_node_get_value_str((IUnknown*)node, "text test");
5402 test_node_put_value_str((IUnknown*)elem, "test text");
5403 test_node_get_value_str((IUnknown*)node, "text test");
5405 IHTMLDOMNode_Release(node);
5408 child_col = get_child_nodes((IUnknown*)elem);
5409 ok(child_col != NULL, "child_coll == NULL\n");
5413 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5415 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5416 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5417 ok(length, "length=0\n");
5420 node = get_child_item(child_col, 0);
5421 ok(node != NULL, "node == NULL\n");
5423 type = get_node_type((IUnknown*)node);
5424 ok(type == 3, "type=%d\n", type);
5425 node2 = node_get_next((IUnknown*)node);
5426 IHTMLDOMNode_Release(node);
5429 node = get_child_item(child_col, 1);
5430 ok(node != NULL, "node == NULL\n");
5432 type = get_node_type((IUnknown*)node);
5433 ok(type == 8, "type=%d\n", type);
5435 test_elem_id((IUnknown*)node, NULL);
5436 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5437 IHTMLDOMNode_Release(node2);
5438 IHTMLDOMNode_Release(node);
5441 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5442 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5444 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5445 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5447 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5448 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5450 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5451 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5453 test_child_col_disp(child_col);
5455 IHTMLDOMChildrenCollection_Release(child_col);
5458 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5459 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5460 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5462 IHTMLElement_Release(elem);
5464 test_stylesheets(doc);
5465 test_create_option_elem(doc);
5466 test_create_img_elem(doc);
5468 elem = get_doc_elem_by_id(doc, "tbl");
5469 ok(elem != NULL, "elem = NULL\n");
5470 test_elem_set_innertext(elem, "inner text");
5471 IHTMLElement_Release(elem);
5473 test_doc_title(doc, "test");
5474 test_doc_set_title(doc, "test title");
5475 test_doc_title(doc, "test title");
5478 hres = IHTMLDocument2_get_Script(doc, &disp);
5479 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5482 IDispatchEx *dispex;
5483 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5484 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5488 BSTR str = a2bstr("Testing");
5489 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5490 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5491 ok(pid != -1, "pid == -1\n");
5493 IDispatchEx_Release(dispex);
5496 IDispatch_Release(disp);
5498 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5499 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5501 str = a2bstr("img");
5502 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5503 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5507 static const elem_type_t img_types[] = { ET_IMG };
5509 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5510 IHTMLElementCollection_Release(col);
5513 elem = get_doc_elem_by_id(doc, "y");
5514 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5515 test_elem_innerhtml((IUnknown*)elem, "inner html");
5516 test_elem_set_innerhtml((IUnknown*)elem, "");
5517 test_elem_innerhtml((IUnknown*)elem, NULL);
5518 node = node_get_next((IUnknown*)elem);
5519 ok(!node, "node = %p\n", node);
5521 elem2 = get_doc_elem_by_id(doc, "x");
5522 test_elem_tag((IUnknown*)elem2, "A");
5523 node = node_get_next((IUnknown*)elem2);
5524 IHTMLDOMNode_Release(node);
5525 IHTMLElement_Release(elem2);
5526 IHTMLElement_Release(elem);
5528 IHTMLDocument3_Release(doc3);
5530 window = get_doc_window(doc);
5531 test_window_name(window, NULL);
5532 set_window_name(window, "test name");
5533 test_window_length(window, 1);
5534 IHTMLWindow2_Release(window);
5537 static void test_elems2(IHTMLDocument2 *doc)
5539 IHTMLElement *elem, *elem2;
5541 static const elem_type_t outer_types[] = {
5546 elem = get_doc_elem_by_id(doc, "divid");
5548 test_elem_set_innerhtml((IUnknown*)elem, "<div id=\"innerid\"></div>");
5549 elem2 = get_doc_elem_by_id(doc, "innerid");
5550 ok(elem2 != NULL, "elem2 == NULL\n");
5551 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
5552 test_elem_all((IUnknown*)elem, outer_types, sizeof(outer_types)/sizeof(*outer_types));
5553 IHTMLElement_Release(elem2);
5555 elem2 = get_doc_elem_by_id(doc, "aid");
5556 ok(elem2 != NULL, "elem2 == NULL\n");
5557 test_elem_set_outerhtml((IUnknown*)elem2, "");
5558 test_elem_all((IUnknown*)elem, outer_types, 1);
5559 IHTMLElement_Release(elem2);
5561 IHTMLElement_Release(elem);
5564 static void test_create_elems(IHTMLDocument2 *doc)
5566 IHTMLElement *elem, *body, *elem2;
5567 IHTMLDOMNode *node, *node2, *node3, *comment;
5568 IHTMLDocument5 *doc5;
5575 static const elem_type_t types1[] = { ET_TESTG };
5577 elem = test_create_elem(doc, "TEST");
5578 test_elem_tag((IUnknown*)elem, "TEST");
5579 type = get_node_type((IUnknown*)elem);
5580 ok(type == 1, "type=%d\n", type);
5581 test_ifaces((IUnknown*)elem, elem_iids);
5582 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5584 hres = IHTMLDocument2_get_body(doc, &body);
5585 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5586 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5588 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5589 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5590 elem2 = get_elem_iface((IUnknown*)node);
5591 IHTMLElement_Release(elem2);
5593 hres = IHTMLElement_get_all(body, &disp);
5594 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5595 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5596 IDispatch_Release(disp);
5598 test_node_remove_child((IUnknown*)body, node);
5600 hres = IHTMLElement_get_all(body, &disp);
5601 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5602 test_elem_collection((IUnknown*)disp, NULL, 0);
5603 IDispatch_Release(disp);
5604 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5606 IHTMLElement_Release(elem);
5607 IHTMLDOMNode_Release(node);
5609 node = test_create_text(doc, "test");
5610 test_ifaces((IUnknown*)node, text_iids);
5611 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5613 V_VT(&var) = VT_NULL;
5614 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5615 IHTMLDOMNode_Release(node);
5617 node = test_create_text(doc, "insert ");
5619 V_VT(&var) = VT_DISPATCH;
5620 V_DISPATCH(&var) = (IDispatch*)node2;
5621 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5622 IHTMLDOMNode_Release(node);
5623 IHTMLDOMNode_Release(node2);
5624 IHTMLDOMNode_Release(node3);
5626 test_elem_innertext(body, "insert test");
5627 test_elem_innerhtml((IUnknown*)body, "insert test");
5629 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5632 str = a2bstr("testing");
5633 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5635 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5638 type = get_node_type((IUnknown*)comment);
5639 ok(type == 8, "type=%d, expected 8\n", type);
5641 test_node_get_value_str((IUnknown*)comment, "testing");
5643 IHTMLDOMNode_Release(comment);
5646 IHTMLDocument5_Release(doc5);
5649 IHTMLElement_Release(body);
5652 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5654 IOleCommandTarget *cmdtrg;
5657 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5658 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5660 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5661 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5663 IOleCommandTarget_Release(cmdtrg);
5666 static void test_indent(IHTMLDocument2 *doc)
5668 IHTMLElementCollection *col;
5669 IHTMLTxtRange *range;
5672 static const elem_type_t all_types[] = {
5681 static const elem_type_t indent_types[] = {
5692 hres = IHTMLDocument2_get_all(doc, &col);
5693 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5694 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5695 IHTMLElementCollection_Release(col);
5697 range = test_create_body_range(doc);
5698 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5699 IHTMLTxtRange_Release(range);
5701 hres = IHTMLDocument2_get_all(doc, &col);
5702 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5703 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5704 IHTMLElementCollection_Release(col);
5707 static void test_cond_comment(IHTMLDocument2 *doc)
5709 IHTMLElementCollection *col;
5712 static const elem_type_t all_types[] = {
5720 hres = IHTMLDocument2_get_all(doc, &col);
5721 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5722 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5723 IHTMLElementCollection_Release(col);
5726 static void test_frame(IDispatch *disp, const char *exp_id)
5728 IHTMLWindow2 *frame2, *parent, *top;
5729 IHTMLDocument2 *parent_doc, *top_doc;
5730 IHTMLWindow4 *frame;
5731 IHTMLFrameBase *frame_elem;
5734 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5735 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5739 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5740 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5741 IHTMLWindow4_Release(frame);
5745 test_frame_doc((IUnknown*)frame_elem);
5746 test_elem_id((IUnknown*)frame_elem, exp_id);
5747 IHTMLElement_Release(frame_elem);
5749 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
5750 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
5754 hres = IHTMLWindow2_get_parent(frame2, &parent);
5755 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
5757 IHTMLWindow2_Release(frame2);
5761 hres = IHTMLWindow2_get_document(parent, &parent_doc);
5762 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5763 IHTMLWindow2_Release(parent);
5765 IHTMLWindow2_Release(frame2);
5769 test_doc_title(parent_doc, "frameset test");
5770 IHTMLDocument2_Release(parent_doc);
5773 hres = IHTMLWindow2_get_top(frame2, &top);
5774 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
5775 IHTMLWindow2_Release(frame2);
5779 hres = IHTMLWindow2_get_document(top, &top_doc);
5780 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
5781 IHTMLWindow2_Release(top);
5785 test_doc_title(top_doc, "frameset test");
5786 IHTMLDocument2_Release(top_doc);
5789 static void test_frameset(IHTMLDocument2 *doc)
5791 IHTMLWindow2 *window;
5792 IHTMLFramesCollection2 *frames;
5795 VARIANT index_var, result_var;
5798 window = get_doc_window(doc);
5800 /* test using IHTMLFramesCollection object */
5802 hres = IHTMLWindow2_get_frames(window, &frames);
5803 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5804 IHTMLWindow2_Release(window);
5808 /* test result length */
5809 hres = IHTMLFramesCollection2_get_length(frames, &length);
5810 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5811 ok(length == 2, "IHTMLFramesCollection2_get_length should have been 2, was: %d\n", length);
5813 /* test first frame */
5814 V_VT(&index_var) = VT_I4;
5815 V_I4(&index_var) = 0;
5816 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5817 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5818 if(SUCCEEDED(hres)) {
5819 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5820 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5822 VariantClear(&result_var);
5824 /* test second frame */
5825 V_I4(&index_var) = 1;
5826 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5827 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5828 if(SUCCEEDED(hres)) {
5829 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5830 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5832 VariantClear(&result_var);
5834 /* fail on third frame */
5835 V_I4(&index_var) = 2;
5836 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5837 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5838 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5839 VariantClear(&result_var);
5841 /* string argument (element id lookup) */
5842 V_VT(&index_var) = VT_BSTR;
5843 V_BSTR(&index_var) = a2bstr("fr1");
5844 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5845 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5846 if(SUCCEEDED(hres)) {
5847 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5848 test_frame(V_DISPATCH(&result_var), "fr1");
5850 VariantClear(&result_var);
5851 VariantClear(&index_var);
5853 /* invalid argument */
5854 V_VT(&index_var) = VT_BOOL;
5855 V_BOOL(&index_var) = VARIANT_TRUE;
5856 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5857 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5858 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5859 VariantClear(&result_var);
5861 IHTMLFramesCollection2_Release(frames);
5863 /* test using IHTMLWindow2 inheritance */
5865 /* test result length */
5866 hres = IHTMLWindow2_get_length(window, &length);
5867 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5868 ok(length == 2, "IHTMLWindow2_get_length should have been 2, was: %d\n", length);
5870 /* test first frame */
5871 V_VT(&index_var) = VT_I4;
5872 V_I4(&index_var) = 0;
5873 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5874 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5875 if(SUCCEEDED(hres)) {
5876 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5877 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5879 VariantClear(&result_var);
5881 /* test second frame */
5882 V_I4(&index_var) = 1;
5883 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5884 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5885 if(SUCCEEDED(hres)) {
5886 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5887 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5889 VariantClear(&result_var);
5891 /* fail on third frame */
5892 V_I4(&index_var) = 2;
5893 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5894 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5895 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5896 VariantClear(&result_var);
5898 /* string argument (element id lookup) */
5899 V_VT(&index_var) = VT_BSTR;
5900 V_BSTR(&index_var) = a2bstr("fr2");
5901 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5902 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5903 if(SUCCEEDED(hres)) {
5904 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
5905 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5907 VariantClear(&result_var);
5908 VariantClear(&index_var);
5910 /* invalid argument */
5911 V_VT(&index_var) = VT_BOOL;
5912 V_BOOL(&index_var) = VARIANT_TRUE;
5913 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5914 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5915 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5916 VariantClear(&result_var);
5918 /* getElementById with node name attributes */
5919 elem = get_doc_elem_by_id(doc, "nm1");
5920 test_elem_id((IUnknown*)elem, "fr1");
5921 IHTMLElement_Release(elem);
5924 static IHTMLDocument2 *notif_doc;
5925 static BOOL doc_complete;
5927 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5928 REFIID riid, void**ppv)
5930 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5935 ok(0, "unexpected call\n");
5936 return E_NOINTERFACE;
5939 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5944 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5949 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5951 if(dispID == DISPID_READYSTATE){
5955 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5956 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5958 if(!strcmp_wa(state, "complete"))
5959 doc_complete = TRUE;
5961 SysFreeString(state);
5967 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5969 ok(0, "unexpected call\n");
5973 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5974 PropertyNotifySink_QueryInterface,
5975 PropertyNotifySink_AddRef,
5976 PropertyNotifySink_Release,
5977 PropertyNotifySink_OnChanged,
5978 PropertyNotifySink_OnRequestEdit
5981 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5983 static IHTMLDocument2 *create_doc_with_string(const char *str)
5985 IPersistStreamInit *init;
5987 IHTMLDocument2 *doc;
5991 notif_doc = doc = create_document();
5995 doc_complete = FALSE;
5997 mem = GlobalAlloc(0, len);
5998 memcpy(mem, str, len);
5999 CreateStreamOnHGlobal(mem, TRUE, &stream);
6001 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
6003 IPersistStreamInit_Load(init, stream);
6004 IPersistStreamInit_Release(init);
6005 IStream_Release(stream);
6010 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
6012 IConnectionPointContainer *container;
6013 IConnectionPoint *cp;
6017 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
6018 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
6020 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
6021 IConnectionPointContainer_Release(container);
6022 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
6024 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
6025 IConnectionPoint_Release(cp);
6026 ok(hres == S_OK, "Advise failed: %08x\n", hres);
6029 typedef void (*domtest_t)(IHTMLDocument2*);
6031 static void run_domtest(const char *str, domtest_t test)
6033 IHTMLDocument2 *doc;
6037 doc = create_doc_with_string(str);
6041 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
6043 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
6044 TranslateMessage(&msg);
6045 DispatchMessage(&msg);
6050 ref = IHTMLDocument2_Release(doc);
6052 ref == 1, /* Vista */
6060 run_domtest(doc_str1, test_doc_elem);
6061 run_domtest(doc_str1, test_get_set_attr);
6062 run_domtest(range_test_str, test_txtrange);
6063 run_domtest(range_test2_str, test_txtrange2);
6064 if (winetest_interactive || ! is_ie_hardened()) {
6065 run_domtest(elem_test_str, test_elems);
6067 skip("IE running in Enhanced Security Configuration\n");
6069 run_domtest(elem_test2_str, test_elems2);
6070 run_domtest(doc_blank, test_create_elems);
6071 run_domtest(doc_blank, test_defaults);
6072 run_domtest(indent_test_str, test_indent);
6073 run_domtest(cond_comment_str, test_cond_comment);
6074 run_domtest(frameset_str, test_frameset);