2 * Copyright 2007-2011 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"
37 static const char doc_blank[] = "<html></html>";
38 static const char doc_str1[] = "<html><body>test</body></html>";
39 static const char range_test_str[] =
40 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
41 static const char range_test2_str[] =
42 "<html><body>abc<hr />123<br /><hr />def</body></html>";
43 static const char elem_test_str[] =
44 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
45 "<body onload=\"Testing()\">text test<!-- a comment -->"
46 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
47 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
48 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
49 "<textarea id=\"X\">text text</textarea>"
50 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
51 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
52 "<test /><object id=\"objid\" vspace=100></object><embed />"
53 "<img id=\"imgid\" name=\"WineImg\"/>"
54 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
55 "<form id=\"frm\"></form>"
57 static const char elem_test2_str[] =
58 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
59 "<body><div id=\"divid\" emptyattr=""></div></body>"
62 static const char indent_test_str[] =
63 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
64 static const char cond_comment_str[] =
65 "<html><head><title>test</title></head><body>"
66 "<!--[if gte IE 4]> <br> <![endif]-->"
68 static const char frameset_str[] =
69 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
70 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
71 "<frame src=\"about:blank\" id=\"fr3\">"
73 static const char emptydiv_str[] =
74 "<html><head><title>emptydiv test</title></head>"
75 "<body><div id=\"divid\"></div></body></html>";
77 static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0};
78 static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0};
79 static WCHAR wordW[] = {'w','o','r','d',0};
113 static const IID * const none_iids[] = {
118 static const IID * const doc_node_iids[] = {
127 &IID_IConnectionPointContainer,
128 &IID_IInternetHostSecurityManager,
134 static const IID * const doc_obj_iids[] = {
141 &IID_IConnectionPointContainer,
148 #define ELEM_IFACES \
150 &IID_IHTMLDOMNode2, \
152 &IID_IHTMLElement2, \
153 &IID_IHTMLElement3, \
154 &IID_IHTMLElement4, \
157 static const IID * const elem_iids[] = {
159 &IID_IConnectionPointContainer,
163 static const IID * const body_iids[] = {
165 &IID_IHTMLTextContainer,
166 &IID_IHTMLBodyElement,
167 &IID_IConnectionPointContainer,
171 static const IID * const anchor_iids[] = {
173 &IID_IHTMLAnchorElement,
174 &IID_IConnectionPointContainer,
178 static const IID * const input_iids[] = {
180 &IID_IHTMLInputElement,
181 &IID_IHTMLInputTextElement,
182 &IID_IConnectionPointContainer,
186 static const IID * const select_iids[] = {
188 &IID_IHTMLSelectElement,
189 &IID_IConnectionPointContainer,
193 static const IID * const textarea_iids[] = {
195 &IID_IHTMLTextAreaElement,
196 &IID_IConnectionPointContainer,
200 static const IID * const option_iids[] = {
202 &IID_IHTMLOptionElement,
203 &IID_IConnectionPointContainer,
207 static const IID * const table_iids[] = {
210 &IID_IConnectionPointContainer,
214 static const IID * const script_iids[] = {
216 &IID_IHTMLScriptElement,
217 &IID_IConnectionPointContainer,
221 static const IID * const text_iids[] = {
224 &IID_IHTMLDOMTextNode,
228 static const IID * const attr_iids[] = {
229 &IID_IHTMLDOMAttribute,
234 static const IID * const location_iids[] = {
240 static const IID * const window_iids[] = {
245 &IID_IServiceProvider,
249 static const IID * const comment_iids[] = {
251 &IID_IHTMLCommentElement,
252 &IID_IConnectionPointContainer,
256 static const IID * const img_iids[] = {
258 &IID_IHTMLImgElement,
259 &IID_IConnectionPointContainer,
263 static const IID * const tr_iids[] = {
266 &IID_IConnectionPointContainer,
270 static const IID * const td_iids[] = {
272 &IID_IConnectionPointContainer,
276 static const IID * const frame_iids[] = {
279 &IID_IHTMLFrameBase2,
280 &IID_IConnectionPointContainer,
284 static const IID * const object_iids[] = {
286 &IID_IHTMLObjectElement,
287 /* FIXME: No IConnectionPointContainer */
291 static const IID * const embed_iids[] = {
293 &IID_IHTMLEmbedElement,
294 /* FIXME: No IConnectionPointContainer */
298 static const IID * const iframe_iids[] = {
301 &IID_IHTMLFrameBase2,
302 &IID_IHTMLIFrameElement,
303 &IID_IConnectionPointContainer,
307 static const IID * const form_iids[] = {
309 &IID_IHTMLFormElement,
310 &IID_IConnectionPointContainer,
314 static const IID * const styleelem_iids[] = {
316 &IID_IHTMLStyleElement,
317 &IID_IConnectionPointContainer,
321 static const IID * const generic_iids[] = {
323 &IID_IHTMLGenericElement,
324 &IID_IConnectionPointContainer,
328 static const IID * const style_iids[] = {
339 static const IID * const cstyle_iids[] = {
343 &IID_IHTMLCurrentStyle,
347 static const IID * const img_factory_iids[] = {
351 &IID_IHTMLImageElementFactory,
361 static const elem_type_info_t elem_type_infos[] = {
362 {"", none_iids, NULL},
363 {"HTML", elem_iids, NULL},
364 {"HEAD", elem_iids, NULL},
365 {"TITLE", elem_iids, NULL},
366 {"BODY", body_iids, &DIID_DispHTMLBody},
367 {"A", anchor_iids, &DIID_DispHTMLAnchorElement},
368 {"INPUT", input_iids, &DIID_DispHTMLInputElement},
369 {"SELECT", select_iids, &DIID_DispHTMLSelectElement},
370 {"TEXTAREA", textarea_iids, &DIID_DispHTMLTextAreaElement},
371 {"OPTION", option_iids, &DIID_DispHTMLOptionElement},
372 {"STYLE", styleelem_iids, &DIID_DispHTMLStyleElement},
373 {"BLOCKQUOTE",elem_iids, NULL},
374 {"P", elem_iids, NULL},
375 {"BR", elem_iids, NULL},
376 {"TABLE", table_iids, &DIID_DispHTMLTable},
377 {"TBODY", elem_iids, NULL},
378 {"SCRIPT", script_iids, &DIID_DispHTMLScriptElement},
379 {"TEST", elem_iids, &DIID_DispHTMLUnknownElement},
380 {"TEST", generic_iids, &DIID_DispHTMLGenericElement},
381 {"!", comment_iids, &DIID_DispHTMLCommentElement},
382 {"IMG", img_iids, &DIID_DispHTMLImg},
383 {"TR", tr_iids, &DIID_DispHTMLTableRow},
384 {"TD", td_iids, NULL},
385 {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame},
386 {"FORM", form_iids, &DIID_DispHTMLFormElement},
387 {"FRAME", frame_iids, &DIID_DispHTMLFrameElement},
388 {"OBJECT", object_iids, &DIID_DispHTMLObjectElement},
389 {"EMBED", embed_iids, &DIID_DispHTMLEmbed},
390 {"DIV", elem_iids, NULL}
393 static const char *dbgstr_guid(REFIID riid)
397 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
398 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
399 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
400 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
405 static int strcmp_wa(LPCWSTR strw, const char *stra)
408 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
409 return lstrcmpA(stra, buf);
412 static BSTR a2bstr(const char *str)
420 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
421 ret = SysAllocStringLen(NULL, len);
422 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
427 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
429 IUnknown *unk1, *unk2;
434 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
435 IUnknown_Release(unk1);
436 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
437 IUnknown_Release(unk2);
442 static IHTMLDocument2 *create_document(void)
445 IHTMLDocument5 *doc5;
448 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
449 &IID_IHTMLDocument2, (void**)&doc);
450 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
454 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
456 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
457 IHTMLDocument2_Release(doc);
461 IHTMLDocument5_Release(doc5);
465 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
466 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
468 const IID * const *piid;
472 for(piid = iids; *piid; piid++) {
473 hres = IDispatch_QueryInterface(iface, *piid, (void**)&unk);
474 ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", dbgstr_guid(*piid), hres);
476 IUnknown_Release(unk);
480 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
481 static void _test_no_iface(unsigned line, IUnknown *iface, REFIID iid)
486 unk = (void*)0xdeadbeef;
487 hres = IUnknown_QueryInterface(iface, iid, (void**)&unk);
488 ok_(__FILE__,line)(hres == E_NOINTERFACE, "hres = %08x, expected E_NOINTERFACE\n", hres);
489 ok_(__FILE__,line)(!unk, "unk = %p\n", unk);
492 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
493 static BOOL _test_get_dispid(unsigned line, IUnknown *unk, IID *iid)
501 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
502 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
507 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
508 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
509 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
511 hres = IDispatchEx_GetTypeInfo(dispex, 0, 0, &typeinfo);
512 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfo failed: %08x\n", hres);
514 if(SUCCEEDED(hres)) {
517 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
518 ok_(__FILE__,line) (hres == S_OK, "GetTypeAttr failed: %08x\n", hres);
520 *iid = type_attr->guid;
524 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
525 ITypeInfo_Release(typeinfo);
528 IDispatchEx_Release(dispex);
532 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
533 static void _test_disp_value(unsigned line, IUnknown *unk, const char *val)
535 DISPPARAMS dp = {NULL,NULL,0,0};
541 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
542 ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatchEx interface: %08x\n", hres);
546 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_PROPERTYGET, &dp, &var, &ei, NULL);
547 IDispatchEx_Release(dispex);
548 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres);
550 ok_(__FILE__,line)(V_VT(&var) == VT_BSTR, "V_VT(value) = %d\n", V_VT(&var));
551 ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&var), val), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var)), val);
555 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
556 static void _test_disp(unsigned line, IUnknown *unk, const IID *diid, const char *val)
560 if(_test_get_dispid(line, unk, &iid))
561 ok_(__FILE__,line) (IsEqualGUID(&iid, diid), "unexpected guid %s\n", dbgstr_guid(&iid));
564 _test_disp_value(line, unk, val);
567 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
568 static void _test_disp2(unsigned line, IUnknown *unk, const IID *diid, const IID *diid2, const char *val)
572 if(_test_get_dispid(line, unk, &iid))
573 ok_(__FILE__,line) (IsEqualGUID(&iid, diid) || broken(IsEqualGUID(&iid, diid2)),
574 "unexpected guid %s\n", dbgstr_guid(&iid));
577 _test_disp_value(line, unk, val);
580 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
581 static IHTMLElement *_get_elem_iface(unsigned line, IUnknown *unk)
586 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement, (void**)&elem);
587 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement: %08x\n", hres);
591 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
592 static IHTMLElement2 *_get_elem2_iface(unsigned line, IUnknown *unk)
597 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement2, (void**)&elem);
598 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement2: %08x\n", hres);
602 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
603 static IHTMLElement3 *_get_elem3_iface(unsigned line, IUnknown *unk)
608 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement3, (void**)&elem);
609 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement3: %08x\n", hres);
613 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
614 static IHTMLElement4 *_get_elem4_iface(unsigned line, IUnknown *unk)
619 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElement4, (void**)&elem);
620 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElement4: %08x\n", hres);
624 #define get_node_iface(u) _get_node_iface(__LINE__,u)
625 static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
630 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
631 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
635 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
636 static IHTMLDOMNode2 *_get_node2_iface(unsigned line, IUnknown *unk)
641 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&node);
642 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode2: %08x\n", hres);
646 #define get_img_iface(u) _get_img_iface(__LINE__,u)
647 static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
649 IHTMLImgElement *img;
652 hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
653 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
657 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
658 static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
660 IHTMLAnchorElement *anchor;
663 hres = IUnknown_QueryInterface(unk, &IID_IHTMLAnchorElement, (void**)&anchor);
664 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLAnchorElement: %08x\n", hres);
668 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
669 static IHTMLTextAreaElement *_get_textarea_iface(unsigned line, IUnknown *unk)
671 IHTMLTextAreaElement *textarea;
674 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextAreaElement, (void**)&textarea);
675 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextAreaElement: %08x\n", hres);
679 #define get_select_iface(u) _get_select_iface(__LINE__,u)
680 static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
682 IHTMLSelectElement *select;
685 hres = IUnknown_QueryInterface(unk, &IID_IHTMLSelectElement, (void**)&select);
686 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLSelectElement: %08x\n", hres);
690 #define get_form_iface(u) _get_form_iface(__LINE__,u)
691 static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
693 IHTMLFormElement *form;
696 hres = IUnknown_QueryInterface(unk, &IID_IHTMLFormElement, (void**)&form);
697 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLFormElement: %08x\n", hres);
701 #define get_text_iface(u) _get_text_iface(__LINE__,u)
702 static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
704 IHTMLDOMTextNode *text;
707 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
708 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
712 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
713 static IHTMLCommentElement *_get_comment_iface(unsigned line, IUnknown *unk)
715 IHTMLCommentElement *comment;
718 hres = IUnknown_QueryInterface(unk, &IID_IHTMLCommentElement, (void**)&comment);
719 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLCommentElement: %08x\n", hres);
723 #define get_object_iface(u) _get_object_iface(__LINE__,u)
724 static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
726 IHTMLObjectElement *obj;
729 hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&obj);
730 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLObjectElement: %08x\n", hres);
734 #define get_style_iface(u) _get_style_iface(__LINE__,u)
735 static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
737 IHTMLStyleElement *obj;
740 hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
741 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
745 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
746 static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
748 IHTMLDOMNode *node = _get_node_iface(line, unk);
752 hres = IHTMLDOMNode_get_nodeName(node, &name);
753 IHTMLDOMNode_Release(node);
754 ok_(__FILE__, line) (hres == S_OK, "get_nodeName failed: %08x\n", hres);
755 ok_(__FILE__, line) (!strcmp_wa(name, exname), "got name: %s, expected %s\n", wine_dbgstr_w(name), exname);
760 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
761 static IHTMLDocument2 *_get_owner_doc(unsigned line, IUnknown *unk)
763 IHTMLDOMNode2 *node = _get_node2_iface(line, unk);
764 IDispatch *disp = (void*)0xdeadbeef;
765 IHTMLDocument2 *doc = NULL;
768 hres = IHTMLDOMNode2_get_ownerDocument(node, &disp);
769 IHTMLDOMNode2_Release(node);
770 ok_(__FILE__,line)(hres == S_OK, "get_ownerDocument failed: %08x\n", hres);
773 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
774 IDispatch_Release(disp);
775 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
781 #define get_doc_window(d) _get_doc_window(__LINE__,d)
782 static IHTMLWindow2 *_get_doc_window(unsigned line, IHTMLDocument2 *doc)
784 IHTMLWindow2 *window;
788 hres = IHTMLDocument2_get_parentWindow(doc, &window);
789 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
790 ok_(__FILE__,line)(window != NULL, "window == NULL\n");
795 #define clone_node(n,d) _clone_node(__LINE__,n,d)
796 static IHTMLDOMNode *_clone_node(unsigned line, IUnknown *unk, VARIANT_BOOL deep)
798 IHTMLDOMNode *node = _get_node_iface(line, unk);
799 IHTMLDOMNode *ret = NULL;
802 hres = IHTMLDOMNode_cloneNode(node, deep, &ret);
803 IHTMLDOMNode_Release(node);
804 ok_(__FILE__,line)(hres == S_OK, "cloneNode failed: %08x\n", hres);
805 ok_(__FILE__,line)(ret != NULL, "ret == NULL\n");
811 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
812 static void _test_elem_tag(unsigned line, IUnknown *unk, const char *extag)
814 IHTMLElement *elem = _get_elem_iface(line, unk);
818 hres = IHTMLElement_get_tagName(elem, &tag);
819 IHTMLElement_Release(elem);
820 ok_(__FILE__, line) (hres == S_OK, "get_tagName failed: %08x\n", hres);
821 ok_(__FILE__, line) (!strcmp_wa(tag, extag), "got tag: %s, expected %s\n", wine_dbgstr_w(tag), extag);
826 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
827 static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
829 _test_elem_tag(line, unk, elem_type_infos[type].tag);
830 _test_ifaces(line, unk, elem_type_infos[type].iids);
832 if(elem_type_infos[type].dispiid && type != ET_A)
833 _test_disp(line, unk, elem_type_infos[type].dispiid, "[object]");
836 #define get_node_type(n) _get_node_type(__LINE__,n)
837 static LONG _get_node_type(unsigned line, IUnknown *unk)
839 IHTMLDOMNode *node = _get_node_iface(line, unk);
843 hres = IHTMLDOMNode_get_nodeType(node, &type);
844 ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
846 IHTMLDOMNode_Release(node);
851 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
852 static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk)
854 IHTMLDOMNode *node = _get_node_iface(line, unk);
855 IHTMLDOMChildrenCollection *col = NULL;
859 hres = IHTMLDOMNode_get_childNodes(node, &disp);
860 IHTMLDOMNode_Release(node);
861 ok_(__FILE__,line) (hres == S_OK, "get_childNodes failed: %08x\n", hres);
865 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDOMChildrenCollection, (void**)&col);
866 IDispatch_Release(disp);
867 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres);
872 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
873 static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, LONG idx)
875 IHTMLDOMNode *node = NULL;
879 hres = IHTMLDOMChildrenCollection_item(col, idx, &disp);
880 ok(hres == S_OK, "item failed: %08x\n", hres);
882 node = _get_node_iface(line, (IUnknown*)disp);
883 IDispatch_Release(disp);
888 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
889 static void _test_elem_attr(unsigned line, IHTMLElement *elem, const char *name, const char *exval)
898 hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
900 ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
903 ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
904 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&value), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value)));
906 ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
909 VariantClear(&value);
912 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
913 static void _test_elem_offset(unsigned line, IUnknown *unk)
915 IHTMLElement *elem = _get_elem_iface(line, unk);
919 hres = IHTMLElement_get_offsetTop(elem, &l);
920 ok_(__FILE__,line) (hres == S_OK, "get_offsetTop failed: %08x\n", hres);
922 hres = IHTMLElement_get_offsetHeight(elem, &l);
923 ok_(__FILE__,line) (hres == S_OK, "get_offsetHeight failed: %08x\n", hres);
925 hres = IHTMLElement_get_offsetWidth(elem, &l);
926 ok_(__FILE__,line) (hres == S_OK, "get_offsetWidth failed: %08x\n", hres);
928 IHTMLElement_Release(elem);
931 #define get_doc_node(d) _get_doc_node(__LINE__,d)
932 static IHTMLDocument2 *_get_doc_node(unsigned line, IHTMLDocument2 *doc)
934 IHTMLWindow2 *window;
938 hres = IHTMLDocument2_get_parentWindow(doc, &window);
939 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
941 hres = IHTMLWindow2_get_document(window, &ret);
942 ok_(__FILE__,line)(hres == S_OK, "get_document failed: %08x\n", hres);
943 ok_(__FILE__,line)(ret != NULL, "document = NULL\n");
948 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
949 static void _test_window_name(unsigned line, IHTMLWindow2 *window, const char *exname)
954 hres = IHTMLWindow2_get_name(window, &name);
955 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
957 ok_(__FILE__,line)(!strcmp_wa(name, exname), "name = %s\n", wine_dbgstr_w(name));
959 ok_(__FILE__,line)(!name, "name = %s\n", wine_dbgstr_w(name));
963 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
964 static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *name)
970 hres = IHTMLWindow2_put_name(window, str);
972 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
974 _test_window_name(line, window, name);
977 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
978 static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen)
983 hres = IHTMLWindow2_get_length(window, &length);
984 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
985 ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen);
988 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
989 static IHTMLWindow2 *_get_frame_content_window(unsigned line, IUnknown *elem)
991 IHTMLFrameBase2 *base2;
992 IHTMLWindow2 *window;
995 hres = IUnknown_QueryInterface(elem, &IID_IHTMLFrameBase2, (void**)&base2);
996 ok(hres == S_OK, "Could not get IHTMFrameBase2 iface: %08x\n", hres);
999 hres = IHTMLFrameBase2_get_contentWindow(base2, &window);
1000 IHTMLFrameBase2_Release(base2);
1001 ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres);
1002 ok(window != NULL, "contentWindow = NULL\n");
1007 static void test_get_set_attr(IHTMLDocument2 *doc)
1010 IHTMLDocument3 *doc3;
1015 /* grab an element to test with */
1016 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1017 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
1019 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1020 IHTMLDocument3_Release(doc3);
1021 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
1023 /* get a non-present attribute */
1024 bstr = a2bstr("notAnAttribute");
1025 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1026 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1027 ok(V_VT(&val) == VT_NULL, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL, V_VT(&val));
1029 SysFreeString(bstr);
1031 /* get a present attribute */
1032 bstr = a2bstr("scrollHeight");
1033 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1034 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1035 ok(V_VT(&val) == VT_I4, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4, V_VT(&val));
1037 SysFreeString(bstr);
1039 /* create a new BSTR attribute */
1040 bstr = a2bstr("newAttribute");
1042 V_VT(&val) = VT_BSTR;
1043 V_BSTR(&val) = a2bstr("the value");
1044 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1045 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1048 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1049 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1050 ok(V_VT(&val) == VT_BSTR, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR, V_VT(&val));
1051 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)));
1054 /* overwrite the attribute with a BOOL */
1055 V_VT(&val) = VT_BOOL;
1056 V_BOOL(&val) = VARIANT_TRUE;
1057 hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
1058 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
1061 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1062 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1063 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1064 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1067 SysFreeString(bstr);
1069 /* case-insensitive */
1070 bstr = a2bstr("newattribute");
1071 hres = IHTMLElement_getAttribute(elem, bstr, 0, &val);
1072 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
1073 ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
1074 ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
1076 SysFreeString(bstr);
1078 IHTMLElement_Release(elem);
1081 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1082 static IHTMLElement *_get_doc_elem(unsigned line, IHTMLDocument2 *doc)
1085 IHTMLDocument3 *doc3;
1088 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1089 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3 interface: %08x\n", hres);
1090 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
1091 ok_(__FILE__,line) (hres == S_OK, "get_documentElement failed: %08x\n", hres);
1092 IHTMLDocument3_Release(doc3);
1097 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1098 static void _test_anchor_href(unsigned line, IUnknown *unk, const char *exhref)
1100 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1104 hres = IHTMLAnchorElement_get_href(anchor, &str);
1105 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1106 ok_(__FILE__,line)(!strcmp_wa(str, exhref), "href = %s, expected %s\n", wine_dbgstr_w(str), exhref);
1109 _test_disp_value(line, unk, exhref);
1112 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1113 static void _test_anchor_put_href(unsigned line, IUnknown *unk, const char *exhref)
1115 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1119 str = a2bstr(exhref);
1120 hres = IHTMLAnchorElement_put_href(anchor, str);
1121 ok_(__FILE__,line)(hres == S_OK, "get_href failed: %08x\n", hres);
1124 _test_disp_value(line, unk, exhref);
1127 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1128 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1133 hres = IHTMLOptionElement_get_text(option, &bstr);
1134 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1135 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1136 SysFreeString(bstr);
1139 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1140 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1145 bstr = a2bstr(text);
1146 hres = IHTMLOptionElement_put_text(option, bstr);
1147 SysFreeString(bstr);
1148 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1150 _test_option_text(line, option, text);
1153 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1154 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1159 hres = IHTMLOptionElement_get_value(option, &bstr);
1160 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1161 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1162 SysFreeString(bstr);
1165 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1166 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1171 bstr = a2bstr(value);
1172 hres = IHTMLOptionElement_put_value(option, bstr);
1173 SysFreeString(bstr);
1174 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1176 _test_option_value(line, option, value);
1179 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1180 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1182 VARIANT_BOOL b = 0x100;
1185 hres = IHTMLOptionElement_get_selected(option, &b);
1186 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1187 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1190 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1191 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1195 hres = IHTMLOptionElement_put_selected(option, b);
1196 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1197 _test_option_selected(line, option, b);
1200 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1201 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1203 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1204 BSTR value = (void*)0xdeadbeef;
1207 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1208 IHTMLTextAreaElement_Release(textarea);
1209 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1211 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1213 ok_(__FILE__,line)(!value, "value = %p\n", value);
1214 SysFreeString(value);
1217 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1218 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1220 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1221 BSTR tmp = a2bstr(value);
1224 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1225 IHTMLTextAreaElement_Release(textarea);
1226 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1229 _test_textarea_value(line, unk, value);
1232 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1233 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1235 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1236 VARIANT_BOOL b = 0x100;
1239 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1240 IHTMLTextAreaElement_Release(textarea);
1241 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1242 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1245 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1246 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1248 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1251 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1252 IHTMLTextAreaElement_Release(textarea);
1253 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1255 _test_textarea_readonly(line, unk, b);
1258 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1259 static void _test_textarea_type(unsigned line, IUnknown *unk)
1261 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1262 BSTR type = (void*)0xdeadbeef;
1265 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1266 IHTMLTextAreaElement_Release(textarea);
1267 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1268 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1269 SysFreeString(type);
1272 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1273 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1275 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1279 text = a2bstr(extext);
1280 hres = IHTMLCommentElement_get_text(comment, &text);
1281 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1282 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1284 IHTMLCommentElement_Release(comment);
1285 SysFreeString(text);
1288 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1289 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1291 IHTMLObjectElement *object = _get_object_iface(line, unk);
1296 hres = IHTMLObjectElement_get_vspace(object, &l);
1297 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1298 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1299 IHTMLObjectElement_Release(object);
1302 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1303 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1304 const char *txt, const char *val)
1306 IHTMLOptionElementFactory *factory;
1307 IHTMLOptionElement *option;
1308 IHTMLWindow2 *window;
1309 VARIANT text, value, empty;
1312 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1313 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1315 hres = IHTMLWindow2_get_Option(window, &factory);
1316 IHTMLWindow2_Release(window);
1317 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1319 V_VT(&text) = VT_BSTR;
1320 V_BSTR(&text) = a2bstr(txt);
1321 V_VT(&value) = VT_BSTR;
1322 V_BSTR(&value) = a2bstr(val);
1323 V_VT(&empty) = VT_EMPTY;
1325 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1326 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1328 IHTMLOptionElementFactory_Release(factory);
1329 VariantClear(&text);
1330 VariantClear(&value);
1332 _test_option_text(line, option, txt);
1333 _test_option_value(line, option, val);
1334 _test_option_selected(line, option, VARIANT_FALSE);
1339 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1340 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1345 hres = IHTMLImgElement_get_width(img, &found);
1346 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1347 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1350 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1351 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1355 hres = IHTMLImgElement_put_width(img, width);
1356 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1358 _test_img_width(line, img, width);
1361 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1362 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1367 hres = IHTMLImgElement_get_height(img, &found);
1368 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1369 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1372 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1373 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1377 hres = IHTMLImgElement_put_height(img, height);
1378 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1380 _test_img_height(line, img, height);
1383 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1384 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1385 LONG wdth, LONG hght)
1387 IHTMLImageElementFactory *factory;
1388 IHTMLImgElement *img;
1389 IHTMLWindow2 *window;
1390 VARIANT width, height;
1394 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1395 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1397 hres = IHTMLWindow2_get_Image(window, &factory);
1398 IHTMLWindow2_Release(window);
1399 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1401 test_ifaces((IUnknown*)factory, img_factory_iids);
1402 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1405 snprintf(buf, 16, "%d", wdth);
1406 V_VT(&width) = VT_BSTR;
1407 V_BSTR(&width) = a2bstr(buf);
1409 V_VT(&width) = VT_EMPTY;
1414 snprintf(buf, 16, "%d", hght);
1415 V_VT(&height) = VT_BSTR;
1416 V_BSTR(&height) = a2bstr(buf);
1418 V_VT(&height) = VT_EMPTY;
1422 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1423 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1425 IHTMLImageElementFactory_Release(factory);
1426 VariantClear(&width);
1427 VariantClear(&height);
1429 if(SUCCEEDED(hres)) {
1430 _test_img_width(line, img, wdth);
1431 _test_img_height(line, img, hght);
1438 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1439 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1441 LONG len = 0xdeadbeef;
1444 hres = IHTMLSelectElement_get_length(select, &len);
1445 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1446 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1449 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1450 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1452 IHTMLSelectElement *select = _get_select_iface(line, unk);
1455 hres = IHTMLSelectElement_put_length(select, length);
1456 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1457 _test_select_length(line, select, length);
1458 IHTMLSelectElement_Release(select);
1461 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1462 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1464 LONG idx = 0xdeadbeef;
1467 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1468 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1469 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1472 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1473 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1477 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1478 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1479 _test_select_selidx(line, select, index);
1482 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1483 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1488 hres = IHTMLSelectElement_get_value(select, &val);
1489 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1491 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1493 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1497 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1498 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1504 hres = IHTMLSelectElement_put_value(select, bstr);
1505 SysFreeString(bstr);
1506 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1509 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1510 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1515 hres = IHTMLSelectElement_get_type(select, &type);
1516 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1517 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1518 SysFreeString(type);
1521 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1522 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1527 hres = IHTMLTxtRange_get_text(range, &text);
1528 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1531 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1532 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1534 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1537 SysFreeString(text);
1541 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1542 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1546 hres = IHTMLTxtRange_collapse(range, b);
1547 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1548 _test_range_text(line, range, NULL);
1551 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1552 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1553 VARIANT_BOOL exb, const char *extext)
1555 VARIANT_BOOL b = 0xe0e0;
1558 hres = IHTMLTxtRange_expand(range, unit, &b);
1559 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1560 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1561 _test_range_text(line, range, extext);
1564 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1565 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1567 LONG c = 0xdeadbeef;
1570 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1571 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1572 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1573 _test_range_text(line, range, NULL);
1576 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1577 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1578 LPWSTR unit, LONG cnt, LONG excnt)
1580 LONG c = 0xdeadbeef;
1583 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1584 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1585 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1588 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1589 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1591 LONG c = 0xdeadbeef;
1594 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1595 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1596 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1599 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1600 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1603 BSTR bstr = a2bstr(text);
1605 hres = IHTMLTxtRange_put_text(range, bstr);
1606 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1607 SysFreeString(bstr);
1608 _test_range_text(line, range, NULL);
1611 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1612 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1618 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1619 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1620 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1623 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1624 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1630 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1631 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1632 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1635 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1636 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1637 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1640 test_range_inrange(range1, range2, VARIANT_TRUE);
1641 test_range_inrange(range2, range1, VARIANT_TRUE);
1645 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1646 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1651 hres = IHTMLTxtRange_parentElement(range, &elem);
1652 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1654 _test_elem_type(line, (IUnknown*)elem, type);
1656 IHTMLElement_Release(elem);
1659 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1660 static void _test_elem_collection(unsigned line, IUnknown *unk,
1661 const elem_type_t *elem_types, LONG exlen)
1663 IHTMLElementCollection *col;
1666 VARIANT name, index;
1667 IDispatch *disp, *disp2;
1670 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1671 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1673 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1675 hres = IHTMLElementCollection_get_length(col, &len);
1676 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1677 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1682 V_VT(&index) = VT_EMPTY;
1684 for(i=0; i<len; i++) {
1685 V_VT(&name) = VT_I4;
1687 disp = (void*)0xdeadbeef;
1688 hres = IHTMLElementCollection_item(col, name, index, &disp);
1689 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1690 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1691 if(FAILED(hres) || !disp)
1694 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1697 V_VT(&name) = VT_UINT;
1699 disp2 = (void*)0xdeadbeef;
1700 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1701 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1702 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1704 IDispatch_Release(disp2);
1707 IDispatch_Release(disp);
1710 V_VT(&name) = VT_I4;
1712 disp = (void*)0xdeadbeef;
1713 hres = IHTMLElementCollection_item(col, name, index, &disp);
1714 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1715 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1717 V_VT(&name) = VT_I4;
1719 disp = (void*)0xdeadbeef;
1720 hres = IHTMLElementCollection_item(col, name, index, &disp);
1721 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1722 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1724 IHTMLElementCollection_Release(col);
1727 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1728 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1730 IHTMLElement *elem = _get_elem_iface(line, unk);
1734 hres = IHTMLElement_get_all(elem, &disp);
1735 IHTMLElement_Release(elem);
1736 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1738 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1739 IDispatch_Release(disp);
1742 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1743 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1745 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1746 IHTMLElementCollection *col = NULL;
1747 elem_type_t *types = NULL;
1752 tmp = a2bstr(elem_type_infos[type].tag);
1753 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1755 IHTMLElement2_Release(elem);
1756 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1757 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1760 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1761 for(i=0; i<exlen; i++)
1765 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1767 HeapFree(GetProcessHeap(), 0, types);
1770 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1771 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1776 hres = IHTMLElement_get_innerText(elem, &text);
1777 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1778 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1779 wine_dbgstr_w(text), extext);
1780 SysFreeString(text);
1783 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1784 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1786 IHTMLDOMChildrenCollection *col;
1791 hres = IHTMLElement_put_innerText(elem, str);
1792 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1795 _test_elem_innertext(line, elem, text);
1798 col = _get_child_nodes(line, (IUnknown*)elem);
1799 ok(col != NULL, "col == NULL\n");
1801 LONG length = 0, type;
1804 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1805 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1806 ok(length == 1, "length = %d\n", length);
1808 node = _get_child_item(line, col, 0);
1809 ok(node != NULL, "node == NULL\n");
1811 type = _get_node_type(line, (IUnknown*)node);
1812 ok(type == 3, "type=%d\n", type);
1813 IHTMLDOMNode_Release(node);
1816 IHTMLDOMChildrenCollection_Release(col);
1821 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1822 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1824 IHTMLElement *elem = _get_elem_iface(line, unk);
1828 hres = IHTMLElement_get_innerHTML(elem, &html);
1829 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1831 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1833 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1835 IHTMLElement_Release(elem);
1836 SysFreeString(html);
1839 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1840 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1842 IHTMLElement *elem = _get_elem_iface(line, unk);
1846 html = a2bstr(inner_html);
1847 hres = IHTMLElement_put_innerHTML(elem, html);
1848 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1850 IHTMLElement_Release(elem);
1851 SysFreeString(html);
1854 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1855 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1857 IHTMLElement *elem = _get_elem_iface(line, unk);
1861 html = a2bstr(outer_html);
1862 hres = IHTMLElement_put_outerHTML(elem, html);
1863 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1865 IHTMLElement_Release(elem);
1866 SysFreeString(html);
1869 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1870 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1872 IHTMLElement *elem = _get_elem_iface(line, unk);
1876 hres = IHTMLElement_get_outerHTML(elem, &html);
1877 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1878 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1880 IHTMLElement_Release(elem);
1881 SysFreeString(html);
1884 #define get_first_child(n) _get_first_child(__LINE__,n)
1885 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1887 IHTMLDOMNode *node = _get_node_iface(line, unk);
1888 IHTMLDOMNode *child = NULL;
1891 hres = IHTMLDOMNode_get_firstChild(node, &child);
1892 IHTMLDOMNode_Release(node);
1893 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1898 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1899 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1901 IHTMLDOMNode *node = _get_node_iface(line, unk);
1902 VARIANT_BOOL b = 0xdead;
1905 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1906 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1907 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1909 IHTMLDOMNode_Release(node);
1912 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1913 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1915 IHTMLDOMNode *node = _get_node_iface(line, unk);
1916 IHTMLDOMNode *parent;
1919 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1920 IHTMLDOMNode_Release(node);
1921 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1926 #define node_get_next(u) _node_get_next(__LINE__,u)
1927 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1929 IHTMLDOMNode *node = _get_node_iface(line, unk);
1933 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1934 IHTMLDOMNode_Release(node);
1935 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1940 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1941 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1943 IHTMLElement *elem = _get_elem_iface(line, unk);
1944 IHTMLElement *parent;
1947 hres = IHTMLElement_get_parentElement(elem, &parent);
1948 IHTMLElement_Release(elem);
1949 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1954 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1955 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1957 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1958 VARIANT_BOOL disabled = 100;
1962 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1963 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1964 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1965 IHTMLElement3_Release(elem3);
1968 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1969 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1971 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1975 hres = IHTMLElement3_put_disabled(elem3, b);
1976 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1978 IHTMLElement3_Release(elem3);
1979 _test_elem3_get_disabled(line, unk, b);
1982 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1983 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
1985 VARIANT_BOOL disabled = 100;
1988 hres = IHTMLSelectElement_get_disabled(select, &disabled);
1989 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1990 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1992 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
1995 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
1996 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
1998 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2002 hres = IHTMLDOMTextNode_get_length(text, &length);
2003 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2004 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2005 IHTMLDOMTextNode_Release(text);
2008 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2009 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2013 hres = IHTMLSelectElement_put_disabled(select, b);
2014 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2016 _test_select_get_disabled(line, select, b);
2019 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2020 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2022 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2023 IHTMLTextContainer *txtcont;
2024 LONG l = -1, l2 = -1;
2027 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2028 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2029 IHTMLElement2_Release(elem);
2031 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2032 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2034 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2035 IHTMLTextContainer_Release(txtcont);
2036 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2037 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2042 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2043 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2045 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2046 IHTMLTextContainer *txtcont;
2047 LONG l = -1, l2 = -1;
2050 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2051 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2052 IHTMLElement2_Release(elem);
2054 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2055 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2057 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2058 IHTMLTextContainer_Release(txtcont);
2059 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2060 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2065 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2066 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2068 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2069 IHTMLTextContainer *txtcont;
2070 LONG l = -1, l2 = -1;
2073 hres = IHTMLElement2_get_scrollTop(elem, &l);
2074 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2075 IHTMLElement2_Release(elem);
2077 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2078 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2080 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2081 IHTMLTextContainer_Release(txtcont);
2082 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2083 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2088 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2089 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2091 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2092 IHTMLTextContainer *txtcont;
2093 LONG l = -1, l2 = -1;
2096 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2097 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2099 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2100 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2101 IHTMLElement2_Release(elem);
2103 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2104 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2106 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2107 IHTMLTextContainer_Release(txtcont);
2108 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2109 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2112 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2113 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2115 IHTMLImgElement *img = _get_img_iface(line, unk);
2119 hres = IHTMLImgElement_get_src(img, &src);
2120 IHTMLImgElement_Release(img);
2121 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2122 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2126 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2127 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2129 IHTMLImgElement *img = _get_img_iface(line, unk);
2134 hres = IHTMLImgElement_put_src(img, tmp);
2135 IHTMLImgElement_Release(img);
2137 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2139 _test_img_src(line, unk, src);
2142 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2143 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2145 IHTMLImgElement *img = _get_img_iface(line, unk);
2149 hres = IHTMLImgElement_get_alt(img, &alt);
2150 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2152 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2154 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2158 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2159 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2161 IHTMLImgElement *img = _get_img_iface(line, unk);
2166 hres = IHTMLImgElement_put_alt(img, tmp);
2167 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2170 _test_img_alt(line, unk, alt);
2173 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2174 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2176 IHTMLImgElement *img = _get_img_iface(line, unk);
2180 hres = IHTMLImgElement_get_name(img, &sName);
2181 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2182 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2183 IHTMLImgElement_Release(img);
2184 SysFreeString(sName);
2187 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2188 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2193 hres = IHTMLInputElement_get_type(input, &type);
2194 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2195 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2196 SysFreeString(type);
2199 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2200 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2202 BSTR name = (BSTR)0xdeadbeef;
2205 hres = IHTMLInputElement_get_name(input, &name);
2206 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2208 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2210 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2211 SysFreeString(name);
2214 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2215 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2217 BSTR tmp = a2bstr(name);
2220 hres = IHTMLInputElement_put_name(input, tmp);
2221 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2224 _test_input_name(line, input, name);
2227 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2228 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2230 VARIANT_BOOL disabled = 100;
2233 hres = IHTMLInputElement_get_disabled(input, &disabled);
2234 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2235 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2237 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2240 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2241 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2245 hres = IHTMLInputElement_put_disabled(input, b);
2246 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2248 _test_input_get_disabled(line, input, b);
2251 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2252 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2254 VARIANT_BOOL checked = 100;
2257 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2258 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2259 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2262 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2263 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2267 hres = IHTMLInputElement_put_defaultChecked(input, b);
2268 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2270 _test_input_get_defaultchecked(line, input, b);
2273 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2274 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2276 VARIANT_BOOL checked = 100;
2279 hres = IHTMLInputElement_get_checked(input, &checked);
2280 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2281 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2284 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2285 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2289 hres = IHTMLInputElement_put_checked(input, b);
2290 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2292 _test_input_get_checked(line, input, b);
2295 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2296 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2298 IHTMLInputElement *input;
2302 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2303 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2307 hres = IHTMLInputElement_get_value(input, &bstr);
2308 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2310 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2312 ok_(__FILE__,line) (!bstr, "exval != NULL\n");
2313 SysFreeString(bstr);
2314 IHTMLInputElement_Release(input);
2317 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2318 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2320 IHTMLInputElement *input;
2324 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2325 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2330 hres = IHTMLInputElement_put_value(input, bstr);
2331 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2332 SysFreeString(bstr);
2333 IHTMLInputElement_Release(input);
2335 _test_input_value(line, unk, val);
2338 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2339 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2344 hres = IHTMLInputElement_get_src(input, &src);
2345 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2347 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2349 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2353 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2354 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2360 hres = IHTMLInputElement_put_src(input, tmp);
2362 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2364 _test_input_src(line, input, src);
2367 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2368 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2370 IHTMLElement *elem = _get_elem_iface(line, unk);
2371 BSTR class = (void*)0xdeadbeef;
2374 hres = IHTMLElement_get_className(elem, &class);
2375 IHTMLElement_Release(elem);
2376 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2378 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2380 ok_(__FILE__,line) (!class, "class != NULL\n");
2381 SysFreeString(class);
2384 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2385 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2387 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2391 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2392 IHTMLElement2_Release(elem2);
2393 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2394 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2397 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2398 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2400 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2403 hres = IHTMLElement2_put_tabIndex(elem2, index);
2404 IHTMLElement2_Release(elem2);
2405 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2407 _test_elem_tabindex(line, unk, index);
2410 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2411 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2413 IHTMLStyleElement *style = _get_style_iface(line, unk);
2417 hres = IHTMLStyleElement_get_media(style, &media);
2418 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2420 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2422 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2424 IHTMLStyleElement_Release(style);
2425 SysFreeString(media);
2428 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2429 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2431 IHTMLStyleElement *style = _get_style_iface(line, unk);
2435 str = a2bstr(media);
2436 hres = IHTMLStyleElement_put_media(style, str);
2437 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2438 IHTMLStyleElement_Release(style);
2441 _test_style_media(line, unk, media);
2444 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2445 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2447 IHTMLStyleElement *style = _get_style_iface(line, unk);
2451 hres = IHTMLStyleElement_get_type(style, &type);
2452 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2454 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2456 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2458 IHTMLStyleElement_Release(style);
2459 SysFreeString(type);
2462 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2463 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2465 IHTMLStyleElement *style = _get_style_iface(line, unk);
2470 hres = IHTMLStyleElement_put_type(style, str);
2471 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2472 IHTMLStyleElement_Release(style);
2475 _test_style_type(line, unk, type);
2478 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2479 static void _test_elem_filters(unsigned line, IUnknown *unk)
2481 IHTMLElement *elem = _get_elem_iface(line, unk);
2483 IHTMLFiltersCollection *filters;
2485 hres = IHTMLElement_get_filters(elem, &filters);
2486 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2487 "get_filters failed: %08x\n", hres);
2491 IDispatchEx *dispex;
2493 hres = IHTMLFiltersCollection_get_length(filters, &len);
2494 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2495 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2497 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2498 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2499 "Could not get IDispatchEx interface: %08x\n", hres);
2500 if(SUCCEEDED(hres)) {
2501 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2502 IDispatchEx_Release(dispex);
2505 IHTMLFiltersCollection_Release(filters);
2508 IHTMLElement_Release(elem);
2511 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2512 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2514 IHTMLElement *elem = _get_elem_iface(line, unk);
2518 tmp = class ? a2bstr(class) : NULL;
2519 hres = IHTMLElement_put_className(elem, tmp);
2520 IHTMLElement_Release(elem);
2521 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2524 _test_elem_class(line, unk, class);
2527 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2528 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2530 IHTMLElement *elem = _get_elem_iface(line, unk);
2531 BSTR id = (void*)0xdeadbeef;
2534 hres = IHTMLElement_get_id(elem, &id);
2535 IHTMLElement_Release(elem);
2536 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2539 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2541 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2546 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2547 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2549 IHTMLElement *elem = _get_elem_iface(line, unk);
2550 BSTR tmp = a2bstr(new_id);
2553 hres = IHTMLElement_put_id(elem, tmp);
2554 IHTMLElement_Release(elem);
2556 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2558 _test_elem_id(line, unk, new_id);
2561 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2562 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2564 IHTMLElement *elem = _get_elem_iface(line, unk);
2568 hres = IHTMLElement_get_title(elem, &title);
2569 IHTMLElement_Release(elem);
2570 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2572 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2574 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2576 SysFreeString(title);
2579 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2580 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2582 IHTMLElement *elem = _get_elem_iface(line, unk);
2586 tmp = a2bstr(title);
2587 hres = IHTMLElement_put_title(elem, tmp);
2588 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2590 IHTMLElement_Release(elem);
2594 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2595 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2597 IHTMLDOMNode *node = _get_node_iface(line, unk);
2601 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2602 IHTMLDOMNode_Release(node);
2603 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2606 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2607 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2609 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2615 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2616 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2618 IHTMLDOMNode *node = _get_node_iface(line, unk);
2622 V_VT(&var) = VT_BSTR;
2623 V_BSTR(&var) = a2bstr(val);
2625 hres = IHTMLDOMNode_put_nodeValue(node, var);
2626 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2627 IHTMLDOMNode_Release(node);
2631 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2632 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2634 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2638 hres = IHTMLElement2_get_clientWidth(elem, &l);
2639 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2640 hres = IHTMLElement2_get_clientHeight(elem, &l);
2641 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2643 IHTMLElement2_Release(elem);
2646 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2647 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2649 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2653 hres = IHTMLElement2_get_clientLeft(elem, &l);
2654 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2655 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2657 hres = IHTMLElement2_get_clientTop(elem, &l);
2658 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2659 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2661 IHTMLElement2_Release(elem);
2664 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2665 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2667 IHTMLFormElement *form = _get_form_iface(line, unk);
2668 LONG len = 0xdeadbeef;
2671 hres = IHTMLFormElement_get_length(form, &len);
2672 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2673 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2675 IHTMLFormElement_Release(form);
2678 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2679 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2681 IHTMLFormElement *form = _get_form_iface(line, unk);
2682 BSTR action = (void*)0xdeadbeef;
2685 hres = IHTMLFormElement_get_action(form, &action);
2686 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2688 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2690 ok_(__FILE__,line)(!action, "action=%p\n", action);
2692 SysFreeString(action);
2693 IHTMLFormElement_Release(form);
2696 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2697 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2699 IHTMLFormElement *form = _get_form_iface(line, unk);
2700 BSTR tmp = a2bstr(action);
2703 hres = IHTMLFormElement_put_action(form, tmp);
2704 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2706 IHTMLFormElement_Release(form);
2708 _test_form_action(line, unk, action);
2711 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2712 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2714 IHTMLFormElement *form = _get_form_iface(line, unk);
2715 BSTR method = (void*)0xdeadbeef;
2718 hres = IHTMLFormElement_get_method(form, &method);
2719 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2721 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2723 ok_(__FILE__,line)(!method, "method=%p\n", method);
2725 SysFreeString(method);
2726 IHTMLFormElement_Release(form);
2729 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2730 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2732 IHTMLFormElement *form = _get_form_iface(line, unk);
2733 BSTR tmp = a2bstr(method);
2736 hres = IHTMLFormElement_put_method(form, tmp);
2737 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2739 IHTMLFormElement_Release(form);
2741 if(exp_hres == S_OK)
2742 _test_form_method(line, unk, method);
2745 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2746 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2748 IHTMLFormElement *form = _get_form_iface(line, unk);
2749 BSTR name = (void*)0xdeadbeef;
2752 hres = IHTMLFormElement_get_name(form, &name);
2753 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2755 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2757 ok_(__FILE__,line)(!name, "name=%p\n", name);
2759 SysFreeString(name);
2760 IHTMLFormElement_Release(form);
2763 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2764 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2766 IHTMLFormElement *form = _get_form_iface(line, unk);
2767 BSTR tmp = a2bstr(name);
2770 hres = IHTMLFormElement_put_name(form, tmp);
2771 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2773 IHTMLFormElement_Release(form);
2775 _test_form_name(line, unk, name);
2778 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2779 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2781 IHTMLFormElement *form = _get_form_iface(line, unk);
2782 BSTR encoding = (void*)0xdeadbeef;
2785 hres = IHTMLFormElement_get_encoding(form, &encoding);
2786 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2788 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2790 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2792 SysFreeString(encoding);
2793 IHTMLFormElement_Release(form);
2796 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2797 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2799 IHTMLFormElement *form = _get_form_iface(line, unk);
2800 BSTR tmp = a2bstr(encoding);
2803 hres = IHTMLFormElement_put_encoding(form, tmp);
2804 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2806 IHTMLFormElement_Release(form);
2808 if(exp_hres == S_OK)
2809 _test_form_encoding(line, unk, encoding);
2812 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2813 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2815 IHTMLElement *elem = _get_elem_iface(line, unk);
2816 IHTMLDocument2 *doc;
2821 hres = IHTMLElement_get_document(elem, &disp);
2822 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2823 ok(disp != NULL, "disp == NULL\n");
2825 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2826 IDispatch_Release(disp);
2827 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2832 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
2833 static IHTMLDOMAttribute *_get_elem_attr_node(unsigned line, IUnknown *unk, const char *attr_name, BOOL expect_success)
2835 IHTMLElement4 *elem = _get_elem4_iface(line, unk);
2836 BSTR str = a2bstr(attr_name);
2837 IHTMLDOMAttribute *attr;
2840 attr = (void*)0xdeadbeef;
2841 hres = IHTMLElement4_getAttributeNode(elem, str, &attr);
2842 ok_(__FILE__,line)(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
2844 ok_(__FILE__,line)(attr != NULL, "attr = NULL\n");
2846 ok_(__FILE__,line)(!attr, "attr = %p\n", attr);
2848 IHTMLElement4_Release(elem);
2853 #define test_attr_node_value(a,b) _test_attr_node_value(__LINE__,a,b)
2854 static void _test_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, const char *exval)
2859 hres = IHTMLDOMAttribute_get_nodeValue(attr, &var);
2860 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2861 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2863 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2865 ok_(__FILE__,line) (!V_BSTR(&var), "nodeValue = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&var)));
2870 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2871 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2873 IHTMLDocument2 *doc;
2877 hres = IHTMLWindow2_get_document(window, &doc);
2878 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2879 ok(doc != NULL, "disp == NULL\n");
2884 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2885 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
2890 hres = IHTMLDocument2_get_body(doc, &elem);
2891 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2892 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
2897 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2898 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2900 IHTMLElement *elem = NULL;
2905 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2906 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2907 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2913 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2914 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2916 IHTMLDocument3 *doc3;
2917 IHTMLDOMNode *node = NULL;
2921 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2922 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2925 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2926 IHTMLDocument3_Release(doc3);
2928 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2929 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2934 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2935 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2937 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2938 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2939 IHTMLDOMNode *new_child = NULL;
2942 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2943 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2944 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2945 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2947 IHTMLDOMNode_Release(node);
2948 IHTMLDOMNode_Release(child);
2953 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
2954 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
2956 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2957 IHTMLDOMNode *new_child = NULL;
2960 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
2961 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
2962 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2963 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2965 IHTMLDOMNode_Release(node);
2970 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
2971 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
2973 IHTMLDOMNode *node = _get_node_iface(line, unk);
2974 IHTMLDOMNode *new_node = NULL;
2977 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
2978 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
2979 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
2980 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
2982 IHTMLDOMNode_Release(node);
2983 IHTMLDOMNode_Release(new_node);
2986 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
2987 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
2992 hres = IHTMLDocument2_get_title(doc, &title);
2993 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2994 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2995 SysFreeString(title);
2998 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
2999 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3004 tmp = a2bstr(title);
3005 hres = IHTMLDocument2_put_title(doc, tmp);
3006 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3010 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
3011 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
3016 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
3017 LOCALE_USER_DEFAULT, &dispid);
3018 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
3021 DISPPARAMS params = {NULL,NULL,0,0};
3022 DISPID dispidNamed = DISPID_PROPERTYPUT;
3027 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3028 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
3029 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
3032 params.cNamedArgs = 1;
3033 params.rgdispidNamedArgs = &dispidNamed;
3034 V_VT(&arg) = VT_BSTR;
3035 V_BSTR(&arg) = a2bstr("none");
3036 params.rgvarg = &arg;
3037 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3038 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3039 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
3042 V_VT(&arg) = VT_BSTR;
3043 V_BSTR(&arg) = a2bstr("dotted");
3044 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3045 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3046 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
3049 V_VT(&arg) = VT_BSTR;
3050 V_BSTR(&arg) = a2bstr("dashed");
3051 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3052 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3053 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
3056 V_VT(&arg) = VT_BSTR;
3057 V_BSTR(&arg) = a2bstr("solid");
3058 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3059 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3060 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
3063 V_VT(&arg) = VT_BSTR;
3064 V_BSTR(&arg) = a2bstr("double");
3065 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3066 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3067 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
3070 V_VT(&arg) = VT_BSTR;
3071 V_BSTR(&arg) = a2bstr("groove");
3072 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3073 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3074 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
3077 V_VT(&arg) = VT_BSTR;
3078 V_BSTR(&arg) = a2bstr("ridge");
3079 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3080 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3081 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
3084 V_VT(&arg) = VT_BSTR;
3085 V_BSTR(&arg) = a2bstr("inset");
3086 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3087 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3088 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
3091 V_VT(&arg) = VT_BSTR;
3092 V_BSTR(&arg) = a2bstr("outset");
3093 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3094 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3095 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
3098 V_VT(&arg) = VT_BSTR;
3099 V_BSTR(&arg) = a2bstr("invalid");
3100 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3101 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3102 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
3105 params.rgvarg = &vDefault;
3106 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3107 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3108 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
3109 VariantClear(&vDefault);
3113 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3114 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
3116 BSTR text = (void*)0xdeadbeef;
3119 hres = IHTMLStyle_get_cssText(style, &text);
3120 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
3122 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
3124 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
3126 SysFreeString(text);
3129 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3130 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
3136 hres = IHTMLStyle_put_cssText(style, tmp);
3137 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3141 static void test_elem_bounding_client_rect(IUnknown *unk)
3143 IHTMLRect *rect, *rect2;
3144 IHTMLElement2 *elem2;
3148 elem2 = get_elem2_iface(unk);
3149 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3150 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3151 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3152 IHTMLElement2_Release(elem2);
3153 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3154 ok(rect != NULL, "rect == NULL\n");
3155 ok(rect != rect2, "rect == rect2\n");
3156 IHTMLRect_Release(rect2);
3158 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3161 hres = IHTMLRect_get_top(rect, &l);
3162 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3163 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3166 hres = IHTMLRect_get_left(rect, &l);
3167 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3168 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3171 hres = IHTMLRect_get_bottom(rect, &l);
3172 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3173 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3176 hres = IHTMLRect_get_right(rect, &l);
3177 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3178 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3180 IHTMLRect_Release(rect);
3183 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3184 const elem_type_t *elem_types, LONG len)
3187 VARIANT name, index;
3191 V_VT(&index) = VT_EMPTY;
3192 V_VT(&name) = VT_BSTR;
3193 V_BSTR(&name) = a2bstr(n);
3195 hres = IHTMLElementCollection_item(col, name, index, &disp);
3196 ok(hres == S_OK, "item failed: %08x\n", hres);
3198 test_elem_collection((IUnknown*)disp, elem_types, len);
3199 IDispatch_Release(disp);
3200 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3204 V_VT(&index) = VT_I4;
3206 for(i=0; i<len; i++) {
3208 disp = (void*)0xdeadbeef;
3209 hres = IHTMLElementCollection_item(col, name, index, &disp);
3210 ok(hres == S_OK, "item failed: %08x\n", hres);
3211 ok(disp != NULL, "disp == NULL\n");
3212 if(FAILED(hres) || !disp)
3215 test_elem_type((IUnknown*)disp, elem_types[i]);
3217 IDispatch_Release(disp);
3221 disp = (void*)0xdeadbeef;
3222 hres = IHTMLElementCollection_item(col, name, index, &disp);
3223 ok(hres == S_OK, "item failed: %08x\n", hres);
3224 ok(disp == NULL, "disp != NULL\n");
3227 disp = (void*)0xdeadbeef;
3228 hres = IHTMLElementCollection_item(col, name, index, &disp);
3229 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3230 ok(disp == NULL, "disp != NULL\n");
3233 SysFreeString(V_BSTR(&name));
3236 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3238 IHTMLElementCollection *col;
3240 IDispatch *disp = (void*)0xdeadbeef;
3241 VARIANT name, index;
3244 hres = IHTMLDocument2_get_all(doc, &col);
3245 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3246 ok(col != NULL, "col == NULL\n");
3247 if(FAILED(hres) || !col)
3250 V_VT(&index) = VT_EMPTY;
3251 V_VT(&name) = VT_BSTR;
3252 V_BSTR(&name) = a2bstr(id);
3254 hres = IHTMLElementCollection_item(col, name, index, &disp);
3255 IHTMLElementCollection_Release(col);
3256 SysFreeString(V_BSTR(&name));
3257 ok(hres == S_OK, "item failed: %08x\n", hres);
3258 if(!expect_success) {
3259 ok(disp == NULL, "disp != NULL\n");
3263 ok(disp != NULL, "disp == NULL\n");
3267 elem = get_elem_iface((IUnknown*)disp);
3268 IDispatch_Release(disp);
3273 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3275 IHTMLDocument3 *doc3;
3280 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3281 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3284 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3286 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3288 IHTMLDocument3_Release(doc3);
3293 static void test_select_elem(IHTMLSelectElement *select)
3295 IDispatch *disp, *disp2;
3296 VARIANT name, index;
3299 test_select_type(select, "select-one");
3300 test_select_length(select, 2);
3301 test_select_selidx(select, 0);
3302 test_select_put_selidx(select, 1);
3304 test_select_set_value(select, "val1");
3305 test_select_value(select, "val1");
3307 test_select_get_disabled(select, VARIANT_FALSE);
3308 test_select_set_disabled(select, VARIANT_TRUE);
3309 test_select_set_disabled(select, VARIANT_FALSE);
3312 hres = IHTMLSelectElement_get_options(select, &disp);
3313 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3314 ok(disp != NULL, "options == NULL\n");
3315 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3316 IDispatch_Release(disp);
3318 V_VT(&index) = VT_EMPTY;
3319 V_VT(&name) = VT_I4;
3321 disp = (void*)0xdeadbeef;
3322 hres = IHTMLSelectElement_item(select, name, index, &disp);
3323 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3324 ok(!disp, "disp = %p\n", disp);
3327 disp = (void*)0xdeadbeef;
3328 hres = IHTMLSelectElement_item(select, name, index, &disp);
3329 ok(hres == S_OK, "item failed: %08x\n", hres);
3330 ok(!disp, "disp = %p\n", disp);
3333 hres = IHTMLSelectElement_item(select, name, index, NULL);
3334 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3337 hres = IHTMLSelectElement_item(select, name, index, &disp);
3338 ok(hres == S_OK, "item failed: %08x\n", hres);
3339 ok(disp != NULL, "disp = NULL\n");
3340 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3342 V_VT(&index) = VT_I4;
3345 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3346 ok(hres == S_OK, "item failed: %08x\n", hres);
3347 ok(disp2 != NULL, "disp = NULL\n");
3348 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3349 IDispatch_Release(disp2);
3350 IDispatch_Release(disp);
3353 static void test_form_item(IHTMLElement *elem)
3355 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3356 IDispatch *disp, *disp2;
3357 VARIANT name, index;
3360 V_VT(&index) = VT_EMPTY;
3361 V_VT(&name) = VT_I4;
3363 disp = (void*)0xdeadbeef;
3364 hres = IHTMLFormElement_item(form, name, index, &disp);
3365 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3366 ok(!disp, "disp = %p\n", disp);
3369 disp = (void*)0xdeadbeef;
3370 hres = IHTMLFormElement_item(form, name, index, &disp);
3371 ok(hres == S_OK, "item failed: %08x\n", hres);
3372 ok(!disp, "disp = %p\n", disp);
3375 hres = IHTMLFormElement_item(form, name, index, NULL);
3376 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3379 hres = IHTMLFormElement_item(form, name, index, &disp);
3380 ok(hres == S_OK, "item failed: %08x\n", hres);
3381 ok(disp != NULL, "disp = NULL\n");
3382 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3384 V_VT(&index) = VT_I4;
3387 hres = IHTMLFormElement_item(form, name, index, &disp2);
3388 ok(hres == S_OK, "item failed: %08x\n", hres);
3389 ok(disp2 != NULL, "disp = NULL\n");
3390 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3391 IDispatch_Release(disp2);
3392 IDispatch_Release(disp);
3395 static void test_create_option_elem(IHTMLDocument2 *doc)
3397 IHTMLOptionElement *option;
3399 option = create_option_elem(doc, "test text", "test value");
3401 test_option_put_text(option, "new text");
3402 test_option_put_value(option, "new value");
3403 test_option_put_selected(option, VARIANT_TRUE);
3404 test_option_put_selected(option, VARIANT_FALSE);
3406 IHTMLOptionElement_Release(option);
3409 static void test_create_img_elem(IHTMLDocument2 *doc)
3411 IHTMLImgElement *img;
3413 img = create_img_elem(doc, 10, 15);
3416 test_img_put_width(img, 5);
3417 test_img_put_height(img, 20);
3419 IHTMLImgElement_Release(img);
3423 img = create_img_elem(doc, -1, -1);
3426 test_img_put_width(img, 5);
3427 test_img_put_height(img, 20);
3429 IHTMLImgElement_Release(img);
3433 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3435 IHTMLBodyElement *body;
3436 IHTMLTxtRange *range;
3440 elem = doc_get_body(doc);
3441 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3442 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3443 IHTMLElement_Release(elem);
3445 hres = IHTMLBodyElement_createTextRange(body, &range);
3446 IHTMLBodyElement_Release(body);
3447 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3452 static void test_txtrange(IHTMLDocument2 *doc)
3454 IHTMLTxtRange *body_range, *range, *range2;
3455 IHTMLSelectionObject *selection;
3456 IDispatch *disp_range;
3459 body_range = test_create_body_range(doc);
3461 test_range_text(body_range, "test abc 123\r\nit's text");
3463 hres = IHTMLTxtRange_duplicate(body_range, &range);
3464 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3466 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3467 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3468 test_range_isequal(range, range2, VARIANT_TRUE);
3470 test_range_text(range, "test abc 123\r\nit's text");
3471 test_range_text(body_range, "test abc 123\r\nit's text");
3473 test_range_collapse(range, TRUE);
3474 test_range_isequal(range, range2, VARIANT_FALSE);
3475 test_range_inrange(range, range2, VARIANT_FALSE);
3476 test_range_inrange(range2, range, VARIANT_TRUE);
3477 IHTMLTxtRange_Release(range2);
3479 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3480 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3481 test_range_move(range, characterW, 2, 2);
3482 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3484 test_range_collapse(range, FALSE);
3485 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3487 test_range_collapse(range, FALSE);
3488 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3489 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3490 test_range_move(range, characterW, 2, 2);
3491 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3492 test_range_moveend(range, characterW, -5, -5);
3493 test_range_text(range, NULL);
3494 test_range_moveend(range, characterW, 3, 3);
3495 test_range_text(range, "c 1");
3496 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3497 test_range_collapse(range, TRUE);
3498 test_range_move(range, characterW, 4, 4);
3499 test_range_moveend(range, characterW, 1, 1);
3500 test_range_text(range, " ");
3501 test_range_move(range, wordW, 1, 1);
3502 test_range_moveend(range, characterW, 2, 2);
3503 test_range_text(range, "ab");
3505 IHTMLTxtRange_Release(range);
3507 hres = IHTMLTxtRange_duplicate(body_range, &range);
3508 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3510 test_range_text(range, "test abc 123\r\nit's text");
3511 test_range_move(range, characterW, 3, 3);
3512 test_range_moveend(range, characterW, 1, 1);
3513 test_range_text(range, "t");
3514 test_range_moveend(range, characterW, 3, 3);
3515 test_range_text(range, "t ab");
3516 test_range_moveend(range, characterW, -2, -2);
3517 test_range_text(range, "t ");
3518 test_range_move(range, characterW, 6, 6);
3519 test_range_moveend(range, characterW, 3, 3);
3520 test_range_text(range, "123");
3521 test_range_moveend(range, characterW, 2, 2);
3522 test_range_text(range, "123\r\ni");
3524 IHTMLTxtRange_Release(range);
3526 hres = IHTMLTxtRange_duplicate(body_range, &range);
3527 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3529 test_range_move(range, wordW, 1, 1);
3530 test_range_moveend(range, characterW, 2, 2);
3531 test_range_text(range, "ab");
3533 test_range_move(range, characterW, -2, -2);
3534 test_range_moveend(range, characterW, 2, 2);
3535 test_range_text(range, "t ");
3537 test_range_move(range, wordW, 3, 3);
3538 test_range_move(range, wordW, -2, -2);
3539 test_range_moveend(range, characterW, 2, 2);
3540 test_range_text(range, "ab");
3542 test_range_move(range, characterW, -6, -5);
3543 test_range_moveend(range, characterW, -1, 0);
3544 test_range_moveend(range, characterW, -6, 0);
3545 test_range_move(range, characterW, 2, 2);
3546 test_range_moveend(range, characterW, 2, 2);
3547 test_range_text(range, "st");
3548 test_range_moveend(range, characterW, -6, -4);
3549 test_range_moveend(range, characterW, 2, 2);
3551 IHTMLTxtRange_Release(range);
3553 hres = IHTMLTxtRange_duplicate(body_range, &range);
3554 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3556 test_range_move(range, wordW, 2, 2);
3557 test_range_moveend(range, characterW, 2, 2);
3558 test_range_text(range, "12");
3560 test_range_move(range, characterW, 15, 14);
3561 test_range_move(range, characterW, -2, -2);
3562 test_range_moveend(range, characterW, 3, 2);
3563 test_range_text(range, "t");
3564 test_range_moveend(range, characterW, -1, -1);
3565 test_range_text(range, "t");
3566 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3567 test_range_move(range, characterW, -2, -2);
3568 test_range_moveend(range, characterW, 2, 2);
3569 test_range_text(range, "s ");
3570 test_range_move(range, characterW, 100, 7);
3571 test_range_move(range, wordW, 1, 0);
3572 test_range_move(range, characterW, -2, -2);
3573 test_range_moveend(range, characterW, 3, 2);
3574 test_range_text(range, "t");
3576 IHTMLTxtRange_Release(range);
3578 hres = IHTMLTxtRange_duplicate(body_range, &range);
3579 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3581 test_range_collapse(range, TRUE);
3582 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3583 test_range_put_text(range, "word");
3584 test_range_text(body_range, "wordabc 123\r\nit's text");
3585 test_range_text(range, NULL);
3586 test_range_moveend(range, characterW, 3, 3);
3587 test_range_text(range, "abc");
3588 test_range_movestart(range, characterW, -2, -2);
3589 test_range_text(range, "rdabc");
3590 test_range_movestart(range, characterW, 3, 3);
3591 test_range_text(range, "bc");
3592 test_range_movestart(range, characterW, 4, 4);
3593 test_range_text(range, NULL);
3594 test_range_movestart(range, characterW, -3, -3);
3595 test_range_text(range, "c 1");
3596 test_range_movestart(range, characterW, -7, -6);
3597 test_range_text(range, "wordabc 1");
3598 test_range_movestart(range, characterW, 100, 22);
3599 test_range_text(range, NULL);
3601 IHTMLTxtRange_Release(range);
3602 IHTMLTxtRange_Release(body_range);
3604 hres = IHTMLDocument2_get_selection(doc, &selection);
3605 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3607 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3608 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3609 IHTMLSelectionObject_Release(selection);
3611 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3612 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3613 IDispatch_Release(disp_range);
3615 test_range_text(range, NULL);
3616 test_range_moveend(range, characterW, 3, 3);
3617 test_range_text(range, "wor");
3618 test_range_parent(range, ET_BODY);
3619 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3620 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3621 test_range_move(range, characterW, 3, 3);
3622 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3623 test_range_moveend(range, characterW, -4, -4);
3624 test_range_put_text(range, "abc def ");
3625 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3626 test_range_move(range, wordW, 1, 1);
3627 test_range_movestart(range, characterW, -1, -1);
3628 test_range_text(range, " ");
3629 test_range_move(range, wordW, 1, 1);
3630 test_range_moveend(range, characterW, 3, 3);
3631 test_range_text(range, "def");
3632 test_range_put_text(range, "xyz");
3633 test_range_moveend(range, characterW, 1, 1);
3634 test_range_move(range, wordW, 1, 1);
3635 test_range_moveend(range, characterW, 2, 2);
3636 test_range_text(range, "ab");
3638 IHTMLTxtRange_Release(range);
3641 static void test_txtrange2(IHTMLDocument2 *doc)
3643 IHTMLTxtRange *range;
3645 range = test_create_body_range(doc);
3647 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3648 test_range_move(range, characterW, 5, 5);
3649 test_range_moveend(range, characterW, 1, 1);
3650 test_range_text(range, "2");
3651 test_range_move(range, characterW, -3, -3);
3652 test_range_moveend(range, characterW, 3, 3);
3653 test_range_text(range, "c\r\n\r\n1");
3654 test_range_collapse(range, VARIANT_FALSE);
3655 test_range_moveend(range, characterW, 4, 4);
3656 test_range_text(range, "23");
3657 test_range_moveend(range, characterW, 1, 1);
3658 test_range_text(range, "23\r\n\r\n\r\nd");
3659 test_range_moveend(range, characterW, -1, -1);
3660 test_range_text(range, "23");
3661 test_range_moveend(range, characterW, -1, -1);
3662 test_range_text(range, "23");
3663 test_range_moveend(range, characterW, -2, -2);
3664 test_range_text(range, "2");
3666 IHTMLTxtRange_Release(range);
3669 static void test_compatmode(IHTMLDocument2 *doc)
3671 IHTMLDocument5 *doc5;
3675 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3676 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3680 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3681 IHTMLDocument5_Release(doc5);
3682 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3683 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3684 SysFreeString(mode);
3687 static void test_location(IHTMLDocument2 *doc)
3689 IHTMLLocation *location, *location2;
3690 IHTMLWindow2 *window;
3695 hres = IHTMLDocument2_get_location(doc, &location);
3696 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3698 hres = IHTMLDocument2_get_location(doc, &location2);
3699 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3701 ok(location == location2, "location != location2\n");
3702 IHTMLLocation_Release(location2);
3704 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3705 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3707 hres = IHTMLWindow2_get_location(window, &location2);
3708 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3709 ok(location == location2, "location != location2\n");
3710 IHTMLLocation_Release(location2);
3712 test_ifaces((IUnknown*)location, location_iids);
3713 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3715 hres = IHTMLLocation_get_pathname(location, &str);
3716 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3717 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3720 hres = IHTMLLocation_get_href(location, NULL);
3721 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3723 hres = IHTMLLocation_get_href(location, &str);
3724 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3725 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3728 ref = IHTMLLocation_Release(location);
3729 ok(!ref, "location chould be destroyed here\n");
3732 static void test_plugins_col(IOmNavigator *nav)
3734 IHTMLPluginsCollection *col, *col2;
3738 hres = IOmNavigator_get_plugins(nav, &col);
3739 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3741 hres = IOmNavigator_get_plugins(nav, &col2);
3742 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3743 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3744 IHTMLPluginsCollection_Release(col2);
3746 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3748 ref = IHTMLPluginsCollection_Release(col);
3749 ok(!ref, "ref=%d\n", ref);
3752 static void test_navigator(IHTMLDocument2 *doc)
3754 IHTMLWindow2 *window;
3755 IOmNavigator *navigator, *navigator2;
3762 static const WCHAR v40[] = {'4','.','0'};
3764 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3765 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3767 hres = IHTMLWindow2_get_navigator(window, &navigator);
3768 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3769 ok(navigator != NULL, "navigator == NULL\n");
3770 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3772 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3773 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3774 ok(navigator != navigator2, "navigator2 != navihgator\n");
3776 IHTMLWindow2_Release(window);
3777 IOmNavigator_Release(navigator2);
3779 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3780 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3781 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3782 SysFreeString(bstr);
3785 hres = IOmNavigator_get_appName(navigator, &bstr);
3786 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3787 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3788 SysFreeString(bstr);
3791 hres = IOmNavigator_get_platform(navigator, &bstr);
3792 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3794 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3796 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3798 SysFreeString(bstr);
3801 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3802 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3803 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3804 SysFreeString(bstr);
3806 hres = IOmNavigator_toString(navigator, NULL);
3807 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3810 hres = IOmNavigator_toString(navigator, &bstr);
3811 ok(hres == S_OK, "toString failed: %08x\n", hres);
3812 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3813 SysFreeString(bstr);
3816 hres = ObtainUserAgentString(0, buf, &size);
3817 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3820 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3821 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3822 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3823 SysFreeString(bstr);
3825 if(!strncmp(buf, "Mozilla/", 8)) {
3827 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3828 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3829 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3830 SysFreeString(bstr);
3832 skip("nonstandard user agent\n");
3835 test_plugins_col(navigator);
3837 ref = IOmNavigator_Release(navigator);
3838 ok(!ref, "navigator should be destroyed here\n");
3841 static void test_screen(IHTMLWindow2 *window)
3843 IHTMLScreen *screen, *screen2;
3844 IDispatchEx *dispex;
3850 hres = IHTMLWindow2_get_screen(window, &screen);
3851 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3852 ok(screen != NULL, "screen == NULL\n");
3855 hres = IHTMLWindow2_get_screen(window, &screen2);
3856 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3857 ok(screen2 != NULL, "screen == NULL\n");
3858 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3859 IHTMLScreen_Release(screen2);
3861 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3862 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3863 if(SUCCEEDED(hres)) {
3864 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3865 IDispatchEx_Release(dispex);
3868 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3870 exl = GetDeviceCaps(hdc, HORZRES);
3872 hres = IHTMLScreen_get_width(screen, &l);
3873 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3874 ok(l == exl, "width = %d, expected %d\n", l, exl);
3876 exl = GetDeviceCaps(hdc, VERTRES);
3878 hres = IHTMLScreen_get_height(screen, &l);
3879 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3880 ok(l == exl, "height = %d, expected %d\n", l, exl);
3882 exl = GetDeviceCaps(hdc, BITSPIXEL);
3884 hres = IHTMLScreen_get_colorDepth(screen, &l);
3885 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3886 ok(l == exl, "height = %d, expected %d\n", l, exl);
3890 IHTMLScreen_Release(screen);
3893 static void test_current_style(IHTMLCurrentStyle *current_style)
3899 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3900 test_ifaces((IUnknown*)current_style, cstyle_iids);
3902 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3903 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3904 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3907 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3908 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3909 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3912 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3913 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3916 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3917 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3918 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3921 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3922 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3923 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3926 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3927 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3928 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3931 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3932 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3933 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3936 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3937 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3938 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3941 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3942 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3943 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3946 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3947 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3948 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3951 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3952 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
3953 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
3956 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
3957 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
3958 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
3961 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
3962 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
3963 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
3966 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
3967 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
3968 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
3971 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
3972 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
3975 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
3976 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
3979 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
3980 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
3983 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
3984 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
3987 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
3988 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
3991 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
3992 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
3995 hres = IHTMLCurrentStyle_get_padding(current_style, &str);
3996 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
3999 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
4000 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4001 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4002 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
4005 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
4006 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4007 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4010 hres = IHTMLCurrentStyle_get_left(current_style, &v);
4011 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4012 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4015 hres = IHTMLCurrentStyle_get_top(current_style, &v);
4016 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4017 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4020 hres = IHTMLCurrentStyle_get_width(current_style, &v);
4021 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4022 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4025 hres = IHTMLCurrentStyle_get_height(current_style, &v);
4026 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4027 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4030 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
4031 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
4032 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4035 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
4036 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4037 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4038 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
4041 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
4042 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4043 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4044 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
4047 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
4048 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4049 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4052 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
4053 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4054 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4057 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
4058 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4059 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4063 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
4064 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4065 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4068 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
4069 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4070 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4073 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
4074 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4075 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4078 hres = IHTMLCurrentStyle_get_color(current_style, &v);
4079 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4080 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4083 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
4084 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
4085 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4088 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
4089 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4090 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4093 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
4094 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4095 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4098 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
4099 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4100 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4103 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
4104 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4105 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4108 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
4109 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
4110 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4113 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
4114 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4115 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4118 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
4119 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4120 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4123 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
4124 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
4125 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4128 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
4129 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4130 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4133 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
4134 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
4135 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4138 hres = IHTMLCurrentStyle_get_right(current_style, &v);
4139 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
4140 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4143 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
4144 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
4145 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4148 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
4149 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
4150 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4153 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
4154 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
4155 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4159 static void test_style2(IHTMLStyle2 *style2)
4165 str = (void*)0xdeadbeef;
4166 hres = IHTMLStyle2_get_position(style2, &str);
4167 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4168 ok(!str, "str != NULL\n");
4170 str = a2bstr("absolute");
4171 hres = IHTMLStyle2_put_position(style2, str);
4172 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4176 hres = IHTMLStyle2_get_position(style2, &str);
4177 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4178 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4182 V_VT(&v) = VT_EMPTY;
4183 hres = IHTMLStyle2_get_right(style2, &v);
4184 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4185 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4186 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4190 V_BSTR(&v) = a2bstr("3px");
4191 hres = IHTMLStyle2_put_right(style2, v);
4192 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4195 V_VT(&v) = VT_EMPTY;
4196 hres = IHTMLStyle2_get_right(style2, &v);
4197 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4198 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4199 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4203 static void test_style3(IHTMLStyle3 *style3)
4208 str = (void*)0xdeadbeef;
4209 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4210 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4211 ok(!str, "str != NULL\n");
4213 str = a2bstr("break-word");
4214 hres = IHTMLStyle3_put_wordWrap(style3, str);
4215 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4219 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4220 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4221 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4225 static void test_style4(IHTMLStyle4 *style4)
4231 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4232 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4235 V_BSTR(&v) = a2bstr("10px");
4236 hres = IHTMLStyle4_put_minHeight(style4, v);
4237 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4240 hres = IHTMLStyle4_get_minHeight(style4, &v);
4241 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4242 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4243 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4246 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4247 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4248 VariantClear(&vdefault);
4251 static void test_default_style(IHTMLStyle *style)
4253 IHTMLStyle2 *style2;
4254 IHTMLStyle3 *style3;
4255 IHTMLStyle4 *style4;
4261 BSTR sOverflowDefault;
4265 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4266 test_ifaces((IUnknown*)style, style_iids);
4268 test_style_csstext(style, NULL);
4270 hres = IHTMLStyle_get_position(style, &str);
4271 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4272 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4275 hres = IHTMLStyle_get_marginRight(style, &v);
4276 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4277 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4278 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4281 hres = IHTMLStyle_get_marginLeft(style, &v);
4282 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4283 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4284 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4286 str = (void*)0xdeadbeef;
4287 hres = IHTMLStyle_get_fontFamily(style, &str);
4288 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4289 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4291 str = (void*)0xdeadbeef;
4292 hres = IHTMLStyle_get_fontWeight(style, &str);
4293 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4294 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4296 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4297 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4299 str = a2bstr("test");
4300 hres = IHTMLStyle_put_fontWeight(style, str);
4301 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4304 str = a2bstr("bold");
4305 hres = IHTMLStyle_put_fontWeight(style, str);
4306 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4309 str = a2bstr("bolder");
4310 hres = IHTMLStyle_put_fontWeight(style, str);
4311 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4314 str = a2bstr("lighter");
4315 hres = IHTMLStyle_put_fontWeight(style, str);
4316 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4319 str = a2bstr("100");
4320 hres = IHTMLStyle_put_fontWeight(style, str);
4321 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4324 str = a2bstr("200");
4325 hres = IHTMLStyle_put_fontWeight(style, str);
4326 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4329 str = a2bstr("300");
4330 hres = IHTMLStyle_put_fontWeight(style, str);
4331 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4334 str = a2bstr("400");
4335 hres = IHTMLStyle_put_fontWeight(style, str);
4336 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4339 str = a2bstr("500");
4340 hres = IHTMLStyle_put_fontWeight(style, str);
4341 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4344 str = a2bstr("600");
4345 hres = IHTMLStyle_put_fontWeight(style, str);
4346 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4349 str = a2bstr("700");
4350 hres = IHTMLStyle_put_fontWeight(style, str);
4351 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4354 str = a2bstr("800");
4355 hres = IHTMLStyle_put_fontWeight(style, str);
4356 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4359 str = a2bstr("900");
4360 hres = IHTMLStyle_put_fontWeight(style, str);
4361 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4364 hres = IHTMLStyle_get_fontWeight(style, &str);
4365 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4366 ok(!strcmp_wa(str, "900"), "str != style900\n");
4369 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4370 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4371 SysFreeString(sDefault);
4374 hres = IHTMLStyle_get_fontVariant(style, NULL);
4375 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4377 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4378 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4380 str = a2bstr("test");
4381 hres = IHTMLStyle_put_fontVariant(style, str);
4382 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4385 str = a2bstr("small-caps");
4386 hres = IHTMLStyle_put_fontVariant(style, str);
4387 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4390 str = a2bstr("normal");
4391 hres = IHTMLStyle_put_fontVariant(style, str);
4392 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4395 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4396 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4397 SysFreeString(sDefault);
4399 str = (void*)0xdeadbeef;
4400 hres = IHTMLStyle_get_display(style, &str);
4401 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4402 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4404 str = (void*)0xdeadbeef;
4405 hres = IHTMLStyle_get_visibility(style, &str);
4406 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4407 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4410 hres = IHTMLStyle_get_fontSize(style, &v);
4411 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4412 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4413 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4416 hres = IHTMLStyle_get_color(style, &v);
4417 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4418 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4419 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4422 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4423 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4424 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4426 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4427 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4428 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4430 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4431 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4432 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4434 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4435 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4438 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4439 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4440 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4442 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4443 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4444 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4446 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4447 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4448 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4450 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4451 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4454 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4455 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4456 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4458 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4459 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4460 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4462 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4463 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4464 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4466 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4467 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4470 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4471 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4472 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4474 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4475 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4476 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4478 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4479 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4480 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4482 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4483 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4486 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4487 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4488 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4490 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4491 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4492 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4494 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4495 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4496 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4498 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4499 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4501 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4502 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4504 str = a2bstr("invalid");
4505 hres = IHTMLStyle_put_textDecoration(style, str);
4506 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4509 str = a2bstr("none");
4510 hres = IHTMLStyle_put_textDecoration(style, str);
4511 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4514 str = a2bstr("underline");
4515 hres = IHTMLStyle_put_textDecoration(style, str);
4516 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4519 str = a2bstr("overline");
4520 hres = IHTMLStyle_put_textDecoration(style, str);
4521 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4524 str = a2bstr("line-through");
4525 hres = IHTMLStyle_put_textDecoration(style, str);
4526 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4529 str = a2bstr("blink");
4530 hres = IHTMLStyle_put_textDecoration(style, str);
4531 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4534 hres = IHTMLStyle_get_textDecoration(style, &str);
4535 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4536 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4539 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4540 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4541 SysFreeString(sDefault);
4543 hres = IHTMLStyle_get_posWidth(style, NULL);
4544 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4546 hres = IHTMLStyle_get_posWidth(style, &f);
4547 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4548 ok(f == 0.0f, "f = %f\n", f);
4550 V_VT(&v) = VT_EMPTY;
4551 hres = IHTMLStyle_get_width(style, &v);
4552 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4553 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4554 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4556 hres = IHTMLStyle_put_posWidth(style, 2.2);
4557 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4559 hres = IHTMLStyle_get_posWidth(style, &f);
4560 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4562 f == 2.2f, /* IE8 */
4566 V_BSTR(&v) = a2bstr("auto");
4567 hres = IHTMLStyle_put_width(style, v);
4568 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4571 V_VT(&v) = VT_EMPTY;
4572 hres = IHTMLStyle_get_width(style, &v);
4573 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4574 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4575 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4580 hres = IHTMLStyle_put_width(style, v);
4581 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4583 V_VT(&v) = VT_EMPTY;
4584 hres = IHTMLStyle_get_width(style, &v);
4585 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4586 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4587 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4591 str = (void*)0xdeadbeef;
4592 hres = IHTMLStyle_get_margin(style, &str);
4593 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4594 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4597 hres = IHTMLStyle_put_margin(style, str);
4598 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4601 hres = IHTMLStyle_get_margin(style, &str);
4602 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4603 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4606 hres = IHTMLStyle_put_margin(style, NULL);
4607 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4609 str = (void*)0xdeadbeef;
4610 hres = IHTMLStyle_get_marginTop(style, &v);
4611 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4612 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4613 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4616 V_BSTR(&v) = a2bstr("6px");
4617 hres = IHTMLStyle_put_marginTop(style, v);
4618 SysFreeString(V_BSTR(&v));
4619 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4621 str = (void*)0xdeadbeef;
4622 hres = IHTMLStyle_get_marginTop(style, &v);
4623 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4624 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4625 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4629 hres = IHTMLStyle_get_border(style, &str);
4630 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4631 ok(!str || !*str, "str is not empty\n");
4634 str = a2bstr("1px");
4635 hres = IHTMLStyle_put_border(style, str);
4636 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4639 V_VT(&v) = VT_EMPTY;
4640 hres = IHTMLStyle_get_left(style, &v);
4641 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4642 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4643 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4647 hres = IHTMLStyle_get_posLeft(style, NULL);
4648 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4651 hres = IHTMLStyle_get_posLeft(style, &f);
4652 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4653 ok(f == 0.0, "expected 0.0 got %f\n", f);
4655 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4656 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4658 hres = IHTMLStyle_get_posLeft(style, &f);
4659 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4661 f == 4.9f, /* IE8 */
4662 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4664 /* Ensure left is updated correctly. */
4665 V_VT(&v) = VT_EMPTY;
4666 hres = IHTMLStyle_get_left(style, &v);
4667 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4668 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4669 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4670 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4671 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4676 V_BSTR(&v) = a2bstr("3px");
4677 hres = IHTMLStyle_put_left(style, v);
4678 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4681 hres = IHTMLStyle_get_posLeft(style, &f);
4682 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4683 ok(f == 3.0, "expected 3.0 got %f\n", f);
4685 V_VT(&v) = VT_EMPTY;
4686 hres = IHTMLStyle_get_left(style, &v);
4687 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4688 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4689 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4693 hres = IHTMLStyle_put_left(style, v);
4694 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4696 V_VT(&v) = VT_EMPTY;
4697 hres = IHTMLStyle_get_left(style, &v);
4698 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4699 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4700 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4703 V_VT(&v) = VT_EMPTY;
4704 hres = IHTMLStyle_get_top(style, &v);
4705 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4706 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4707 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4711 hres = IHTMLStyle_get_posTop(style, NULL);
4712 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4715 hres = IHTMLStyle_get_posTop(style, &f);
4716 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4717 ok(f == 0.0, "expected 0.0 got %f\n", f);
4719 hres = IHTMLStyle_put_posTop(style, 4.9f);
4720 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4722 hres = IHTMLStyle_get_posTop(style, &f);
4723 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4725 f == 4.9f, /* IE8 */
4726 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4729 V_BSTR(&v) = a2bstr("3px");
4730 hres = IHTMLStyle_put_top(style, v);
4731 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4734 V_VT(&v) = VT_EMPTY;
4735 hres = IHTMLStyle_get_top(style, &v);
4736 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4737 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4738 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4741 hres = IHTMLStyle_get_posTop(style, &f);
4742 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4743 ok(f == 3.0, "expected 3.0 got %f\n", f);
4746 hres = IHTMLStyle_put_top(style, v);
4747 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4749 V_VT(&v) = VT_EMPTY;
4750 hres = IHTMLStyle_get_top(style, &v);
4751 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4752 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4753 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4756 /* Test posHeight */
4757 hres = IHTMLStyle_get_posHeight(style, NULL);
4758 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4760 V_VT(&v) = VT_EMPTY;
4761 hres = IHTMLStyle_get_height(style, &v);
4762 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4763 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4764 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4768 hres = IHTMLStyle_get_posHeight(style, &f);
4769 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4770 ok(f == 0.0, "expected 0.0 got %f\n", f);
4772 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4773 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4775 hres = IHTMLStyle_get_posHeight(style, &f);
4776 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4778 f == 4.9f, /* IE8 */
4779 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4782 V_BSTR(&v) = a2bstr("64px");
4783 hres = IHTMLStyle_put_height(style, v);
4784 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4787 V_VT(&v) = VT_EMPTY;
4788 hres = IHTMLStyle_get_height(style, &v);
4789 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4790 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4791 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4794 hres = IHTMLStyle_get_posHeight(style, &f);
4795 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4796 ok(f == 64.0, "expected 64.0 got %f\n", f);
4798 str = (void*)0xdeadbeef;
4799 hres = IHTMLStyle_get_cursor(style, &str);
4800 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4801 ok(!str, "get_cursor != NULL\n");
4804 str = a2bstr("default");
4805 hres = IHTMLStyle_put_cursor(style, str);
4806 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4810 hres = IHTMLStyle_get_cursor(style, &str);
4811 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4812 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4815 V_VT(&v) = VT_EMPTY;
4816 hres = IHTMLStyle_get_verticalAlign(style, &v);
4817 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4818 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4819 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4823 V_BSTR(&v) = a2bstr("middle");
4824 hres = IHTMLStyle_put_verticalAlign(style, v);
4825 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4828 V_VT(&v) = VT_EMPTY;
4829 hres = IHTMLStyle_get_verticalAlign(style, &v);
4830 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4831 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4832 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4835 str = (void*)0xdeadbeef;
4836 hres = IHTMLStyle_get_textAlign(style, &str);
4837 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4838 ok(!str, "textAlign != NULL\n");
4840 str = a2bstr("center");
4841 hres = IHTMLStyle_put_textAlign(style, str);
4842 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4846 hres = IHTMLStyle_get_textAlign(style, &str);
4847 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4848 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4851 str = (void*)0xdeadbeef;
4852 hres = IHTMLStyle_get_filter(style, &str);
4853 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4854 ok(!str, "filter != NULL\n");
4856 str = a2bstr("alpha(opacity=100)");
4857 hres = IHTMLStyle_put_filter(style, str);
4858 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4861 V_VT(&v) = VT_EMPTY;
4862 hres = IHTMLStyle_get_zIndex(style, &v);
4863 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4864 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4865 ok(!V_I4(&v), "V_I4(v) != 0\n");
4869 V_BSTR(&v) = a2bstr("1");
4870 hres = IHTMLStyle_put_zIndex(style, v);
4871 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4874 V_VT(&v) = VT_EMPTY;
4875 hres = IHTMLStyle_get_zIndex(style, &v);
4876 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4877 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4878 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4882 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4883 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4885 str = a2bstr("test");
4886 hres = IHTMLStyle_put_fontStyle(style, str);
4887 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4890 str = a2bstr("italic");
4891 hres = IHTMLStyle_put_fontStyle(style, str);
4892 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4895 str = a2bstr("oblique");
4896 hres = IHTMLStyle_put_fontStyle(style, str);
4897 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4900 str = a2bstr("normal");
4901 hres = IHTMLStyle_put_fontStyle(style, str);
4902 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4905 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4906 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4907 SysFreeString(sDefault);
4910 hres = IHTMLStyle_get_overflow(style, NULL);
4911 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4913 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4914 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4916 str = a2bstr("test");
4917 hres = IHTMLStyle_put_overflow(style, str);
4918 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4921 str = a2bstr("visible");
4922 hres = IHTMLStyle_put_overflow(style, str);
4923 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4926 str = a2bstr("scroll");
4927 hres = IHTMLStyle_put_overflow(style, str);
4928 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4931 str = a2bstr("hidden");
4932 hres = IHTMLStyle_put_overflow(style, str);
4933 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4936 str = a2bstr("auto");
4937 hres = IHTMLStyle_put_overflow(style, str);
4938 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4941 hres = IHTMLStyle_get_overflow(style, &str);
4942 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4943 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4947 hres = IHTMLStyle_put_overflow(style, str);
4948 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4951 hres = IHTMLStyle_get_overflow(style, &str);
4952 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4953 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4956 /* restore overflow default */
4957 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
4958 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4959 SysFreeString(sOverflowDefault);
4961 /* Attribute Tests*/
4962 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
4963 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4965 str = a2bstr("position");
4966 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
4967 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
4969 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4970 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4971 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4974 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
4975 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
4978 V_BSTR(&v) = a2bstr("absolute");
4979 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4980 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4983 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
4984 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
4985 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
4986 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4991 hres = IHTMLStyle_setAttribute(style, str, v, 1);
4992 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
4997 str = a2bstr("borderLeftStyle");
4998 test_border_styles(style, str);
5001 str = a2bstr("borderbottomstyle");
5002 test_border_styles(style, str);
5005 str = a2bstr("borderrightstyle");
5006 test_border_styles(style, str);
5009 str = a2bstr("bordertopstyle");
5010 test_border_styles(style, str);
5013 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
5014 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5016 str = a2bstr("none dotted dashed solid");
5017 hres = IHTMLStyle_put_borderStyle(style, str);
5018 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5021 str = a2bstr("none dotted dashed solid");
5022 hres = IHTMLStyle_get_borderStyle(style, &str);
5023 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5024 ok(!strcmp_wa(str, "none dotted dashed solid"),
5025 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
5028 str = a2bstr("double groove ridge inset");
5029 hres = IHTMLStyle_put_borderStyle(style, str);
5030 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5033 str = a2bstr("window-inset outset ridge inset");
5034 hres = IHTMLStyle_put_borderStyle(style, str);
5035 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5038 str = a2bstr("window-inset");
5039 hres = IHTMLStyle_put_borderStyle(style, str);
5040 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5043 str = a2bstr("none none none none none");
5044 hres = IHTMLStyle_put_borderStyle(style, str);
5045 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5048 str = a2bstr("invalid none none none");
5049 hres = IHTMLStyle_put_borderStyle(style, str);
5050 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5053 str = a2bstr("none invalid none none");
5054 hres = IHTMLStyle_put_borderStyle(style, str);
5055 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5058 hres = IHTMLStyle_put_borderStyle(style, sDefault);
5059 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5060 SysFreeString(sDefault);
5062 /* backgoundColor */
5063 hres = IHTMLStyle_get_backgroundColor(style, &v);
5064 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5065 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5066 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5070 hres = IHTMLStyle_get_padding(style, &str);
5071 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5072 ok(!str, "padding = %s\n", wine_dbgstr_w(str));
5076 hres = IHTMLStyle_put_padding(style, str);
5077 ok(hres == S_OK, "put_padding failed: %08x\n", hres);
5080 hres = IHTMLStyle_get_padding(style, &str);
5081 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5082 ok(!strcmp_wa(str, "1px"), "padding = %s\n", wine_dbgstr_w(str));
5086 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
5087 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5090 V_BSTR(&v) = a2bstr("10");
5091 hres = IHTMLStyle_put_paddingLeft(style, v);
5092 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5095 hres = IHTMLStyle_get_paddingLeft(style, &v);
5096 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5097 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5100 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
5101 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5103 /* BackgroundRepeat */
5104 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
5105 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5107 str = a2bstr("invalid");
5108 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5109 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
5112 str = a2bstr("repeat");
5113 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5114 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5117 str = a2bstr("no-repeat");
5118 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5119 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5122 str = a2bstr("repeat-x");
5123 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5124 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5127 str = a2bstr("repeat-y");
5128 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5129 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5132 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
5133 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5134 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
5137 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
5138 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5139 SysFreeString(sDefault);
5142 hres = IHTMLStyle_get_borderColor(style, &sDefault);
5143 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5145 str = a2bstr("red green red blue");
5146 hres = IHTMLStyle_put_borderColor(style, str);
5147 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5150 hres = IHTMLStyle_get_borderColor(style, &str);
5151 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5152 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
5155 hres = IHTMLStyle_put_borderColor(style, sDefault);
5156 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5157 SysFreeString(sDefault);
5160 hres = IHTMLStyle_get_borderRight(style, &sDefault);
5161 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
5163 str = a2bstr("thick dotted red");
5164 hres = IHTMLStyle_put_borderRight(style, str);
5165 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5168 /* IHTMLStyle_get_borderRight appears to have a bug where
5169 it returns the first letter of the color. So we check
5170 each style individually.
5173 hres = IHTMLStyle_get_borderRightColor(style, &v);
5174 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
5175 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5179 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5180 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5181 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5184 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5185 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5186 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5189 hres = IHTMLStyle_put_borderRight(style, sDefault);
5190 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5191 SysFreeString(sDefault);
5194 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5195 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5197 str = a2bstr("thick dotted red");
5198 hres = IHTMLStyle_put_borderTop(style, str);
5199 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5202 /* IHTMLStyle_get_borderTop appears to have a bug where
5203 it returns the first letter of the color. So we check
5204 each style individually.
5207 hres = IHTMLStyle_get_borderTopColor(style, &v);
5208 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5209 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5213 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5214 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5215 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5218 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5219 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5220 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5223 hres = IHTMLStyle_put_borderTop(style, sDefault);
5224 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5225 SysFreeString(sDefault);
5228 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5229 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5231 str = a2bstr("thick dotted red");
5232 hres = IHTMLStyle_put_borderBottom(style, str);
5233 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5236 /* IHTMLStyle_get_borderBottom appears to have a bug where
5237 it returns the first letter of the color. So we check
5238 each style individually.
5241 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5242 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5243 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5247 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5248 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5249 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5252 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5253 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5254 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5257 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5258 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5259 SysFreeString(sDefault);
5262 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5263 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5265 str = a2bstr("thick dotted red");
5266 hres = IHTMLStyle_put_borderLeft(style, str);
5267 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5270 /* IHTMLStyle_get_borderLeft appears to have a bug where
5271 it returns the first letter of the color. So we check
5272 each style individually.
5275 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5276 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5277 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5281 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5282 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5283 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5286 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5287 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5288 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5291 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5292 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5293 SysFreeString(sDefault);
5295 /* backgroundPositionX */
5296 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5297 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5298 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5299 ok(!V_BSTR(&v), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5303 V_BSTR(&v) = a2bstr("10px");
5304 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5305 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5308 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5309 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5310 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5311 ok(!strcmp_wa(V_BSTR(&v), "10px"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5314 /* backgroundPositionY */
5315 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5316 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5317 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5321 V_BSTR(&v) = a2bstr("15px");
5322 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5323 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5326 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5327 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5328 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5329 ok(!strcmp_wa(V_BSTR(&v), "15px"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5332 /* backgroundPosition */
5334 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5335 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5336 ok(!strcmp_wa(str, "10px 15px"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5339 str = a2bstr("center 20%");
5340 hres = IHTMLStyle_put_backgroundPosition(style, str);
5341 ok(hres == S_OK, "put_backgroundPosition failed: %08x\n", hres);
5345 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5346 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5347 ok(!strcmp_wa(str, "center 20%"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5350 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5351 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5352 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5353 ok(!strcmp_wa(V_BSTR(&v), "center"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5356 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5357 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5358 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5359 ok(!strcmp_wa(V_BSTR(&v), "20%"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5362 /* borderTopWidth */
5363 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5364 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5367 V_BSTR(&v) = a2bstr("10px");
5368 hres = IHTMLStyle_put_borderTopWidth(style, v);
5369 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5372 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5373 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5374 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5377 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5378 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5379 VariantClear(&vDefault);
5381 /* borderRightWidth */
5382 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5383 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5386 V_BSTR(&v) = a2bstr("10");
5387 hres = IHTMLStyle_put_borderRightWidth(style, v);
5388 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5391 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5392 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5393 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5396 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5397 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5398 VariantClear(&vDefault);
5400 /* borderBottomWidth */
5401 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5402 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5405 V_BSTR(&v) = a2bstr("10");
5406 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5407 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5410 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5411 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5412 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5415 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5416 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5417 VariantClear(&vDefault);
5419 /* borderLeftWidth */
5420 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5421 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5424 V_BSTR(&v) = a2bstr("10");
5425 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5426 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5429 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5430 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5431 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5434 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5435 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5436 VariantClear(&vDefault);
5439 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5440 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5443 V_BSTR(&v) = a2bstr("10");
5444 hres = IHTMLStyle_put_wordSpacing(style, v);
5445 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5448 hres = IHTMLStyle_get_wordSpacing(style, &v);
5449 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5450 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5451 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5454 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5455 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5456 VariantClear(&vDefault);
5459 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5460 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5463 V_BSTR(&v) = a2bstr("11");
5464 hres = IHTMLStyle_put_letterSpacing(style, v);
5465 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5468 hres = IHTMLStyle_get_letterSpacing(style, &v);
5469 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5470 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5471 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5474 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5475 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5476 VariantClear(&vDefault);
5478 /* borderTopColor */
5479 hres = IHTMLStyle_get_borderTopColor(style, &vDefault);
5480 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5483 V_BSTR(&v) = a2bstr("red");
5484 hres = IHTMLStyle_put_borderTopColor(style, v);
5485 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5488 hres = IHTMLStyle_get_borderTopColor(style, &v);
5489 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5490 ok(!strcmp_wa(V_BSTR(&v), "red"), "expecte red = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5493 hres = IHTMLStyle_put_borderTopColor(style, vDefault);
5494 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5496 /* borderRightColor */
5497 hres = IHTMLStyle_get_borderRightColor(style, &vDefault);
5498 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5501 V_BSTR(&v) = a2bstr("blue");
5502 hres = IHTMLStyle_put_borderRightColor(style, v);
5503 ok(hres == S_OK, "put_borderRightColor: %08x\n", hres);
5506 hres = IHTMLStyle_get_borderRightColor(style, &v);
5507 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5508 ok(!strcmp_wa(V_BSTR(&v), "blue"), "expected blue = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5511 hres = IHTMLStyle_put_borderRightColor(style, vDefault);
5512 ok(hres == S_OK, "putborderRightColorr: %08x\n", hres);
5514 /* borderBottomColor */
5515 hres = IHTMLStyle_get_borderBottomColor(style, &vDefault);
5516 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5519 V_BSTR(&v) = a2bstr("cyan");
5520 hres = IHTMLStyle_put_borderBottomColor(style, v);
5521 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5524 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5525 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5526 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5529 hres = IHTMLStyle_put_borderBottomColor(style, vDefault);
5530 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5532 /* borderLeftColor */
5533 hres = IHTMLStyle_get_borderLeftColor(style, &vDefault);
5534 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5537 V_BSTR(&v) = a2bstr("cyan");
5538 hres = IHTMLStyle_put_borderLeftColor(style, v);
5539 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5542 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5543 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5544 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5547 hres = IHTMLStyle_put_borderLeftColor(style, vDefault);
5548 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5550 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5551 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5552 if(SUCCEEDED(hres)) {
5553 test_style2(style2);
5554 IHTMLStyle2_Release(style2);
5557 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5558 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5559 if(SUCCEEDED(hres)) {
5560 test_style3(style3);
5561 IHTMLStyle3_Release(style3);
5564 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5565 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5566 if(SUCCEEDED(hres)) {
5567 test_style4(style4);
5568 IHTMLStyle4_Release(style4);
5572 #define test_style_filter(a,b) _test_style_filter(__LINE__,a,b)
5573 static void _test_style_filter(unsigned line, IHTMLStyle *style, const char *exval)
5578 str = (void*)0xdeadbeef;
5579 hres = IHTMLStyle_get_filter(style, &str);
5580 ok_(__FILE__,line)(hres == S_OK, "get_filter failed: %08x\n", hres);
5582 ok_(__FILE__,line)(str && !strcmp_wa(str, exval), "filter = %s, expected %s\n", wine_dbgstr_w(str), exval);
5584 ok_(__FILE__,line)(!str, "str = %s, expected NULL\n", wine_dbgstr_w(str));
5589 #define set_style_filter(a,b) _set_style_filter(__LINE__,a,b)
5590 static void _set_style_filter(unsigned line, IHTMLStyle *style, const char *val)
5592 BSTR str = a2bstr(val);
5595 hres = IHTMLStyle_put_filter(style, str);
5596 ok_(__FILE__,line)(hres == S_OK, "put_filter failed: %08x\n", hres);
5599 _test_style_filter(line, style, val);
5602 static void test_style_filters(IHTMLElement *elem)
5607 hres = IHTMLElement_get_style(elem, &style);
5608 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5610 test_style_filter(style, NULL);
5611 set_style_filter(style, "alpha(opacity=50.00000)");
5612 set_style_filter(style, "alpha(opacity=100)");
5614 IHTMLStyle_Release(style);
5616 hres = IHTMLElement_get_style(elem, &style);
5617 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5619 test_style_filter(style, "alpha(opacity=100)");
5620 set_style_filter(style, "xxx(a,b,c) alpha(opacity=100)");
5621 set_style_filter(style, NULL);
5623 IHTMLStyle_Release(style);
5626 static void test_set_csstext(IHTMLStyle *style)
5631 test_style_set_csstext(style, "background-color: black;");
5633 hres = IHTMLStyle_get_backgroundColor(style, &v);
5634 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5635 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5636 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5640 static void test_default_selection(IHTMLDocument2 *doc)
5642 IHTMLSelectionObject *selection;
5643 IHTMLTxtRange *range;
5648 hres = IHTMLDocument2_get_selection(doc, &selection);
5649 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5651 hres = IHTMLSelectionObject_get_type(selection, &str);
5652 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5653 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5656 hres = IHTMLSelectionObject_createRange(selection, &disp);
5657 IHTMLSelectionObject_Release(selection);
5658 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5660 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5661 IDispatch_Release(disp);
5662 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5664 test_range_text(range, NULL);
5665 IHTMLTxtRange_Release(range);
5668 static void test_doc_elem(IHTMLDocument2 *doc)
5670 IHTMLDocument2 *doc_node, *owner_doc;
5672 IHTMLDocument3 *doc3;
5675 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5676 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5678 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5679 IHTMLDocument3_Release(doc3);
5680 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5682 test_node_name((IUnknown*)elem, "HTML");
5683 test_elem_tag((IUnknown*)elem, "HTML");
5685 doc_node = get_doc_node(doc);
5686 owner_doc = get_owner_doc((IUnknown*)elem);
5687 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5688 IHTMLDocument2_Release(owner_doc);
5690 owner_doc = get_owner_doc((IUnknown*)doc_node);
5691 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5692 IHTMLDocument2_Release(doc_node);
5694 test_elem_client_rect((IUnknown*)elem);
5696 IHTMLElement_Release(elem);
5699 static void test_default_body(IHTMLBodyElement *body)
5706 bstr = (void*)0xdeadbeef;
5707 hres = IHTMLBodyElement_get_background(body, &bstr);
5708 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5709 ok(bstr == NULL, "bstr != NULL\n");
5711 l = elem_get_scroll_height((IUnknown*)body);
5712 ok(l != -1, "scrollHeight == -1\n");
5713 l = elem_get_scroll_width((IUnknown*)body);
5714 ok(l != -1, "scrollWidth == -1\n");
5715 l = elem_get_scroll_top((IUnknown*)body);
5716 ok(!l, "scrollTop = %d\n", l);
5717 elem_get_scroll_left((IUnknown*)body);
5719 /* get_text tests */
5720 hres = IHTMLBodyElement_get_text(body, &v);
5721 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5722 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5723 ok(bstr == NULL, "bstr != NULL\n");
5725 /* get_text - Invalid Text */
5727 V_BSTR(&v) = a2bstr("Invalid");
5728 hres = IHTMLBodyElement_put_text(body, v);
5729 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5733 hres = IHTMLBodyElement_get_text(body, &v);
5734 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5735 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5736 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5739 /* get_text - Valid Text */
5741 V_BSTR(&v) = a2bstr("#FF0000");
5742 hres = IHTMLBodyElement_put_text(body, v);
5743 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5747 hres = IHTMLBodyElement_get_text(body, &v);
5748 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5749 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5750 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5754 static void test_body_funs(IHTMLBodyElement *body)
5756 VARIANT vbg, vDefaultbg;
5759 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5760 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5761 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5762 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5764 V_VT(&vbg) = VT_BSTR;
5765 V_BSTR(&vbg) = a2bstr("red");
5766 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5767 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5770 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5771 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5772 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5773 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5776 /* Restore Originial */
5777 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5778 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5779 VariantClear(&vDefaultbg);
5782 static void test_window(IHTMLDocument2 *doc)
5784 IHTMLWindow2 *window, *window2, *self;
5785 IHTMLDocument2 *doc2 = NULL;
5791 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5792 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5793 test_ifaces((IUnknown*)window, window_iids);
5794 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5796 hres = IHTMLWindow2_get_document(window, &doc2);
5797 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5798 ok(doc2 != NULL, "doc2 == NULL\n");
5800 test_ifaces((IUnknown*)doc2, doc_node_iids);
5801 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5803 test_ifaces((IUnknown*)doc, doc_obj_iids);
5804 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5806 unk = (void*)0xdeadbeef;
5807 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5808 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5809 ok(!unk, "unk = %p\n", unk);
5811 IHTMLDocument_Release(doc2);
5813 hres = IHTMLWindow2_get_window(window, &window2);
5814 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5815 ok(window2 != NULL, "window2 == NULL\n");
5817 hres = IHTMLWindow2_get_self(window, &self);
5818 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5819 ok(window2 != NULL, "self == NULL\n");
5821 ok(self == window2, "self != window2\n");
5823 IHTMLWindow2_Release(window2);
5824 IHTMLWindow2_Release(self);
5827 hres = IHTMLDocument2_get_Script(doc, &disp);
5828 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5829 ok(disp == (void*)window, "disp != window\n");
5830 IDispatch_Release(disp);
5832 hres = IHTMLWindow2_toString(window, NULL);
5833 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5836 hres = IHTMLWindow2_toString(window, &str);
5837 ok(hres == S_OK, "toString failed: %08x\n", hres);
5838 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5841 test_window_name(window, NULL);
5842 set_window_name(window, "test");
5843 test_window_length(window, 0);
5844 test_screen(window);
5846 IHTMLWindow2_Release(window);
5849 static void test_defaults(IHTMLDocument2 *doc)
5851 IHTMLStyleSheetsCollection *stylesheetcol;
5852 IHTMLCurrentStyle *cstyle;
5853 IHTMLBodyElement *body;
5854 IHTMLElement2 *elem2;
5859 IHTMLElementCollection *collection;
5861 elem = doc_get_body(doc);
5863 hres = IHTMLDocument2_get_images(doc, NULL);
5864 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5866 hres = IHTMLDocument2_get_images(doc, &collection);
5867 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5870 test_elem_collection((IUnknown*)collection, NULL, 0);
5871 IHTMLElementCollection_Release(collection);
5874 hres = IHTMLDocument2_get_applets(doc, NULL);
5875 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5877 hres = IHTMLDocument2_get_applets(doc, &collection);
5878 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5881 test_elem_collection((IUnknown*)collection, NULL, 0);
5882 IHTMLElementCollection_Release(collection);
5885 hres = IHTMLDocument2_get_links(doc, NULL);
5886 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5888 hres = IHTMLDocument2_get_links(doc, &collection);
5889 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5892 test_elem_collection((IUnknown*)collection, NULL, 0);
5893 IHTMLElementCollection_Release(collection);
5896 hres = IHTMLDocument2_get_forms(doc, NULL);
5897 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5899 hres = IHTMLDocument2_get_forms(doc, &collection);
5900 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5903 test_elem_collection((IUnknown*)collection, NULL, 0);
5904 IHTMLElementCollection_Release(collection);
5907 hres = IHTMLDocument2_get_anchors(doc, NULL);
5908 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5910 hres = IHTMLDocument2_get_anchors(doc, &collection);
5911 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5914 test_elem_collection((IUnknown*)collection, NULL, 0);
5915 IHTMLElementCollection_Release(collection);
5918 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5919 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5920 test_default_body(body);
5921 test_body_funs(body);
5922 IHTMLBodyElement_Release(body);
5924 hres = IHTMLElement_get_style(elem, &style);
5925 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5927 test_default_style(style);
5929 test_compatmode(doc);
5931 test_navigator(doc);
5933 elem2 = get_elem2_iface((IUnknown*)elem);
5934 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5935 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5936 if(SUCCEEDED(hres)) {
5937 test_current_style(cstyle);
5938 IHTMLCurrentStyle_Release(cstyle);
5940 IHTMLElement2_Release(elem2);
5942 IHTMLElement_Release(elem);
5944 test_set_csstext(style);
5945 IHTMLStyle_Release(style);
5947 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5948 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5951 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5952 ok(hres == S_OK, "get_length failed: %08x\n", hres);
5953 ok(l == 0, "length = %d\n", l);
5955 IHTMLStyleSheetsCollection_Release(stylesheetcol);
5957 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
5958 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
5960 test_default_selection(doc);
5961 test_doc_title(doc, "");
5964 static void test_tr_elem(IHTMLElement *elem)
5966 IHTMLElementCollection *col;
5970 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
5972 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
5973 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
5978 hres = IHTMLTableRow_get_cells(row, &col);
5979 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
5980 ok(col != NULL, "get_cells returned NULL\n");
5982 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
5983 IHTMLElementCollection_Release(col);
5985 IHTMLTable_Release(row);
5988 static void test_table_elem(IHTMLElement *elem)
5990 IHTMLElementCollection *col;
5995 static const elem_type_t row_types[] = {ET_TR,ET_TR};
5996 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
5998 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
5999 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
6004 hres = IHTMLTable_get_rows(table, &col);
6005 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
6006 ok(col != NULL, "get_ros returned NULL\n");
6008 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
6009 IHTMLElementCollection_Release(col);
6011 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
6013 node = clone_node((IUnknown*)table, VARIANT_TRUE);
6014 test_elem_tag((IUnknown*)node, "TABLE");
6015 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
6016 IHTMLDOMNode_Release(node);
6018 node = clone_node((IUnknown*)table, VARIANT_FALSE);
6019 test_elem_tag((IUnknown*)node, "TABLE");
6020 test_elem_all((IUnknown*)node, NULL, 0);
6021 IHTMLDOMNode_Release(node);
6023 IHTMLTable_Release(table);
6026 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
6035 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
6036 SafeArrayAccessData(sa, (void**)&var);
6037 V_VT(var) = VT_BSTR;
6038 V_BSTR(var) = a2bstr(text);
6039 SafeArrayUnaccessData(sa);
6042 hres = IHTMLDocument2_writeln(doc, sa);
6044 hres = IHTMLDocument2_write(doc, sa);
6045 ok(hres == S_OK, "write failed: %08x\n", hres);
6047 SafeArrayDestroy(sa);
6050 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
6052 IHTMLDocument2 *window_doc, *elem_doc;
6053 IHTMLFrameElement3 *frame_elem3;
6054 IHTMLWindow2 *content_window;
6057 content_window = get_frame_content_window(frame_elem);
6058 window_doc = get_window_doc(content_window);
6059 IHTMLWindow2_Release(content_window);
6061 elem_doc = get_elem_doc(frame_elem);
6062 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
6065 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
6066 if(SUCCEEDED(hres)) {
6067 IDispatch *disp = NULL;
6069 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
6070 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
6071 ok(disp != NULL, "contentDocument == NULL\n");
6072 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
6074 IDispatch_Release(disp);
6075 IHTMLFrameElement3_Release(frame_elem3);
6077 win_skip("IHTMLFrameElement3 not supported\n");
6081 IHTMLDocument2_Release(elem_doc);
6082 IHTMLDocument2_Release(window_doc);
6085 static void test_iframe_elem(IHTMLElement *elem)
6087 IHTMLDocument2 *content_doc, *owner_doc;
6088 IHTMLElementCollection *col;
6089 IHTMLWindow2 *content_window;
6095 static const elem_type_t all_types[] = {
6103 test_frame_doc((IUnknown*)elem, TRUE);
6105 content_window = get_frame_content_window((IUnknown*)elem);
6106 test_window_length(content_window, 0);
6108 content_doc = get_window_doc(content_window);
6109 IHTMLWindow2_Release(content_window);
6111 str = a2bstr("text/html");
6112 V_VT(&errv) = VT_ERROR;
6114 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
6116 ok(hres == S_OK, "open failed: %08x\n", hres);
6117 ok(disp != NULL, "disp == NULL\n");
6118 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
6119 IDispatch_Release(disp);
6121 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
6122 doc_write(content_doc, TRUE, "</html>");
6124 hres = IHTMLDocument2_get_all(content_doc, &col);
6125 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6126 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6127 IHTMLElementCollection_Release(col);
6129 hres = IHTMLDocument2_close(content_doc);
6130 ok(hres == S_OK, "close failed: %08x\n", hres);
6132 owner_doc = get_owner_doc((IUnknown*)content_doc);
6133 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
6135 IHTMLDocument2_Release(content_doc);
6138 static void test_stylesheet(IDispatch *disp)
6140 IHTMLStyleSheetRulesCollection *col = NULL;
6141 IHTMLStyleSheet *stylesheet;
6144 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
6145 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
6147 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
6148 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
6149 ok(col != NULL, "col == NULL\n");
6151 IHTMLStyleSheetRulesCollection_Release(col);
6152 IHTMLStyleSheet_Release(stylesheet);
6155 static void test_stylesheets(IHTMLDocument2 *doc)
6157 IHTMLStyleSheetsCollection *col = NULL;
6162 hres = IHTMLDocument2_get_styleSheets(doc, &col);
6163 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
6164 ok(col != NULL, "col == NULL\n");
6166 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
6168 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
6169 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6170 ok(len == 1, "len=%d\n", len);
6176 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6177 ok(hres == S_OK, "item failed: %08x\n", hres);
6178 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
6179 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6180 test_stylesheet(V_DISPATCH(&res));
6187 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6188 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6189 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
6190 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6193 IHTMLStyleSheetsCollection_Release(col);
6196 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
6198 IDispatchEx *dispex;
6200 DISPPARAMS dp = {NULL, NULL, 0, 0};
6208 static const WCHAR w0[] = {'0',0};
6209 static const WCHAR w100[] = {'1','0','0',0};
6211 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
6212 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
6214 bstr = SysAllocString(w0);
6215 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6216 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6217 SysFreeString(bstr);
6220 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
6221 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
6222 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
6223 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
6224 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
6225 type = get_node_type((IUnknown*)node);
6226 ok(type == 3, "type=%d\n", type);
6227 IHTMLDOMNode_Release(node);
6230 bstr = SysAllocString(w100);
6231 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6232 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
6233 SysFreeString(bstr);
6235 IDispatchEx_Release(dispex);
6240 static void test_elems(IHTMLDocument2 *doc)
6242 IHTMLElementCollection *col;
6243 IHTMLDOMChildrenCollection *child_col;
6244 IHTMLElement *elem, *elem2, *elem3;
6245 IHTMLDOMNode *node, *node2;
6246 IHTMLWindow2 *window;
6250 IHTMLElementCollection *collection;
6251 IHTMLDocument3 *doc3;
6254 static const elem_type_t all_types[] = {
6282 static const elem_type_t item_types[] = {
6288 hres = IHTMLDocument2_get_all(doc, &col);
6289 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6290 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6291 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
6292 IHTMLElementCollection_Release(col);
6294 hres = IHTMLDocument2_get_images(doc, &collection);
6295 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6298 static const elem_type_t images_types[] = {ET_IMG};
6299 test_elem_collection((IUnknown*)collection, images_types, 1);
6301 IHTMLElementCollection_Release(collection);
6304 hres = IHTMLDocument2_get_links(doc, &collection);
6305 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6308 static const elem_type_t images_types[] = {ET_A};
6309 test_elem_collection((IUnknown*)collection, images_types, 1);
6311 IHTMLElementCollection_Release(collection);
6314 hres = IHTMLDocument2_get_anchors(doc, &collection);
6315 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6318 static const elem_type_t anchor_types[] = {ET_A};
6319 test_elem_collection((IUnknown*)collection, anchor_types, 1);
6321 IHTMLElementCollection_Release(collection);
6324 elem = get_doc_elem(doc);
6325 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
6326 IHTMLElement_Release(elem);
6328 get_elem_by_id(doc, "xxx", FALSE);
6329 elem = get_doc_elem_by_id(doc, "xxx");
6330 ok(!elem, "elem != NULL\n");
6332 elem = get_doc_elem_by_id(doc, "s");
6333 ok(elem != NULL, "elem == NULL\n");
6335 test_elem_type((IUnknown*)elem, ET_SELECT);
6336 test_elem_attr(elem, "xxx", NULL);
6337 test_elem_attr(elem, "id", "s");
6338 test_elem_class((IUnknown*)elem, NULL);
6339 test_elem_set_class((IUnknown*)elem, "cl");
6340 test_elem_set_class((IUnknown*)elem, NULL);
6341 test_elem_tabindex((IUnknown*)elem, 0);
6342 test_elem_set_tabindex((IUnknown*)elem, 1);
6343 test_elem_filters((IUnknown*)elem);
6345 node = test_node_get_parent((IUnknown*)elem);
6346 ok(node != NULL, "node == NULL\n");
6347 test_node_name((IUnknown*)node, "BODY");
6348 node2 = test_node_get_parent((IUnknown*)node);
6349 IHTMLDOMNode_Release(node);
6350 ok(node2 != NULL, "node == NULL\n");
6351 test_node_name((IUnknown*)node2, "HTML");
6352 node = test_node_get_parent((IUnknown*)node2);
6353 IHTMLDOMNode_Release(node2);
6354 ok(node != NULL, "node == NULL\n");
6357 test_node_name((IUnknown*)node, "#document");
6358 type = get_node_type((IUnknown*)node);
6359 ok(type == 9, "type=%d, expected 9\n", type);
6360 node2 = test_node_get_parent((IUnknown*)node);
6361 IHTMLDOMNode_Release(node);
6362 ok(node2 == NULL, "node != NULL\n");
6365 elem2 = test_elem_get_parent((IUnknown*)elem);
6366 ok(elem2 != NULL, "elem2 == NULL\n");
6367 test_node_name((IUnknown*)elem2, "BODY");
6368 elem3 = test_elem_get_parent((IUnknown*)elem2);
6369 IHTMLElement_Release(elem2);
6370 ok(elem3 != NULL, "elem3 == NULL\n");
6371 test_node_name((IUnknown*)elem3, "HTML");
6372 elem2 = test_elem_get_parent((IUnknown*)elem3);
6373 IHTMLElement_Release(elem3);
6374 ok(elem2 == NULL, "elem2 != NULL\n");
6376 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6377 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6378 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6380 test_elem_innertext(elem, "opt1opt2");
6382 IHTMLElement_Release(elem);
6385 elem = get_elem_by_id(doc, "s", TRUE);
6387 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6388 IHTMLDocument2 *doc_node, *elem_doc;
6390 test_select_elem(select);
6392 test_elem_title((IUnknown*)select, NULL);
6393 test_elem_set_title((IUnknown*)select, "Title");
6394 test_elem_title((IUnknown*)select, "Title");
6395 test_elem_offset((IUnknown*)select);
6396 test_elem_bounding_client_rect((IUnknown*)select);
6398 node = get_first_child((IUnknown*)select);
6399 ok(node != NULL, "node == NULL\n");
6401 test_elem_type((IUnknown*)node, ET_OPTION);
6402 IHTMLDOMNode_Release(node);
6405 type = get_node_type((IUnknown*)select);
6406 ok(type == 1, "type=%d\n", type);
6408 IHTMLSelectElement_Release(select);
6410 elem_doc = get_elem_doc((IUnknown*)elem);
6412 doc_node = get_doc_node(doc);
6413 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6414 IHTMLDocument2_Release(doc_node);
6415 IHTMLDocument2_Release(elem_doc);
6417 IHTMLElement_Release(elem);
6420 elem = get_elem_by_id(doc, "sc", TRUE);
6422 IHTMLScriptElement *script;
6425 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6426 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6432 hres = IHTMLScriptElement_put_type (script, NULL);
6433 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6434 hres = IHTMLScriptElement_get_type(script, &type);
6435 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6436 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6438 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6439 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6440 hres = IHTMLScriptElement_get_type(script, &type);
6441 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6442 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6444 SysFreeString(type);
6447 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6448 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6450 hres = IHTMLScriptElement_get_defer(script, &vb);
6451 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6452 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6454 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6455 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6457 str = (BSTR)0xdeadbeef;
6458 hres = IHTMLScriptElement_get_src(script, &str);
6459 ok(hres == S_OK, "get_src failed: %08x\n", hres);
6460 ok(!str, "src = %s\n", wine_dbgstr_w(str));
6463 IHTMLScriptElement_Release(script);
6466 elem = get_elem_by_id(doc, "in", TRUE);
6468 IHTMLInputElement *input;
6470 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6471 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6473 test_elem_id((IUnknown*)elem, "in");
6474 test_elem_put_id((IUnknown*)elem, "newin");
6475 test_input_get_disabled(input, VARIANT_FALSE);
6476 test_input_set_disabled(input, VARIANT_TRUE);
6477 test_input_set_disabled(input, VARIANT_FALSE);
6478 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6479 test_input_get_disabled(input, VARIANT_TRUE);
6480 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6481 test_input_get_disabled(input, VARIANT_FALSE);
6482 test_elem_client_size((IUnknown*)elem);
6483 test_input_type(input, "text");
6485 test_node_get_value_str((IUnknown*)elem, NULL);
6486 test_node_put_value_str((IUnknown*)elem, "test");
6487 test_node_get_value_str((IUnknown*)elem, NULL);
6488 test_input_value((IUnknown*)elem, NULL);
6489 test_input_put_value((IUnknown*)elem, "test");
6490 test_elem_class((IUnknown*)elem, "testclass");
6491 test_elem_tabindex((IUnknown*)elem, 2);
6492 test_elem_set_tabindex((IUnknown*)elem, 3);
6493 test_elem_title((IUnknown*)elem, "test title");
6495 test_input_get_defaultchecked(input, VARIANT_FALSE);
6496 test_input_set_defaultchecked(input, VARIANT_TRUE);
6497 test_input_set_defaultchecked(input, VARIANT_FALSE);
6499 test_input_get_checked(input, VARIANT_FALSE);
6500 test_input_set_checked(input, VARIANT_TRUE);
6501 test_input_set_checked(input, VARIANT_FALSE);
6503 test_input_name(input, NULL);
6504 test_input_set_name(input, "test");
6506 test_input_src(input, NULL);
6507 test_input_set_src(input, "about:blank");
6509 IHTMLInputElement_Release(input);
6510 IHTMLElement_Release(elem);
6513 elem = get_elem_by_id(doc, "imgid", TRUE);
6515 test_img_src((IUnknown*)elem, "");
6516 test_img_set_src((IUnknown*)elem, "about:blank");
6517 test_img_alt((IUnknown*)elem, NULL);
6518 test_img_set_alt((IUnknown*)elem, "alt test");
6519 test_img_name((IUnknown*)elem, "WineImg");
6520 IHTMLElement_Release(elem);
6523 elem = get_elem_by_id(doc, "styleid", TRUE);
6525 test_style_media((IUnknown*)elem, NULL);
6526 test_style_put_media((IUnknown*)elem, "screen");
6527 test_style_type((IUnknown*)elem, NULL);
6528 test_style_put_type((IUnknown*)elem, "text/css");
6529 IHTMLElement_Release(elem);
6532 elem = get_doc_elem_by_id(doc, "tbl");
6533 ok(elem != NULL, "elem == NULL\n");
6535 test_table_elem(elem);
6536 IHTMLElement_Release(elem);
6539 elem = get_doc_elem_by_id(doc, "row2");
6540 ok(elem != NULL, "elem == NULL\n");
6543 IHTMLElement_Release(elem);
6546 elem = get_doc_elem_by_id(doc, "ifr");
6547 ok(elem != NULL, "elem == NULL\n");
6549 test_iframe_elem(elem);
6550 IHTMLElement_Release(elem);
6553 elem = get_doc_elem_by_id(doc, "objid");
6554 ok(elem != NULL, "elem == NULL\n");
6556 test_object_vspace((IUnknown*)elem, 100);
6557 IHTMLElement_Release(elem);
6560 elem = get_elem_by_id(doc, "a", TRUE);
6562 test_anchor_href((IUnknown*)elem, "http://test/");
6564 /* Change the href */
6565 test_anchor_put_href((IUnknown*)elem, "http://test1/");
6566 test_anchor_href((IUnknown*)elem, "http://test1/");
6568 /* Restore the href */
6569 test_anchor_put_href((IUnknown*)elem, "http://test/");
6570 test_anchor_href((IUnknown*)elem, "http://test/");
6571 IHTMLElement_Release(elem);
6574 elem = doc_get_body(doc);
6576 node = get_first_child((IUnknown*)elem);
6577 ok(node != NULL, "node == NULL\n");
6579 test_ifaces((IUnknown*)node, text_iids);
6580 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6582 node2 = get_first_child((IUnknown*)node);
6583 ok(!node2, "node2 != NULL\n");
6585 type = get_node_type((IUnknown*)node);
6586 ok(type == 3, "type=%d\n", type);
6588 test_node_get_value_str((IUnknown*)node, "text test");
6589 test_node_put_value_str((IUnknown*)elem, "test text");
6590 test_node_get_value_str((IUnknown*)node, "text test");
6592 IHTMLDOMNode_Release(node);
6595 child_col = get_child_nodes((IUnknown*)elem);
6596 ok(child_col != NULL, "child_coll == NULL\n");
6600 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6602 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6603 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6604 ok(length, "length=0\n");
6607 node = get_child_item(child_col, 0);
6608 ok(node != NULL, "node == NULL\n");
6610 type = get_node_type((IUnknown*)node);
6611 ok(type == 3, "type=%d\n", type);
6612 node2 = node_get_next((IUnknown*)node);
6613 IHTMLDOMNode_Release(node);
6616 node = get_child_item(child_col, 1);
6617 ok(node != NULL, "node == NULL\n");
6619 type = get_node_type((IUnknown*)node);
6620 ok(type == 8, "type=%d\n", type);
6622 test_elem_id((IUnknown*)node, NULL);
6623 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6624 IHTMLDOMNode_Release(node2);
6625 IHTMLDOMNode_Release(node);
6628 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6629 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6631 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6632 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6634 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6635 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6637 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6638 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6640 test_child_col_disp(child_col);
6642 IHTMLDOMChildrenCollection_Release(child_col);
6645 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6646 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6647 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6649 IHTMLElement_Release(elem);
6651 elem = get_doc_elem_by_id(doc, "frm");
6652 ok(elem != NULL, "elem == NULL\n");
6654 test_form_length((IUnknown*)elem, 0);
6655 IHTMLElement_Release(elem);
6658 test_stylesheets(doc);
6659 test_create_option_elem(doc);
6660 test_create_img_elem(doc);
6662 elem = get_doc_elem_by_id(doc, "tbl");
6663 ok(elem != NULL, "elem = NULL\n");
6664 test_elem_set_innertext(elem, "inner text");
6665 IHTMLElement_Release(elem);
6667 test_doc_title(doc, "test");
6668 test_doc_set_title(doc, "test title");
6669 test_doc_title(doc, "test title");
6672 hres = IHTMLDocument2_get_Script(doc, &disp);
6673 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6676 IDispatchEx *dispex;
6677 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6678 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6682 BSTR str = a2bstr("Testing");
6683 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6684 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6685 ok(pid != -1, "pid == -1\n");
6687 IDispatchEx_Release(dispex);
6690 IDispatch_Release(disp);
6692 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6693 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6695 str = a2bstr("img");
6696 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6697 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6701 static const elem_type_t img_types[] = { ET_IMG };
6703 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6704 IHTMLElementCollection_Release(col);
6707 elem = get_doc_elem_by_id(doc, "y");
6708 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6709 test_elem_innerhtml((IUnknown*)elem, "inner html");
6710 test_elem_set_innerhtml((IUnknown*)elem, "");
6711 test_elem_innerhtml((IUnknown*)elem, NULL);
6712 node = node_get_next((IUnknown*)elem);
6713 ok(!node, "node = %p\n", node);
6715 elem2 = get_doc_elem_by_id(doc, "x");
6716 test_elem_tag((IUnknown*)elem2, "A");
6717 node = node_get_next((IUnknown*)elem2);
6718 IHTMLDOMNode_Release(node);
6719 IHTMLElement_Release(elem2);
6720 IHTMLElement_Release(elem);
6722 IHTMLDocument3_Release(doc3);
6724 elem = get_elem_by_id(doc, "s", TRUE);
6726 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6728 test_select_put_length((IUnknown*)elem, 3);
6729 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6730 test_select_put_length((IUnknown*)elem, 1);
6731 test_elem_all((IUnknown*)elem, select_types, 1);
6732 IHTMLElement_Release(elem);
6735 window = get_doc_window(doc);
6736 test_window_name(window, NULL);
6737 set_window_name(window, "test name");
6738 test_window_length(window, 1);
6739 IHTMLWindow2_Release(window);
6742 static void test_attr(IHTMLElement *elem)
6744 IHTMLDOMAttribute *attr, *attr2;
6746 get_elem_attr_node((IUnknown*)elem, "noattr", FALSE);
6748 attr = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6750 test_disp((IUnknown*)attr, &DIID_DispHTMLDOMAttribute, "[object]");
6751 test_ifaces((IUnknown*)attr, attr_iids);
6752 test_no_iface((IUnknown*)attr, &IID_IHTMLDOMNode);
6754 attr2 = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6756 ok(iface_cmp((IUnknown*)attr, (IUnknown*)attr2), "attr != attr2\n");
6757 IHTMLDOMAttribute_Release(attr2);
6759 test_attr_node_value(attr, "divid");
6761 IHTMLDOMAttribute_Release(attr);
6763 attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
6764 test_attr_node_value(attr, NULL);
6765 IHTMLDOMAttribute_Release(attr);
6768 static void test_elems2(IHTMLDocument2 *doc)
6770 IHTMLElement *elem, *elem2, *div;
6772 static const elem_type_t outer_types[] = {
6777 div = get_doc_elem_by_id(doc, "divid");
6779 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6780 elem2 = get_doc_elem_by_id(doc, "innerid");
6781 ok(elem2 != NULL, "elem2 == NULL\n");
6782 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6783 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6784 IHTMLElement_Release(elem2);
6786 elem2 = get_doc_elem_by_id(doc, "aid");
6787 ok(elem2 != NULL, "elem2 == NULL\n");
6788 test_elem_set_outerhtml((IUnknown*)elem2, "");
6789 test_elem_all((IUnknown*)div, outer_types, 1);
6790 IHTMLElement_Release(elem2);
6792 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6793 elem = get_elem_by_id(doc, "ta", TRUE);
6795 test_textarea_value((IUnknown*)elem, NULL);
6796 test_textarea_put_value((IUnknown*)elem, "test");
6797 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6798 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6799 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6800 test_textarea_type((IUnknown*)elem);
6801 IHTMLElement_Release(elem);
6804 test_elem_set_innerhtml((IUnknown*)div,
6805 "<form id=\"form\"><input type=\"button\"></input><input type=\"text\"></input></textarea>");
6806 elem = get_elem_by_id(doc, "form", TRUE);
6808 test_form_length((IUnknown*)elem, 2);
6809 test_form_item(elem);
6810 test_form_action((IUnknown*)elem, NULL);
6811 test_form_put_action((IUnknown*)elem, "about:blank");
6812 test_form_method((IUnknown*)elem, "get");
6813 test_form_put_method((IUnknown*)elem, S_OK, "post");
6814 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
6815 test_form_method((IUnknown*)elem, "post");
6816 test_form_name((IUnknown*)elem, NULL);
6817 test_form_put_name((IUnknown*)elem, "Name");
6818 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
6819 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
6820 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
6821 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
6822 test_form_encoding((IUnknown*)elem, "multipart/form-data");
6823 IHTMLElement_Release(elem);
6827 test_style_filters(div);
6829 IHTMLElement_Release(div);
6832 static void test_create_elems(IHTMLDocument2 *doc)
6834 IHTMLElement *elem, *body, *elem2;
6835 IHTMLDOMNode *node, *node2, *node3, *comment;
6836 IHTMLDocument5 *doc5;
6843 static const elem_type_t types1[] = { ET_TESTG };
6845 elem = test_create_elem(doc, "TEST");
6846 test_elem_tag((IUnknown*)elem, "TEST");
6847 type = get_node_type((IUnknown*)elem);
6848 ok(type == 1, "type=%d\n", type);
6849 test_ifaces((IUnknown*)elem, elem_iids);
6850 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6852 body = doc_get_body(doc);
6853 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6855 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6856 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6857 elem2 = get_elem_iface((IUnknown*)node);
6858 IHTMLElement_Release(elem2);
6860 hres = IHTMLElement_get_all(body, &disp);
6861 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6862 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6863 IDispatch_Release(disp);
6865 test_node_remove_child((IUnknown*)body, node);
6867 hres = IHTMLElement_get_all(body, &disp);
6868 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6869 test_elem_collection((IUnknown*)disp, NULL, 0);
6870 IDispatch_Release(disp);
6871 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6873 IHTMLElement_Release(elem);
6874 IHTMLDOMNode_Release(node);
6876 node = test_create_text(doc, "test");
6877 test_ifaces((IUnknown*)node, text_iids);
6878 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6879 test_text_length((IUnknown*)node, 4);
6881 V_VT(&var) = VT_NULL;
6882 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6883 IHTMLDOMNode_Release(node);
6885 node = test_create_text(doc, "insert ");
6887 V_VT(&var) = VT_DISPATCH;
6888 V_DISPATCH(&var) = (IDispatch*)node2;
6889 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6890 IHTMLDOMNode_Release(node);
6891 IHTMLDOMNode_Release(node2);
6892 IHTMLDOMNode_Release(node3);
6894 test_elem_innertext(body, "insert test");
6895 test_elem_innerhtml((IUnknown*)body, "insert test");
6897 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6900 str = a2bstr("testing");
6901 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6903 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6906 type = get_node_type((IUnknown*)comment);
6907 ok(type == 8, "type=%d, expected 8\n", type);
6909 test_node_get_value_str((IUnknown*)comment, "testing");
6910 test_elem_title((IUnknown*)comment, NULL);
6911 test_elem_set_title((IUnknown*)comment, "comment title");
6912 test_elem_title((IUnknown*)comment, "comment title");
6913 test_comment_text((IUnknown*)comment, "<!--testing-->");
6914 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6916 IHTMLDOMNode_Release(comment);
6919 IHTMLDocument5_Release(doc5);
6922 IHTMLElement_Release(body);
6925 static void test_null_write(IHTMLDocument2 *doc)
6929 doc_write(doc, FALSE, NULL);
6930 doc_write(doc, TRUE, NULL);
6932 hres = IHTMLDocument2_write(doc, NULL);
6934 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6936 hres = IHTMLDocument2_writeln(doc, NULL);
6938 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
6941 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
6943 IOleCommandTarget *cmdtrg;
6946 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6947 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
6949 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
6950 ok(hres == S_OK, "Exec failed: %08x\n", hres);
6952 IOleCommandTarget_Release(cmdtrg);
6955 static void test_indent(IHTMLDocument2 *doc)
6957 IHTMLElementCollection *col;
6958 IHTMLTxtRange *range;
6961 static const elem_type_t all_types[] = {
6970 static const elem_type_t indent_types[] = {
6981 hres = IHTMLDocument2_get_all(doc, &col);
6982 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6983 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6984 IHTMLElementCollection_Release(col);
6986 range = test_create_body_range(doc);
6987 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
6988 IHTMLTxtRange_Release(range);
6990 hres = IHTMLDocument2_get_all(doc, &col);
6991 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6992 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
6993 IHTMLElementCollection_Release(col);
6996 static void test_cond_comment(IHTMLDocument2 *doc)
6998 IHTMLElementCollection *col;
7001 static const elem_type_t all_types[] = {
7009 hres = IHTMLDocument2_get_all(doc, &col);
7010 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7011 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7012 IHTMLElementCollection_Release(col);
7015 static void test_frame(IDispatch *disp, const char *exp_id)
7017 IHTMLWindow2 *frame2, *parent, *top;
7018 IHTMLDocument2 *parent_doc, *top_doc;
7019 IHTMLWindow4 *frame;
7020 IHTMLFrameBase *frame_elem;
7023 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
7024 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
7028 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
7029 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
7030 IHTMLWindow4_Release(frame);
7034 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
7035 test_frame_doc((IUnknown*)frame_elem, FALSE);
7036 test_elem_id((IUnknown*)frame_elem, exp_id);
7037 IHTMLElement_Release(frame_elem);
7039 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
7040 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
7044 hres = IHTMLWindow2_get_parent(frame2, &parent);
7045 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
7047 IHTMLWindow2_Release(frame2);
7051 hres = IHTMLWindow2_get_document(parent, &parent_doc);
7052 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7053 IHTMLWindow2_Release(parent);
7055 IHTMLWindow2_Release(frame2);
7059 test_doc_title(parent_doc, "frameset test");
7060 IHTMLDocument2_Release(parent_doc);
7063 hres = IHTMLWindow2_get_top(frame2, &top);
7064 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
7065 IHTMLWindow2_Release(frame2);
7069 hres = IHTMLWindow2_get_document(top, &top_doc);
7070 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7071 IHTMLWindow2_Release(top);
7075 test_doc_title(top_doc, "frameset test");
7076 IHTMLDocument2_Release(top_doc);
7079 static void test_frameset(IHTMLDocument2 *doc)
7081 IHTMLWindow2 *window;
7082 IHTMLFramesCollection2 *frames;
7084 IHTMLFrameBase *fbase;
7086 VARIANT index_var, result_var;
7090 window = get_doc_window(doc);
7092 /* test using IHTMLFramesCollection object */
7094 hres = IHTMLWindow2_get_frames(window, &frames);
7095 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
7096 IHTMLWindow2_Release(window);
7100 /* test result length */
7101 hres = IHTMLFramesCollection2_get_length(frames, &length);
7102 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
7103 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
7105 /* test first frame */
7106 V_VT(&index_var) = VT_I4;
7107 V_I4(&index_var) = 0;
7108 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7109 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7110 if(SUCCEEDED(hres)) {
7111 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7112 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7114 VariantClear(&result_var);
7116 /* test second frame */
7117 V_I4(&index_var) = 1;
7118 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7119 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7120 if(SUCCEEDED(hres)) {
7121 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7122 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7124 VariantClear(&result_var);
7126 /* fail on next frame */
7127 V_I4(&index_var) = 3;
7128 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7129 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
7130 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7131 VariantClear(&result_var);
7133 /* string argument (element id lookup) */
7134 V_VT(&index_var) = VT_BSTR;
7135 V_BSTR(&index_var) = a2bstr("fr1");
7136 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7137 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7138 if(SUCCEEDED(hres)) {
7139 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7140 test_frame(V_DISPATCH(&result_var), "fr1");
7142 VariantClear(&result_var);
7143 VariantClear(&index_var);
7145 /* invalid argument */
7146 V_VT(&index_var) = VT_BOOL;
7147 V_BOOL(&index_var) = VARIANT_TRUE;
7148 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7149 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
7150 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7151 VariantClear(&result_var);
7153 IHTMLFramesCollection2_Release(frames);
7155 /* test using IHTMLWindow2 inheritance */
7157 /* test result length */
7158 hres = IHTMLWindow2_get_length(window, &length);
7159 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
7160 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
7162 /* test first frame */
7163 V_VT(&index_var) = VT_I4;
7164 V_I4(&index_var) = 0;
7165 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7166 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7167 if(SUCCEEDED(hres)) {
7168 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7169 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7171 VariantClear(&result_var);
7173 /* test second frame */
7174 V_I4(&index_var) = 1;
7175 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7176 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7177 if(SUCCEEDED(hres)) {
7178 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7179 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7181 VariantClear(&result_var);
7183 /* fail on next frame */
7184 V_I4(&index_var) = 3;
7185 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7186 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
7187 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7188 VariantClear(&result_var);
7190 /* string argument (element id lookup) */
7191 V_VT(&index_var) = VT_BSTR;
7192 V_BSTR(&index_var) = a2bstr("fr2");
7193 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7194 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7195 if(SUCCEEDED(hres)) {
7196 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7197 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7199 VariantClear(&result_var);
7200 VariantClear(&index_var);
7202 /* invalid argument */
7203 V_VT(&index_var) = VT_BOOL;
7204 V_BOOL(&index_var) = VARIANT_TRUE;
7205 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7206 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
7207 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7208 VariantClear(&result_var);
7210 /* getElementById with node name attributes */
7211 elem = get_doc_elem_by_id(doc, "nm1");
7212 test_elem_id((IUnknown*)elem, "fr1");
7214 /* get/put scrolling */
7215 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7216 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7218 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7219 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7220 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
7224 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7225 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
7228 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7229 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7230 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7233 str = a2bstr("junk");
7234 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7235 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
7236 "with E_INVALIDARG, instead: 0x%08x\n", hres);
7239 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7240 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7241 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7245 hres = IHTMLFrameBase_get_name(fbase, &str);
7246 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7247 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
7250 IHTMLFrameBase_Release(fbase);
7251 IHTMLElement_Release(elem);
7253 /* get_name with no name attr */
7254 elem = get_doc_elem_by_id(doc, "fr3");
7255 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7256 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7258 hres = IHTMLFrameBase_get_name(fbase, &str);
7259 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7260 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
7263 IHTMLFrameBase_Release(fbase);
7264 IHTMLElement_Release(elem);
7267 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
7269 IHTMLDocument2 *frag;
7270 IHTMLDocument3 *doc3;
7273 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
7274 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
7276 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
7277 IHTMLDocument3_Release(doc3);
7278 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
7279 ok(frag != NULL, "frag == NULL\n");
7284 static void test_docfrag(IHTMLDocument2 *doc)
7286 IHTMLElement *div, *body, *br;
7287 IHTMLElementCollection *col;
7288 IHTMLLocation *location;
7289 IHTMLDocument2 *frag;
7292 static const elem_type_t all_types[] = {
7301 frag = create_docfrag(doc);
7303 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
7305 body = (void*)0xdeadbeef;
7306 hres = IHTMLDocument2_get_body(frag, &body);
7307 ok(hres == S_OK, "get_body failed: %08x\n", hres);
7308 ok(!body, "body != NULL\n");
7310 location = (void*)0xdeadbeef;
7311 hres = IHTMLDocument2_get_location(frag, &location);
7312 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
7313 ok(location == (void*)0xdeadbeef, "location changed\n");
7315 br = test_create_elem(doc, "BR");
7316 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
7317 IHTMLElement_Release(br);
7319 div = get_elem_by_id(doc, "divid", TRUE);
7320 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
7321 IHTMLElement_Release(div);
7323 hres = IHTMLDocument2_get_all(doc, &col);
7324 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7325 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7326 IHTMLElementCollection_Release(col);
7328 IHTMLDocument2_Release(frag);
7331 static IHTMLDocument2 *notif_doc;
7332 static BOOL doc_complete;
7334 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
7335 REFIID riid, void**ppv)
7337 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
7342 ok(0, "unexpected call\n");
7343 return E_NOINTERFACE;
7346 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
7351 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
7356 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
7358 if(dispID == DISPID_READYSTATE){
7362 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
7363 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
7365 if(!strcmp_wa(state, "complete"))
7366 doc_complete = TRUE;
7368 SysFreeString(state);
7374 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
7376 ok(0, "unexpected call\n");
7380 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
7381 PropertyNotifySink_QueryInterface,
7382 PropertyNotifySink_AddRef,
7383 PropertyNotifySink_Release,
7384 PropertyNotifySink_OnChanged,
7385 PropertyNotifySink_OnRequestEdit
7388 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
7390 static IHTMLDocument2 *create_doc_with_string(const char *str)
7392 IPersistStreamInit *init;
7394 IHTMLDocument2 *doc;
7398 notif_doc = doc = create_document();
7402 doc_complete = FALSE;
7404 mem = GlobalAlloc(0, len);
7405 memcpy(mem, str, len);
7406 CreateStreamOnHGlobal(mem, TRUE, &stream);
7408 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
7410 IPersistStreamInit_Load(init, stream);
7411 IPersistStreamInit_Release(init);
7412 IStream_Release(stream);
7417 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
7419 IConnectionPointContainer *container;
7420 IConnectionPoint *cp;
7424 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
7425 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
7427 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
7428 IConnectionPointContainer_Release(container);
7429 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
7431 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
7432 IConnectionPoint_Release(cp);
7433 ok(hres == S_OK, "Advise failed: %08x\n", hres);
7436 typedef void (*domtest_t)(IHTMLDocument2*);
7438 static void run_domtest(const char *str, domtest_t test)
7440 IHTMLDocument2 *doc;
7444 doc = create_doc_with_string(str);
7448 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
7450 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
7451 TranslateMessage(&msg);
7452 DispatchMessage(&msg);
7457 ref = IHTMLDocument2_Release(doc);
7458 ok(!ref || broken(ref == 1), /* Vista */
7466 run_domtest(doc_str1, test_doc_elem);
7467 run_domtest(doc_str1, test_get_set_attr);
7468 run_domtest(range_test_str, test_txtrange);
7469 run_domtest(range_test2_str, test_txtrange2);
7470 if (winetest_interactive || ! is_ie_hardened()) {
7471 run_domtest(elem_test_str, test_elems);
7473 skip("IE running in Enhanced Security Configuration\n");
7475 run_domtest(elem_test2_str, test_elems2);
7476 run_domtest(doc_blank, test_create_elems);
7477 run_domtest(doc_blank, test_defaults);
7478 run_domtest(doc_blank, test_null_write);
7479 run_domtest(indent_test_str, test_indent);
7480 run_domtest(cond_comment_str, test_cond_comment);
7481 run_domtest(frameset_str, test_frameset);
7482 run_domtest(emptydiv_str, test_docfrag);