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]-->"
61 static const char frameset_str[] =
62 "<html><head><title>frameset test</title></head><frameset rows=\"28, *\">"
63 "<frame src=\"about:blank\" id=\"fr1\"><frame src=\"about:blank\" id=\"fr2\">"
66 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
67 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
68 static WCHAR wordW[] = {'w','o','r','d',0};
97 static const IID * const none_iids[] = {
102 static const IID * const doc_node_iids[] = {
111 &IID_IConnectionPointContainer,
112 &IID_IInternetHostSecurityManager,
116 static const IID * const doc_obj_iids[] = {
123 &IID_IConnectionPointContainer,
128 static const IID * const elem_iids[] = {
135 &IID_IConnectionPointContainer,
139 static const IID * const body_iids[] = {
145 &IID_IHTMLTextContainer,
146 &IID_IHTMLBodyElement,
148 &IID_IConnectionPointContainer,
152 static const IID * const anchor_iids[] = {
158 &IID_IHTMLAnchorElement,
160 &IID_IConnectionPointContainer,
164 static const IID * const input_iids[] = {
170 &IID_IHTMLInputElement,
171 &IID_IHTMLInputTextElement,
173 &IID_IConnectionPointContainer,
177 static const IID * const select_iids[] = {
183 &IID_IHTMLSelectElement,
185 &IID_IConnectionPointContainer,
189 static const IID * const textarea_iids[] = {
195 &IID_IHTMLTextAreaElement,
197 &IID_IConnectionPointContainer,
201 static const IID * const option_iids[] = {
207 &IID_IHTMLOptionElement,
209 &IID_IConnectionPointContainer,
213 static const IID * const table_iids[] = {
221 &IID_IConnectionPointContainer,
225 static const IID * const script_iids[] = {
231 &IID_IHTMLScriptElement,
233 &IID_IConnectionPointContainer,
237 static const IID * const text_iids[] = {
240 &IID_IHTMLDOMTextNode,
244 static const IID * const location_iids[] = {
250 static const IID * const window_iids[] = {
258 static const IID * const comment_iids[] = {
264 &IID_IHTMLCommentElement,
266 &IID_IConnectionPointContainer,
270 static const IID * const img_iids[] = {
277 &IID_IHTMLImgElement,
278 &IID_IConnectionPointContainer,
282 static const IID * const tr_iids[] = {
290 &IID_IConnectionPointContainer,
294 static const IID * const td_iids[] = {
301 &IID_IConnectionPointContainer,
305 static const IID * const iframe_iids[] = {
312 &IID_IHTMLFrameBase2,
314 &IID_IConnectionPointContainer,
318 static const IID * const generic_iids[] = {
324 &IID_IHTMLGenericElement,
326 &IID_IConnectionPointContainer,
330 static const IID * const style_iids[] = {
341 static const IID * const cstyle_iids[] = {
345 &IID_IHTMLCurrentStyle,
349 static const IID * const img_factory_iids[] = {
353 &IID_IHTMLImageElementFactory,
363 static const elem_type_info_t elem_type_infos[] = {
364 {"", none_iids, NULL},
365 {"HTML", elem_iids, NULL},
366 {"HEAD", elem_iids, NULL},
367 {"TITLE", elem_iids, NULL},
368 {"BODY", body_iids, &DIID_DispHTMLBody},
369 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
370 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
371 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
372 {"TEXTAREA", textarea_iids, NULL},
373 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
374 {"STYLE", elem_iids, NULL},
375 {"BLOCKQUOTE",elem_iids, NULL},
376 {"P", elem_iids, NULL},
377 {"BR", elem_iids, NULL},
378 {"TABLE", table_iids, &DIID_DispHTMLTable},
379 {"TBODY", elem_iids, NULL},
380 {"SCRIPT", script_iids, NULL},
381 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
382 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
383 {"!", comment_iids, &DIID_DispHTMLCommentElement},
384 {"IMG", img_iids, &DIID_DispHTMLImg},
385 {"TR", tr_iids, &DIID_DispHTMLTableRow},
386 {"TD", td_iids, NULL},
387 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}
390 static const char *dbgstr_guid(REFIID riid)
394 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
395 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
396 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
397 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
402 static int strcmp_wa(LPCWSTR strw, const char *stra)
405 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
406 return lstrcmpA(stra, buf);
409 static BSTR a2bstr(const char *str)
414 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
415 ret = SysAllocStringLen(NULL, len);
416 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
421 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
423 IUnknown *unk1, *unk2;
428 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
429 IUnknown_Release(unk1);
430 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
431 IUnknown_Release(unk2);
436 static IHTMLDocument2 *create_document(void)
439 IHTMLDocument5 *doc5;
442 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
443 &IID_IHTMLDocument2, (void**)&doc);
444 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
448 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
450 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
451 IHTMLDocument2_Release(doc);
455 IHTMLDocument5_Release(doc5);
459 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
460 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
462 const IID * const *piid;
466 for(piid = iids; *piid; piid++) {
467 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
468 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
470 IUnknown_Release(unk);
474 #define test_get_dispid(u,id) _test_disp(__LINE__,u,id)
475 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
483 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
484 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
489 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
490 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
491 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
493 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
494 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
496 if(SUCCEEDED(hres)) {
499 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
500 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
502 *iid = type_attr->guid;
506 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
507 ITypeInfo_Release(typeinfo);
510 IDispatchEx_Release(dispex);
514 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
515 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
517 DISPPARAMS dp = {NULL,NULL,0,0};
523 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
524 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
528 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
529 IDispatchEx_Release(dispex);
530 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
532 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
533 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
537 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
538 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
542 if(_test_get_dispid(line, unk, &iid))
543 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
546 _test_disp_value(line, unk, val);
549 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
550 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
554 if(_test_get_dispid(line, unk, &iid))
555 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
556 "unexpected guid %s\n", dbgstr_guid(&iid));
559 _test_disp_value(line, unk, val);
562 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
563 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
568 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
569 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
573 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
574 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
579 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
580 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
584 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
585 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
590 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
591 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
595 #define get_node_iface(u) _get_node_iface(__LINE__,u)
596 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
601 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
602 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
606 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
607 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
612 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
613 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
617 #define get_img_iface(u) _get_img_iface(__LINE__,u)
618 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
620 IHTMLImgElement *img;
623 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
624 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
628 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
629 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
631 IHTMLAnchorElement *anchor;
634 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
635 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
639 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
640 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
642 IHTMLDOMNode *node = _get_node_iface(line, unk);
646 hres = IHTMLDOMNode_get_nodeName(node, &name);
647 IHTMLDOMNode_Release(node);
648 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
649 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
654 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
655 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
657 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
658 IDispatch *disp = (void*)0xdeadbeef;
659 IHTMLDocument2 *doc = NULL;
662 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
663 IHTMLDOMNode2_Release(node);
664 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
667 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
668 IDispatch_Release(disp);
669 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
675 #define get_doc_window(d) _get_doc_window(__LINE__,d)
676 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
678 IHTMLWindow2 *window;
682 hres = IHTMLDocument2_get_parentWindow(doc, &window);
683 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
684 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
689 #define clone_node(n,d) _clone_node(__LINE__,n,d)
690 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
692 IHTMLDOMNode *node = _get_node_iface(line, unk);
693 IHTMLDOMNode *ret = NULL;
696 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
697 IHTMLDOMNode_Release(node);
698 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
699 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
705 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
706 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
708 IHTMLElement *elem = _get_elem_iface(line, unk);
712 hres = IHTMLElement_get_tagName(elem, &tag);
713 IHTMLElement_Release(elem);
714 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
715 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
720 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
721 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
723 _test_elem_tag(line, unk, elem_type_infos[type].tag);
724 _test_ifaces(line, unk, elem_type_infos[type].iids);
726 if(elem_type_infos[type].dispiid && type != ET_A)
727 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
730 #define get_node_type(n) _get_node_type(__LINE__,n)
731 static LONG _get_node_type(unsigned line, IUnknown *unk)
733 IHTMLDOMNode *node = _get_node_iface(line, unk);
737 hres = IHTMLDOMNode_get_nodeType(node, &type);
738 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
740 IHTMLDOMNode_Release(node);
745 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
746 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
748 IHTMLDOMNode *node = _get_node_iface(line, unk);
749 IHTMLDOMChildrenCollection *col = NULL;
753 hres = IHTMLDOMNode_get_childNodes(node, &disp);
754 IHTMLDOMNode_Release(node);
755 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
759 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
760 IDispatch_Release(disp);
761 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
766 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
767 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
769 IHTMLDOMNode *node = NULL;
773 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
774 ok(hres == S_OK, "item failed: %08x\n", hres);
776 node = _get_node_iface(line, (IUnknown*)disp);
777 IDispatch_Release(disp);
782 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
783 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
792 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
794 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
797 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
798 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
800 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
803 VariantClear(&value);
806 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
807 static void _test_elem_offset(unsigned line, IUnknown *unk)
809 IHTMLElement *elem = _get_elem_iface(line, unk);
813 hres = IHTMLElement_get_offsetTop(elem, &l);
814 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
816 hres = IHTMLElement_get_offsetHeight(elem, &l);
817 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
819 hres = IHTMLElement_get_offsetWidth(elem, &l);
820 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
822 IHTMLElement_Release(elem);
825 #define get_doc_node(d) _get_doc_node(__LINE__,d)
826 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
828 IHTMLWindow2 *window;
832 hres = IHTMLDocument2_get_parentWindow(doc, &window);
833 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
835 hres = IHTMLWindow2_get_document(window, &ret);
836 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
837 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
842 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
843 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
848 hres = IHTMLWindow2_get_name(window, &name);
849 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
851 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
853 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
856 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
857 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
863 hres = IHTMLWindow2_put_name(window, str);
865 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
867 _test_window_name(line, window, name);
870 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
871 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
876 hres = IHTMLWindow2_get_length(window, &length);
877 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
878 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
881 static void test_get_set_attr(IHTMLDocument2 *doc)
884 IHTMLDocument3 *doc3;
889 /* grab an element to test with */
890 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
891 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
893 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
894 IHTMLDocument3_Release(doc3);
895 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
897 /* get a non-present attribute */
898 bstr = a2bstr("notAnAttribute");
899 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
900 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
901 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
905 /* get a present attribute */
906 bstr = a2bstr("scrollHeight");
907 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
908 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
909 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
913 /* create a new BSTR attribute */
914 bstr = a2bstr("newAttribute");
916 V_VT(&val) = VT_BSTR;
917 V_BSTR(&val) = a2bstr("the value");
918 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
919 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
922 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
923 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
924 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
925 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)));
928 /* overwrite the attribute with a BOOL */
929 V_VT(&val) = VT_BOOL;
930 V_BOOL(&val) = VARIANT_TRUE;
931 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
932 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
935 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
936 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
937 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
938 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
943 /* case-insensitive */
944 bstr = a2bstr("newattribute");
945 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
946 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
947 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
948 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
952 IHTMLElement_Release(elem);
955 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
956 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
959 IHTMLDocument3 *doc3;
962 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
963 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
964 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
965 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
966 IHTMLDocument3_Release(doc3);
971 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
972 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
974 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
978 hres = IHTMLAnchorElement_get_href(anchor, &str);
979 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
980 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
983 _test_disp_value(line, unk, exhref);
986 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
987 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
992 hres = IHTMLOptionElement_get_text(option, &bstr);
993 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
994 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
998 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
999 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1004 bstr = a2bstr(text);
1005 hres = IHTMLOptionElement_put_text(option, bstr);
1006 SysFreeString(bstr);
1007 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1009 _test_option_text(line, option, text);
1012 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1013 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1018 hres = IHTMLOptionElement_get_value(option, &bstr);
1019 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1020 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1021 SysFreeString(bstr);
1024 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1025 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1030 bstr = a2bstr(value);
1031 hres = IHTMLOptionElement_put_value(option, bstr);
1032 SysFreeString(bstr);
1033 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1035 _test_option_value(line, option, value);
1038 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1039 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1040 const char *txt, const char *val)
1042 IHTMLOptionElementFactory *factory;
1043 IHTMLOptionElement *option;
1044 IHTMLWindow2 *window;
1045 VARIANT text, value, empty;
1048 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1049 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1051 hres = IHTMLWindow2_get_Option(window, &factory);
1052 IHTMLWindow2_Release(window);
1053 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1055 V_VT(&text) = VT_BSTR;
1056 V_BSTR(&text) = a2bstr(txt);
1057 V_VT(&value) = VT_BSTR;
1058 V_BSTR(&value) = a2bstr(val);
1059 V_VT(&empty) = VT_EMPTY;
1061 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1062 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1064 IHTMLOptionElementFactory_Release(factory);
1065 VariantClear(&text);
1066 VariantClear(&value);
1068 _test_option_text(line, option, txt);
1069 _test_option_value(line, option, val);
1074 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1075 static void _test_img_width(unsigned line, IHTMLImgElement *img, const long exp)
1080 hres = IHTMLImgElement_get_width(img, &found);
1081 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1082 todo_wine ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1085 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1086 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const long width)
1090 hres = IHTMLImgElement_put_width(img, width);
1091 todo_wine ok(hres == S_OK, "put_width failed: %08x\n", hres);
1093 _test_img_width(line, img, width);
1096 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1097 static void _test_img_height(unsigned line, IHTMLImgElement *img, const long exp)
1102 hres = IHTMLImgElement_get_height(img, &found);
1103 todo_wine ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1104 todo_wine ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1107 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1108 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const long height)
1112 hres = IHTMLImgElement_put_height(img, height);
1113 todo_wine ok(hres == S_OK, "put_height failed: %08x\n", hres);
1115 _test_img_height(line, img, height);
1118 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1119 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1120 LONG wdth, LONG hght)
1122 IHTMLImageElementFactory *factory;
1123 IHTMLImgElement *img;
1124 IHTMLWindow2 *window;
1125 VARIANT width, height;
1129 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1130 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1132 hres = IHTMLWindow2_get_Image(window, &factory);
1133 IHTMLWindow2_Release(window);
1134 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1136 test_ifaces((IUnknown*)factory, img_factory_iids);
1137 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1140 snprintf(buf, 16, "%d", wdth);
1141 V_VT(&width) = VT_BSTR;
1142 V_BSTR(&width) = a2bstr(buf);
1144 V_VT(&width) = VT_EMPTY;
1149 snprintf(buf, 16, "%d", hght);
1150 V_VT(&height) = VT_BSTR;
1151 V_BSTR(&height) = a2bstr(buf);
1153 V_VT(&height) = VT_EMPTY;
1157 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1158 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1160 IHTMLImageElementFactory_Release(factory);
1161 VariantClear(&width);
1162 VariantClear(&height);
1164 if(SUCCEEDED(hres)) {
1165 _test_img_width(line, img, wdth);
1166 _test_img_height(line, img, hght);
1173 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1174 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1176 LONG len = 0xdeadbeef;
1179 hres = IHTMLSelectElement_get_length(select, &len);
1180 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1181 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1184 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1185 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1187 LONG idx = 0xdeadbeef;
1190 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1191 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1192 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1195 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1196 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1200 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1201 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1202 _test_select_selidx(line, select, index);
1205 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1206 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1211 hres = IHTMLSelectElement_get_value(select, &val);
1212 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1214 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1216 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1219 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1220 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1226 hres = IHTMLSelectElement_put_value(select, bstr);
1227 SysFreeString(bstr);
1228 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1231 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1232 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1237 hres = IHTMLSelectElement_get_type(select, &type);
1238 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1239 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1242 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1243 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1248 hres = IHTMLTxtRange_get_text(range, &text);
1249 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1252 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1253 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1255 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1258 SysFreeString(text);
1262 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1263 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1267 hres = IHTMLTxtRange_collapse(range, b);
1268 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1269 _test_range_text(line, range, NULL);
1272 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1273 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1274 VARIANT_BOOL exb, const char *extext)
1276 VARIANT_BOOL b = 0xe0e0;
1279 hres = IHTMLTxtRange_expand(range, unit, &b);
1280 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1281 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1282 _test_range_text(line, range, extext);
1285 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1286 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1288 LONG c = 0xdeadbeef;
1291 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1292 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1293 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1294 _test_range_text(line, range, NULL);
1297 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1298 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1299 LPWSTR unit, LONG cnt, LONG excnt)
1301 LONG c = 0xdeadbeef;
1304 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1305 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1306 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1309 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1310 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1312 LONG c = 0xdeadbeef;
1315 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1316 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1317 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1320 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1321 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1324 BSTR bstr = a2bstr(text);
1326 hres = IHTMLTxtRange_put_text(range, bstr);
1327 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1328 SysFreeString(bstr);
1329 _test_range_text(line, range, NULL);
1332 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1333 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1339 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1340 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1341 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1344 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1345 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1351 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1352 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1353 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1356 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1357 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1358 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1361 test_range_inrange(range1, range2, VARIANT_TRUE);
1362 test_range_inrange(range2, range1, VARIANT_TRUE);
1366 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1367 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1372 hres = IHTMLTxtRange_parentElement(range, &elem);
1373 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1375 _test_elem_type(line, (IUnknown*)elem, type);
1377 IHTMLElement_Release(elem);
1380 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1381 static void _test_elem_collection(unsigned line, IUnknown *unk,
1382 const elem_type_t *elem_types, LONG exlen)
1384 IHTMLElementCollection *col;
1387 VARIANT name, index;
1388 IDispatch *disp, *disp2;
1391 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1392 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1394 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1396 hres = IHTMLElementCollection_get_length(col, &len);
1397 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1398 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1403 V_VT(&index) = VT_EMPTY;
1405 for(i=0; i<len; i++) {
1406 V_VT(&name) = VT_I4;
1408 disp = (void*)0xdeadbeef;
1409 hres = IHTMLElementCollection_item(col, name, index, &disp);
1410 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1411 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1412 if(FAILED(hres) || !disp)
1415 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1418 V_VT(&name) = VT_UINT;
1420 disp2 = (void*)0xdeadbeef;
1421 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1422 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1423 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1425 IDispatch_Release(disp2);
1428 IDispatch_Release(disp);
1431 V_VT(&name) = VT_I4;
1433 disp = (void*)0xdeadbeef;
1434 hres = IHTMLElementCollection_item(col, name, index, &disp);
1435 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1436 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1438 V_VT(&name) = VT_I4;
1440 disp = (void*)0xdeadbeef;
1441 hres = IHTMLElementCollection_item(col, name, index, &disp);
1442 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1443 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1445 IHTMLElementCollection_Release(col);
1448 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1449 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1451 IHTMLElement *elem = _get_elem_iface(line, unk);
1455 hres = IHTMLElement_get_all(elem, &disp);
1456 IHTMLElement_Release(elem);
1457 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1459 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1460 IDispatch_Release(disp);
1463 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1464 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1466 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1467 IHTMLElementCollection *col = NULL;
1468 elem_type_t *types = NULL;
1473 tmp = a2bstr(elem_type_infos[type].tag);
1474 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1476 IHTMLElement2_Release(elem);
1477 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1478 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1481 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1482 for(i=0; i<exlen; i++)
1486 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1488 HeapFree(GetProcessHeap(), 0, types);
1491 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1492 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1497 hres = IHTMLElement_get_innerText(elem, &text);
1498 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1499 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1500 wine_dbgstr_w(text), extext);
1501 SysFreeString(text);
1504 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1505 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1507 IHTMLDOMChildrenCollection *col;
1512 hres = IHTMLElement_put_innerText(elem, str);
1513 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1516 _test_elem_innertext(line, elem, text);
1519 col = _get_child_nodes(line, (IUnknown*)elem);
1520 ok(col != NULL, "col == NULL\n");
1522 LONG length = 0, type;
1525 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1526 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1527 ok(length == 1, "length = %d\n", length);
1529 node = _get_child_item(line, col, 0);
1530 ok(node != NULL, "node == NULL\n");
1532 type = _get_node_type(line, (IUnknown*)node);
1533 ok(type == 3, "type=%d\n", type);
1534 IHTMLDOMNode_Release(node);
1537 IHTMLDOMChildrenCollection_Release(col);
1542 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1543 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1545 IHTMLElement *elem = _get_elem_iface(line, unk);
1549 hres = IHTMLElement_get_innerHTML(elem, &html);
1550 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1552 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1554 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1556 IHTMLElement_Release(elem);
1557 SysFreeString(html);
1560 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1561 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1563 IHTMLElement *elem = _get_elem_iface(line, unk);
1567 html = a2bstr(inner_html);
1568 hres = IHTMLElement_put_innerHTML(elem, html);
1569 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1571 IHTMLElement_Release(elem);
1572 SysFreeString(html);
1575 #define get_first_child(n) _get_first_child(__LINE__,n)
1576 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1578 IHTMLDOMNode *node = _get_node_iface(line, unk);
1579 IHTMLDOMNode *child = NULL;
1582 hres = IHTMLDOMNode_get_firstChild(node, &child);
1583 IHTMLDOMNode_Release(node);
1584 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1589 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1590 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1592 IHTMLDOMNode *node = _get_node_iface(line, unk);
1593 VARIANT_BOOL b = 0xdead;
1596 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1597 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1598 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1600 IHTMLDOMNode_Release(node);
1603 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1604 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1606 IHTMLDOMNode *node = _get_node_iface(line, unk);
1607 IHTMLDOMNode *parent;
1610 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1611 IHTMLDOMNode_Release(node);
1612 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1617 #define node_get_next(u) _node_get_next(__LINE__,u)
1618 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1620 IHTMLDOMNode *node = _get_node_iface(line, unk);
1624 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1625 IHTMLDOMNode_Release(node);
1626 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1631 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1632 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1634 IHTMLElement *elem = _get_elem_iface(line, unk);
1635 IHTMLElement *parent;
1638 hres = IHTMLElement_get_parentElement(elem, &parent);
1639 IHTMLElement_Release(elem);
1640 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1645 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1646 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1648 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1649 VARIANT_BOOL disabled = 100;
1653 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1654 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1655 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1656 IHTMLElement3_Release(elem3);
1659 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1660 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1662 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1666 hres = IHTMLElement3_put_disabled(elem3, b);
1667 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1669 IHTMLElement3_Release(elem3);
1670 _test_elem3_get_disabled(line, unk, b);
1673 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1674 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1676 VARIANT_BOOL disabled = 100;
1679 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1680 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1681 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1683 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1686 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1687 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
1691 hres = IHTMLSelectElement_put_disabled(select, b);
1692 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1694 _test_select_get_disabled(line, select, b);
1697 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1698 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
1700 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1701 IHTMLTextContainer *txtcont;
1702 LONG l = -1, l2 = -1;
1705 hres = IHTMLElement2_get_scrollHeight(elem, &l);
1706 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
1707 IHTMLElement2_Release(elem);
1709 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1710 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1712 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
1713 IHTMLTextContainer_Release(txtcont);
1714 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
1715 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
1720 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1721 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
1723 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1724 IHTMLTextContainer *txtcont;
1725 LONG l = -1, l2 = -1;
1728 hres = IHTMLElement2_get_scrollWidth(elem, &l);
1729 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
1730 IHTMLElement2_Release(elem);
1732 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1733 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1735 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
1736 IHTMLTextContainer_Release(txtcont);
1737 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
1738 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
1743 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1744 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
1746 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1747 IHTMLTextContainer *txtcont;
1748 LONG l = -1, l2 = -1;
1751 hres = IHTMLElement2_get_scrollTop(elem, &l);
1752 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1753 IHTMLElement2_Release(elem);
1755 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1756 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1758 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
1759 IHTMLTextContainer_Release(txtcont);
1760 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
1761 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
1766 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1767 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
1769 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1770 IHTMLTextContainer *txtcont;
1771 LONG l = -1, l2 = -1;
1774 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
1775 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
1777 hres = IHTMLElement2_get_scrollLeft(elem, &l);
1778 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
1779 IHTMLElement2_Release(elem);
1781 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
1782 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
1784 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
1785 IHTMLTextContainer_Release(txtcont);
1786 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
1787 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
1790 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1791 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
1793 IHTMLImgElement *img = _get_img_iface(line, unk);
1797 hres = IHTMLImgElement_get_src(img, &src);
1798 IHTMLImgElement_Release(img);
1799 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1800 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1804 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1805 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
1807 IHTMLImgElement *img = _get_img_iface(line, unk);
1812 hres = IHTMLImgElement_put_src(img, tmp);
1813 IHTMLImgElement_Release(img);
1815 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1817 _test_img_src(line, unk, src);
1820 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1821 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
1823 IHTMLImgElement *img = _get_img_iface(line, unk);
1827 hres = IHTMLImgElement_get_alt(img, &alt);
1828 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1830 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
1832 ok_(__FILE__,line) (!alt, "alt != NULL\n");
1836 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1837 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
1839 IHTMLImgElement *img = _get_img_iface(line, unk);
1844 hres = IHTMLImgElement_put_alt(img, tmp);
1845 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
1848 _test_img_alt(line, unk, alt);
1851 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1852 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1854 VARIANT_BOOL disabled = 100;
1857 hres = IHTMLInputElement_get_disabled(input, &disabled);
1858 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1859 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1861 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
1864 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1865 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1869 hres = IHTMLInputElement_put_disabled(input, b);
1870 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1872 _test_input_get_disabled(line, input, b);
1875 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1876 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1878 VARIANT_BOOL checked = 100;
1881 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
1882 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1883 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1886 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1887 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1891 hres = IHTMLInputElement_put_defaultChecked(input, b);
1892 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
1894 _test_input_get_defaultchecked(line, input, b);
1897 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1898 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
1900 VARIANT_BOOL checked = 100;
1903 hres = IHTMLInputElement_get_checked(input, &checked);
1904 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1905 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
1908 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1909 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
1913 hres = IHTMLInputElement_put_checked(input, b);
1914 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
1916 _test_input_get_checked(line, input, b);
1919 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1920 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
1922 IHTMLInputElement *input;
1926 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1927 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1931 hres = IHTMLInputElement_get_value(input, &bstr);
1932 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1934 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
1936 ok_(__FILE__,line) (!exval, "exval != NULL\n");
1937 SysFreeString(bstr);
1938 IHTMLInputElement_Release(input);
1941 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1942 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
1944 IHTMLInputElement *input;
1948 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
1949 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
1954 hres = IHTMLInputElement_get_value(input, &bstr);
1955 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1956 SysFreeString(bstr);
1957 IHTMLInputElement_Release(input);
1960 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
1961 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
1966 hres = IHTMLInputElement_get_src(input, &src);
1967 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
1969 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
1971 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
1975 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
1976 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
1982 hres = IHTMLInputElement_put_src(input, tmp);
1984 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
1986 _test_input_src(line, input, src);
1989 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1990 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
1992 IHTMLElement *elem = _get_elem_iface(line, unk);
1993 BSTR class = (void*)0xdeadbeef;
1996 hres = IHTMLElement_get_className(elem, &class);
1997 IHTMLElement_Release(elem);
1998 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2000 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2002 ok_(__FILE__,line) (!class, "class != NULL\n");
2003 SysFreeString(class);
2006 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2007 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2009 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2013 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2014 IHTMLElement2_Release(elem2);
2015 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2016 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2019 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2020 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2022 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2025 hres = IHTMLElement2_put_tabIndex(elem2, index);
2026 IHTMLElement2_Release(elem2);
2027 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2029 _test_elem_tabindex(line, unk, index);
2032 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2033 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2035 IHTMLElement *elem = _get_elem_iface(line, unk);
2039 tmp = class ? a2bstr(class) : NULL;
2040 hres = IHTMLElement_put_className(elem, tmp);
2041 IHTMLElement_Release(elem);
2042 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2045 _test_elem_class(line, unk, class);
2048 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2049 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2051 IHTMLElement *elem = _get_elem_iface(line, unk);
2052 BSTR id = (void*)0xdeadbeef;
2055 hres = IHTMLElement_get_id(elem, &id);
2056 IHTMLElement_Release(elem);
2057 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2060 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2062 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2067 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2068 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2070 IHTMLElement *elem = _get_elem_iface(line, unk);
2071 BSTR tmp = a2bstr(new_id);
2074 hres = IHTMLElement_put_id(elem, tmp);
2075 IHTMLElement_Release(elem);
2077 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2079 _test_elem_id(line, unk, new_id);
2082 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2083 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2085 IHTMLElement *elem = _get_elem_iface(line, unk);
2089 hres = IHTMLElement_get_title(elem, &title);
2090 IHTMLElement_Release(elem);
2091 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2093 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2095 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2097 SysFreeString(title);
2100 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2101 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2103 IHTMLElement *elem = _get_elem_iface(line, unk);
2107 tmp = a2bstr(title);
2108 hres = IHTMLElement_put_title(elem, tmp);
2109 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2111 IHTMLElement_Release(elem);
2115 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2116 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2118 IHTMLDOMNode *node = _get_node_iface(line, unk);
2122 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2123 IHTMLDOMNode_Release(node);
2124 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2127 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2128 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2130 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2136 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2137 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2139 IHTMLDOMNode *node = _get_node_iface(line, unk);
2143 V_VT(&var) = VT_BSTR;
2144 V_BSTR(&var) = a2bstr(val);
2146 hres = IHTMLDOMNode_put_nodeValue(node, var);
2147 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2148 IHTMLDOMNode_Release(node);
2152 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2153 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2155 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2159 hres = IHTMLElement2_get_clientWidth(elem, &l);
2160 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2161 hres = IHTMLElement2_get_clientHeight(elem, &l);
2162 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2164 IHTMLElement2_Release(elem);
2167 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2168 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2170 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2174 hres = IHTMLElement2_get_clientLeft(elem, &l);
2175 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2176 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2178 hres = IHTMLElement2_get_clientTop(elem, &l);
2179 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2180 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2182 IHTMLElement2_Release(elem);
2185 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2186 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2188 IHTMLElement *elem = NULL;
2193 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2194 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2195 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2200 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2201 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2203 IHTMLDocument3 *doc3;
2204 IHTMLDOMNode *node = NULL;
2208 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2209 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2212 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2213 IHTMLDocument3_Release(doc3);
2214 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2215 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2220 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2221 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2223 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2224 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2225 IHTMLDOMNode *new_child = NULL;
2228 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2229 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2230 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2231 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2233 IHTMLDOMNode_Release(node);
2234 IHTMLDOMNode_Release(child);
2239 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2240 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2242 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2243 IHTMLDOMNode *new_child = NULL;
2246 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2247 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2248 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2249 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2251 IHTMLDOMNode_Release(node);
2256 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2257 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2259 IHTMLDOMNode *node = _get_node_iface(line, unk);
2260 IHTMLDOMNode *new_node = NULL;
2263 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2264 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2265 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2266 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2268 IHTMLDOMNode_Release(node);
2269 IHTMLDOMNode_Release(new_node);
2272 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2273 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2278 hres = IHTMLDocument2_get_title(doc, &title);
2279 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2280 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2281 SysFreeString(title);
2284 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2285 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
2290 tmp = a2bstr(title);
2291 hres = IHTMLDocument2_put_title(doc, tmp);
2292 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2296 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
2297 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
2302 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
2303 LOCALE_USER_DEFAULT, &dispid);
2304 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
2307 DISPPARAMS params = {NULL,NULL,0,0};
2308 DISPID dispidNamed = DISPID_PROPERTYPUT;
2313 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2314 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
2315 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
2318 params.cNamedArgs = 1;
2319 params.rgdispidNamedArgs = &dispidNamed;
2320 V_VT(&arg) = VT_BSTR;
2321 V_BSTR(&arg) = a2bstr("none");
2322 params.rgvarg = &arg;
2323 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2324 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2325 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
2328 V_VT(&arg) = VT_BSTR;
2329 V_BSTR(&arg) = a2bstr("dotted");
2330 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2331 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2332 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
2335 V_VT(&arg) = VT_BSTR;
2336 V_BSTR(&arg) = a2bstr("dashed");
2337 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2338 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2339 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
2342 V_VT(&arg) = VT_BSTR;
2343 V_BSTR(&arg) = a2bstr("solid");
2344 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2345 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2346 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
2349 V_VT(&arg) = VT_BSTR;
2350 V_BSTR(&arg) = a2bstr("double");
2351 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2352 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2353 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
2356 V_VT(&arg) = VT_BSTR;
2357 V_BSTR(&arg) = a2bstr("groove");
2358 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2359 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2360 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
2363 V_VT(&arg) = VT_BSTR;
2364 V_BSTR(&arg) = a2bstr("ridge");
2365 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2366 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2367 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
2370 V_VT(&arg) = VT_BSTR;
2371 V_BSTR(&arg) = a2bstr("inset");
2372 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2373 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2374 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
2377 V_VT(&arg) = VT_BSTR;
2378 V_BSTR(&arg) = a2bstr("outset");
2379 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2380 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2381 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
2384 V_VT(&arg) = VT_BSTR;
2385 V_BSTR(&arg) = a2bstr("invalid");
2386 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2387 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2388 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
2391 params.rgvarg = &vDefault;
2392 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
2393 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
2394 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
2398 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
2399 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
2401 BSTR text = (void*)0xdeadbeef;
2404 hres = IHTMLStyle_get_cssText(style, &text);
2405 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
2407 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
2409 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
2411 SysFreeString(text);
2414 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
2415 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
2421 hres = IHTMLStyle_put_cssText(style, tmp);
2422 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
2426 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
2427 const elem_type_t *elem_types, LONG len)
2430 VARIANT name, index;
2434 V_VT(&index) = VT_EMPTY;
2435 V_VT(&name) = VT_BSTR;
2436 V_BSTR(&name) = a2bstr(n);
2438 hres = IHTMLElementCollection_item(col, name, index, &disp);
2439 ok(hres == S_OK, "item failed: %08x\n", hres);
2441 test_elem_collection((IUnknown*)disp, elem_types, len);
2442 IDispatch_Release(disp);
2443 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
2447 V_VT(&index) = VT_I4;
2449 for(i=0; i<len; i++) {
2451 disp = (void*)0xdeadbeef;
2452 hres = IHTMLElementCollection_item(col, name, index, &disp);
2453 ok(hres == S_OK, "item failed: %08x\n", hres);
2454 ok(disp != NULL, "disp == NULL\n");
2455 if(FAILED(hres) || !disp)
2458 test_elem_type((IUnknown*)disp, elem_types[i]);
2460 IDispatch_Release(disp);
2464 disp = (void*)0xdeadbeef;
2465 hres = IHTMLElementCollection_item(col, name, index, &disp);
2466 ok(hres == S_OK, "item failed: %08x\n", hres);
2467 ok(disp == NULL, "disp != NULL\n");
2470 disp = (void*)0xdeadbeef;
2471 hres = IHTMLElementCollection_item(col, name, index, &disp);
2472 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
2473 ok(disp == NULL, "disp != NULL\n");
2476 SysFreeString(V_BSTR(&name));
2479 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
2481 IHTMLElementCollection *col;
2483 IDispatch *disp = (void*)0xdeadbeef;
2484 VARIANT name, index;
2487 hres = IHTMLDocument2_get_all(doc, &col);
2488 ok(hres == S_OK, "get_all failed: %08x\n", hres);
2489 ok(col != NULL, "col == NULL\n");
2490 if(FAILED(hres) || !col)
2493 V_VT(&index) = VT_EMPTY;
2494 V_VT(&name) = VT_BSTR;
2495 V_BSTR(&name) = a2bstr(id);
2497 hres = IHTMLElementCollection_item(col, name, index, &disp);
2498 IHTMLElementCollection_Release(col);
2499 SysFreeString(V_BSTR(&name));
2500 ok(hres == S_OK, "item failed: %08x\n", hres);
2501 if(!expect_success) {
2502 ok(disp == NULL, "disp != NULL\n");
2506 ok(disp != NULL, "disp == NULL\n");
2510 elem = get_elem_iface((IUnknown*)disp);
2511 IDispatch_Release(disp);
2516 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
2518 IHTMLDocument3 *doc3;
2523 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2524 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2527 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
2529 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
2531 IHTMLDocument3_Release(doc3);
2536 static void test_select_elem(IHTMLSelectElement *select)
2538 test_select_type(select, "select-one");
2539 test_select_length(select, 2);
2540 test_select_selidx(select, 0);
2541 test_select_put_selidx(select, 1);
2543 test_select_set_value(select, "val1");
2544 test_select_value(select, "val1");
2546 test_select_get_disabled(select, VARIANT_FALSE);
2547 test_select_set_disabled(select, VARIANT_TRUE);
2548 test_select_set_disabled(select, VARIANT_FALSE);
2551 static void test_create_option_elem(IHTMLDocument2 *doc)
2553 IHTMLOptionElement *option;
2555 option = create_option_elem(doc, "test text", "test value");
2557 test_option_put_text(option, "new text");
2558 test_option_put_value(option, "new value");
2560 IHTMLOptionElement_Release(option);
2563 static void test_create_img_elem(IHTMLDocument2 *doc)
2565 IHTMLImgElement *img;
2567 img = create_img_elem(doc, 10, 15);
2570 test_img_put_width(img, 5);
2571 test_img_put_height(img, 20);
2573 IHTMLImgElement_Release(img);
2577 img = create_img_elem(doc, -1, -1);
2580 test_img_put_width(img, 5);
2581 test_img_put_height(img, 20);
2583 IHTMLImgElement_Release(img);
2587 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
2589 IHTMLBodyElement *body;
2590 IHTMLTxtRange *range;
2594 hres = IHTMLDocument2_get_body(doc, &elem);
2595 ok(hres == S_OK, "get_body failed: %08x\n", hres);
2597 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
2598 IHTMLElement_Release(elem);
2600 hres = IHTMLBodyElement_createTextRange(body, &range);
2601 IHTMLBodyElement_Release(body);
2602 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
2607 static void test_txtrange(IHTMLDocument2 *doc)
2609 IHTMLTxtRange *body_range, *range, *range2;
2610 IHTMLSelectionObject *selection;
2611 IDispatch *disp_range;
2614 body_range = test_create_body_range(doc);
2616 test_range_text(body_range, "test abc 123\r\nit's text");
2618 hres = IHTMLTxtRange_duplicate(body_range, &range);
2619 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2621 hres = IHTMLTxtRange_duplicate(body_range, &range2);
2622 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2623 test_range_isequal(range, range2, VARIANT_TRUE);
2625 test_range_text(range, "test abc 123\r\nit's text");
2626 test_range_text(body_range, "test abc 123\r\nit's text");
2628 test_range_collapse(range, TRUE);
2629 test_range_isequal(range, range2, VARIANT_FALSE);
2630 test_range_inrange(range, range2, VARIANT_FALSE);
2631 test_range_inrange(range2, range, VARIANT_TRUE);
2632 IHTMLTxtRange_Release(range2);
2634 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2635 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
2636 test_range_move(range, characterW, 2, 2);
2637 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2639 test_range_collapse(range, FALSE);
2640 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
2642 test_range_collapse(range, FALSE);
2643 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2644 test_range_expand(range, wordW, VARIANT_FALSE, "123");
2645 test_range_move(range, characterW, 2, 2);
2646 test_range_expand(range, wordW, VARIANT_TRUE, "123");
2647 test_range_moveend(range, characterW, -5, -5);
2648 test_range_text(range, NULL);
2649 test_range_moveend(range, characterW, 3, 3);
2650 test_range_text(range, "c 1");
2651 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
2652 test_range_collapse(range, TRUE);
2653 test_range_move(range, characterW, 4, 4);
2654 test_range_moveend(range, characterW, 1, 1);
2655 test_range_text(range, " ");
2656 test_range_move(range, wordW, 1, 1);
2657 test_range_moveend(range, characterW, 2, 2);
2658 test_range_text(range, "ab");
2660 IHTMLTxtRange_Release(range);
2662 hres = IHTMLTxtRange_duplicate(body_range, &range);
2663 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2665 test_range_text(range, "test abc 123\r\nit's text");
2666 test_range_move(range, characterW, 3, 3);
2667 test_range_moveend(range, characterW, 1, 1);
2668 test_range_text(range, "t");
2669 test_range_moveend(range, characterW, 3, 3);
2670 test_range_text(range, "t ab");
2671 test_range_moveend(range, characterW, -2, -2);
2672 test_range_text(range, "t ");
2673 test_range_move(range, characterW, 6, 6);
2674 test_range_moveend(range, characterW, 3, 3);
2675 test_range_text(range, "123");
2676 test_range_moveend(range, characterW, 2, 2);
2677 test_range_text(range, "123\r\ni");
2679 IHTMLTxtRange_Release(range);
2681 hres = IHTMLTxtRange_duplicate(body_range, &range);
2682 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2684 test_range_move(range, wordW, 1, 1);
2685 test_range_moveend(range, characterW, 2, 2);
2686 test_range_text(range, "ab");
2688 test_range_move(range, characterW, -2, -2);
2689 test_range_moveend(range, characterW, 2, 2);
2690 test_range_text(range, "t ");
2692 test_range_move(range, wordW, 3, 3);
2693 test_range_move(range, wordW, -2, -2);
2694 test_range_moveend(range, characterW, 2, 2);
2695 test_range_text(range, "ab");
2697 test_range_move(range, characterW, -6, -5);
2698 test_range_moveend(range, characterW, -1, 0);
2699 test_range_moveend(range, characterW, -6, 0);
2700 test_range_move(range, characterW, 2, 2);
2701 test_range_moveend(range, characterW, 2, 2);
2702 test_range_text(range, "st");
2703 test_range_moveend(range, characterW, -6, -4);
2704 test_range_moveend(range, characterW, 2, 2);
2706 IHTMLTxtRange_Release(range);
2708 hres = IHTMLTxtRange_duplicate(body_range, &range);
2709 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2711 test_range_move(range, wordW, 2, 2);
2712 test_range_moveend(range, characterW, 2, 2);
2713 test_range_text(range, "12");
2715 test_range_move(range, characterW, 15, 14);
2716 test_range_move(range, characterW, -2, -2);
2717 test_range_moveend(range, characterW, 3, 2);
2718 test_range_text(range, "t");
2719 test_range_moveend(range, characterW, -1, -1);
2720 test_range_text(range, "t");
2721 test_range_expand(range, wordW, VARIANT_TRUE, "text");
2722 test_range_move(range, characterW, -2, -2);
2723 test_range_moveend(range, characterW, 2, 2);
2724 test_range_text(range, "s ");
2725 test_range_move(range, characterW, 100, 7);
2726 test_range_move(range, wordW, 1, 0);
2727 test_range_move(range, characterW, -2, -2);
2728 test_range_moveend(range, characterW, 3, 2);
2729 test_range_text(range, "t");
2731 IHTMLTxtRange_Release(range);
2733 hres = IHTMLTxtRange_duplicate(body_range, &range);
2734 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
2736 test_range_collapse(range, TRUE);
2737 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
2738 test_range_put_text(range, "word");
2739 test_range_text(body_range, "wordabc 123\r\nit's text");
2740 test_range_text(range, NULL);
2741 test_range_moveend(range, characterW, 3, 3);
2742 test_range_text(range, "abc");
2743 test_range_movestart(range, characterW, -2, -2);
2744 test_range_text(range, "rdabc");
2745 test_range_movestart(range, characterW, 3, 3);
2746 test_range_text(range, "bc");
2747 test_range_movestart(range, characterW, 4, 4);
2748 test_range_text(range, NULL);
2749 test_range_movestart(range, characterW, -3, -3);
2750 test_range_text(range, "c 1");
2751 test_range_movestart(range, characterW, -7, -6);
2752 test_range_text(range, "wordabc 1");
2753 test_range_movestart(range, characterW, 100, 22);
2754 test_range_text(range, NULL);
2756 IHTMLTxtRange_Release(range);
2757 IHTMLTxtRange_Release(body_range);
2759 hres = IHTMLDocument2_get_selection(doc, &selection);
2760 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
2762 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
2763 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
2764 IHTMLSelectionObject_Release(selection);
2766 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
2767 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
2768 IDispatch_Release(disp_range);
2770 test_range_text(range, NULL);
2771 test_range_moveend(range, characterW, 3, 3);
2772 test_range_text(range, "wor");
2773 test_range_parent(range, ET_BODY);
2774 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2775 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
2776 test_range_move(range, characterW, 3, 3);
2777 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
2778 test_range_moveend(range, characterW, -4, -4);
2779 test_range_put_text(range, "abc def ");
2780 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
2781 test_range_move(range, wordW, 1, 1);
2782 test_range_movestart(range, characterW, -1, -1);
2783 test_range_text(range, " ");
2784 test_range_move(range, wordW, 1, 1);
2785 test_range_moveend(range, characterW, 3, 3);
2786 test_range_text(range, "def");
2787 test_range_put_text(range, "xyz");
2788 test_range_moveend(range, characterW, 1, 1);
2789 test_range_move(range, wordW, 1, 1);
2790 test_range_moveend(range, characterW, 2, 2);
2791 test_range_text(range, "ab");
2793 IHTMLTxtRange_Release(range);
2796 static void test_txtrange2(IHTMLDocument2 *doc)
2798 IHTMLTxtRange *range;
2800 range = test_create_body_range(doc);
2802 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2803 test_range_move(range, characterW, 5, 5);
2804 test_range_moveend(range, characterW, 1, 1);
2805 test_range_text(range, "2");
2806 test_range_move(range, characterW, -3, -3);
2807 test_range_moveend(range, characterW, 3, 3);
2808 test_range_text(range, "c\r\n\r\n1");
2809 test_range_collapse(range, VARIANT_FALSE);
2810 test_range_moveend(range, characterW, 4, 4);
2811 test_range_text(range, "23");
2812 test_range_moveend(range, characterW, 1, 1);
2813 test_range_text(range, "23\r\n\r\n\r\nd");
2814 test_range_moveend(range, characterW, -1, -1);
2815 test_range_text(range, "23");
2816 test_range_moveend(range, characterW, -1, -1);
2817 test_range_text(range, "23");
2818 test_range_moveend(range, characterW, -2, -2);
2819 test_range_text(range, "2");
2821 IHTMLTxtRange_Release(range);
2824 static void test_compatmode(IHTMLDocument2 *doc)
2826 IHTMLDocument5 *doc5;
2830 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
2831 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
2835 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
2836 IHTMLDocument5_Release(doc5);
2837 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
2838 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
2839 SysFreeString(mode);
2842 static void test_location(IHTMLDocument2 *doc)
2844 IHTMLLocation *location, *location2;
2845 IHTMLWindow2 *window;
2850 hres = IHTMLDocument2_get_location(doc, &location);
2851 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2853 hres = IHTMLDocument2_get_location(doc, &location2);
2854 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2856 ok(location == location2, "location != location2\n");
2857 IHTMLLocation_Release(location2);
2859 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2860 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2862 hres = IHTMLWindow2_get_location(window, &location2);
2863 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2864 ok(location == location2, "location != location2\n");
2865 IHTMLLocation_Release(location2);
2867 test_ifaces((IUnknown*)location, location_iids);
2868 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
2870 hres = IHTMLLocation_get_pathname(location, &str);
2871 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
2872 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
2874 hres = IHTMLLocation_get_href(location, NULL);
2875 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
2877 hres = IHTMLLocation_get_href(location, &str);
2878 ok(hres == S_OK, "get_href failed: %08x\n", hres);
2879 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
2881 ref = IHTMLLocation_Release(location);
2882 ok(!ref, "location chould be destroyed here\n");
2885 static void test_navigator(IHTMLDocument2 *doc)
2887 IHTMLWindow2 *window;
2888 IOmNavigator *navigator, *navigator2;
2895 static const WCHAR v40[] = {'4','.','0'};
2897 hres = IHTMLDocument2_get_parentWindow(doc, &window);
2898 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
2900 hres = IHTMLWindow2_get_navigator(window, &navigator);
2901 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2902 ok(navigator != NULL, "navigator == NULL\n");
2903 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
2905 hres = IHTMLWindow2_get_navigator(window, &navigator2);
2906 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
2907 ok(navigator != navigator2, "navigator2 != navihgator\n");
2909 IHTMLWindow2_Release(window);
2910 IOmNavigator_Release(navigator2);
2912 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
2913 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
2914 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2915 SysFreeString(bstr);
2918 hres = IOmNavigator_get_appName(navigator, &bstr);
2919 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
2920 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
2921 SysFreeString(bstr);
2924 hres = IOmNavigator_get_platform(navigator, &bstr);
2925 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
2927 ok(!strcmp_wa(bstr, "Win64"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2929 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
2931 SysFreeString(bstr);
2934 hres = IOmNavigator_get_appVersion(navigator, &bstr);
2935 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
2936 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
2937 SysFreeString(bstr);
2939 hres = IOmNavigator_toString(navigator, NULL);
2940 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
2943 hres = IOmNavigator_toString(navigator, &bstr);
2944 ok(hres == S_OK, "toString failed: %08x\n", hres);
2945 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
2946 SysFreeString(bstr);
2949 hres = ObtainUserAgentString(0, buf, &size);
2950 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
2953 hres = IOmNavigator_get_userAgent(navigator, &bstr);
2954 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
2955 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
2956 SysFreeString(bstr);
2958 ref = IOmNavigator_Release(navigator);
2959 ok(!ref, "navigator should be destroyed here\n");
2962 static void test_current_style(IHTMLCurrentStyle *current_style)
2968 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
2969 test_ifaces((IUnknown*)current_style, cstyle_iids);
2971 hres = IHTMLCurrentStyle_get_display(current_style, &str);
2972 ok(hres == S_OK, "get_display failed: %08x\n", hres);
2973 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
2976 hres = IHTMLCurrentStyle_get_position(current_style, &str);
2977 ok(hres == S_OK, "get_position failed: %08x\n", hres);
2978 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
2981 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
2982 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
2985 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
2986 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
2987 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
2990 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
2991 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
2992 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
2995 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
2996 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
2997 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3000 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3001 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3002 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3005 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3006 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3007 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3010 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3011 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3012 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3015 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3016 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3017 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3020 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3021 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3022 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3025 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3026 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3027 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3030 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3031 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3032 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3035 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3036 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3037 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3040 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3041 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3044 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3045 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3048 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3049 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3052 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3053 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3056 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3057 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3060 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3061 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3064 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
3065 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3066 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3067 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
3070 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
3071 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3072 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3075 hres = IHTMLCurrentStyle_get_left(current_style, &v);
3076 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3077 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3080 hres = IHTMLCurrentStyle_get_top(current_style, &v);
3081 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3082 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3085 hres = IHTMLCurrentStyle_get_width(current_style, &v);
3086 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3087 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3090 hres = IHTMLCurrentStyle_get_height(current_style, &v);
3091 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3092 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3095 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
3096 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
3097 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3100 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
3101 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3102 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
3103 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
3106 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
3107 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3108 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3109 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
3112 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
3113 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3114 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3117 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
3118 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3119 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3122 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
3123 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
3124 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3128 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
3129 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
3130 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3133 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
3134 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
3135 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3138 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
3139 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
3140 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3143 hres = IHTMLCurrentStyle_get_color(current_style, &v);
3144 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3145 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3148 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
3149 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
3150 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3153 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
3154 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
3155 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3158 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
3159 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
3160 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3163 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
3164 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
3165 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3168 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
3169 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
3170 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3173 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
3174 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
3175 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3178 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
3179 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3180 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3183 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
3184 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
3185 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3188 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
3189 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
3190 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3193 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
3194 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
3195 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3198 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
3199 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
3200 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3203 hres = IHTMLCurrentStyle_get_right(current_style, &v);
3204 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
3205 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3208 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
3209 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3210 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3213 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
3214 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
3215 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3218 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
3219 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
3220 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3224 static void test_style2(IHTMLStyle2 *style2)
3229 str = (void*)0xdeadbeef;
3230 hres = IHTMLStyle2_get_position(style2, &str);
3231 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3232 ok(!str, "str != NULL\n");
3234 str = a2bstr("absolute");
3235 hres = IHTMLStyle2_put_position(style2, str);
3236 ok(hres == S_OK, "put_position failed: %08x\n", hres);
3240 hres = IHTMLStyle2_get_position(style2, &str);
3241 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3242 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3246 static void test_style3(IHTMLStyle3 *style3)
3251 str = (void*)0xdeadbeef;
3252 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3253 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3254 ok(!str, "str != NULL\n");
3256 str = a2bstr("break-word");
3257 hres = IHTMLStyle3_put_wordWrap(style3, str);
3258 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
3262 hres = IHTMLStyle3_get_wordWrap(style3, &str);
3263 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
3264 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
3268 static void test_style4(IHTMLStyle4 *style4)
3274 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
3275 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3278 V_BSTR(&v) = a2bstr("10px");
3279 hres = IHTMLStyle4_put_minHeight(style4, v);
3280 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3283 hres = IHTMLStyle4_get_minHeight(style4, &v);
3284 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
3285 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
3286 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
3288 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
3289 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
3290 VariantClear(&vdefault);
3293 static void test_default_style(IHTMLStyle *style)
3295 IHTMLStyle2 *style2;
3296 IHTMLStyle3 *style3;
3297 IHTMLStyle4 *style4;
3303 BSTR sOverflowDefault;
3307 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
3308 test_ifaces((IUnknown*)style, style_iids);
3310 test_style_csstext(style, NULL);
3312 hres = IHTMLStyle_get_position(style, &str);
3313 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3314 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3317 hres = IHTMLStyle_get_marginRight(style, &v);
3318 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
3319 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
3320 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3323 hres = IHTMLStyle_get_marginLeft(style, &v);
3324 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
3325 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
3326 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3328 str = (void*)0xdeadbeef;
3329 hres = IHTMLStyle_get_fontFamily(style, &str);
3330 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3331 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
3333 str = (void*)0xdeadbeef;
3334 hres = IHTMLStyle_get_fontWeight(style, &str);
3335 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3336 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
3338 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
3339 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3341 str = a2bstr("test");
3342 hres = IHTMLStyle_put_fontWeight(style, str);
3343 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
3346 str = a2bstr("bold");
3347 hres = IHTMLStyle_put_fontWeight(style, str);
3348 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3351 str = a2bstr("bolder");
3352 hres = IHTMLStyle_put_fontWeight(style, str);
3353 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3356 str = a2bstr("lighter");
3357 hres = IHTMLStyle_put_fontWeight(style, str);
3358 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3361 str = a2bstr("100");
3362 hres = IHTMLStyle_put_fontWeight(style, str);
3363 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3366 str = a2bstr("200");
3367 hres = IHTMLStyle_put_fontWeight(style, str);
3368 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3371 str = a2bstr("300");
3372 hres = IHTMLStyle_put_fontWeight(style, str);
3373 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3376 str = a2bstr("400");
3377 hres = IHTMLStyle_put_fontWeight(style, str);
3378 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3381 str = a2bstr("500");
3382 hres = IHTMLStyle_put_fontWeight(style, str);
3383 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3386 str = a2bstr("600");
3387 hres = IHTMLStyle_put_fontWeight(style, str);
3388 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3391 str = a2bstr("700");
3392 hres = IHTMLStyle_put_fontWeight(style, str);
3393 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3396 str = a2bstr("800");
3397 hres = IHTMLStyle_put_fontWeight(style, str);
3398 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3401 str = a2bstr("900");
3402 hres = IHTMLStyle_put_fontWeight(style, str);
3403 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3406 hres = IHTMLStyle_get_fontWeight(style, &str);
3407 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
3408 ok(!strcmp_wa(str, "900"), "str != style900\n");
3411 hres = IHTMLStyle_put_fontWeight(style, sDefault);
3412 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
3413 SysFreeString(sDefault);
3416 hres = IHTMLStyle_get_fontVariant(style, NULL);
3417 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
3419 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
3420 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3422 str = a2bstr("test");
3423 hres = IHTMLStyle_put_fontVariant(style, str);
3424 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
3427 str = a2bstr("small-caps");
3428 hres = IHTMLStyle_put_fontVariant(style, str);
3429 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3432 str = a2bstr("normal");
3433 hres = IHTMLStyle_put_fontVariant(style, str);
3434 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3437 hres = IHTMLStyle_put_fontVariant(style, sDefault);
3438 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
3439 SysFreeString(sDefault);
3441 str = (void*)0xdeadbeef;
3442 hres = IHTMLStyle_get_display(style, &str);
3443 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3444 ok(!str, "display = %s\n", wine_dbgstr_w(str));
3446 str = (void*)0xdeadbeef;
3447 hres = IHTMLStyle_get_visibility(style, &str);
3448 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3449 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
3452 hres = IHTMLStyle_get_fontSize(style, &v);
3453 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
3454 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
3455 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3458 hres = IHTMLStyle_get_color(style, &v);
3459 ok(hres == S_OK, "get_color failed: %08x\n", hres);
3460 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
3461 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3464 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3465 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3466 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3468 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
3469 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3470 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
3472 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
3473 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
3474 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
3476 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
3477 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
3480 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3481 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3482 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3484 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
3485 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3486 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
3488 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
3489 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
3490 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
3492 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
3493 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
3496 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3497 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3498 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3500 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
3501 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3502 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
3504 hres = IHTMLStyle_get_textDecorationNone(style, &b);
3505 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
3506 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
3508 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
3509 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
3512 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3513 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3514 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3516 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
3517 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3518 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
3520 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
3521 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
3522 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
3524 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
3525 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
3528 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3529 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3530 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3532 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
3533 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
3534 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
3536 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
3537 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
3538 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
3540 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
3541 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
3543 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
3544 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3546 str = a2bstr("invalid");
3547 hres = IHTMLStyle_put_textDecoration(style, str);
3548 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
3551 str = a2bstr("none");
3552 hres = IHTMLStyle_put_textDecoration(style, str);
3553 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3556 str = a2bstr("underline");
3557 hres = IHTMLStyle_put_textDecoration(style, str);
3558 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3561 str = a2bstr("overline");
3562 hres = IHTMLStyle_put_textDecoration(style, str);
3563 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3566 str = a2bstr("line-through");
3567 hres = IHTMLStyle_put_textDecoration(style, str);
3568 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3571 str = a2bstr("blink");
3572 hres = IHTMLStyle_put_textDecoration(style, str);
3573 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3576 hres = IHTMLStyle_get_textDecoration(style, &str);
3577 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3578 ok(!strcmp_wa(str, "blink"), "str != blink\n");
3581 hres = IHTMLStyle_put_textDecoration(style, sDefault);
3582 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
3583 SysFreeString(sDefault);
3585 hres = IHTMLStyle_get_posWidth(style, NULL);
3586 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
3588 hres = IHTMLStyle_get_posWidth(style, &f);
3589 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3590 ok(f == 0.0f, "f = %f\n", f);
3592 V_VT(&v) = VT_EMPTY;
3593 hres = IHTMLStyle_get_width(style, &v);
3594 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3595 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3596 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
3598 hres = IHTMLStyle_put_posWidth(style, 2.2);
3599 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
3601 hres = IHTMLStyle_get_posWidth(style, &f);
3602 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
3604 f == 2.2f, /* IE8 */
3608 V_BSTR(&v) = a2bstr("auto");
3609 hres = IHTMLStyle_put_width(style, v);
3610 ok(hres == S_OK, "put_width failed: %08x\n", hres);
3613 V_VT(&v) = VT_EMPTY;
3614 hres = IHTMLStyle_get_width(style, &v);
3615 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3616 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3617 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
3621 str = (void*)0xdeadbeef;
3622 hres = IHTMLStyle_get_margin(style, &str);
3623 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3624 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
3627 hres = IHTMLStyle_put_margin(style, str);
3628 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3631 hres = IHTMLStyle_get_margin(style, &str);
3632 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3633 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
3635 hres = IHTMLStyle_put_margin(style, NULL);
3636 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
3639 hres = IHTMLStyle_get_border(style, &str);
3640 ok(hres == S_OK, "get_border failed: %08x\n", hres);
3641 ok(!str || !*str, "str is not empty\n");
3644 str = a2bstr("1px");
3645 hres = IHTMLStyle_put_border(style, str);
3646 ok(hres == S_OK, "put_border failed: %08x\n", hres);
3649 V_VT(&v) = VT_EMPTY;
3650 hres = IHTMLStyle_get_left(style, &v);
3651 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3652 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3653 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3657 hres = IHTMLStyle_get_posLeft(style, NULL);
3658 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
3661 hres = IHTMLStyle_get_posLeft(style, &f);
3662 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3663 ok(f == 0.0, "expected 0.0 got %f\n", f);
3665 hres = IHTMLStyle_put_posLeft(style, 4.9f);
3666 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
3668 hres = IHTMLStyle_get_posLeft(style, &f);
3669 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3671 f == 4.9f, /* IE8 */
3672 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3674 /* Ensure left is updated correctly. */
3675 V_VT(&v) = VT_EMPTY;
3676 hres = IHTMLStyle_get_left(style, &v);
3677 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3678 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3679 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
3680 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
3681 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3686 V_BSTR(&v) = a2bstr("3px");
3687 hres = IHTMLStyle_put_left(style, v);
3688 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3691 hres = IHTMLStyle_get_posLeft(style, &f);
3692 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
3693 ok(f == 3.0, "expected 3.0 got %f\n", f);
3695 V_VT(&v) = VT_EMPTY;
3696 hres = IHTMLStyle_get_left(style, &v);
3697 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3698 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3699 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3703 hres = IHTMLStyle_put_left(style, v);
3704 ok(hres == S_OK, "put_left failed: %08x\n", hres);
3706 V_VT(&v) = VT_EMPTY;
3707 hres = IHTMLStyle_get_left(style, &v);
3708 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3709 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3710 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3713 V_VT(&v) = VT_EMPTY;
3714 hres = IHTMLStyle_get_top(style, &v);
3715 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3716 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3717 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3721 hres = IHTMLStyle_get_posTop(style, NULL);
3722 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
3725 hres = IHTMLStyle_get_posTop(style, &f);
3726 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3727 ok(f == 0.0, "expected 0.0 got %f\n", f);
3729 hres = IHTMLStyle_put_posTop(style, 4.9f);
3730 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
3732 hres = IHTMLStyle_get_posTop(style, &f);
3733 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3735 f == 4.9f, /* IE8 */
3736 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3739 V_BSTR(&v) = a2bstr("3px");
3740 hres = IHTMLStyle_put_top(style, v);
3741 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3744 V_VT(&v) = VT_EMPTY;
3745 hres = IHTMLStyle_get_top(style, &v);
3746 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3747 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3748 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3751 hres = IHTMLStyle_get_posTop(style, &f);
3752 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
3753 ok(f == 3.0, "expected 3.0 got %f\n", f);
3756 hres = IHTMLStyle_put_top(style, v);
3757 ok(hres == S_OK, "put_top failed: %08x\n", hres);
3759 V_VT(&v) = VT_EMPTY;
3760 hres = IHTMLStyle_get_top(style, &v);
3761 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3762 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3763 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3766 /* Test posHeight */
3767 hres = IHTMLStyle_get_posHeight(style, NULL);
3768 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
3770 V_VT(&v) = VT_EMPTY;
3771 hres = IHTMLStyle_get_height(style, &v);
3772 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3773 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3774 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3778 hres = IHTMLStyle_get_posHeight(style, &f);
3779 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3780 ok(f == 0.0, "expected 0.0 got %f\n", f);
3782 hres = IHTMLStyle_put_posHeight(style, 4.9f);
3783 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
3785 hres = IHTMLStyle_get_posHeight(style, &f);
3786 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3788 f == 4.9f, /* IE8 */
3789 "expected 4.0 or 4.9 (IE8) got %f\n", f);
3792 V_BSTR(&v) = a2bstr("64px");
3793 hres = IHTMLStyle_put_height(style, v);
3794 ok(hres == S_OK, "put_height failed: %08x\n", hres);
3797 V_VT(&v) = VT_EMPTY;
3798 hres = IHTMLStyle_get_height(style, &v);
3799 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3800 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3801 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3804 hres = IHTMLStyle_get_posHeight(style, &f);
3805 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
3806 ok(f == 64.0, "expected 64.0 got %f\n", f);
3808 str = (void*)0xdeadbeef;
3809 hres = IHTMLStyle_get_cursor(style, &str);
3810 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3811 ok(!str, "get_cursor != NULL\n");
3814 str = a2bstr("default");
3815 hres = IHTMLStyle_put_cursor(style, str);
3816 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
3820 hres = IHTMLStyle_get_cursor(style, &str);
3821 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3822 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3825 V_VT(&v) = VT_EMPTY;
3826 hres = IHTMLStyle_get_verticalAlign(style, &v);
3827 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
3828 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3829 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
3833 V_BSTR(&v) = a2bstr("middle");
3834 hres = IHTMLStyle_put_verticalAlign(style, v);
3835 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
3838 V_VT(&v) = VT_EMPTY;
3839 hres = IHTMLStyle_get_verticalAlign(style, &v);
3840 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
3841 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
3842 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3845 str = (void*)0xdeadbeef;
3846 hres = IHTMLStyle_get_textAlign(style, &str);
3847 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3848 ok(!str, "textAlign != NULL\n");
3850 str = a2bstr("center");
3851 hres = IHTMLStyle_put_textAlign(style, str);
3852 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
3856 hres = IHTMLStyle_get_textAlign(style, &str);
3857 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3858 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
3861 str = (void*)0xdeadbeef;
3862 hres = IHTMLStyle_get_filter(style, &str);
3863 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
3864 ok(!str, "filter != NULL\n");
3866 str = a2bstr("alpha(opacity=100)");
3867 hres = IHTMLStyle_put_filter(style, str);
3868 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
3871 V_VT(&v) = VT_EMPTY;
3872 hres = IHTMLStyle_get_zIndex(style, &v);
3873 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3874 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3875 ok(!V_I4(&v), "V_I4(v) != 0\n");
3879 V_BSTR(&v) = a2bstr("1");
3880 hres = IHTMLStyle_put_zIndex(style, v);
3881 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
3884 V_VT(&v) = VT_EMPTY;
3885 hres = IHTMLStyle_get_zIndex(style, &v);
3886 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
3887 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
3888 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
3892 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
3893 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3895 str = a2bstr("test");
3896 hres = IHTMLStyle_put_fontStyle(style, str);
3897 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
3900 str = a2bstr("italic");
3901 hres = IHTMLStyle_put_fontStyle(style, str);
3902 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3905 str = a2bstr("oblique");
3906 hres = IHTMLStyle_put_fontStyle(style, str);
3907 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3910 str = a2bstr("normal");
3911 hres = IHTMLStyle_put_fontStyle(style, str);
3912 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3915 hres = IHTMLStyle_put_fontStyle(style, sDefault);
3916 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
3917 SysFreeString(sDefault);
3920 hres = IHTMLStyle_get_overflow(style, NULL);
3921 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
3923 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
3924 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3926 str = a2bstr("test");
3927 hres = IHTMLStyle_put_overflow(style, str);
3928 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
3931 str = a2bstr("visible");
3932 hres = IHTMLStyle_put_overflow(style, str);
3933 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3936 str = a2bstr("scroll");
3937 hres = IHTMLStyle_put_overflow(style, str);
3938 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3941 str = a2bstr("hidden");
3942 hres = IHTMLStyle_put_overflow(style, str);
3943 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3946 str = a2bstr("auto");
3947 hres = IHTMLStyle_put_overflow(style, str);
3948 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3951 hres = IHTMLStyle_get_overflow(style, &str);
3952 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3953 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
3957 hres = IHTMLStyle_put_overflow(style, str);
3958 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3961 hres = IHTMLStyle_get_overflow(style, &str);
3962 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3963 ok(!str, "str=%s\n", wine_dbgstr_w(str));
3966 /* restore overflow default */
3967 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
3968 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
3969 SysFreeString(sOverflowDefault);
3971 /* Attribute Tests*/
3972 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
3973 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3975 str = a2bstr("position");
3976 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
3977 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
3979 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3980 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3981 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3984 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
3985 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
3988 V_BSTR(&v) = a2bstr("absolute");
3989 hres = IHTMLStyle_setAttribute(style, str, v, 1);
3990 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
3993 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
3994 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
3995 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
3996 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4001 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4002 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4007 str = a2bstr("borderLeftStyle");
4008 test_border_styles(style, str);
4011 str = a2bstr("borderbottomstyle");
4012 test_border_styles(style, str);
4015 str = a2bstr("borderrightstyle");
4016 test_border_styles(style, str);
4019 str = a2bstr("bordertopstyle");
4020 test_border_styles(style, str);
4023 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
4024 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4026 str = a2bstr("none dotted dashed solid");
4027 hres = IHTMLStyle_put_borderStyle(style, str);
4028 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4031 str = a2bstr("none dotted dashed solid");
4032 hres = IHTMLStyle_get_borderStyle(style, &str);
4033 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4034 ok(!strcmp_wa(str, "none dotted dashed solid"),
4035 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4038 str = a2bstr("double groove ridge inset");
4039 hres = IHTMLStyle_put_borderStyle(style, str);
4040 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4043 str = a2bstr("window-inset outset ridge inset");
4044 hres = IHTMLStyle_put_borderStyle(style, str);
4045 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4048 str = a2bstr("window-inset");
4049 hres = IHTMLStyle_put_borderStyle(style, str);
4050 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4053 str = a2bstr("none none none none none");
4054 hres = IHTMLStyle_put_borderStyle(style, str);
4055 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4058 str = a2bstr("invalid none none none");
4059 hres = IHTMLStyle_put_borderStyle(style, str);
4060 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4063 str = a2bstr("none invalid none none");
4064 hres = IHTMLStyle_put_borderStyle(style, str);
4065 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
4068 hres = IHTMLStyle_put_borderStyle(style, sDefault);
4069 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
4070 SysFreeString(sDefault);
4072 /* backgoundColor */
4073 hres = IHTMLStyle_get_backgroundColor(style, &v);
4074 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4075 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4076 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4080 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
4081 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4084 V_BSTR(&v) = a2bstr("10");
4085 hres = IHTMLStyle_put_paddingLeft(style, v);
4086 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4089 hres = IHTMLStyle_get_paddingLeft(style, &v);
4090 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
4091 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4093 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
4094 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
4096 /* BackgroundRepeat */
4097 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
4098 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4100 str = a2bstr("invalid");
4101 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4102 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
4105 str = a2bstr("repeat");
4106 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4107 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4110 str = a2bstr("no-repeat");
4111 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4112 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4115 str = a2bstr("repeat-x");
4116 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4117 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4120 str = a2bstr("repeat-y");
4121 hres = IHTMLStyle_put_backgroundRepeat(style, str);
4122 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4125 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
4126 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4127 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
4130 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
4131 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
4132 SysFreeString(sDefault);
4135 hres = IHTMLStyle_get_borderColor(style, &sDefault);
4136 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4138 str = a2bstr("red green red blue");
4139 hres = IHTMLStyle_put_borderColor(style, str);
4140 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4143 hres = IHTMLStyle_get_borderColor(style, &str);
4144 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4145 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
4148 hres = IHTMLStyle_put_borderColor(style, sDefault);
4149 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
4150 SysFreeString(sDefault);
4153 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
4154 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
4156 str = a2bstr("thick dotted red");
4157 hres = IHTMLStyle_put_borderLeft(style, str);
4158 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4161 /* IHTMLStyle_get_borderLeft appears to have a bug where
4162 it returns the first letter of the color. So we check
4163 each style individually.
4166 hres = IHTMLStyle_get_borderLeftColor(style, &v);
4167 todo_wine ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4168 todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4172 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4173 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4174 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4177 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
4178 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
4179 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
4182 hres = IHTMLStyle_put_borderLeft(style, sDefault);
4183 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
4184 SysFreeString(sDefault);
4186 /* backgroundPositionX */
4187 hres = IHTMLStyle_get_backgroundPositionX(style, &vDefault);
4188 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4191 V_BSTR(&v) = a2bstr("10px");
4192 hres = IHTMLStyle_put_backgroundPositionX(style, v);
4193 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4196 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
4197 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
4198 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4201 hres = IHTMLStyle_put_backgroundPositionX(style, vDefault);
4202 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
4203 VariantClear(&vDefault);
4205 /* backgroundPositionY */
4206 hres = IHTMLStyle_get_backgroundPositionY(style, &vDefault);
4207 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4210 V_BSTR(&v) = a2bstr("10px");
4211 hres = IHTMLStyle_put_backgroundPositionY(style, v);
4212 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4215 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
4216 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
4217 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4220 hres = IHTMLStyle_put_backgroundPositionY(style, vDefault);
4221 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
4222 VariantClear(&vDefault);
4224 /* borderTopWidth */
4225 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
4226 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4229 V_BSTR(&v) = a2bstr("10px");
4230 hres = IHTMLStyle_put_borderTopWidth(style, v);
4231 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4234 hres = IHTMLStyle_get_borderTopWidth(style, &v);
4235 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
4236 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4239 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
4240 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
4241 VariantClear(&vDefault);
4243 /* borderRightWidth */
4244 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
4245 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4248 V_BSTR(&v) = a2bstr("10");
4249 hres = IHTMLStyle_put_borderRightWidth(style, v);
4250 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4253 hres = IHTMLStyle_get_borderRightWidth(style, &v);
4254 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
4255 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4258 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
4259 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
4260 VariantClear(&vDefault);
4262 /* borderBottomWidth */
4263 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
4264 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4267 V_BSTR(&v) = a2bstr("10");
4268 hres = IHTMLStyle_put_borderBottomWidth(style, v);
4269 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4272 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
4273 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
4274 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4277 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
4278 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
4279 VariantClear(&vDefault);
4281 /* borderLeftWidth */
4282 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
4283 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4286 V_BSTR(&v) = a2bstr("10");
4287 hres = IHTMLStyle_put_borderLeftWidth(style, v);
4288 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4291 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
4292 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
4293 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4296 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
4297 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
4298 VariantClear(&vDefault);
4301 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
4302 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4305 V_BSTR(&v) = a2bstr("10");
4306 hres = IHTMLStyle_put_wordSpacing(style, v);
4307 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4310 hres = IHTMLStyle_get_wordSpacing(style, &v);
4311 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
4312 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4313 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4316 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
4317 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
4318 VariantClear(&vDefault);
4321 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
4322 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4325 V_BSTR(&v) = a2bstr("11");
4326 hres = IHTMLStyle_put_letterSpacing(style, v);
4327 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4330 hres = IHTMLStyle_get_letterSpacing(style, &v);
4331 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
4332 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4333 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4336 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
4337 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
4338 VariantClear(&vDefault);
4340 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
4341 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
4342 if(SUCCEEDED(hres)) {
4343 test_style2(style2);
4344 IHTMLStyle2_Release(style2);
4347 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
4348 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
4349 if(SUCCEEDED(hres)) {
4350 test_style3(style3);
4351 IHTMLStyle3_Release(style3);
4354 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
4355 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
4356 if(SUCCEEDED(hres)) {
4357 test_style4(style4);
4358 IHTMLStyle4_Release(style4);
4362 static void test_set_csstext(IHTMLStyle *style)
4367 test_style_set_csstext(style, "background-color: black;");
4369 hres = IHTMLStyle_get_backgroundColor(style, &v);
4370 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
4371 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4372 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4376 static void test_default_selection(IHTMLDocument2 *doc)
4378 IHTMLSelectionObject *selection;
4379 IHTMLTxtRange *range;
4384 hres = IHTMLDocument2_get_selection(doc, &selection);
4385 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
4387 hres = IHTMLSelectionObject_get_type(selection, &str);
4388 ok(hres == S_OK, "get_type failed: %08x\n", hres);
4389 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
4392 hres = IHTMLSelectionObject_createRange(selection, &disp);
4393 IHTMLSelectionObject_Release(selection);
4394 ok(hres == S_OK, "createRange failed: %08x\n", hres);
4396 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
4397 IDispatch_Release(disp);
4398 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
4400 test_range_text(range, NULL);
4401 IHTMLTxtRange_Release(range);
4404 static void test_doc_elem(IHTMLDocument2 *doc)
4406 IHTMLDocument2 *doc_node, *owner_doc;
4408 IHTMLDocument3 *doc3;
4411 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
4412 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
4414 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
4415 IHTMLDocument3_Release(doc3);
4416 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
4418 test_node_name((IUnknown*)elem, "HTML");
4419 test_elem_tag((IUnknown*)elem, "HTML");
4421 doc_node = get_doc_node(doc);
4422 owner_doc = get_owner_doc((IUnknown*)elem);
4423 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
4424 IHTMLDocument2_Release(owner_doc);
4426 owner_doc = get_owner_doc((IUnknown*)doc_node);
4427 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4428 IHTMLDocument2_Release(doc_node);
4430 test_elem_client_rect((IUnknown*)elem);
4432 IHTMLElement_Release(elem);
4435 static void test_default_body(IHTMLBodyElement *body)
4441 WCHAR sBodyText[] = {'#','F','F','0','0','0','0',0};
4442 WCHAR sTextInvalid[] = {'I','n','v','a','l','i','d',0};
4444 bstr = (void*)0xdeadbeef;
4445 hres = IHTMLBodyElement_get_background(body, &bstr);
4446 ok(hres == S_OK, "get_background failed: %08x\n", hres);
4447 ok(bstr == NULL, "bstr != NULL\n");
4449 l = elem_get_scroll_height((IUnknown*)body);
4450 ok(l != -1, "scrollHeight == -1\n");
4451 l = elem_get_scroll_width((IUnknown*)body);
4452 ok(l != -1, "scrollWidth == -1\n");
4453 l = elem_get_scroll_top((IUnknown*)body);
4454 ok(!l, "scrollTop = %d\n", l);
4455 elem_get_scroll_left((IUnknown*)body);
4457 /* get_text tests */
4458 hres = IHTMLBodyElement_get_text(body, &v);
4459 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4460 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4461 ok(bstr == NULL, "bstr != NULL\n");
4464 /* get_text - Invalid Text */
4466 V_BSTR(&v) = SysAllocString(sTextInvalid);
4467 hres = IHTMLBodyElement_put_text(body, v);
4468 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4472 hres = IHTMLBodyElement_get_text(body, &v);
4473 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4474 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4475 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v != '#00a0d0'\n");
4478 /* get_text - Valid Text */
4480 V_BSTR(&v) = SysAllocString(sBodyText);
4481 hres = IHTMLBodyElement_put_text(body, v);
4482 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4486 hres = IHTMLBodyElement_get_text(body, &v);
4487 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
4488 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
4489 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v != '#ff0000'\n");
4493 static void test_body_funs(IHTMLBodyElement *body)
4495 static WCHAR sRed[] = {'r','e','d',0};
4500 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
4501 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4502 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
4504 V_VT(&vbg) = VT_BSTR;
4505 V_BSTR(&vbg) = SysAllocString(sRed);
4506 hres = IHTMLBodyElement_put_bgColor(body, vbg);
4507 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4510 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
4511 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
4512 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
4513 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
4516 /* Restore Originial */
4517 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
4518 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
4519 VariantClear(&vDefaultbg);
4522 static void test_window(IHTMLDocument2 *doc)
4524 IHTMLWindow2 *window, *window2, *self;
4525 IHTMLDocument2 *doc2 = NULL;
4531 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4532 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4533 test_ifaces((IUnknown*)window, window_iids);
4534 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
4536 hres = IHTMLWindow2_get_document(window, &doc2);
4537 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4538 ok(doc2 != NULL, "doc2 == NULL\n");
4540 test_ifaces((IUnknown*)doc2, doc_node_iids);
4541 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4543 test_ifaces((IUnknown*)doc, doc_obj_iids);
4544 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
4546 unk = (void*)0xdeadbeef;
4547 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
4548 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
4549 ok(!unk, "unk = %p\n", unk);
4551 IHTMLDocument_Release(doc2);
4553 hres = IHTMLWindow2_get_window(window, &window2);
4554 ok(hres == S_OK, "get_window failed: %08x\n", hres);
4555 ok(window2 != NULL, "window2 == NULL\n");
4557 hres = IHTMLWindow2_get_self(window, &self);
4558 ok(hres == S_OK, "get_self failed: %08x\n", hres);
4559 ok(window2 != NULL, "self == NULL\n");
4561 ok(self == window2, "self != window2\n");
4563 IHTMLWindow2_Release(window2);
4564 IHTMLWindow2_Release(self);
4567 hres = IHTMLDocument2_get_Script(doc, &disp);
4568 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
4569 ok(disp == (void*)window, "disp != window\n");
4570 IDispatch_Release(disp);
4572 hres = IHTMLWindow2_toString(window, NULL);
4573 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
4576 hres = IHTMLWindow2_toString(window, &str);
4577 ok(hres == S_OK, "toString failed: %08x\n", hres);
4578 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
4581 test_window_name(window, NULL);
4582 set_window_name(window, "test");
4583 test_window_length(window, 0);
4585 IHTMLWindow2_Release(window);
4588 static void test_defaults(IHTMLDocument2 *doc)
4590 IHTMLStyleSheetsCollection *stylesheetcol;
4591 IHTMLCurrentStyle *cstyle;
4592 IHTMLBodyElement *body;
4593 IHTMLElement2 *elem2;
4598 IHTMLElementCollection *collection;
4600 hres = IHTMLDocument2_get_body(doc, &elem);
4601 ok(hres == S_OK, "get_body failed: %08x\n", hres);
4603 hres = IHTMLDocument2_get_images(doc, NULL);
4604 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4606 hres = IHTMLDocument2_get_images(doc, &collection);
4607 ok(hres == S_OK, "get_images failed: %08x\n", hres);
4610 test_elem_collection((IUnknown*)collection, NULL, 0);
4611 IHTMLElementCollection_Release(collection);
4614 hres = IHTMLDocument2_get_applets(doc, NULL);
4615 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4617 hres = IHTMLDocument2_get_applets(doc, &collection);
4618 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
4621 test_elem_collection((IUnknown*)collection, NULL, 0);
4622 IHTMLElementCollection_Release(collection);
4625 hres = IHTMLDocument2_get_links(doc, NULL);
4626 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4628 hres = IHTMLDocument2_get_links(doc, &collection);
4629 ok(hres == S_OK, "get_links failed: %08x\n", hres);
4632 test_elem_collection((IUnknown*)collection, NULL, 0);
4633 IHTMLElementCollection_Release(collection);
4636 hres = IHTMLDocument2_get_forms(doc, NULL);
4637 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4639 hres = IHTMLDocument2_get_forms(doc, &collection);
4640 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
4643 test_elem_collection((IUnknown*)collection, NULL, 0);
4644 IHTMLElementCollection_Release(collection);
4647 hres = IHTMLDocument2_get_anchors(doc, NULL);
4648 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
4650 hres = IHTMLDocument2_get_anchors(doc, &collection);
4651 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
4654 test_elem_collection((IUnknown*)collection, NULL, 0);
4655 IHTMLElementCollection_Release(collection);
4658 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
4659 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
4660 test_default_body(body);
4661 test_body_funs(body);
4662 IHTMLBodyElement_Release(body);
4664 hres = IHTMLElement_get_style(elem, &style);
4665 ok(hres == S_OK, "get_style failed: %08x\n", hres);
4667 test_default_style(style);
4669 test_compatmode(doc);
4671 test_navigator(doc);
4673 elem2 = get_elem2_iface((IUnknown*)elem);
4674 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
4675 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
4676 if(SUCCEEDED(hres)) {
4677 test_current_style(cstyle);
4678 IHTMLCurrentStyle_Release(cstyle);
4680 IHTMLElement2_Release(elem2);
4682 IHTMLElement_Release(elem);
4684 test_set_csstext(style);
4685 IHTMLStyle_Release(style);
4687 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
4688 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4691 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
4692 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4693 ok(l == 0, "length = %d\n", l);
4695 IHTMLStyleSheetsCollection_Release(stylesheetcol);
4697 test_default_selection(doc);
4698 test_doc_title(doc, "");
4701 static void test_tr_elem(IHTMLElement *elem)
4703 IHTMLElementCollection *col;
4707 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
4709 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
4710 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
4715 hres = IHTMLTableRow_get_cells(row, &col);
4716 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
4717 ok(col != NULL, "get_cells returned NULL\n");
4719 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
4720 IHTMLElementCollection_Release(col);
4722 IHTMLTable_Release(row);
4725 static void test_table_elem(IHTMLElement *elem)
4727 IHTMLElementCollection *col;
4732 static const elem_type_t row_types[] = {ET_TR,ET_TR};
4733 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
4735 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
4736 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
4741 hres = IHTMLTable_get_rows(table, &col);
4742 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
4743 ok(col != NULL, "get_ros returned NULL\n");
4745 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
4746 IHTMLElementCollection_Release(col);
4748 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
4750 node = clone_node((IUnknown*)table, VARIANT_TRUE);
4751 test_elem_tag((IUnknown*)node, "TABLE");
4752 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
4753 IHTMLDOMNode_Release(node);
4755 node = clone_node((IUnknown*)table, VARIANT_FALSE);
4756 test_elem_tag((IUnknown*)node, "TABLE");
4757 test_elem_all((IUnknown*)node, NULL, 0);
4758 IHTMLDOMNode_Release(node);
4760 IHTMLTable_Release(table);
4763 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
4773 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
4774 SafeArrayAccessData(sa, (void**)&var);
4775 V_VT(var) = VT_BSTR;
4776 V_BSTR(var) = str = a2bstr(text);
4777 SafeArrayUnaccessData(sa);
4780 hres = IHTMLDocument2_writeln(doc, sa);
4782 hres = IHTMLDocument2_write(doc, sa);
4783 ok(hres == S_OK, "write failed: %08x\n", hres);
4786 SafeArrayDestroy(sa);
4789 static void test_iframe_elem(IHTMLElement *elem)
4791 IHTMLDocument2 *content_doc, *owner_doc;
4792 IHTMLElementCollection *col;
4793 IHTMLWindow2 *content_window;
4794 IHTMLFrameBase2 *base2;
4800 static const elem_type_t all_types[] = {
4808 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
4809 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
4812 content_window = NULL;
4813 hres = IHTMLFrameBase2_get_contentWindow(base2, &content_window);
4814 IHTMLFrameBase2_Release(base2);
4815 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
4816 ok(content_window != NULL, "contentWindow = NULL\n");
4818 test_window_length(content_window, 0);
4821 hres = IHTMLWindow2_get_document(content_window, &content_doc);
4822 IHTMLWindow2_Release(content_window);
4823 ok(hres == S_OK, "get_document failed: %08x\n", hres);
4824 ok(content_doc != NULL, "content_doc = NULL\n");
4826 str = a2bstr("text/html");
4827 V_VT(&errv) = VT_ERROR;
4829 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
4831 ok(hres == S_OK, "open failed: %08x\n", hres);
4832 ok(disp != NULL, "disp == NULL\n");
4833 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
4834 IDispatch_Release(disp);
4836 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
4837 doc_write(content_doc, TRUE, "</html>");
4839 hres = IHTMLDocument2_get_all(content_doc, &col);
4840 ok(hres == S_OK, "get_all failed: %08x\n", hres);
4841 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
4842 IHTMLElementCollection_Release(col);
4844 hres = IHTMLDocument2_close(content_doc);
4845 ok(hres == S_OK, "close failed: %08x\n", hres);
4847 owner_doc = get_owner_doc((IUnknown*)content_doc);
4848 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
4850 IHTMLDocument2_Release(content_doc);
4853 static void test_stylesheet(IDispatch *disp)
4855 IHTMLStyleSheetRulesCollection *col = NULL;
4856 IHTMLStyleSheet *stylesheet;
4859 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
4860 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
4862 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
4863 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
4864 ok(col != NULL, "col == NULL\n");
4866 IHTMLStyleSheetRulesCollection_Release(col);
4867 IHTMLStyleSheet_Release(stylesheet);
4870 static void test_stylesheets(IHTMLDocument2 *doc)
4872 IHTMLStyleSheetsCollection *col = NULL;
4877 hres = IHTMLDocument2_get_styleSheets(doc, &col);
4878 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
4879 ok(col != NULL, "col == NULL\n");
4881 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
4882 ok(hres == S_OK, "get_length failed: %08x\n", hres);
4883 ok(len == 1, "len=%d\n", len);
4889 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4890 ok(hres == S_OK, "item failed: %08x\n", hres);
4891 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
4892 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4893 test_stylesheet(V_DISPATCH(&res));
4900 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
4901 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
4902 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
4903 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
4906 IHTMLStyleSheetsCollection_Release(col);
4909 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
4911 IDispatchEx *dispex;
4913 DISPPARAMS dp = {NULL, NULL, 0, 0};
4921 static const WCHAR w0[] = {'0',0};
4922 static const WCHAR w100[] = {'1','0','0',0};
4924 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
4925 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
4927 bstr = SysAllocString(w0);
4928 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4929 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
4930 SysFreeString(bstr);
4933 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
4934 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
4935 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
4936 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
4937 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
4938 type = get_node_type((IUnknown*)node);
4939 ok(type == 3, "type=%d\n", type);
4940 IHTMLDOMNode_Release(node);
4943 bstr = SysAllocString(w100);
4944 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
4945 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
4946 SysFreeString(bstr);
4948 IDispatchEx_Release(dispex);
4953 static void test_elems(IHTMLDocument2 *doc)
4955 IHTMLElementCollection *col;
4956 IHTMLDOMChildrenCollection *child_col;
4957 IHTMLElement *elem, *elem2, *elem3;
4958 IHTMLDOMNode *node, *node2;
4959 IHTMLWindow2 *window;
4963 IHTMLElementCollection *collection;
4964 IHTMLDocument3 *doc3;
4967 static const elem_type_t all_types[] = {
4992 static const elem_type_t item_types[] = {
4998 hres = IHTMLDocument2_get_all(doc, &col);
4999 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5000 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5001 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
5002 IHTMLElementCollection_Release(col);
5004 hres = IHTMLDocument2_get_images(doc, &collection);
5005 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5008 static const elem_type_t images_types[] = {ET_IMG};
5009 test_elem_collection((IUnknown*)collection, images_types, 1);
5011 IHTMLElementCollection_Release(collection);
5014 hres = IHTMLDocument2_get_links(doc, &collection);
5015 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5018 static const elem_type_t images_types[] = {ET_A};
5019 test_elem_collection((IUnknown*)collection, images_types, 1);
5021 IHTMLElementCollection_Release(collection);
5024 hres = IHTMLDocument2_get_anchors(doc, &collection);
5025 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5028 static const elem_type_t anchor_types[] = {ET_A};
5029 test_elem_collection((IUnknown*)collection, anchor_types, 1);
5031 IHTMLElementCollection_Release(collection);
5034 elem = get_doc_elem(doc);
5035 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
5036 IHTMLElement_Release(elem);
5038 get_elem_by_id(doc, "xxx", FALSE);
5039 elem = get_doc_elem_by_id(doc, "xxx");
5040 ok(!elem, "elem != NULL\n");
5042 elem = get_doc_elem_by_id(doc, "s");
5043 ok(elem != NULL, "elem == NULL\n");
5045 test_elem_type((IUnknown*)elem, ET_SELECT);
5046 test_elem_attr(elem, "xxx", NULL);
5047 test_elem_attr(elem, "id", "s");
5048 test_elem_class((IUnknown*)elem, NULL);
5049 test_elem_set_class((IUnknown*)elem, "cl");
5050 test_elem_set_class((IUnknown*)elem, NULL);
5051 test_elem_tabindex((IUnknown*)elem, 0);
5052 test_elem_set_tabindex((IUnknown*)elem, 1);
5054 node = test_node_get_parent((IUnknown*)elem);
5055 ok(node != NULL, "node == NULL\n");
5056 test_node_name((IUnknown*)node, "BODY");
5057 node2 = test_node_get_parent((IUnknown*)node);
5058 IHTMLDOMNode_Release(node);
5059 ok(node2 != NULL, "node == NULL\n");
5060 test_node_name((IUnknown*)node2, "HTML");
5061 node = test_node_get_parent((IUnknown*)node2);
5062 IHTMLDOMNode_Release(node2);
5063 ok(node != NULL, "node == NULL\n");
5066 test_node_name((IUnknown*)node, "#document");
5067 type = get_node_type((IUnknown*)node);
5068 ok(type == 9, "type=%d, expected 9\n", type);
5069 node2 = test_node_get_parent((IUnknown*)node);
5070 IHTMLDOMNode_Release(node);
5071 ok(node2 == NULL, "node != NULL\n");
5074 elem2 = test_elem_get_parent((IUnknown*)elem);
5075 ok(elem2 != NULL, "elem2 == NULL\n");
5076 test_node_name((IUnknown*)elem2, "BODY");
5077 elem3 = test_elem_get_parent((IUnknown*)elem2);
5078 IHTMLElement_Release(elem2);
5079 ok(elem3 != NULL, "elem3 == NULL\n");
5080 test_node_name((IUnknown*)elem3, "HTML");
5081 elem2 = test_elem_get_parent((IUnknown*)elem3);
5082 IHTMLElement_Release(elem3);
5083 ok(elem2 == NULL, "elem2 != NULL\n");
5085 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
5086 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
5087 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
5089 test_elem_innertext(elem, "opt1opt2");
5091 IHTMLElement_Release(elem);
5094 elem = get_elem_by_id(doc, "s", TRUE);
5096 IHTMLSelectElement *select;
5097 IHTMLDocument2 *doc_node;
5099 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLSelectElement, (void**)&select);
5100 ok(hres == S_OK, "Could not get IHTMLSelectElement interface: %08x\n", hres);
5102 test_select_elem(select);
5104 test_elem_title((IUnknown*)select, NULL);
5105 test_elem_set_title((IUnknown*)select, "Title");
5106 test_elem_title((IUnknown*)select, "Title");
5107 test_elem_offset((IUnknown*)select);
5109 node = get_first_child((IUnknown*)select);
5110 ok(node != NULL, "node == NULL\n");
5112 test_elem_type((IUnknown*)node, ET_OPTION);
5113 IHTMLDOMNode_Release(node);
5116 type = get_node_type((IUnknown*)select);
5117 ok(type == 1, "type=%d\n", type);
5119 IHTMLSelectElement_Release(select);
5121 hres = IHTMLElement_get_document(elem, &disp);
5122 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5124 doc_node = get_doc_node(doc);
5125 ok(iface_cmp((IUnknown*)disp, (IUnknown*)doc_node), "disp != doc\n");
5126 IHTMLDocument2_Release(doc_node);
5128 IHTMLElement_Release(elem);
5131 elem = get_elem_by_id(doc, "sc", TRUE);
5133 IHTMLScriptElement *script;
5136 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
5137 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
5143 hres = IHTMLScriptElement_get_type(script, &type);
5144 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5145 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
5146 SysFreeString(type);
5149 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
5150 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5152 hres = IHTMLScriptElement_get_defer(script, &vb);
5153 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
5154 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
5156 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
5157 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
5160 IHTMLScriptElement_Release(script);
5163 elem = get_elem_by_id(doc, "in", TRUE);
5165 IHTMLInputElement *input;
5167 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
5168 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
5170 test_elem_id((IUnknown*)elem, "in");
5171 test_elem_put_id((IUnknown*)elem, "newin");
5172 test_input_get_disabled(input, VARIANT_FALSE);
5173 test_input_set_disabled(input, VARIANT_TRUE);
5174 test_input_set_disabled(input, VARIANT_FALSE);
5175 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
5176 test_input_get_disabled(input, VARIANT_TRUE);
5177 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
5178 test_input_get_disabled(input, VARIANT_FALSE);
5179 test_elem_client_size((IUnknown*)elem);
5181 test_node_get_value_str((IUnknown*)elem, NULL);
5182 test_node_put_value_str((IUnknown*)elem, "test");
5183 test_node_get_value_str((IUnknown*)elem, NULL);
5184 test_input_value((IUnknown*)elem, NULL);
5185 test_input_put_value((IUnknown*)elem, "test");
5186 test_input_value((IUnknown*)elem, NULL);
5187 test_elem_class((IUnknown*)elem, "testclass");
5188 test_elem_tabindex((IUnknown*)elem, 2);
5189 test_elem_set_tabindex((IUnknown*)elem, 3);
5190 test_elem_title((IUnknown*)elem, "test title");
5192 test_input_get_defaultchecked(input, VARIANT_FALSE);
5193 test_input_set_defaultchecked(input, VARIANT_TRUE);
5194 test_input_set_defaultchecked(input, VARIANT_FALSE);
5196 test_input_get_checked(input, VARIANT_FALSE);
5197 test_input_set_checked(input, VARIANT_TRUE);
5198 test_input_set_checked(input, VARIANT_FALSE);
5200 test_input_src(input, NULL);
5201 test_input_set_src(input, "about:blank");
5203 IHTMLInputElement_Release(input);
5204 IHTMLElement_Release(elem);
5207 elem = get_elem_by_id(doc, "imgid", TRUE);
5209 test_img_src((IUnknown*)elem, "");
5210 test_img_set_src((IUnknown*)elem, "about:blank");
5211 test_img_alt((IUnknown*)elem, NULL);
5212 test_img_set_alt((IUnknown*)elem, "alt test");
5213 IHTMLElement_Release(elem);
5216 elem = get_doc_elem_by_id(doc, "tbl");
5217 ok(elem != NULL, "elem == NULL\n");
5219 test_table_elem(elem);
5220 IHTMLElement_Release(elem);
5223 elem = get_doc_elem_by_id(doc, "row2");
5224 ok(elem != NULL, "elem == NULL\n");
5227 IHTMLElement_Release(elem);
5230 elem = get_doc_elem_by_id(doc, "ifr");
5231 ok(elem != NULL, "elem == NULL\n");
5233 test_iframe_elem(elem);
5234 IHTMLElement_Release(elem);
5237 elem = get_elem_by_id(doc, "a", TRUE);
5239 test_anchor_href((IUnknown*)elem, "http://test/");
5240 IHTMLElement_Release(elem);
5243 hres = IHTMLDocument2_get_body(doc, &elem);
5244 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5246 node = get_first_child((IUnknown*)elem);
5247 ok(node != NULL, "node == NULL\n");
5249 test_ifaces((IUnknown*)node, text_iids);
5250 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5252 node2 = get_first_child((IUnknown*)node);
5253 ok(!node2, "node2 != NULL\n");
5255 type = get_node_type((IUnknown*)node);
5256 ok(type == 3, "type=%d\n", type);
5258 test_node_get_value_str((IUnknown*)node, "text test");
5259 test_node_put_value_str((IUnknown*)elem, "test text");
5260 test_node_get_value_str((IUnknown*)node, "text test");
5262 IHTMLDOMNode_Release(node);
5265 child_col = get_child_nodes((IUnknown*)elem);
5266 ok(child_col != NULL, "child_coll == NULL\n");
5270 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
5272 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
5273 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5274 ok(length, "length=0\n");
5277 node = get_child_item(child_col, 0);
5278 ok(node != NULL, "node == NULL\n");
5280 type = get_node_type((IUnknown*)node);
5281 ok(type == 3, "type=%d\n", type);
5282 node2 = node_get_next((IUnknown*)node);
5283 IHTMLDOMNode_Release(node);
5286 node = get_child_item(child_col, 1);
5287 ok(node != NULL, "node == NULL\n");
5289 type = get_node_type((IUnknown*)node);
5290 ok(type == 8, "type=%d\n", type);
5292 test_elem_id((IUnknown*)node, NULL);
5293 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
5294 IHTMLDOMNode_Release(node2);
5295 IHTMLDOMNode_Release(node);
5298 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
5299 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5301 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
5302 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
5304 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
5305 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5307 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
5308 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
5310 test_child_col_disp(child_col);
5312 IHTMLDOMChildrenCollection_Release(child_col);
5315 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
5316 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
5317 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
5319 IHTMLElement_Release(elem);
5321 test_stylesheets(doc);
5322 test_create_option_elem(doc);
5323 test_create_img_elem(doc);
5325 elem = get_doc_elem_by_id(doc, "tbl");
5326 ok(elem != NULL, "elem = NULL\n");
5327 test_elem_set_innertext(elem, "inner text");
5328 IHTMLElement_Release(elem);
5330 test_doc_title(doc, "test");
5331 test_doc_set_title(doc, "test title");
5332 test_doc_title(doc, "test title");
5335 hres = IHTMLDocument2_get_Script(doc, &disp);
5336 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5339 IDispatchEx *dispex;
5340 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
5341 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
5345 BSTR str = a2bstr("Testing");
5346 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
5347 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
5348 ok(pid != -1, "pid == -1\n");
5350 IDispatchEx_Release(dispex);
5353 IDispatch_Release(disp);
5355 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5356 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
5358 str = a2bstr("img");
5359 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
5360 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
5364 static const elem_type_t img_types[] = { ET_IMG };
5366 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
5367 IHTMLElementCollection_Release(col);
5370 elem = get_doc_elem_by_id(doc, "y");
5371 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
5372 test_elem_innerhtml((IUnknown*)elem, "inner html");
5373 test_elem_set_innerhtml((IUnknown*)elem, "");
5374 test_elem_innerhtml((IUnknown*)elem, NULL);
5375 node = node_get_next((IUnknown*)elem);
5376 ok(!node, "node = %p\n", node);
5378 elem2 = get_doc_elem_by_id(doc, "x");
5379 node = node_get_next((IUnknown*)elem2);
5380 IHTMLDOMNode_Release(node);
5381 IHTMLElement_Release(elem2);
5382 IHTMLElement_Release(elem);
5384 IHTMLDocument3_Release(doc3);
5386 window = get_doc_window(doc);
5387 test_window_name(window, NULL);
5388 set_window_name(window, "test name");
5389 test_window_length(window, 1);
5390 IHTMLWindow2_Release(window);
5393 static void test_create_elems(IHTMLDocument2 *doc)
5395 IHTMLElement *elem, *body, *elem2;
5396 IHTMLDOMNode *node, *node2, *node3, *comment;
5397 IHTMLDocument5 *doc5;
5404 static const elem_type_t types1[] = { ET_TESTG };
5406 elem = test_create_elem(doc, "TEST");
5407 test_elem_tag((IUnknown*)elem, "TEST");
5408 type = get_node_type((IUnknown*)elem);
5409 ok(type == 1, "type=%d\n", type);
5410 test_ifaces((IUnknown*)elem, elem_iids);
5411 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
5413 hres = IHTMLDocument2_get_body(doc, &body);
5414 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5415 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5417 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
5418 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
5419 elem2 = get_elem_iface((IUnknown*)node);
5420 IHTMLElement_Release(elem2);
5422 hres = IHTMLElement_get_all(body, &disp);
5423 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5424 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
5425 IDispatch_Release(disp);
5427 test_node_remove_child((IUnknown*)body, node);
5429 hres = IHTMLElement_get_all(body, &disp);
5430 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5431 test_elem_collection((IUnknown*)disp, NULL, 0);
5432 IDispatch_Release(disp);
5433 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
5435 IHTMLElement_Release(elem);
5436 IHTMLDOMNode_Release(node);
5438 node = test_create_text(doc, "test");
5439 test_ifaces((IUnknown*)node, text_iids);
5440 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
5442 V_VT(&var) = VT_NULL;
5443 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
5444 IHTMLDOMNode_Release(node);
5446 node = test_create_text(doc, "insert ");
5448 V_VT(&var) = VT_DISPATCH;
5449 V_DISPATCH(&var) = (IDispatch*)node2;
5450 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
5451 IHTMLDOMNode_Release(node);
5452 IHTMLDOMNode_Release(node2);
5453 IHTMLDOMNode_Release(node3);
5455 test_elem_innertext(body, "insert test");
5456 test_elem_innerhtml((IUnknown*)body, "insert test");
5458 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5461 str = a2bstr("testing");
5462 hres = IHTMLDocument5_createComment(doc5, str, &comment);
5464 ok(hres == S_OK, "createComment failed: %08x\n", hres);
5467 type = get_node_type((IUnknown*)comment);
5468 ok(type == 8, "type=%d, expected 8\n", type);
5470 test_node_get_value_str((IUnknown*)comment, "testing");
5472 IHTMLDOMNode_Release(comment);
5475 IHTMLDocument5_Release(doc5);
5478 IHTMLElement_Release(body);
5481 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
5483 IOleCommandTarget *cmdtrg;
5486 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
5487 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
5489 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
5490 ok(hres == S_OK, "Exec failed: %08x\n", hres);
5492 IOleCommandTarget_Release(cmdtrg);
5495 static void test_indent(IHTMLDocument2 *doc)
5497 IHTMLElementCollection *col;
5498 IHTMLTxtRange *range;
5501 static const elem_type_t all_types[] = {
5510 static const elem_type_t indent_types[] = {
5521 hres = IHTMLDocument2_get_all(doc, &col);
5522 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5523 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5524 IHTMLElementCollection_Release(col);
5526 range = test_create_body_range(doc);
5527 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
5528 IHTMLTxtRange_Release(range);
5530 hres = IHTMLDocument2_get_all(doc, &col);
5531 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5532 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
5533 IHTMLElementCollection_Release(col);
5536 static void test_cond_comment(IHTMLDocument2 *doc)
5538 IHTMLElementCollection *col;
5541 static const elem_type_t all_types[] = {
5549 hres = IHTMLDocument2_get_all(doc, &col);
5550 ok(hres == S_OK, "get_all failed: %08x\n", hres);
5551 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
5552 IHTMLElementCollection_Release(col);
5555 static void test_frame(IDispatch *disp, const char *exp_id)
5557 IHTMLWindow4 *frame;
5558 IHTMLFrameBase *frame_elem;
5559 IHTMLElement *html_elem;
5563 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
5564 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
5568 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
5569 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
5570 IHTMLWindow4_Release(frame);
5574 hres = IHTMLFrameBase_QueryInterface(frame_elem, &IID_IHTMLElement, (void**)&html_elem);
5575 ok(hres == S_OK, "Could not get IHTMLElement interface: 0x%08x\n", hres);
5576 IHTMLFrameBase_Release(frame_elem);
5580 hres = IHTMLElement_get_id(html_elem, &bstr);
5581 ok(hres == S_OK, "IHTMLElement_get_id failed: 0x%08x\n", hres);
5582 ok(!strcmp_wa(bstr, exp_id), "Expected ID: \"%s\", found ID: %s\n", exp_id, wine_dbgstr_w(bstr));
5583 IHTMLElement_Release(html_elem);
5584 SysFreeString(bstr);
5587 static void test_frameset(IHTMLDocument2 *doc)
5589 IHTMLWindow2 *window;
5590 IHTMLFramesCollection2 *frames;
5592 VARIANT index_var, result_var;
5595 window = get_doc_window(doc);
5597 /* test using IHTMLFramesCollection object */
5599 hres = IHTMLWindow2_get_frames(window, &frames);
5600 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
5601 IHTMLWindow2_Release(window);
5605 /* test result length */
5606 hres = IHTMLFramesCollection2_get_length(frames, &length);
5607 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
5608 ok(length == 2, "IHTMLFramesCollection2_get_length should have been 2, was: %d\n", length);
5610 /* test first frame */
5611 V_VT(&index_var) = VT_I4;
5612 V_I4(&index_var) = 0;
5613 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5614 todo_wine ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5615 if(SUCCEEDED(hres)) {
5616 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5617 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5619 VariantClear(&result_var);
5621 /* test second frame */
5622 V_I4(&index_var) = 1;
5623 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5624 todo_wine ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5625 if(SUCCEEDED(hres)) {
5626 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5627 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5629 VariantClear(&result_var);
5631 /* fail on third frame */
5632 V_I4(&index_var) = 2;
5633 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5634 todo_wine ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
5635 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5636 VariantClear(&result_var);
5638 /* string argument (element id lookup) */
5639 V_VT(&index_var) = VT_BSTR;
5640 V_BSTR(&index_var) = a2bstr("fr1");
5641 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5642 todo_wine ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
5643 if(SUCCEEDED(hres)) {
5644 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5645 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5647 VariantClear(&result_var);
5648 VariantClear(&index_var);
5650 /* invalid argument */
5651 V_VT(&index_var) = VT_BOOL;
5652 V_BOOL(&index_var) = VARIANT_TRUE;
5653 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
5654 todo_wine ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
5655 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5656 VariantClear(&result_var);
5658 IHTMLFramesCollection2_Release(frames);
5660 /* test using IHTMLWindow2 inheritance */
5662 /* test result length */
5663 hres = IHTMLWindow2_get_length(window, &length);
5664 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
5665 ok(length == 2, "IHTMLWindow2_get_length should have been 2, was: %d\n", length);
5667 /* test first frame */
5668 V_VT(&index_var) = VT_I4;
5669 V_I4(&index_var) = 0;
5670 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5671 todo_wine ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5672 if(SUCCEEDED(hres)) {
5673 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5674 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
5676 VariantClear(&result_var);
5678 /* test second frame */
5679 V_I4(&index_var) = 1;
5680 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5681 todo_wine ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5682 if(SUCCEEDED(hres)) {
5683 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5684 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5686 VariantClear(&result_var);
5688 /* fail on third frame */
5689 V_I4(&index_var) = 2;
5690 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5691 todo_wine ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
5692 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
5693 VariantClear(&result_var);
5695 /* string argument (element id lookup) */
5696 V_VT(&index_var) = VT_BSTR;
5697 V_BSTR(&index_var) = a2bstr("fr2");
5698 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5699 todo_wine ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
5700 if(SUCCEEDED(hres)) {
5701 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x", V_VT(&result_var));
5702 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
5704 VariantClear(&result_var);
5705 VariantClear(&index_var);
5707 /* invalid argument */
5708 V_VT(&index_var) = VT_BOOL;
5709 V_BOOL(&index_var) = VARIANT_TRUE;
5710 hres = IHTMLWindow2_item(window, &index_var, &result_var);
5711 todo_wine ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
5712 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
5713 VariantClear(&result_var);
5716 static IHTMLDocument2 *notif_doc;
5717 static BOOL doc_complete;
5719 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
5720 REFIID riid, void**ppv)
5722 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5727 ok(0, "unexpected call\n");
5728 return E_NOINTERFACE;
5731 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
5736 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
5741 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
5743 if(dispID == DISPID_READYSTATE){
5747 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
5748 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
5750 if(!strcmp_wa(state, "complete"))
5751 doc_complete = TRUE;
5753 SysFreeString(state);
5759 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
5761 ok(0, "unexpected call\n");
5765 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
5766 PropertyNotifySink_QueryInterface,
5767 PropertyNotifySink_AddRef,
5768 PropertyNotifySink_Release,
5769 PropertyNotifySink_OnChanged,
5770 PropertyNotifySink_OnRequestEdit
5773 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
5775 static IHTMLDocument2 *create_doc_with_string(const char *str)
5777 IPersistStreamInit *init;
5779 IHTMLDocument2 *doc;
5783 notif_doc = doc = create_document();
5787 doc_complete = FALSE;
5789 mem = GlobalAlloc(0, len);
5790 memcpy(mem, str, len);
5791 CreateStreamOnHGlobal(mem, TRUE, &stream);
5793 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5795 IPersistStreamInit_Load(init, stream);
5796 IPersistStreamInit_Release(init);
5797 IStream_Release(stream);
5802 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
5804 IConnectionPointContainer *container;
5805 IConnectionPoint *cp;
5809 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
5810 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
5812 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5813 IConnectionPointContainer_Release(container);
5814 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
5816 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
5817 IConnectionPoint_Release(cp);
5818 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5821 typedef void (*domtest_t)(IHTMLDocument2*);
5823 static void run_domtest(const char *str, domtest_t test)
5825 IHTMLDocument2 *doc;
5826 IHTMLElement *body = NULL;
5831 doc = create_doc_with_string(str);
5835 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
5837 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
5838 TranslateMessage(&msg);
5839 DispatchMessage(&msg);
5842 hres = IHTMLDocument2_get_body(doc, &body);
5843 ok(hres == S_OK, "get_body failed: %08x\n", hres);
5846 IHTMLElement_Release(body);
5849 skip("Could not get document body. Assuming no Gecko installed.\n");
5852 ref = IHTMLDocument2_Release(doc);
5854 ref == 1, /* Vista */
5858 static void gecko_installer_workaround(BOOL disable)
5863 static BOOL has_url = FALSE;
5864 static char url[2048];
5866 if(!disable && !has_url)
5869 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
5870 if(res != ERROR_SUCCESS)
5874 DWORD type, size = sizeof(url);
5876 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
5877 if(res == ERROR_SUCCESS && type == REG_SZ)
5880 RegDeleteValue(hkey, "GeckoUrl");
5882 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
5890 gecko_installer_workaround(TRUE);
5893 run_domtest(doc_str1, test_doc_elem);
5894 run_domtest(doc_str1, test_get_set_attr);
5895 run_domtest(range_test_str, test_txtrange);
5896 run_domtest(range_test2_str, test_txtrange2);
5897 if (winetest_interactive || ! is_ie_hardened()) {
5898 run_domtest(elem_test_str, test_elems);
5900 skip("IE running in Enhanced Security Configuration\n");
5902 run_domtest(doc_blank, test_create_elems);
5903 run_domtest(doc_blank, test_defaults);
5904 run_domtest(indent_test_str, test_indent);
5905 run_domtest(cond_comment_str, test_cond_comment);
5906 run_domtest(frameset_str, test_frameset);
5909 gecko_installer_workaround(FALSE);