2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
34 #include "mshtml_test.h"
36 static const char doc_blank[] = "<html></html>";
37 static const char doc_str1[] = "<html><body>test</body></html>";
38 static const char range_test_str[] =
39 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
40 static const char range_test2_str[] =
41 "<html><body>abc<hr />123<br /><hr />def</body></html>";
42 static const char elem_test_str[] =
43 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
44 "<body onload=\"Testing()\">text test<!-- a comment -->"
45 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
46 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
47 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
48 "<textarea id=\"X\">text text</textarea>"
49 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
50 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
53 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 static const char indent_test_str[] =
56 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
57 static const char cond_comment_str[] =
58 "<html><head><title>test</title></head><body>"
59 "<!--[if gte IE 4]> <br> <![endif]-->"
62 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
63 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
64 static WCHAR wordW[] = {'w','o','r','d',0};
93 static const IID * const none_iids[] = {
98 static const IID * const doc_node_iids[] = {
107 &IID_IConnectionPointContainer,
108 &IID_IInternetHostSecurityManager,
112 static const IID * const doc_obj_iids[] = {
119 &IID_IConnectionPointContainer,
124 static const IID * const elem_iids[] = {
131 &IID_IConnectionPointContainer,
135 static const IID * const body_iids[] = {
141 &IID_IHTMLTextContainer,
142 &IID_IHTMLBodyElement,
144 &IID_IConnectionPointContainer,
148 static const IID * const anchor_iids[] = {
154 &IID_IHTMLAnchorElement,
156 &IID_IConnectionPointContainer,
160 static const IID * const input_iids[] = {
166 &IID_IHTMLInputElement,
167 &IID_IHTMLInputTextElement,
169 &IID_IConnectionPointContainer,
173 static const IID * const select_iids[] = {
179 &IID_IHTMLSelectElement,
181 &IID_IConnectionPointContainer,
185 static const IID * const textarea_iids[] = {
191 &IID_IHTMLTextAreaElement,
193 &IID_IConnectionPointContainer,
197 static const IID * const option_iids[] = {
203 &IID_IHTMLOptionElement,
205 &IID_IConnectionPointContainer,
209 static const IID * const table_iids[] = {
217 &IID_IConnectionPointContainer,
221 static const IID * const script_iids[] = {
227 &IID_IHTMLScriptElement,
229 &IID_IConnectionPointContainer,
233 static const IID * const text_iids[] = {
236 &IID_IHTMLDOMTextNode,
240 static const IID * const location_iids[] = {
246 static const IID * const window_iids[] = {
254 static const IID * const comment_iids[] = {
260 &IID_IHTMLCommentElement,
262 &IID_IConnectionPointContainer,
266 static const IID * const img_iids[] = {
273 &IID_IHTMLImgElement,
274 &IID_IConnectionPointContainer,
278 static const IID * const tr_iids[] = {
286 &IID_IConnectionPointContainer,
290 static const IID * const td_iids[] = {
297 &IID_IConnectionPointContainer,
301 static const IID * const iframe_iids[] = {
308 &IID_IHTMLFrameBase2,
310 &IID_IConnectionPointContainer,
314 static const IID * const generic_iids[] = {
320 &IID_IHTMLGenericElement,
322 &IID_IConnectionPointContainer,
326 static const IID * const style_iids[] = {
337 static const IID * const cstyle_iids[] = {
341 &IID_IHTMLCurrentStyle,
351 static const elem_type_info_t elem_type_infos[] = {
352 {"", none_iids, NULL},
353 {"HTML", elem_iids, NULL},
354 {"HEAD", elem_iids, NULL},
355 {"TITLE", elem_iids, NULL},
356 {"BODY", body_iids, &DIID_DispHTMLBody},
357 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
358 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
359 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
360 {"TEXTAREA", textarea_iids, NULL},
361 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
362 {"STYLE", elem_iids, NULL},
363 {"BLOCKQUOTE",elem_iids, NULL},
364 {"P", elem_iids, NULL},
365 {"BR", elem_iids, NULL},
366 {"TABLE", table_iids, &DIID_DispHTMLTable},
367 {"TBODY", elem_iids, NULL},
368 {"SCRIPT", script_iids, NULL},
369 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
370 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
371 {"!", comment_iids, &DIID_DispHTMLCommentElement},
372 {"IMG", img_iids, &DIID_DispHTMLImg},
373 {"TR", tr_iids, &DIID_DispHTMLTableRow},
374 {"TD", td_iids, NULL},
375 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
378 static const char *dbgstr_guid(REFIID riid)
382 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
383 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
384 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
385 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
390 static int strcmp_wa(LPCWSTR strw, const char *stra)
393 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
394 return lstrcmpA(stra, buf);
397 static BSTR a2bstr(const char *str)
402 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
403 ret = SysAllocStringLen(NULL, len);
404 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
409 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
411 IUnknown *unk1, *unk2;
416 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
417 IUnknown_Release(unk1);
418 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
419 IUnknown_Release(unk2);
424 static IHTMLDocument2 *create_document(void)
427 IHTMLDocument5 *doc5;
430 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
431 &IID_IHTMLDocument2, (void**)&doc);
432 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
434 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
436 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
437 IHTMLDocument2_Release(doc);
441 IHTMLDocument5_Release(doc5);
445 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
446 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
448 const IID * const *piid;
452 for(piid = iids; *piid; piid++) {
453 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
454 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
456 IUnknown_Release(unk);
460 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
461 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
469 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
470 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
475 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
476 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
477 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
479 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
480 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
482 if(SUCCEEDED(hres)) {
485 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
486 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
488 *iid = type_attr->guid;
492 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
493 ITypeInfo_Release(typeinfo);
496 IDispatchEx_Release(dispex);
500 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
501 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
503 DISPPARAMS dp = {NULL,NULL,0,0};
509 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
510 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
514 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
515 IDispatchEx_Release(dispex);
516 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
518 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
519 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
523 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
524 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
528 if(_test_get_dispid(line, unk, &iid))
529 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
532 _test_disp_value(line, unk, val);
535 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
536 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
540 if(_test_get_dispid(line, unk, &iid))
541 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
542 "unexpected guid %s\n", dbgstr_guid(&iid));
545 _test_disp_value(line, unk, val);
548 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
549 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
554 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
555 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
559 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
560 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
565 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
566 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
570 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
571 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
576 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
577 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
581 #define get_node_iface(u) _get_node_iface(__LINE__,u)
582 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
587 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
588 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
592 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
593 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
598 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
599 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
603 #define get_img_iface(u) _get_img_iface(__LINE__,u)
604 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
606 IHTMLImgElement *img;
609 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
610 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
614 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
615 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
617 IHTMLAnchorElement *anchor;
620 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
621 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
625 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
626 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
628 IHTMLDOMNode *node = _get_node_iface(line, unk);
632 hres = IHTMLDOMNode_get_nodeName(node, &name);
633 IHTMLDOMNode_Release(node);
634 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
635 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
640 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
641 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
643 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
644 IDispatch *disp = (void*)0xdeadbeef;
648 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
649 IHTMLDOMNode2_Release(node);
650 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
651 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
653 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
654 IDispatch_Release(disp);
655 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
660 #define get_doc_window(d) _get_doc_window(__LINE__,d)
661 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
663 IHTMLWindow2 *window;
667 hres = IHTMLDocument2_get_parentWindow(doc, &window);
668 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
669 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
674 #define clone_node(n,d) _clone_node(__LINE__,n,d)
675 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
677 IHTMLDOMNode *node = _get_node_iface(line, unk);
678 IHTMLDOMNode *ret = NULL;
681 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
682 IHTMLDOMNode_Release(node);
683 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
684 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
690 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
691 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
693 IHTMLElement *elem = _get_elem_iface(line, unk);
697 hres = IHTMLElement_get_tagName(elem, &tag);
698 IHTMLElement_Release(elem);
699 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
700 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
705 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
706 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
708 _test_elem_tag(line, unk, elem_type_infos[type].tag);
709 _test_ifaces(line, unk, elem_type_infos[type].iids);
711 if(elem_type_infos[type].dispiid && type != ET_A)
712 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
715 #define get_node_type(n) _get_node_type(__LINE__,n)
716 static LONG _get_node_type(unsigned line, IUnknown *unk)
718 IHTMLDOMNode *node = _get_node_iface(line, unk);
722 hres = IHTMLDOMNode_get_nodeType(node, &type);
723 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
725 IHTMLDOMNode_Release(node);
730 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
731 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
733 IHTMLDOMNode *node = _get_node_iface(line, unk);
734 IHTMLDOMChildrenCollection *col = NULL;
738 hres = IHTMLDOMNode_get_childNodes(node, &disp);
739 IHTMLDOMNode_Release(node);
740 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
744 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
745 IDispatch_Release(disp);
746 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
751 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
752 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
754 IHTMLDOMNode *node = NULL;
758 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
759 ok(hres == S_OK, "item failed: %08x\n", hres);
761 node = _get_node_iface(line, (IUnknown*)disp);
762 IDispatch_Release(disp);
767 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
768 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
777 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
779 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
782 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
783 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
785 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
788 VariantClear(&value);
791 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
792 static void _test_elem_offset(unsigned line, IUnknown *unk)
794 IHTMLElement *elem = _get_elem_iface(line, unk);
798 hres = IHTMLElement_get_offsetTop(elem, &l);
799 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
801 hres = IHTMLElement_get_offsetHeight(elem, &l);
802 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
804 hres = IHTMLElement_get_offsetWidth(elem, &l);
805 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
807 IHTMLElement_Release(elem);
810 #define get_doc_node(d) _get_doc_node(__LINE__,d)
811 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
813 IHTMLWindow2 *window;
817 hres = IHTMLDocument2_get_parentWindow(doc, &window);
818 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
820 hres = IHTMLWindow2_get_document(window, &ret);
821 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
822 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
827 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
828 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
833 hres = IHTMLWindow2_get_name(window, &name);
834 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
836 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
838 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
841 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
842 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
848 hres = IHTMLWindow2_put_name(window, str);
850 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
852 _test_window_name(line, window, name);
855 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
856 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
861 hres = IHTMLWindow2_get_length(window, &length);
862 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
863 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
866 static void test_get_set_attr(IHTMLDocument2 *doc)
869 IHTMLDocument3 *doc3;
874 /* grab an element to test with */
875 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
876 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
878 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
879 IHTMLDocument3_Release(doc3);
880 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
882 /* get a non-present attribute */
883 bstr = a2bstr("notAnAttribute");
884 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
885 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
886 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
890 /* get a present attribute */
891 bstr = a2bstr("scrollHeight");
892 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
893 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
894 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
898 /* create a new BSTR attribute */
899 bstr = a2bstr("newAttribute");
901 V_VT(&val) = VT_BSTR;
902 V_BSTR(&val) = a2bstr("the value");
903 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
904 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
907 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
908 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
909 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
910 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)));
913 /* overwrite the attribute with a BOOL */
914 V_VT(&val) = VT_BOOL;
915 V_BOOL(&val) = VARIANT_TRUE;
916 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
917 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
920 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
921 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
922 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
923 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
928 /* case-insensitive */
929 bstr = a2bstr("newattribute");
930 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
931 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
932 todo_wine ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
933 todo_wine ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
937 IHTMLElement_Release(elem);
940 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
941 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
944 IHTMLDocument3 *doc3;
947 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
948 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
949 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
950 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
951 IHTMLDocument3_Release(doc3);
956 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
957 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
959 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
963 hres = IHTMLAnchorElement_get_href(anchor, &str);
964 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
965 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
968 _test_disp_value(line, unk, exhref);
971 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
972 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
977 hres = IHTMLOptionElement_get_text(option, &bstr);
978 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
979 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
983 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
984 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
990 hres = IHTMLOptionElement_put_text(option, bstr);
992 ok(hres == S_OK, "put_text failed: %08x\n", hres);
994 _test_option_text(line, option, text);
997 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
998 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1003 hres = IHTMLOptionElement_get_value(option, &bstr);
1004 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1005 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1006 SysFreeString(bstr);
1009 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1010 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1015 bstr = a2bstr(value);
1016 hres = IHTMLOptionElement_put_value(option, bstr);
1017 SysFreeString(bstr);
1018 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1020 _test_option_value(line, option, value);
1023 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1024 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1025 const char *txt, const char *val)
1027 IHTMLOptionElementFactory *factory;
1028 IHTMLOptionElement *option;
1029 IHTMLWindow2 *window;
1030 VARIANT text, value, empty;
1033 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1034 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1036 hres = IHTMLWindow2_get_Option(window, &factory);
1037 IHTMLWindow2_Release(window);
1038 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1040 V_VT(&text) = VT_BSTR;
1041 V_BSTR(&text) = a2bstr(txt);
1042 V_VT(&value) = VT_BSTR;
1043 V_BSTR(&value) = a2bstr(val);
1044 V_VT(&empty) = VT_EMPTY;
1046 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1047 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1049 IHTMLOptionElementFactory_Release(factory);
1050 VariantClear(&text);
1051 VariantClear(&value);
1053 _test_option_text(line, option, txt);
1054 _test_option_value(line, option, val);
1059 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1060 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1062 LONG len = 0xdeadbeef;
1065 hres = IHTMLSelectElement_get_length(select, &len);
1066 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1067 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1070 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1071 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1073 LONG idx = 0xdeadbeef;
1076 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1077 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1078 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1081 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1082 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1086 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1087 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1088 _test_select_selidx(line, select, index);
1091 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1092 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1097 hres = IHTMLSelectElement_get_value(select, &val);
1098 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1100 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1102 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1105 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1106 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1112 hres = IHTMLSelectElement_put_value(select, bstr);
1113 SysFreeString(bstr);
1114 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1117 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1118 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1123 hres = IHTMLSelectElement_get_type(select, &type);
1124 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1125 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1128 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1129 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1134 hres = IHTMLTxtRange_get_text(range, &text);
1135 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1138 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1139 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1141 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1144 SysFreeString(text);
1148 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1149 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1153 hres = IHTMLTxtRange_collapse(range, b);
1154 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1155 _test_range_text(line, range, NULL);
1158 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1159 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1160 VARIANT_BOOL exb, const char *extext)
1162 VARIANT_BOOL b = 0xe0e0;
1165 hres = IHTMLTxtRange_expand(range, unit, &b);
1166 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1167 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1168 _test_range_text(line, range, extext);
1171 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1172 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1174 LONG c = 0xdeadbeef;
1177 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1178 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1179 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1180 _test_range_text(line, range, NULL);
1183 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1184 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1185 LPWSTR unit, LONG cnt, LONG excnt)
1187 LONG c = 0xdeadbeef;
1190 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1191 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1192 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1195 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1196 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1198 LONG c = 0xdeadbeef;
1201 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1202 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1203 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1206 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1207 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1210 BSTR bstr = a2bstr(text);
1212 hres = IHTMLTxtRange_put_text(range, bstr);
1213 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1214 SysFreeString(bstr);
1215 _test_range_text(line, range, NULL);
1218 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1219 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1225 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1226 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1227 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1230 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1231 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1237 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1238 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1239 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1242 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1243 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1244 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1247 test_range_inrange(range1, range2, VARIANT_TRUE);
1248 test_range_inrange(range2, range1, VARIANT_TRUE);
1252 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1253 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1258 hres = IHTMLTxtRange_parentElement(range, &elem);
1259 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1261 _test_elem_type(line, (IUnknown*)elem, type);
1263 IHTMLElement_Release(elem);
1266 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1267 static void _test_elem_collection(unsigned line, IUnknown *unk,
1268 const elem_type_t *elem_types, LONG exlen)
1270 IHTMLElementCollection *col;
1273 VARIANT name, index;
1274 IDispatch *disp, *disp2;
1277 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1278 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1280 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1282 hres = IHTMLElementCollection_get_length(col, &len);
1283 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1284 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1289 V_VT(&index) = VT_EMPTY;
1291 for(i=0; i<len; i++) {
1292 V_VT(&name) = VT_I4;
1294 disp = (void*)0xdeadbeef;
1295 hres = IHTMLElementCollection_item(col, name, index, &disp);
1296 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1297 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1298 if(FAILED(hres) || !disp)
1301 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1304 V_VT(&name) = VT_UINT;
1306 disp2 = (void*)0xdeadbeef;
1307 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1308 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1309 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1311 IDispatch_Release(disp2);
1314 IDispatch_Release(disp);
1317 V_VT(&name) = VT_I4;
1319 disp = (void*)0xdeadbeef;
1320 hres = IHTMLElementCollection_item(col, name, index, &disp);
1321 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1322 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1324 V_VT(&name) = VT_I4;
1326 disp = (void*)0xdeadbeef;
1327 hres = IHTMLElementCollection_item(col, name, index, &disp);
1328 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1329 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1331 IHTMLElementCollection_Release(col);
1334 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1335 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1337 IHTMLElement *elem = _get_elem_iface(line, unk);
1341 hres = IHTMLElement_get_all(elem, &disp);
1342 IHTMLElement_Release(elem);
1343 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1345 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1346 IDispatch_Release(disp);
1349 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1350 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1352 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1353 IHTMLElementCollection *col = NULL;
1354 elem_type_t *types = NULL;
1359 tmp = a2bstr(elem_type_infos[type].tag);
1360 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1362 IHTMLElement2_Release(elem);
1363 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1364 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1367 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1368 for(i=0; i<exlen; i++)
1372 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1374 HeapFree(GetProcessHeap(), 0, types);
1377 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1378 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1383 hres = IHTMLElement_get_innerText(elem, &text);
1384 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1385 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1386 wine_dbgstr_w(text), extext);
1387 SysFreeString(text);
1390 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1391 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1393 IHTMLDOMChildrenCollection *col;
1398 hres = IHTMLElement_put_innerText(elem, str);
1399 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1402 _test_elem_innertext(line, elem, text);
1405 col = _get_child_nodes(line, (IUnknown*)elem);
1406 ok(col != NULL, "col == NULL\n");
1408 LONG length = 0, type;
1411 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1412 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1413 ok(length == 1, "length = %d\n", length);
1415 node = _get_child_item(line, col, 0);
1416 ok(node != NULL, "node == NULL\n");
1418 type = _get_node_type(line, (IUnknown*)node);
1419 ok(type == 3, "type=%d\n", type);
1420 IHTMLDOMNode_Release(node);
1423 IHTMLDOMChildrenCollection_Release(col);
1428 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1429 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1431 IHTMLElement *elem = _get_elem_iface(line, unk);
1435 hres = IHTMLElement_get_innerHTML(elem, &html);
1436 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1438 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1440 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1442 IHTMLElement_Release(elem);
1443 SysFreeString(html);
1446 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1447 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1449 IHTMLElement *elem = _get_elem_iface(line, unk);
1453 html = a2bstr(inner_html);
1454 hres = IHTMLElement_put_innerHTML(elem, html);
1455 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1457 IHTMLElement_Release(elem);
1458 SysFreeString(html);
1461 #define get_first_child(n) _get_first_child(__LINE__,n)
1462 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1464 IHTMLDOMNode *node = _get_node_iface(line, unk);
1465 IHTMLDOMNode *child = NULL;
1468 hres = IHTMLDOMNode_get_firstChild(node, &child);
1469 IHTMLDOMNode_Release(node);
1470 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1475 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1476 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1478 IHTMLDOMNode *node = _get_node_iface(line, unk);
1479 VARIANT_BOOL b = 0xdead;
1482 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1483 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1484 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1486 IHTMLDOMNode_Release(node);
1489 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1490 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1492 IHTMLDOMNode *node = _get_node_iface(line, unk);
1493 IHTMLDOMNode *parent;
1496 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1497 IHTMLDOMNode_Release(node);
1498 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1503 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1504 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1506 IHTMLElement *elem = _get_elem_iface(line, unk);
1507 IHTMLElement *parent;
1510 hres = IHTMLElement_get_parentElement(elem, &parent);
1511 IHTMLElement_Release(elem);
1512 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1517 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1518 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1520 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1521 VARIANT_BOOL disabled = 100;
1525 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1526 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1527 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1528 IHTMLElement3_Release(elem3);
1531 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1532 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1534 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1538 hres = IHTMLElement3_put_disabled(elem3, b);
1539 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1541 IHTMLElement3_Release(elem3);
1542 _test_elem3_get_disabled(line, unk, b);
1545 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1546 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1548 VARIANT_BOOL disabled = 100;
1551 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1552 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1553 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1555 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1558 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1559 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1563 hres = IHTMLSelectElement_put_disabled(select, b);
1564 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1566 _test_select_get_disabled(line, select, b);
1569 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1570 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1572 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1573 IHTMLTextContainer *txtcont;
1574 LONG l = -1, l2 = -1;
1577 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1578 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1579 IHTMLElement2_Release(elem);
1581 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1582 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1584 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1585 IHTMLTextContainer_Release(txtcont);
1586 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1587 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1592 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1593 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1595 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1596 IHTMLTextContainer *txtcont;
1597 LONG l = -1, l2 = -1;
1600 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1601 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1602 IHTMLElement2_Release(elem);
1604 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1605 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1607 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1608 IHTMLTextContainer_Release(txtcont);
1609 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1610 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1615 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1616 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1618 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1619 IHTMLTextContainer *txtcont;
1620 LONG l = -1, l2 = -1;
1623 hres = IHTMLElement2_get_scrollTop(elem, &l);
1624 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1625 IHTMLElement2_Release(elem);
1627 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1628 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1630 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1631 IHTMLTextContainer_Release(txtcont);
1632 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1633 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1638 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1639 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1641 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1642 IHTMLTextContainer *txtcont;
1643 LONG l = -1, l2 = -1;
1646 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1647 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1649 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1650 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1651 IHTMLElement2_Release(elem);
1653 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1654 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1656 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1657 IHTMLTextContainer_Release(txtcont);
1658 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1659 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1662 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1663 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1665 IHTMLImgElement *img = _get_img_iface(line, unk);
1669 hres = IHTMLImgElement_get_src(img, &src);
1670 IHTMLImgElement_Release(img);
1671 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1672 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1676 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1677 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1679 IHTMLImgElement *img = _get_img_iface(line, unk);
1684 hres = IHTMLImgElement_put_src(img, tmp);
1685 IHTMLImgElement_Release(img);
1687 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1689 _test_img_src(line, unk, src);
1692 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1693 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1695 IHTMLImgElement *img = _get_img_iface(line, unk);
1699 hres = IHTMLImgElement_get_alt(img, &alt);
1700 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1702 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1704 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1708 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1709 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1711 IHTMLImgElement *img = _get_img_iface(line, unk);
1716 hres = IHTMLImgElement_put_alt(img, tmp);
1717 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1720 _test_img_alt(line, unk, alt);
1723 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1724 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1726 VARIANT_BOOL disabled = 100;
1729 hres = IHTMLInputElement_get_disabled(input, &disabled);
1730 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1731 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1733 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1736 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1737 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1741 hres = IHTMLInputElement_put_disabled(input, b);
1742 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1744 _test_input_get_disabled(line, input, b);
1747 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1748 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1750 VARIANT_BOOL checked = 100;
1753 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1754 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1755 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1758 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1759 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1763 hres = IHTMLInputElement_put_defaultChecked(input, b);
1764 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1766 _test_input_get_defaultchecked(line, input, b);
1769 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1770 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1772 VARIANT_BOOL checked = 100;
1775 hres = IHTMLInputElement_get_checked(input, &checked);
1776 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1777 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1780 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1781 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1785 hres = IHTMLInputElement_put_checked(input, b);
1786 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1788 _test_input_get_checked(line, input, b);
1791 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1792 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1794 IHTMLInputElement *input;
1798 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1799 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1803 hres = IHTMLInputElement_get_value(input, &bstr);
1804 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1806 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1808 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1809 SysFreeString(bstr);
1810 IHTMLInputElement_Release(input);
1813 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1814 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1816 IHTMLInputElement *input;
1820 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1821 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1826 hres = IHTMLInputElement_get_value(input, &bstr);
1827 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1828 SysFreeString(bstr);
1829 IHTMLInputElement_Release(input);
1832 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1833 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1838 hres = IHTMLInputElement_get_src(input, &src);
1839 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1841 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1843 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1847 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1848 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1854 hres = IHTMLInputElement_put_src(input, tmp);
1856 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1858 _test_input_src(line, input, src);
1861 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1862 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1864 IHTMLElement *elem = _get_elem_iface(line, unk);
1865 BSTR class = (void*)0xdeadbeef;
1868 hres = IHTMLElement_get_className(elem, &class);
1869 IHTMLElement_Release(elem);
1870 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
1872 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
1874 ok_(__FILE__,line) (!class, "class != NULL\n");
1875 SysFreeString(class);
1878 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1879 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
1881 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1885 hres = IHTMLElement2_get_tabIndex(elem2, &index);
1886 IHTMLElement2_Release(elem2);
1887 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1888 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
1891 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1892 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
1894 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
1897 hres = IHTMLElement2_put_tabIndex(elem2, index);
1898 IHTMLElement2_Release(elem2);
1899 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
1901 _test_elem_tabindex(line, unk, index);
1904 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1905 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
1907 IHTMLElement *elem = _get_elem_iface(line, unk);
1911 tmp = class ? a2bstr(class) : NULL;
1912 hres = IHTMLElement_put_className(elem, tmp);
1913 IHTMLElement_Release(elem);
1914 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
1917 _test_elem_class(line, unk, class);
1920 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1921 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
1923 IHTMLElement *elem = _get_elem_iface(line, unk);
1924 BSTR id = (void*)0xdeadbeef;
1927 hres = IHTMLElement_get_id(elem, &id);
1928 IHTMLElement_Release(elem);
1929 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
1932 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
1934 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
1939 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1940 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
1942 IHTMLElement *elem = _get_elem_iface(line, unk);
1943 BSTR tmp = a2bstr(new_id);
1946 hres = IHTMLElement_put_id(elem, tmp);
1947 IHTMLElement_Release(elem);
1949 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
1951 _test_elem_id(line, unk, new_id);
1954 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1955 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
1957 IHTMLElement *elem = _get_elem_iface(line, unk);
1961 hres = IHTMLElement_get_title(elem, &title);
1962 IHTMLElement_Release(elem);
1963 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1965 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
1967 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
1969 SysFreeString(title);
1972 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1973 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
1975 IHTMLElement *elem = _get_elem_iface(line, unk);
1979 tmp = a2bstr(title);
1980 hres = IHTMLElement_put_title(elem, tmp);
1981 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
1983 IHTMLElement_Release(elem);
1987 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1988 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
1990 IHTMLDOMNode *node = _get_node_iface(line, unk);
1994 hres = IHTMLDOMNode_get_nodeValue(node, &var);
1995 IHTMLDOMNode_Release(node);
1996 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
1999 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2000 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2002 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2008 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2009 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2011 IHTMLDOMNode *node = _get_node_iface(line, unk);
2015 V_VT(&var) = VT_BSTR;
2016 V_BSTR(&var) = a2bstr(val);
2018 hres = IHTMLDOMNode_put_nodeValue(node, var);
2019 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2020 IHTMLDOMNode_Release(node);
2024 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2025 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2027 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2031 hres = IHTMLElement2_get_clientWidth(elem, &l);
2032 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2033 hres = IHTMLElement2_get_clientHeight(elem, &l);
2034 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2036 IHTMLElement2_Release(elem);
2039 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2040 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2042 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2046 hres = IHTMLElement2_get_clientLeft(elem, &l);
2047 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2048 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2050 hres = IHTMLElement2_get_clientTop(elem, &l);
2051 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2052 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2054 IHTMLElement2_Release(elem);
2057 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2058 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2060 IHTMLElement *elem = NULL;
2065 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2066 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2067 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2072 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2073 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2075 IHTMLDocument3 *doc3;
2076 IHTMLDOMNode *node = NULL;
2080 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2081 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2084 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2085 IHTMLDocument3_Release(doc3);
2086 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2087 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2092 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2093 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2095 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2096 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2097 IHTMLDOMNode *new_child = NULL;
2100 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2101 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2102 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2103 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2105 IHTMLDOMNode_Release(node);
2106 IHTMLDOMNode_Release(child);
2111 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2112 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2114 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2115 IHTMLDOMNode *new_child = NULL;
2118 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2119 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2120 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2121 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2123 IHTMLDOMNode_Release(node);
2128 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2129 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2131 IHTMLDOMNode *node = _get_node_iface(line, unk);
2132 IHTMLDOMNode *new_node = NULL;
2135 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2136 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2137 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2138 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2140 IHTMLDOMNode_Release(node);
2141 IHTMLDOMNode_Release(new_node);
2144 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2145 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2150 hres = IHTMLDocument2_get_title(doc, &title);
2151 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2152 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2153 SysFreeString(title);
2156 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2157 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2162 tmp = a2bstr(title);
2163 hres = IHTMLDocument2_put_title(doc, tmp);
2164 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2168 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2169 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2174 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2175 LOCALE_USER_DEFAULT, &dispid);
2176 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2179 DISPPARAMS params = {NULL,NULL,0,0};
2180 DISPID dispidNamed = DISPID_PROPERTYPUT;
2185 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2186 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2187 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2190 params.cNamedArgs = 1;
2191 params.rgdispidNamedArgs = &dispidNamed;
2192 V_VT(&arg) = VT_BSTR;
2193 V_BSTR(&arg) = a2bstr("none");
2194 params.rgvarg = &arg;
2195 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2196 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2197 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2200 V_VT(&arg) = VT_BSTR;
2201 V_BSTR(&arg) = a2bstr("dotted");
2202 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2203 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2204 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2207 V_VT(&arg) = VT_BSTR;
2208 V_BSTR(&arg) = a2bstr("dashed");
2209 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2210 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2211 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2214 V_VT(&arg) = VT_BSTR;
2215 V_BSTR(&arg) = a2bstr("solid");
2216 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2217 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2218 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2221 V_VT(&arg) = VT_BSTR;
2222 V_BSTR(&arg) = a2bstr("double");
2223 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2224 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2225 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2228 V_VT(&arg) = VT_BSTR;
2229 V_BSTR(&arg) = a2bstr("groove");
2230 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2231 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2232 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2235 V_VT(&arg) = VT_BSTR;
2236 V_BSTR(&arg) = a2bstr("ridge");
2237 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2238 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2239 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2242 V_VT(&arg) = VT_BSTR;
2243 V_BSTR(&arg) = a2bstr("inset");
2244 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2245 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2246 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2249 V_VT(&arg) = VT_BSTR;
2250 V_BSTR(&arg) = a2bstr("outset");
2251 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2252 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2253 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2256 V_VT(&arg) = VT_BSTR;
2257 V_BSTR(&arg) = a2bstr("invalid");
2258 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2259 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2260 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2263 params.rgvarg = &vDefault;
2264 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2265 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2266 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2270 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2271 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2273 BSTR text = (void*)0xdeadbeef;
2276 hres = IHTMLStyle_get_cssText(style, &text);
2277 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2279 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2281 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2283 SysFreeString(text);
2286 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2287 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2293 hres = IHTMLStyle_put_cssText(style, tmp);
2294 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2298 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2299 const elem_type_t *elem_types, LONG len)
2302 VARIANT name, index;
2306 V_VT(&index) = VT_EMPTY;
2307 V_VT(&name) = VT_BSTR;
2308 V_BSTR(&name) = a2bstr(n);
2310 hres = IHTMLElementCollection_item(col, name, index, &disp);
2311 ok(hres == S_OK, "item failed: %08x\n", hres);
2313 test_elem_collection((IUnknown*)disp, elem_types, len);
2314 IDispatch_Release(disp);
2315 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2319 V_VT(&index) = VT_I4;
2321 for(i=0; i<len; i++) {
2323 disp = (void*)0xdeadbeef;
2324 hres = IHTMLElementCollection_item(col, name, index, &disp);
2325 ok(hres == S_OK, "item failed: %08x\n", hres);
2326 ok(disp != NULL, "disp == NULL\n");
2327 if(FAILED(hres) || !disp)
2330 test_elem_type((IUnknown*)disp, elem_types[i]);
2332 IDispatch_Release(disp);
2336 disp = (void*)0xdeadbeef;
2337 hres = IHTMLElementCollection_item(col, name, index, &disp);
2338 ok(hres == S_OK, "item failed: %08x\n", hres);
2339 ok(disp == NULL, "disp != NULL\n");
2342 disp = (void*)0xdeadbeef;
2343 hres = IHTMLElementCollection_item(col, name, index, &disp);
2344 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2345 ok(disp == NULL, "disp != NULL\n");
2348 SysFreeString(V_BSTR(&name));
2351 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2353 IHTMLElementCollection *col;
2355 IDispatch *disp = (void*)0xdeadbeef;
2356 VARIANT name, index;
2359 hres = IHTMLDocument2_get_all(doc, &col);
2360 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2361 ok(col != NULL, "col == NULL\n");
2362 if(FAILED(hres) || !col)
2365 V_VT(&index) = VT_EMPTY;
2366 V_VT(&name) = VT_BSTR;
2367 V_BSTR(&name) = a2bstr(id);
2369 hres = IHTMLElementCollection_item(col, name, index, &disp);
2370 IHTMLElementCollection_Release(col);
2371 SysFreeString(V_BSTR(&name));
2372 ok(hres == S_OK, "item failed: %08x\n", hres);
2373 if(!expect_success) {
2374 ok(disp == NULL, "disp != NULL\n");
2378 ok(disp != NULL, "disp == NULL\n");
2382 elem = get_elem_iface((IUnknown*)disp);
2383 IDispatch_Release(disp);
2388 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2390 IHTMLDocument3 *doc3;
2395 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2396 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2399 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2401 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2403 IHTMLDocument3_Release(doc3);
2408 static void test_select_elem(IHTMLSelectElement *select)
2410 test_select_type(select, "select-one");
2411 test_select_length(select, 2);
2412 test_select_selidx(select, 0);
2413 test_select_put_selidx(select, 1);
2415 test_select_set_value(select, "val1");
2416 test_select_value(select, "val1");
2418 test_select_get_disabled(select, VARIANT_FALSE);
2419 test_select_set_disabled(select, VARIANT_TRUE);
2420 test_select_set_disabled(select, VARIANT_FALSE);
2423 static void test_create_option_elem(IHTMLDocument2 *doc)
2425 IHTMLOptionElement *option;
2427 option = create_option_elem(doc, "test text", "test value");
2429 test_option_put_text(option, "new text");
2430 test_option_put_value(option, "new value");
2432 IHTMLOptionElement_Release(option);
2435 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2437 IHTMLBodyElement *body;
2438 IHTMLTxtRange *range;
2442 hres = IHTMLDocument2_get_body(doc, &elem);
2443 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2445 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2446 IHTMLElement_Release(elem);
2448 hres = IHTMLBodyElement_createTextRange(body, &range);
2449 IHTMLBodyElement_Release(body);
2450 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2455 static void test_txtrange(IHTMLDocument2 *doc)
2457 IHTMLTxtRange *body_range, *range, *range2;
2458 IHTMLSelectionObject *selection;
2459 IDispatch *disp_range;
2462 body_range = test_create_body_range(doc);
2464 test_range_text(body_range, "test abc 123\r\nit's text");
2466 hres = IHTMLTxtRange_duplicate(body_range, &range);
2467 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2469 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2470 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2471 test_range_isequal(range, range2, VARIANT_TRUE);
2473 test_range_text(range, "test abc 123\r\nit's text");
2474 test_range_text(body_range, "test abc 123\r\nit's text");
2476 test_range_collapse(range, TRUE);
2477 test_range_isequal(range, range2, VARIANT_FALSE);
2478 test_range_inrange(range, range2, VARIANT_FALSE);
2479 test_range_inrange(range2, range, VARIANT_TRUE);
2480 IHTMLTxtRange_Release(range2);
2482 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2483 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2484 test_range_move(range, characterW, 2, 2);
2485 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2487 test_range_collapse(range, FALSE);
2488 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2490 test_range_collapse(range, FALSE);
2491 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2492 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2493 test_range_move(range, characterW, 2, 2);
2494 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2495 test_range_moveend(range, characterW, -5, -5);
2496 test_range_text(range, NULL);
2497 test_range_moveend(range, characterW, 3, 3);
2498 test_range_text(range, "c 1");
2499 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2500 test_range_collapse(range, TRUE);
2501 test_range_move(range, characterW, 4, 4);
2502 test_range_moveend(range, characterW, 1, 1);
2503 test_range_text(range, " ");
2504 test_range_move(range, wordW, 1, 1);
2505 test_range_moveend(range, characterW, 2, 2);
2506 test_range_text(range, "ab");
2508 IHTMLTxtRange_Release(range);
2510 hres = IHTMLTxtRange_duplicate(body_range, &range);
2511 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2513 test_range_text(range, "test abc 123\r\nit's text");
2514 test_range_move(range, characterW, 3, 3);
2515 test_range_moveend(range, characterW, 1, 1);
2516 test_range_text(range, "t");
2517 test_range_moveend(range, characterW, 3, 3);
2518 test_range_text(range, "t ab");
2519 test_range_moveend(range, characterW, -2, -2);
2520 test_range_text(range, "t ");
2521 test_range_move(range, characterW, 6, 6);
2522 test_range_moveend(range, characterW, 3, 3);
2523 test_range_text(range, "123");
2524 test_range_moveend(range, characterW, 2, 2);
2525 test_range_text(range, "123\r\ni");
2527 IHTMLTxtRange_Release(range);
2529 hres = IHTMLTxtRange_duplicate(body_range, &range);
2530 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2532 test_range_move(range, wordW, 1, 1);
2533 test_range_moveend(range, characterW, 2, 2);
2534 test_range_text(range, "ab");
2536 test_range_move(range, characterW, -2, -2);
2537 test_range_moveend(range, characterW, 2, 2);
2538 test_range_text(range, "t ");
2540 test_range_move(range, wordW, 3, 3);
2541 test_range_move(range, wordW, -2, -2);
2542 test_range_moveend(range, characterW, 2, 2);
2543 test_range_text(range, "ab");
2545 test_range_move(range, characterW, -6, -5);
2546 test_range_moveend(range, characterW, -1, 0);
2547 test_range_moveend(range, characterW, -6, 0);
2548 test_range_move(range, characterW, 2, 2);
2549 test_range_moveend(range, characterW, 2, 2);
2550 test_range_text(range, "st");
2551 test_range_moveend(range, characterW, -6, -4);
2552 test_range_moveend(range, characterW, 2, 2);
2554 IHTMLTxtRange_Release(range);
2556 hres = IHTMLTxtRange_duplicate(body_range, &range);
2557 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2559 test_range_move(range, wordW, 2, 2);
2560 test_range_moveend(range, characterW, 2, 2);
2561 test_range_text(range, "12");
2563 test_range_move(range, characterW, 15, 14);
2564 test_range_move(range, characterW, -2, -2);
2565 test_range_moveend(range, characterW, 3, 2);
2566 test_range_text(range, "t");
2567 test_range_moveend(range, characterW, -1, -1);
2568 test_range_text(range, "t");
2569 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2570 test_range_move(range, characterW, -2, -2);
2571 test_range_moveend(range, characterW, 2, 2);
2572 test_range_text(range, "s ");
2573 test_range_move(range, characterW, 100, 7);
2574 test_range_move(range, wordW, 1, 0);
2575 test_range_move(range, characterW, -2, -2);
2576 test_range_moveend(range, characterW, 3, 2);
2577 test_range_text(range, "t");
2579 IHTMLTxtRange_Release(range);
2581 hres = IHTMLTxtRange_duplicate(body_range, &range);
2582 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2584 test_range_collapse(range, TRUE);
2585 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2586 test_range_put_text(range, "word");
2587 test_range_text(body_range, "wordabc 123\r\nit's text");
2588 test_range_text(range, NULL);
2589 test_range_moveend(range, characterW, 3, 3);
2590 test_range_text(range, "abc");
2591 test_range_movestart(range, characterW, -2, -2);
2592 test_range_text(range, "rdabc");
2593 test_range_movestart(range, characterW, 3, 3);
2594 test_range_text(range, "bc");
2595 test_range_movestart(range, characterW, 4, 4);
2596 test_range_text(range, NULL);
2597 test_range_movestart(range, characterW, -3, -3);
2598 test_range_text(range, "c 1");
2599 test_range_movestart(range, characterW, -7, -6);
2600 test_range_text(range, "wordabc 1");
2601 test_range_movestart(range, characterW, 100, 22);
2602 test_range_text(range, NULL);
2604 IHTMLTxtRange_Release(range);
2605 IHTMLTxtRange_Release(body_range);
2607 hres = IHTMLDocument2_get_selection(doc, &selection);
2608 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2610 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2611 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2612 IHTMLSelectionObject_Release(selection);
2614 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2615 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2616 IDispatch_Release(disp_range);
2618 test_range_text(range, NULL);
2619 test_range_moveend(range, characterW, 3, 3);
2620 test_range_text(range, "wor");
2621 test_range_parent(range, ET_BODY);
2622 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2623 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2624 test_range_move(range, characterW, 3, 3);
2625 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2626 test_range_moveend(range, characterW, -4, -4);
2627 test_range_put_text(range, "abc def ");
2628 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2629 test_range_move(range, wordW, 1, 1);
2630 test_range_movestart(range, characterW, -1, -1);
2631 test_range_text(range, " ");
2632 test_range_move(range, wordW, 1, 1);
2633 test_range_moveend(range, characterW, 3, 3);
2634 test_range_text(range, "def");
2635 test_range_put_text(range, "xyz");
2636 test_range_moveend(range, characterW, 1, 1);
2637 test_range_move(range, wordW, 1, 1);
2638 test_range_moveend(range, characterW, 2, 2);
2639 test_range_text(range, "ab");
2641 IHTMLTxtRange_Release(range);
2644 static void test_txtrange2(IHTMLDocument2 *doc)
2646 IHTMLTxtRange *range;
2648 range = test_create_body_range(doc);
2650 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2651 test_range_move(range, characterW, 5, 5);
2652 test_range_moveend(range, characterW, 1, 1);
2653 test_range_text(range, "2");
2654 test_range_move(range, characterW, -3, -3);
2655 test_range_moveend(range, characterW, 3, 3);
2656 test_range_text(range, "c\r\n\r\n1");
2657 test_range_collapse(range, VARIANT_FALSE);
2658 test_range_moveend(range, characterW, 4, 4);
2659 test_range_text(range, "23");
2660 test_range_moveend(range, characterW, 1, 1);
2661 test_range_text(range, "23\r\n\r\n\r\nd");
2662 test_range_moveend(range, characterW, -1, -1);
2663 test_range_text(range, "23");
2664 test_range_moveend(range, characterW, -1, -1);
2665 test_range_text(range, "23");
2666 test_range_moveend(range, characterW, -2, -2);
2667 test_range_text(range, "2");
2669 IHTMLTxtRange_Release(range);
2672 static void test_compatmode(IHTMLDocument2 *doc)
2674 IHTMLDocument5 *doc5;
2678 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2679 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2683 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2684 IHTMLDocument5_Release(doc5);
2685 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2686 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2687 SysFreeString(mode);
2690 static void test_location(IHTMLDocument2 *doc)
2692 IHTMLLocation *location, *location2;
2693 IHTMLWindow2 *window;
2698 hres = IHTMLDocument2_get_location(doc, &location);
2699 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2701 hres = IHTMLDocument2_get_location(doc, &location2);
2702 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2704 ok(location == location2, "location != location2\n");
2705 IHTMLLocation_Release(location2);
2707 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2708 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2710 hres = IHTMLWindow2_get_location(window, &location2);
2711 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2712 ok(location == location2, "location != location2\n");
2713 IHTMLLocation_Release(location2);
2715 test_ifaces((IUnknown*)location, location_iids);
2716 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2718 hres = IHTMLLocation_get_pathname(location, &str);
2719 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2720 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2722 hres = IHTMLLocation_get_href(location, NULL);
2723 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2725 hres = IHTMLLocation_get_href(location, &str);
2726 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2727 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2729 ref = IHTMLLocation_Release(location);
2730 ok(!ref, "location chould be destroyed here\n");
2733 static void test_navigator(IHTMLDocument2 *doc)
2735 IHTMLWindow2 *window;
2736 IOmNavigator *navigator, *navigator2;
2743 static const WCHAR v40[] = {'4','.','0'};
2745 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2746 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2748 hres = IHTMLWindow2_get_navigator(window, &navigator);
2749 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2750 ok(navigator != NULL, "navigator == NULL\n");
2751 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2753 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2754 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2755 ok(navigator != navigator2, "navigator2 != navihgator\n");
2757 IHTMLWindow2_Release(window);
2758 IOmNavigator_Release(navigator2);
2760 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2761 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2762 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2763 SysFreeString(bstr);
2766 hres = IOmNavigator_get_appName(navigator, &bstr);
2767 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2768 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2769 SysFreeString(bstr);
2772 hres = IOmNavigator_get_platform(navigator, &bstr);
2773 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2775 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2777 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2779 SysFreeString(bstr);
2782 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2783 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2784 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2785 SysFreeString(bstr);
2787 hres = IOmNavigator_toString(navigator, NULL);
2788 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2791 hres = IOmNavigator_toString(navigator, &bstr);
2792 ok(hres == S_OK, "toString failed: %08x\n", hres);
2793 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2794 SysFreeString(bstr);
2797 hres = ObtainUserAgentString(0, buf, &size);
2798 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2801 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2802 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2803 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2804 SysFreeString(bstr);
2806 ref = IOmNavigator_Release(navigator);
2807 ok(!ref, "navigator should be destroyed here\n");
2810 static void test_current_style(IHTMLCurrentStyle *current_style)
2816 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2817 test_ifaces((IUnknown*)current_style, cstyle_iids);
2819 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2820 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2821 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2824 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2825 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2826 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2829 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2830 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2833 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2834 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2835 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2838 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2839 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2840 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2843 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2844 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2845 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
2848 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
2849 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
2850 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
2853 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
2854 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
2855 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
2858 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
2859 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
2860 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
2863 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
2864 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
2865 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
2868 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
2869 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
2870 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
2873 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
2874 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
2875 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
2878 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
2879 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
2880 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
2883 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
2884 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
2885 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
2888 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
2889 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
2892 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
2893 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
2896 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
2897 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
2900 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
2901 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
2904 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
2905 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
2908 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
2909 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
2912 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
2913 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
2914 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2915 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
2918 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
2919 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
2920 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2923 hres = IHTMLCurrentStyle_get_left(current_style, &v);
2924 ok(hres == S_OK, "get_left failed: %08x\n", hres);
2925 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2928 hres = IHTMLCurrentStyle_get_top(current_style, &v);
2929 ok(hres == S_OK, "get_top failed: %08x\n", hres);
2930 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2933 hres = IHTMLCurrentStyle_get_width(current_style, &v);
2934 ok(hres == S_OK, "get_width failed: %08x\n", hres);
2935 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2938 hres = IHTMLCurrentStyle_get_height(current_style, &v);
2939 ok(hres == S_OK, "get_height failed: %08x\n", hres);
2940 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2943 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
2944 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
2945 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2948 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
2949 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
2950 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2951 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
2954 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
2955 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
2956 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2957 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
2960 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
2961 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
2962 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2965 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
2966 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
2967 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2970 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
2971 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
2972 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2976 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
2977 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
2978 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2981 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
2982 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
2983 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2986 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
2987 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
2988 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2991 hres = IHTMLCurrentStyle_get_color(current_style, &v);
2992 ok(hres == S_OK, "get_color failed: %08x\n", hres);
2993 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2996 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
2997 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
2998 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3001 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3002 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3003 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3006 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3007 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3008 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3011 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3012 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3013 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3016 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3017 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3018 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3021 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3022 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3023 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3026 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3027 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3028 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3031 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3032 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3033 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3036 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3037 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3038 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3041 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3042 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3043 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3046 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3047 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3048 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3051 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3052 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3053 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3056 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3057 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3058 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3061 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3062 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3063 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3066 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3067 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3068 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3072 static void test_style2(IHTMLStyle2 *style2)
3077 str = (void*)0xdeadbeef;
3078 hres = IHTMLStyle2_get_position(style2, &str);
3079 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3080 ok(!str, "str != NULL\n");
3082 str = a2bstr("absolute");
3083 hres = IHTMLStyle2_put_position(style2, str);
3084 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3088 hres = IHTMLStyle2_get_position(style2, &str);
3089 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3090 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3094 static void test_style3(IHTMLStyle3 *style3)
3099 str = (void*)0xdeadbeef;
3100 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3101 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3102 ok(!str, "str != NULL\n");
3104 str = a2bstr("break-word");
3105 hres = IHTMLStyle3_put_wordWrap(style3, str);
3106 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3110 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3111 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3112 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3116 static void test_style4(IHTMLStyle4 *style4)
3122 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3123 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3126 V_BSTR(&v) = a2bstr("10px");
3127 hres = IHTMLStyle4_put_minHeight(style4, v);
3128 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3131 hres = IHTMLStyle4_get_minHeight(style4, &v);
3132 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3133 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3134 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3136 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3137 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3138 VariantClear(&vdefault);
3141 static void test_default_style(IHTMLStyle *style)
3143 IHTMLStyle2 *style2;
3144 IHTMLStyle3 *style3;
3145 IHTMLStyle4 *style4;
3151 BSTR sOverflowDefault;
3155 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3156 test_ifaces((IUnknown*)style, style_iids);
3158 test_style_csstext(style, NULL);
3160 hres = IHTMLStyle_get_position(style, &str);
3161 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3162 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3165 hres = IHTMLStyle_get_marginRight(style, &v);
3166 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3167 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3168 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3171 hres = IHTMLStyle_get_marginLeft(style, &v);
3172 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3173 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3174 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3176 str = (void*)0xdeadbeef;
3177 hres = IHTMLStyle_get_fontFamily(style, &str);
3178 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3179 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3181 str = (void*)0xdeadbeef;
3182 hres = IHTMLStyle_get_fontWeight(style, &str);
3183 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3184 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3186 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3187 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3189 str = a2bstr("test");
3190 hres = IHTMLStyle_put_fontWeight(style, str);
3191 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3194 str = a2bstr("bold");
3195 hres = IHTMLStyle_put_fontWeight(style, str);
3196 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3199 str = a2bstr("bolder");
3200 hres = IHTMLStyle_put_fontWeight(style, str);
3201 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3204 str = a2bstr("lighter");
3205 hres = IHTMLStyle_put_fontWeight(style, str);
3206 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3209 str = a2bstr("100");
3210 hres = IHTMLStyle_put_fontWeight(style, str);
3211 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3214 str = a2bstr("200");
3215 hres = IHTMLStyle_put_fontWeight(style, str);
3216 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3219 str = a2bstr("300");
3220 hres = IHTMLStyle_put_fontWeight(style, str);
3221 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3224 str = a2bstr("400");
3225 hres = IHTMLStyle_put_fontWeight(style, str);
3226 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3229 str = a2bstr("500");
3230 hres = IHTMLStyle_put_fontWeight(style, str);
3231 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3234 str = a2bstr("600");
3235 hres = IHTMLStyle_put_fontWeight(style, str);
3236 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3239 str = a2bstr("700");
3240 hres = IHTMLStyle_put_fontWeight(style, str);
3241 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3244 str = a2bstr("800");
3245 hres = IHTMLStyle_put_fontWeight(style, str);
3246 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3249 str = a2bstr("900");
3250 hres = IHTMLStyle_put_fontWeight(style, str);
3251 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3254 hres = IHTMLStyle_get_fontWeight(style, &str);
3255 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3256 ok(!strcmp_wa(str, "900"), "str != style900\n");
3259 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3260 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3261 SysFreeString(sDefault);
3264 hres = IHTMLStyle_get_fontVariant(style, NULL);
3265 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3267 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3268 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3270 str = a2bstr("test");
3271 hres = IHTMLStyle_put_fontVariant(style, str);
3272 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3275 str = a2bstr("small-caps");
3276 hres = IHTMLStyle_put_fontVariant(style, str);
3277 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3280 str = a2bstr("normal");
3281 hres = IHTMLStyle_put_fontVariant(style, str);
3282 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3285 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3286 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3287 SysFreeString(sDefault);
3289 str = (void*)0xdeadbeef;
3290 hres = IHTMLStyle_get_display(style, &str);
3291 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3292 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3294 str = (void*)0xdeadbeef;
3295 hres = IHTMLStyle_get_visibility(style, &str);
3296 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3297 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3300 hres = IHTMLStyle_get_fontSize(style, &v);
3301 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3302 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3303 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3306 hres = IHTMLStyle_get_color(style, &v);
3307 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3308 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3309 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3312 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3313 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3314 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3316 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3317 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3318 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3320 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3321 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3322 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3324 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3325 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3328 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3329 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3330 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3332 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3333 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3334 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3336 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3337 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3338 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3340 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3341 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3344 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3345 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3346 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3348 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3349 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3350 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3352 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3353 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3354 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3356 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3357 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3360 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3361 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3362 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3364 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3365 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3366 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3368 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3369 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3370 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3372 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3373 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3376 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3377 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3378 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3380 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3381 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3382 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3384 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3385 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3386 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3388 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3389 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3391 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3392 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3394 str = a2bstr("invalid");
3395 hres = IHTMLStyle_put_textDecoration(style, str);
3396 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3399 str = a2bstr("none");
3400 hres = IHTMLStyle_put_textDecoration(style, str);
3401 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3404 str = a2bstr("underline");
3405 hres = IHTMLStyle_put_textDecoration(style, str);
3406 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3409 str = a2bstr("overline");
3410 hres = IHTMLStyle_put_textDecoration(style, str);
3411 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3414 str = a2bstr("line-through");
3415 hres = IHTMLStyle_put_textDecoration(style, str);
3416 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3419 str = a2bstr("blink");
3420 hres = IHTMLStyle_put_textDecoration(style, str);
3421 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3424 hres = IHTMLStyle_get_textDecoration(style, &str);
3425 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3426 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3429 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3430 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3431 SysFreeString(sDefault);
3433 hres = IHTMLStyle_get_posWidth(style, NULL);
3434 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3436 hres = IHTMLStyle_get_posWidth(style, &f);
3437 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3438 ok(f == 0.0f, "f = %f\n", f);
3440 V_VT(&v) = VT_EMPTY;
3441 hres = IHTMLStyle_get_width(style, &v);
3442 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3443 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3444 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3446 hres = IHTMLStyle_put_posWidth(style, 2.2);
3447 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3449 hres = IHTMLStyle_get_posWidth(style, &f);
3450 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3452 f == 2.2f, /* IE8 */
3456 V_BSTR(&v) = a2bstr("auto");
3457 hres = IHTMLStyle_put_width(style, v);
3458 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3461 V_VT(&v) = VT_EMPTY;
3462 hres = IHTMLStyle_get_width(style, &v);
3463 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3464 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3465 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3469 str = (void*)0xdeadbeef;
3470 hres = IHTMLStyle_get_margin(style, &str);
3471 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3472 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3475 hres = IHTMLStyle_put_margin(style, str);
3476 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3479 hres = IHTMLStyle_get_margin(style, &str);
3480 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3481 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3483 hres = IHTMLStyle_put_margin(style, NULL);
3484 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3487 hres = IHTMLStyle_get_border(style, &str);
3488 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3489 ok(!str || !*str, "str is not empty\n");
3492 str = a2bstr("1px");
3493 hres = IHTMLStyle_put_border(style, str);
3494 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3497 V_VT(&v) = VT_EMPTY;
3498 hres = IHTMLStyle_get_left(style, &v);
3499 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3500 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3501 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3505 hres = IHTMLStyle_get_posLeft(style, NULL);
3506 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3509 hres = IHTMLStyle_get_posLeft(style, &f);
3510 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3511 ok(f == 0.0, "expected 0.0 got %f\n", f);
3513 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3514 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3516 hres = IHTMLStyle_get_posLeft(style, &f);
3517 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3519 f == 4.9f, /* IE8 */
3520 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3522 /* Ensure left is updated correctly. */
3523 V_VT(&v) = VT_EMPTY;
3524 hres = IHTMLStyle_get_left(style, &v);
3525 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3526 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3527 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3528 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3529 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3534 V_BSTR(&v) = a2bstr("3px");
3535 hres = IHTMLStyle_put_left(style, v);
3536 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3539 hres = IHTMLStyle_get_posLeft(style, &f);
3540 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3541 ok(f == 3.0, "expected 3.0 got %f\n", f);
3543 V_VT(&v) = VT_EMPTY;
3544 hres = IHTMLStyle_get_left(style, &v);
3545 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3546 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3547 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3551 hres = IHTMLStyle_put_left(style, v);
3552 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3554 V_VT(&v) = VT_EMPTY;
3555 hres = IHTMLStyle_get_left(style, &v);
3556 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3557 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3558 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3561 V_VT(&v) = VT_EMPTY;
3562 hres = IHTMLStyle_get_top(style, &v);
3563 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3564 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3565 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3569 hres = IHTMLStyle_get_posTop(style, NULL);
3570 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3573 hres = IHTMLStyle_get_posTop(style, &f);
3574 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3575 ok(f == 0.0, "expected 0.0 got %f\n", f);
3577 hres = IHTMLStyle_put_posTop(style, 4.9f);
3578 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3580 hres = IHTMLStyle_get_posTop(style, &f);
3581 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3583 f == 4.9f, /* IE8 */
3584 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3587 V_BSTR(&v) = a2bstr("3px");
3588 hres = IHTMLStyle_put_top(style, v);
3589 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3592 V_VT(&v) = VT_EMPTY;
3593 hres = IHTMLStyle_get_top(style, &v);
3594 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3595 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3596 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3599 hres = IHTMLStyle_get_posTop(style, &f);
3600 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3601 ok(f == 3.0, "expected 3.0 got %f\n", f);
3604 hres = IHTMLStyle_put_top(style, v);
3605 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3607 V_VT(&v) = VT_EMPTY;
3608 hres = IHTMLStyle_get_top(style, &v);
3609 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3610 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3611 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3614 /* Test posHeight */
3615 hres = IHTMLStyle_get_posHeight(style, NULL);
3616 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3618 V_VT(&v) = VT_EMPTY;
3619 hres = IHTMLStyle_get_height(style, &v);
3620 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3621 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3622 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3626 hres = IHTMLStyle_get_posHeight(style, &f);
3627 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3628 ok(f == 0.0, "expected 0.0 got %f\n", f);
3630 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3631 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3633 hres = IHTMLStyle_get_posHeight(style, &f);
3634 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3636 f == 4.9f, /* IE8 */
3637 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3640 V_BSTR(&v) = a2bstr("64px");
3641 hres = IHTMLStyle_put_height(style, v);
3642 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3645 V_VT(&v) = VT_EMPTY;
3646 hres = IHTMLStyle_get_height(style, &v);
3647 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3648 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3649 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3652 hres = IHTMLStyle_get_posHeight(style, &f);
3653 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3654 ok(f == 64.0, "expected 64.0 got %f\n", f);
3656 str = (void*)0xdeadbeef;
3657 hres = IHTMLStyle_get_cursor(style, &str);
3658 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3659 ok(!str, "get_cursor != NULL\n");
3662 str = a2bstr("default");
3663 hres = IHTMLStyle_put_cursor(style, str);
3664 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3668 hres = IHTMLStyle_get_cursor(style, &str);
3669 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3670 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3673 V_VT(&v) = VT_EMPTY;
3674 hres = IHTMLStyle_get_verticalAlign(style, &v);
3675 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3676 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3677 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3681 V_BSTR(&v) = a2bstr("middle");
3682 hres = IHTMLStyle_put_verticalAlign(style, v);
3683 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3686 V_VT(&v) = VT_EMPTY;
3687 hres = IHTMLStyle_get_verticalAlign(style, &v);
3688 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3689 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3690 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3693 str = (void*)0xdeadbeef;
3694 hres = IHTMLStyle_get_textAlign(style, &str);
3695 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3696 ok(!str, "textAlign != NULL\n");
3698 str = a2bstr("center");
3699 hres = IHTMLStyle_put_textAlign(style, str);
3700 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3704 hres = IHTMLStyle_get_textAlign(style, &str);
3705 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3706 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3709 str = (void*)0xdeadbeef;
3710 hres = IHTMLStyle_get_filter(style, &str);
3711 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3712 ok(!str, "filter != NULL\n");
3714 str = a2bstr("alpha(opacity=100)");
3715 hres = IHTMLStyle_put_filter(style, str);
3716 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3719 V_VT(&v) = VT_EMPTY;
3720 hres = IHTMLStyle_get_zIndex(style, &v);
3721 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3722 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3723 ok(!V_I4(&v), "V_I4(v) != 0\n");
3727 V_BSTR(&v) = a2bstr("1");
3728 hres = IHTMLStyle_put_zIndex(style, v);
3729 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3732 V_VT(&v) = VT_EMPTY;
3733 hres = IHTMLStyle_get_zIndex(style, &v);
3734 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3735 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3736 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3740 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3741 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3743 str = a2bstr("test");
3744 hres = IHTMLStyle_put_fontStyle(style, str);
3745 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3748 str = a2bstr("italic");
3749 hres = IHTMLStyle_put_fontStyle(style, str);
3750 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3753 str = a2bstr("oblique");
3754 hres = IHTMLStyle_put_fontStyle(style, str);
3755 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3758 str = a2bstr("normal");
3759 hres = IHTMLStyle_put_fontStyle(style, str);
3760 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3763 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3764 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3765 SysFreeString(sDefault);
3768 hres = IHTMLStyle_get_overflow(style, NULL);
3769 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3771 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3772 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3774 str = a2bstr("test");
3775 hres = IHTMLStyle_put_overflow(style, str);
3776 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3779 str = a2bstr("visible");
3780 hres = IHTMLStyle_put_overflow(style, str);
3781 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3784 str = a2bstr("scroll");
3785 hres = IHTMLStyle_put_overflow(style, str);
3786 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3789 str = a2bstr("hidden");
3790 hres = IHTMLStyle_put_overflow(style, str);
3791 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3794 str = a2bstr("auto");
3795 hres = IHTMLStyle_put_overflow(style, str);
3796 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3799 hres = IHTMLStyle_get_overflow(style, &str);
3800 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3801 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3805 hres = IHTMLStyle_put_overflow(style, str);
3806 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3809 hres = IHTMLStyle_get_overflow(style, &str);
3810 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3811 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3814 /* restore overflow default */
3815 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3816 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3817 SysFreeString(sOverflowDefault);
3819 /* Attribute Tests*/
3820 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3821 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3823 str = a2bstr("position");
3824 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3825 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3827 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3828 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3829 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3832 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3833 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3836 V_BSTR(&v) = a2bstr("absolute");
3837 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3838 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3841 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3842 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3843 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3844 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3849 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3850 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3855 str = a2bstr("borderLeftStyle");
3856 test_border_styles(style, str);
3859 str = a2bstr("borderbottomstyle");
3860 test_border_styles(style, str);
3863 str = a2bstr("borderrightstyle");
3864 test_border_styles(style, str);
3867 str = a2bstr("bordertopstyle");
3868 test_border_styles(style, str);
3871 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
3872 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3874 str = a2bstr("none dotted dashed solid");
3875 hres = IHTMLStyle_put_borderStyle(style, str);
3876 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3879 str = a2bstr("none dotted dashed solid");
3880 hres = IHTMLStyle_get_borderStyle(style, &str);
3881 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3882 ok(!strcmp_wa(str, "none dotted dashed solid"),
3883 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3886 str = a2bstr("double groove ridge inset");
3887 hres = IHTMLStyle_put_borderStyle(style, str);
3888 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3891 str = a2bstr("window-inset outset ridge inset");
3892 hres = IHTMLStyle_put_borderStyle(style, str);
3893 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3896 str = a2bstr("window-inset");
3897 hres = IHTMLStyle_put_borderStyle(style, str);
3898 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3901 str = a2bstr("none none none none none");
3902 hres = IHTMLStyle_put_borderStyle(style, str);
3903 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3906 str = a2bstr("invalid none none none");
3907 hres = IHTMLStyle_put_borderStyle(style, str);
3908 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3911 str = a2bstr("none invalid none none");
3912 hres = IHTMLStyle_put_borderStyle(style, str);
3913 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
3916 hres = IHTMLStyle_put_borderStyle(style, sDefault);
3917 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
3918 SysFreeString(sDefault);
3920 /* backgoundColor */
3921 hres = IHTMLStyle_get_backgroundColor(style, &v);
3922 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
3923 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3924 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3928 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
3929 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3932 V_BSTR(&v) = a2bstr("10");
3933 hres = IHTMLStyle_put_paddingLeft(style, v);
3934 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3937 hres = IHTMLStyle_get_paddingLeft(style, &v);
3938 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
3939 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3941 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
3942 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
3944 /* BackgroundRepeat */
3945 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
3946 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3948 str = a2bstr("invalid");
3949 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3950 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
3953 str = a2bstr("repeat");
3954 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3955 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3958 str = a2bstr("no-repeat");
3959 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3960 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3963 str = a2bstr("repeat-x");
3964 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3965 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3968 str = a2bstr("repeat-y");
3969 hres = IHTMLStyle_put_backgroundRepeat(style, str);
3970 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3973 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
3974 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3975 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
3978 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
3979 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
3980 SysFreeString(sDefault);
3983 hres = IHTMLStyle_get_borderColor(style, &sDefault);
3984 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3986 str = a2bstr("red green red blue");
3987 hres = IHTMLStyle_put_borderColor(style, str);
3988 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3991 hres = IHTMLStyle_get_borderColor(style, &str);
3992 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3993 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
3996 hres = IHTMLStyle_put_borderColor(style, sDefault);
3997 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
3998 SysFreeString(sDefault);
4001 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4002 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4004 str = a2bstr("thick dotted red");
4005 hres = IHTMLStyle_put_borderLeft(style, str);
4006 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4009 /* IHTMLStyle_get_borderLeft appears to have a bug where
4010 it returns the first letter of the color. So we check
4011 each style individually.
4014 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4015 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4016 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4020 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4021 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4022 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4025 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4026 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4027 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4030 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4031 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4032 SysFreeString(sDefault);
4034 /* backgroundPositionX */
4035 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4036 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4039 V_BSTR(&v) = a2bstr("10px");
4040 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4041 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4044 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4045 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4046 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4049 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4050 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4051 VariantClear(&vDefault);
4053 /* backgroundPositionY */
4054 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4055 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4058 V_BSTR(&v) = a2bstr("10px");
4059 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4060 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4063 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4064 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4065 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4068 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4069 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4070 VariantClear(&vDefault);
4072 /* borderTopWidth */
4073 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4074 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4077 V_BSTR(&v) = a2bstr("10px");
4078 hres = IHTMLStyle_put_borderTopWidth(style, v);
4079 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4082 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4083 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4084 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4087 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4088 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4089 VariantClear(&vDefault);
4091 /* borderRightWidth */
4092 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4093 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4096 V_BSTR(&v) = a2bstr("10");
4097 hres = IHTMLStyle_put_borderRightWidth(style, v);
4098 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4101 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4102 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4103 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4106 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4107 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4108 VariantClear(&vDefault);
4110 /* borderBottomWidth */
4111 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4112 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4115 V_BSTR(&v) = a2bstr("10");
4116 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4117 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4120 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4121 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4122 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4125 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4126 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4127 VariantClear(&vDefault);
4129 /* borderLeftWidth */
4130 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4131 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4134 V_BSTR(&v) = a2bstr("10");
4135 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4136 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4139 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4140 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4141 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4144 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4145 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4146 VariantClear(&vDefault);
4149 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4150 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4153 V_BSTR(&v) = a2bstr("10");
4154 hres = IHTMLStyle_put_wordSpacing(style, v);
4155 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4158 hres = IHTMLStyle_get_wordSpacing(style, &v);
4159 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4160 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4161 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4164 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4165 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4166 VariantClear(&vDefault);
4169 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4170 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4173 V_BSTR(&v) = a2bstr("11");
4174 hres = IHTMLStyle_put_letterSpacing(style, v);
4175 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4178 hres = IHTMLStyle_get_letterSpacing(style, &v);
4179 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4180 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4181 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4184 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4185 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4186 VariantClear(&vDefault);
4188 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4189 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4190 if(SUCCEEDED(hres)) {
4191 test_style2(style2);
4192 IHTMLStyle2_Release(style2);
4195 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4196 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4197 if(SUCCEEDED(hres)) {
4198 test_style3(style3);
4199 IHTMLStyle3_Release(style3);
4202 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4203 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4204 if(SUCCEEDED(hres)) {
4205 test_style4(style4);
4206 IHTMLStyle4_Release(style4);
4210 static void test_set_csstext(IHTMLStyle *style)
4215 test_style_set_csstext(style, "background-color: black;");
4217 hres = IHTMLStyle_get_backgroundColor(style, &v);
4218 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4219 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4220 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4224 static void test_default_selection(IHTMLDocument2 *doc)
4226 IHTMLSelectionObject *selection;
4227 IHTMLTxtRange *range;
4232 hres = IHTMLDocument2_get_selection(doc, &selection);
4233 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4235 hres = IHTMLSelectionObject_get_type(selection, &str);
4236 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4237 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4240 hres = IHTMLSelectionObject_createRange(selection, &disp);
4241 IHTMLSelectionObject_Release(selection);
4242 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4244 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4245 IDispatch_Release(disp);
4246 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4248 test_range_text(range, NULL);
4249 IHTMLTxtRange_Release(range);
4252 static void test_doc_elem(IHTMLDocument2 *doc)
4254 IHTMLDocument2 *doc_node, *owner_doc;
4256 IHTMLDocument3 *doc3;
4259 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4260 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4262 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4263 IHTMLDocument3_Release(doc3);
4264 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4266 test_node_name((IUnknown*)elem, "HTML");
4267 test_elem_tag((IUnknown*)elem, "HTML");
4269 doc_node = get_doc_node(doc);
4270 owner_doc = get_owner_doc((IUnknown*)elem);
4271 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4272 IHTMLDocument2_Release(doc_node);
4273 IHTMLDocument2_Release(owner_doc);
4275 test_elem_client_rect((IUnknown*)elem);
4277 IHTMLElement_Release(elem);
4280 static void test_default_body(IHTMLBodyElement *body)
4286 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4287 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4289 bstr = (void*)0xdeadbeef;
4290 hres = IHTMLBodyElement_get_background(body, &bstr);
4291 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4292 ok(bstr == NULL, "bstr != NULL\n");
4294 l = elem_get_scroll_height((IUnknown*)body);
4295 ok(l != -1, "scrollHeight == -1\n");
4296 l = elem_get_scroll_width((IUnknown*)body);
4297 ok(l != -1, "scrollWidth == -1\n");
4298 l = elem_get_scroll_top((IUnknown*)body);
4299 ok(!l, "scrollTop = %d\n", l);
4300 elem_get_scroll_left((IUnknown*)body);
4302 /* get_text tests */
4303 hres = IHTMLBodyElement_get_text(body, &v);
4304 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4305 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4306 ok(bstr == NULL, "bstr != NULL\n");
4309 /* get_text - Invalid Text */
4311 V_BSTR(&v) = SysAllocString(sTextInvalid);
4312 hres = IHTMLBodyElement_put_text(body, v);
4313 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4317 hres = IHTMLBodyElement_get_text(body, &v);
4318 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4319 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4320 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4323 /* get_text - Valid Text */
4325 V_BSTR(&v) = SysAllocString(sBodyText);
4326 hres = IHTMLBodyElement_put_text(body, v);
4327 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4331 hres = IHTMLBodyElement_get_text(body, &v);
4332 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4333 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4334 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4338 static void test_body_funs(IHTMLBodyElement *body)
4340 static WCHAR sRed[] = {'r','e','d',0};
4345 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4346 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4347 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4349 V_VT(&vbg) = VT_BSTR;
4350 V_BSTR(&vbg) = SysAllocString(sRed);
4351 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4352 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4355 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4356 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4357 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4358 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4361 /* Restore Originial */
4362 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4363 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4364 VariantClear(&vDefaultbg);
4367 static void test_window(IHTMLDocument2 *doc)
4369 IHTMLWindow2 *window, *window2, *self;
4370 IHTMLDocument2 *doc2 = NULL;
4376 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4377 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4378 test_ifaces((IUnknown*)window, window_iids);
4379 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4381 hres = IHTMLWindow2_get_document(window, &doc2);
4382 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4383 ok(doc2 != NULL, "doc2 == NULL\n");
4385 test_ifaces((IUnknown*)doc2, doc_node_iids);
4386 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4388 test_ifaces((IUnknown*)doc, doc_obj_iids);
4389 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4391 unk = (void*)0xdeadbeef;
4392 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4393 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4394 ok(!unk, "unk = %p\n", unk);
4396 IHTMLDocument_Release(doc2);
4398 hres = IHTMLWindow2_get_window(window, &window2);
4399 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4400 ok(window2 != NULL, "window2 == NULL\n");
4402 hres = IHTMLWindow2_get_self(window, &self);
4403 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4404 ok(window2 != NULL, "self == NULL\n");
4406 ok(self == window2, "self != window2\n");
4408 IHTMLWindow2_Release(window2);
4409 IHTMLWindow2_Release(self);
4412 hres = IHTMLDocument2_get_Script(doc, &disp);
4413 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4414 ok(disp == (void*)window, "disp != window\n");
4415 IDispatch_Release(disp);
4417 hres = IHTMLWindow2_toString(window, NULL);
4418 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4421 hres = IHTMLWindow2_toString(window, &str);
4422 ok(hres == S_OK, "toString failed: %08x\n", hres);
4423 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4426 test_window_name(window, NULL);
4427 set_window_name(window, "test");
4428 test_window_length(window, 0);
4430 IHTMLWindow2_Release(window);
4433 static void test_defaults(IHTMLDocument2 *doc)
4435 IHTMLStyleSheetsCollection *stylesheetcol;
4436 IHTMLCurrentStyle *cstyle;
4437 IHTMLBodyElement *body;
4438 IHTMLElement2 *elem2;
4443 IHTMLElementCollection *collection;
4445 hres = IHTMLDocument2_get_body(doc, &elem);
4446 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4448 hres = IHTMLDocument2_get_images(doc, NULL);
4449 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4451 hres = IHTMLDocument2_get_images(doc, &collection);
4452 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4455 test_elem_collection((IUnknown*)collection, NULL, 0);
4456 IHTMLElementCollection_Release(collection);
4459 hres = IHTMLDocument2_get_applets(doc, NULL);
4460 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4462 hres = IHTMLDocument2_get_applets(doc, &collection);
4463 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4466 test_elem_collection((IUnknown*)collection, NULL, 0);
4467 IHTMLElementCollection_Release(collection);
4470 hres = IHTMLDocument2_get_links(doc, NULL);
4471 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4473 hres = IHTMLDocument2_get_links(doc, &collection);
4474 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4477 test_elem_collection((IUnknown*)collection, NULL, 0);
4478 IHTMLElementCollection_Release(collection);
4481 hres = IHTMLDocument2_get_forms(doc, NULL);
4482 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4484 hres = IHTMLDocument2_get_forms(doc, &collection);
4485 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4488 test_elem_collection((IUnknown*)collection, NULL, 0);
4489 IHTMLElementCollection_Release(collection);
4492 hres = IHTMLDocument2_get_anchors(doc, NULL);
4493 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4495 hres = IHTMLDocument2_get_anchors(doc, &collection);
4496 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4499 test_elem_collection((IUnknown*)collection, NULL, 0);
4500 IHTMLElementCollection_Release(collection);
4503 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4504 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4505 test_default_body(body);
4506 test_body_funs(body);
4507 IHTMLBodyElement_Release(body);
4509 hres = IHTMLElement_get_style(elem, &style);
4510 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4512 test_default_style(style);
4514 test_compatmode(doc);
4516 test_navigator(doc);
4518 elem2 = get_elem2_iface((IUnknown*)elem);
4519 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4520 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4521 if(SUCCEEDED(hres)) {
4522 test_current_style(cstyle);
4523 IHTMLCurrentStyle_Release(cstyle);
4525 IHTMLElement2_Release(elem2);
4527 IHTMLElement_Release(elem);
4529 test_set_csstext(style);
4530 IHTMLStyle_Release(style);
4532 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4533 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4536 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4537 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4538 ok(l == 0, "length = %d\n", l);
4540 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4542 test_default_selection(doc);
4543 test_doc_title(doc, "");
4546 static void test_tr_elem(IHTMLElement *elem)
4548 IHTMLElementCollection *col;
4552 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4554 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4555 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4560 hres = IHTMLTableRow_get_cells(row, &col);
4561 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4562 ok(col != NULL, "get_cells returned NULL\n");
4564 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4565 IHTMLElementCollection_Release(col);
4567 IHTMLTable_Release(row);
4570 static void test_table_elem(IHTMLElement *elem)
4572 IHTMLElementCollection *col;
4577 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4578 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4580 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4581 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4586 hres = IHTMLTable_get_rows(table, &col);
4587 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4588 ok(col != NULL, "get_ros returned NULL\n");
4590 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4591 IHTMLElementCollection_Release(col);
4593 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4595 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4596 test_elem_tag((IUnknown*)node, "TABLE");
4597 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4598 IHTMLDOMNode_Release(node);
4600 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4601 test_elem_tag((IUnknown*)node, "TABLE");
4602 test_elem_all((IUnknown*)node, NULL, 0);
4603 IHTMLDOMNode_Release(node);
4605 IHTMLTable_Release(table);
4608 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4618 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4619 SafeArrayAccessData(sa, (void**)&var);
4620 V_VT(var) = VT_BSTR;
4621 V_BSTR(var) = str = a2bstr(text);
4622 SafeArrayUnaccessData(sa);
4625 hres = IHTMLDocument2_writeln(doc, sa);
4627 hres = IHTMLDocument2_write(doc, sa);
4628 ok(hres == S_OK, "write failed: %08x\n", hres);
4631 SafeArrayDestroy(sa);
4634 static void test_iframe_elem(IHTMLElement *elem)
4636 IHTMLElementCollection *col;
4637 IHTMLDocument2 *content_doc;
4638 IHTMLWindow2 *content_window;
4639 IHTMLFrameBase2 *base2;
4645 static const elem_type_t all_types[] = {
4653 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4654 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4657 content_window = NULL;
4658 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4659 IHTMLFrameBase2_Release(base2);
4660 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4661 ok(content_window != NULL, "contentWindow = NULL\n");
4663 test_window_length(content_window, 0);
4666 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4667 IHTMLWindow2_Release(content_window);
4668 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4669 ok(content_doc != NULL, "content_doc = NULL\n");
4671 str = a2bstr("text/html");
4672 V_VT(&errv) = VT_ERROR;
4674 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4676 ok(hres == S_OK, "open failed: %08x\n", hres);
4677 ok(disp != NULL, "disp == NULL\n");
4678 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4679 IDispatch_Release(disp);
4681 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4682 doc_write(content_doc, TRUE, "</html>");
4684 hres = IHTMLDocument2_get_all(content_doc, &col);
4685 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4686 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4687 IHTMLElementCollection_Release(col);
4689 hres = IHTMLDocument2_close(content_doc);
4690 ok(hres == S_OK, "close failed: %08x\n", hres);
4692 IHTMLDocument2_Release(content_doc);
4695 static void test_stylesheet(IDispatch *disp)
4697 IHTMLStyleSheetRulesCollection *col = NULL;
4698 IHTMLStyleSheet *stylesheet;
4701 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4702 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4704 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4705 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4706 ok(col != NULL, "col == NULL\n");
4708 IHTMLStyleSheetRulesCollection_Release(col);
4709 IHTMLStyleSheet_Release(stylesheet);
4712 static void test_stylesheets(IHTMLDocument2 *doc)
4714 IHTMLStyleSheetsCollection *col = NULL;
4719 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4720 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4721 ok(col != NULL, "col == NULL\n");
4723 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4724 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4725 ok(len == 1, "len=%d\n", len);
4731 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4732 ok(hres == S_OK, "item failed: %08x\n", hres);
4733 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4734 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4735 test_stylesheet(V_DISPATCH(&res));
4742 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4743 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4744 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4745 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4748 IHTMLStyleSheetsCollection_Release(col);
4751 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4753 IDispatchEx *dispex;
4755 DISPPARAMS dp = {NULL, NULL, 0, 0};
4763 static const WCHAR w0[] = {'0',0};
4764 static const WCHAR w100[] = {'1','0','0',0};
4766 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4767 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4769 bstr = SysAllocString(w0);
4770 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4771 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4772 SysFreeString(bstr);
4775 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4776 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4777 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4778 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4779 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4780 type = get_node_type((IUnknown*)node);
4781 ok(type == 3, "type=%d\n", type);
4782 IHTMLDOMNode_Release(node);
4785 bstr = SysAllocString(w100);
4786 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4787 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4788 SysFreeString(bstr);
4790 IDispatchEx_Release(dispex);
4795 static void test_elems(IHTMLDocument2 *doc)
4797 IHTMLElementCollection *col;
4798 IHTMLDOMChildrenCollection *child_col;
4799 IHTMLElement *elem, *elem2, *elem3;
4800 IHTMLDOMNode *node, *node2;
4801 IHTMLWindow2 *window;
4805 IHTMLElementCollection *collection;
4806 IHTMLDocument3 *doc3;
4809 static const elem_type_t all_types[] = {
4834 static const elem_type_t item_types[] = {
4840 hres = IHTMLDocument2_get_all(doc, &col);
4841 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4842 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4843 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
4844 IHTMLElementCollection_Release(col);
4846 hres = IHTMLDocument2_get_images(doc, &collection);
4847 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4850 static const elem_type_t images_types[] = {ET_IMG};
4851 test_elem_collection((IUnknown*)collection, images_types, 1);
4853 IHTMLElementCollection_Release(collection);
4856 hres = IHTMLDocument2_get_links(doc, &collection);
4857 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4860 static const elem_type_t images_types[] = {ET_A};
4861 test_elem_collection((IUnknown*)collection, images_types, 1);
4863 IHTMLElementCollection_Release(collection);
4866 hres = IHTMLDocument2_get_anchors(doc, &collection);
4867 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4870 static const elem_type_t anchor_types[] = {ET_A};
4871 test_elem_collection((IUnknown*)collection, anchor_types, 1);
4873 IHTMLElementCollection_Release(collection);
4876 elem = get_doc_elem(doc);
4877 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
4878 IHTMLElement_Release(elem);
4880 get_elem_by_id(doc, "xxx", FALSE);
4881 elem = get_doc_elem_by_id(doc, "xxx");
4882 ok(!elem, "elem != NULL\n");
4884 elem = get_doc_elem_by_id(doc, "s");
4885 ok(elem != NULL, "elem == NULL\n");
4887 test_elem_type((IUnknown*)elem, ET_SELECT);
4888 test_elem_attr(elem, "xxx", NULL);
4889 test_elem_attr(elem, "id", "s");
4890 test_elem_class((IUnknown*)elem, NULL);
4891 test_elem_set_class((IUnknown*)elem, "cl");
4892 test_elem_set_class((IUnknown*)elem, NULL);
4893 test_elem_tabindex((IUnknown*)elem, 0);
4894 test_elem_set_tabindex((IUnknown*)elem, 1);
4896 node = test_node_get_parent((IUnknown*)elem);
4897 ok(node != NULL, "node == NULL\n");
4898 test_node_name((IUnknown*)node, "BODY");
4899 node2 = test_node_get_parent((IUnknown*)node);
4900 IHTMLDOMNode_Release(node);
4901 ok(node2 != NULL, "node == NULL\n");
4902 test_node_name((IUnknown*)node2, "HTML");
4903 node = test_node_get_parent((IUnknown*)node2);
4904 IHTMLDOMNode_Release(node2);
4905 ok(node != NULL, "node == NULL\n");
4908 test_node_name((IUnknown*)node, "#document");
4909 type = get_node_type((IUnknown*)node);
4910 ok(type == 9, "type=%d, expected 9\n", type);
4911 node2 = test_node_get_parent((IUnknown*)node);
4912 IHTMLDOMNode_Release(node);
4913 ok(node2 == NULL, "node != NULL\n");
4916 elem2 = test_elem_get_parent((IUnknown*)elem);
4917 ok(elem2 != NULL, "elem2 == NULL\n");
4918 test_node_name((IUnknown*)elem2, "BODY");
4919 elem3 = test_elem_get_parent((IUnknown*)elem2);
4920 IHTMLElement_Release(elem2);
4921 ok(elem3 != NULL, "elem3 == NULL\n");
4922 test_node_name((IUnknown*)elem3, "HTML");
4923 elem2 = test_elem_get_parent((IUnknown*)elem3);
4924 IHTMLElement_Release(elem3);
4925 ok(elem2 == NULL, "elem2 != NULL\n");
4927 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
4928 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
4929 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
4931 test_elem_innertext(elem, "opt1opt2");
4933 IHTMLElement_Release(elem);
4936 elem = get_elem_by_id(doc, "s", TRUE);
4938 IHTMLSelectElement *select;
4939 IHTMLDocument2 *doc_node;
4941 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
4942 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
4944 test_select_elem(select);
4946 test_elem_title((IUnknown*)select, NULL);
4947 test_elem_set_title((IUnknown*)select, "Title");
4948 test_elem_title((IUnknown*)select, "Title");
4949 test_elem_offset((IUnknown*)select);
4951 node = get_first_child((IUnknown*)select);
4952 ok(node != NULL, "node == NULL\n");
4954 test_elem_type((IUnknown*)node, ET_OPTION);
4955 IHTMLDOMNode_Release(node);
4958 type = get_node_type((IUnknown*)select);
4959 ok(type == 1, "type=%d\n", type);
4961 IHTMLSelectElement_Release(select);
4963 hres = IHTMLElement_get_document(elem, &disp);
4964 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4966 doc_node = get_doc_node(doc);
4967 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
4968 IHTMLDocument2_Release(doc_node);
4970 IHTMLElement_Release(elem);
4973 elem = get_elem_by_id(doc, "sc", TRUE);
4975 IHTMLScriptElement *script;
4978 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
4979 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
4985 hres = IHTMLScriptElement_get_type(script, &type);
4986 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4987 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
4988 SysFreeString(type);
4991 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
4992 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
4994 hres = IHTMLScriptElement_get_defer(script, &vb);
4995 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
4996 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
4998 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
4999 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5002 IHTMLScriptElement_Release(script);
5005 elem = get_elem_by_id(doc, "in", TRUE);
5007 IHTMLInputElement *input;
5009 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5010 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5012 test_elem_id((IUnknown*)elem, "in");
5013 test_elem_put_id((IUnknown*)elem, "newin");
5014 test_input_get_disabled(input, VARIANT_FALSE);
5015 test_input_set_disabled(input, VARIANT_TRUE);
5016 test_input_set_disabled(input, VARIANT_FALSE);
5017 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5018 test_input_get_disabled(input, VARIANT_TRUE);
5019 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5020 test_input_get_disabled(input, VARIANT_FALSE);
5021 test_elem_client_size((IUnknown*)elem);
5023 test_node_get_value_str((IUnknown*)elem, NULL);
5024 test_node_put_value_str((IUnknown*)elem, "test");
5025 test_node_get_value_str((IUnknown*)elem, NULL);
5026 test_input_value((IUnknown*)elem, NULL);
5027 test_input_put_value((IUnknown*)elem, "test");
5028 test_input_value((IUnknown*)elem, NULL);
5029 test_elem_class((IUnknown*)elem, "testclass");
5030 test_elem_tabindex((IUnknown*)elem, 2);
5031 test_elem_set_tabindex((IUnknown*)elem, 3);
5032 test_elem_title((IUnknown*)elem, "test title");
5034 test_input_get_defaultchecked(input, VARIANT_FALSE);
5035 test_input_set_defaultchecked(input, VARIANT_TRUE);
5036 test_input_set_defaultchecked(input, VARIANT_FALSE);
5038 test_input_get_checked(input, VARIANT_FALSE);
5039 test_input_set_checked(input, VARIANT_TRUE);
5040 test_input_set_checked(input, VARIANT_FALSE);
5042 test_input_src(input, NULL);
5043 test_input_set_src(input, "about:blank");
5045 IHTMLInputElement_Release(input);
5046 IHTMLElement_Release(elem);
5049 elem = get_elem_by_id(doc, "imgid", TRUE);
5051 test_img_src((IUnknown*)elem, "");
5052 test_img_set_src((IUnknown*)elem, "about:blank");
5053 test_img_alt((IUnknown*)elem, NULL);
5054 test_img_set_alt((IUnknown*)elem, "alt test");
5055 IHTMLElement_Release(elem);
5058 elem = get_doc_elem_by_id(doc, "tbl");
5059 ok(elem != NULL, "elem == NULL\n");
5061 test_table_elem(elem);
5062 IHTMLElement_Release(elem);
5065 elem = get_doc_elem_by_id(doc, "row2");
5066 ok(elem != NULL, "elem == NULL\n");
5069 IHTMLElement_Release(elem);
5072 elem = get_doc_elem_by_id(doc, "ifr");
5073 ok(elem != NULL, "elem == NULL\n");
5075 test_iframe_elem(elem);
5076 IHTMLElement_Release(elem);
5079 elem = get_elem_by_id(doc, "a", TRUE);
5081 test_anchor_href((IUnknown*)elem, "http://test/");
5082 IHTMLElement_Release(elem);
5085 hres = IHTMLDocument2_get_body(doc, &elem);
5086 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5088 node = get_first_child((IUnknown*)elem);
5089 ok(node != NULL, "node == NULL\n");
5091 test_ifaces((IUnknown*)node, text_iids);
5092 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5094 node2 = get_first_child((IUnknown*)node);
5095 ok(!node2, "node2 != NULL\n");
5097 type = get_node_type((IUnknown*)node);
5098 ok(type == 3, "type=%d\n", type);
5100 test_node_get_value_str((IUnknown*)node, "text test");
5101 test_node_put_value_str((IUnknown*)elem, "test text");
5102 test_node_get_value_str((IUnknown*)node, "text test");
5104 IHTMLDOMNode_Release(node);
5107 child_col = get_child_nodes((IUnknown*)elem);
5108 ok(child_col != NULL, "child_coll == NULL\n");
5112 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5114 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5115 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5116 ok(length, "length=0\n");
5118 node = get_child_item(child_col, 0);
5119 ok(node != NULL, "node == NULL\n");
5121 type = get_node_type((IUnknown*)node);
5122 ok(type == 3, "type=%d\n", type);
5123 IHTMLDOMNode_Release(node);
5126 node = get_child_item(child_col, 1);
5127 ok(node != NULL, "node == NULL\n");
5129 type = get_node_type((IUnknown*)node);
5130 ok(type == 8, "type=%d\n", type);
5132 test_elem_id((IUnknown*)node, NULL);
5133 IHTMLDOMNode_Release(node);
5136 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5137 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5139 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5140 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5142 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5143 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5145 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5146 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5148 test_child_col_disp(child_col);
5150 IHTMLDOMChildrenCollection_Release(child_col);
5153 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5154 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5155 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5157 IHTMLElement_Release(elem);
5159 test_stylesheets(doc);
5160 test_create_option_elem(doc);
5162 elem = get_doc_elem_by_id(doc, "tbl");
5163 ok(elem != NULL, "elem = NULL\n");
5164 test_elem_set_innertext(elem, "inner text");
5165 IHTMLElement_Release(elem);
5167 test_doc_title(doc, "test");
5168 test_doc_set_title(doc, "test title");
5169 test_doc_title(doc, "test title");
5172 hres = IHTMLDocument2_get_Script(doc, &disp);
5173 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5176 IDispatchEx *dispex;
5177 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5178 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5182 BSTR str = a2bstr("Testing");
5183 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5184 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5185 ok(pid != -1, "pid == -1\n");
5187 IDispatchEx_Release(dispex);
5190 IDispatch_Release(disp);
5192 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5193 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5195 str = a2bstr("img");
5196 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5197 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5201 static const elem_type_t img_types[] = { ET_IMG };
5203 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5204 IHTMLElementCollection_Release(col);
5207 elem = get_doc_elem_by_id(doc, "y");
5208 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5209 test_elem_innerhtml((IUnknown*)elem, "inner html");
5210 test_elem_set_innerhtml((IUnknown*)elem, "");
5211 test_elem_innerhtml((IUnknown*)elem, NULL);
5212 IHTMLElement_Release(elem);
5214 IHTMLDocument3_Release(doc3);
5216 window = get_doc_window(doc);
5217 test_window_name(window, NULL);
5218 set_window_name(window, "test name");
5219 test_window_length(window, 1);
5220 IHTMLWindow2_Release(window);
5223 static void test_create_elems(IHTMLDocument2 *doc)
5225 IHTMLElement *elem, *body, *elem2;
5226 IHTMLDOMNode *node, *node2, *node3, *comment;
5227 IHTMLDocument5 *doc5;
5234 static const elem_type_t types1[] = { ET_TESTG };
5236 elem = test_create_elem(doc, "TEST");
5237 test_elem_tag((IUnknown*)elem, "TEST");
5238 type = get_node_type((IUnknown*)elem);
5239 ok(type == 1, "type=%d\n", type);
5240 test_ifaces((IUnknown*)elem, elem_iids);
5241 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5243 hres = IHTMLDocument2_get_body(doc, &body);
5244 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5245 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5247 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5248 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5249 elem2 = get_elem_iface((IUnknown*)node);
5250 IHTMLElement_Release(elem2);
5252 hres = IHTMLElement_get_all(body, &disp);
5253 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5254 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5255 IDispatch_Release(disp);
5257 test_node_remove_child((IUnknown*)body, node);
5259 hres = IHTMLElement_get_all(body, &disp);
5260 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5261 test_elem_collection((IUnknown*)disp, NULL, 0);
5262 IDispatch_Release(disp);
5263 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5265 IHTMLElement_Release(elem);
5266 IHTMLDOMNode_Release(node);
5268 node = test_create_text(doc, "test");
5269 test_ifaces((IUnknown*)node, text_iids);
5270 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5272 V_VT(&var) = VT_NULL;
5273 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5274 IHTMLDOMNode_Release(node);
5276 node = test_create_text(doc, "insert ");
5278 V_VT(&var) = VT_DISPATCH;
5279 V_DISPATCH(&var) = (IDispatch*)node2;
5280 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5281 IHTMLDOMNode_Release(node);
5282 IHTMLDOMNode_Release(node2);
5283 IHTMLDOMNode_Release(node3);
5285 test_elem_innertext(body, "insert test");
5286 test_elem_innerhtml((IUnknown*)body, "insert test");
5288 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5291 str = a2bstr("testing");
5292 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5294 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5297 type = get_node_type((IUnknown*)comment);
5298 ok(type == 8, "type=%d, expected 8\n", type);
5300 test_node_get_value_str((IUnknown*)comment, "testing");
5302 IHTMLDOMNode_Release(comment);
5305 IHTMLDocument5_Release(doc5);
5308 IHTMLElement_Release(body);
5311 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5313 IOleCommandTarget *cmdtrg;
5316 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5317 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5319 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5320 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5322 IOleCommandTarget_Release(cmdtrg);
5325 static void test_indent(IHTMLDocument2 *doc)
5327 IHTMLElementCollection *col;
5328 IHTMLTxtRange *range;
5331 static const elem_type_t all_types[] = {
5340 static const elem_type_t indent_types[] = {
5351 hres = IHTMLDocument2_get_all(doc, &col);
5352 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5353 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5354 IHTMLElementCollection_Release(col);
5356 range = test_create_body_range(doc);
5357 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5358 IHTMLTxtRange_Release(range);
5360 hres = IHTMLDocument2_get_all(doc, &col);
5361 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5362 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5363 IHTMLElementCollection_Release(col);
5366 static void test_cond_comment(IHTMLDocument2 *doc)
5368 IHTMLElementCollection *col;
5371 static const elem_type_t all_types[] = {
5379 hres = IHTMLDocument2_get_all(doc, &col);
5380 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5381 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5382 IHTMLElementCollection_Release(col);
5385 static IHTMLDocument2 *notif_doc;
5386 static BOOL doc_complete;
5388 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5389 REFIID riid, void**ppv)
5391 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5396 ok(0, "unexpected call\n");
5397 return E_NOINTERFACE;
5400 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5405 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5410 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5412 if(dispID == DISPID_READYSTATE){
5416 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5417 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5419 if(!strcmp_wa(state, "complete"))
5420 doc_complete = TRUE;
5422 SysFreeString(state);
5428 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5430 ok(0, "unexpected call\n");
5434 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5435 PropertyNotifySink_QueryInterface,
5436 PropertyNotifySink_AddRef,
5437 PropertyNotifySink_Release,
5438 PropertyNotifySink_OnChanged,
5439 PropertyNotifySink_OnRequestEdit
5442 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5444 static IHTMLDocument2 *create_doc_with_string(const char *str)
5446 IPersistStreamInit *init;
5448 IHTMLDocument2 *doc;
5452 notif_doc = doc = create_document();
5456 doc_complete = FALSE;
5458 mem = GlobalAlloc(0, len);
5459 memcpy(mem, str, len);
5460 CreateStreamOnHGlobal(mem, TRUE, &stream);
5462 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5464 IPersistStreamInit_Load(init, stream);
5465 IPersistStreamInit_Release(init);
5466 IStream_Release(stream);
5471 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5473 IConnectionPointContainer *container;
5474 IConnectionPoint *cp;
5478 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5479 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5481 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5482 IConnectionPointContainer_Release(container);
5483 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5485 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5486 IConnectionPoint_Release(cp);
5487 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5490 typedef void (*domtest_t)(IHTMLDocument2*);
5492 static void run_domtest(const char *str, domtest_t test)
5494 IHTMLDocument2 *doc;
5495 IHTMLElement *body = NULL;
5500 doc = create_doc_with_string(str);
5504 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5506 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5507 TranslateMessage(&msg);
5508 DispatchMessage(&msg);
5511 hres = IHTMLDocument2_get_body(doc, &body);
5512 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5515 IHTMLElement_Release(body);
5518 skip("Could not get document body. Assuming no Gecko installed.\n");
5521 ref = IHTMLDocument2_Release(doc);
5523 ref == 1, /* Vista */
5527 static void gecko_installer_workaround(BOOL disable)
5532 static BOOL has_url = FALSE;
5533 static char url[2048];
5535 if(!disable && !has_url)
5538 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5539 if(res != ERROR_SUCCESS)
5543 DWORD type, size = sizeof(url);
5545 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5546 if(res == ERROR_SUCCESS && type == REG_SZ)
5549 RegDeleteValue(hkey, "GeckoUrl");
5551 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5559 gecko_installer_workaround(TRUE);
5562 run_domtest(doc_str1, test_doc_elem);
5563 run_domtest(doc_str1, test_get_set_attr);
5564 run_domtest(range_test_str, test_txtrange);
5565 run_domtest(range_test2_str, test_txtrange2);
5566 if (winetest_interactive || ! is_ie_hardened()) {
5567 run_domtest(elem_test_str, test_elems);
5569 skip("IE running in Enhanced Security Configuration\n");
5571 run_domtest(doc_blank, test_create_elems);
5572 run_domtest(doc_blank, test_defaults);
5573 run_domtest(indent_test_str, test_indent);
5574 run_domtest(cond_comment_str, test_cond_comment);
5577 gecko_installer_workaround(FALSE);