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_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1128 static void _test_anchor_get_target(unsigned line, IUnknown *unk, const char *target)
1130 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1134 hres = IHTMLAnchorElement_get_target(anchor, &str);
1135 ok_(__FILE__,line)(hres == S_OK, "get_target failed: %08x\n", hres);
1137 ok_(__FILE__,line)(!strcmp_wa(str, target), "target = %s, expected %s\n", wine_dbgstr_w(str), target);
1139 ok_(__FILE__,line)(str == NULL, "target = %s, expected NULL\n", wine_dbgstr_w(str));
1143 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1144 static void _test_anchor_put_target(unsigned line, IUnknown *unk, const char *target)
1146 IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk);
1150 str = target ? a2bstr(target) : NULL;
1151 hres = IHTMLAnchorElement_put_target(anchor, str);
1152 ok_(__FILE__,line)(hres == S_OK, "put_target failed: %08x\n", hres);
1157 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1158 static void _test_option_text(unsigned line, IHTMLOptionElement *option, const char *text)
1163 hres = IHTMLOptionElement_get_text(option, &bstr);
1164 ok_(__FILE__,line) (hres == S_OK, "get_text failed: %08x\n", hres);
1165 ok_(__FILE__,line) (!strcmp_wa(bstr, text), "text=%s\n", wine_dbgstr_w(bstr));
1166 SysFreeString(bstr);
1169 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1170 static void _test_option_put_text(unsigned line, IHTMLOptionElement *option, const char *text)
1175 bstr = a2bstr(text);
1176 hres = IHTMLOptionElement_put_text(option, bstr);
1177 SysFreeString(bstr);
1178 ok(hres == S_OK, "put_text failed: %08x\n", hres);
1180 _test_option_text(line, option, text);
1183 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1184 static void _test_option_value(unsigned line, IHTMLOptionElement *option, const char *value)
1189 hres = IHTMLOptionElement_get_value(option, &bstr);
1190 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1191 ok_(__FILE__,line) (!strcmp_wa(bstr, value), "value=%s\n", wine_dbgstr_w(bstr));
1192 SysFreeString(bstr);
1195 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1196 static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, const char *value)
1201 bstr = a2bstr(value);
1202 hres = IHTMLOptionElement_put_value(option, bstr);
1203 SysFreeString(bstr);
1204 ok(hres == S_OK, "put_value failed: %08x\n", hres);
1206 _test_option_value(line, option, value);
1209 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1210 static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
1212 VARIANT_BOOL b = 0x100;
1215 hres = IHTMLOptionElement_get_selected(option, &b);
1216 ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
1217 ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
1220 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1221 static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
1225 hres = IHTMLOptionElement_put_selected(option, b);
1226 ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
1227 _test_option_selected(line, option, b);
1230 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1231 static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
1233 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1234 BSTR value = (void*)0xdeadbeef;
1237 hres = IHTMLTextAreaElement_get_value(textarea, &value);
1238 IHTMLTextAreaElement_Release(textarea);
1239 ok_(__FILE__,line)(hres == S_OK, "get_value failed: %08x\n", hres);
1241 ok_(__FILE__,line)(!strcmp_wa(value, exval), "value = %s, expected %s\n", wine_dbgstr_w(value), exval);
1243 ok_(__FILE__,line)(!value, "value = %p\n", value);
1244 SysFreeString(value);
1247 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1248 static void _test_textarea_put_value(unsigned line, IUnknown *unk, const char *value)
1250 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1251 BSTR tmp = a2bstr(value);
1254 hres = IHTMLTextAreaElement_put_value(textarea, tmp);
1255 IHTMLTextAreaElement_Release(textarea);
1256 ok_(__FILE__,line)(hres == S_OK, "put_value failed: %08x\n", hres);
1259 _test_textarea_value(line, unk, value);
1262 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1263 static void _test_textarea_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL ex)
1265 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1266 VARIANT_BOOL b = 0x100;
1269 hres = IHTMLTextAreaElement_get_readOnly(textarea, &b);
1270 IHTMLTextAreaElement_Release(textarea);
1271 ok_(__FILE__,line)(hres == S_OK, "get_readOnly failed: %08x\n", hres);
1272 ok_(__FILE__,line)(b == ex, "readOnly = %x, expected %x\n", b, ex);
1275 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1276 static void _test_textarea_put_readonly(unsigned line, IUnknown *unk, VARIANT_BOOL b)
1278 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1281 hres = IHTMLTextAreaElement_put_readOnly(textarea, b);
1282 IHTMLTextAreaElement_Release(textarea);
1283 ok_(__FILE__,line)(hres == S_OK, "put_readOnly failed: %08x\n", hres);
1285 _test_textarea_readonly(line, unk, b);
1288 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1289 static void _test_textarea_type(unsigned line, IUnknown *unk)
1291 IHTMLTextAreaElement *textarea = _get_textarea_iface(line, unk);
1292 BSTR type = (void*)0xdeadbeef;
1295 hres = IHTMLTextAreaElement_get_type(textarea, &type);
1296 IHTMLTextAreaElement_Release(textarea);
1297 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
1298 ok_(__FILE__,line)(!strcmp_wa(type, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type));
1299 SysFreeString(type);
1302 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1303 static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
1305 IHTMLCommentElement *comment = _get_comment_iface(__LINE__,unk);
1309 text = a2bstr(extext);
1310 hres = IHTMLCommentElement_get_text(comment, &text);
1311 ok_(__FILE__,line)(hres == S_OK, "get_text failed: %08x\n", hres);
1312 ok_(__FILE__,line)(!strcmp_wa(text, extext), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text), extext);
1314 IHTMLCommentElement_Release(comment);
1315 SysFreeString(text);
1318 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1319 static void _test_object_vspace(unsigned line, IUnknown *unk, LONG exl)
1321 IHTMLObjectElement *object = _get_object_iface(line, unk);
1326 hres = IHTMLObjectElement_get_vspace(object, &l);
1327 ok_(__FILE__,line)(hres == S_OK, "get_vspace failed: %08x\n", hres);
1328 ok_(__FILE__,line)(l == exl, "vspace=%d, expected %d\n", l, exl);
1329 IHTMLObjectElement_Release(object);
1332 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1333 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
1334 const char *txt, const char *val)
1336 IHTMLOptionElementFactory *factory;
1337 IHTMLOptionElement *option;
1338 IHTMLWindow2 *window;
1339 VARIANT text, value, empty;
1342 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1343 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1345 hres = IHTMLWindow2_get_Option(window, &factory);
1346 IHTMLWindow2_Release(window);
1347 ok_(__FILE__,line) (hres == S_OK, "get_Option failed: %08x\n", hres);
1349 V_VT(&text) = VT_BSTR;
1350 V_BSTR(&text) = a2bstr(txt);
1351 V_VT(&value) = VT_BSTR;
1352 V_BSTR(&value) = a2bstr(val);
1353 V_VT(&empty) = VT_EMPTY;
1355 hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
1356 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1358 IHTMLOptionElementFactory_Release(factory);
1359 VariantClear(&text);
1360 VariantClear(&value);
1362 _test_option_text(line, option, txt);
1363 _test_option_value(line, option, val);
1364 _test_option_selected(line, option, VARIANT_FALSE);
1369 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1370 static void _test_img_width(unsigned line, IHTMLImgElement *img, const LONG exp)
1375 hres = IHTMLImgElement_get_width(img, &found);
1376 ok_(__FILE__,line) (hres == S_OK, "get_width failed: %08x\n", hres);
1377 ok_(__FILE__,line) (found == exp, "width=%d\n", found);
1380 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1381 static void _test_img_put_width(unsigned line, IHTMLImgElement *img, const LONG width)
1385 hres = IHTMLImgElement_put_width(img, width);
1386 ok(hres == S_OK, "put_width failed: %08x\n", hres);
1388 _test_img_width(line, img, width);
1391 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1392 static void _test_img_height(unsigned line, IHTMLImgElement *img, const LONG exp)
1397 hres = IHTMLImgElement_get_height(img, &found);
1398 ok_(__FILE__,line) (hres == S_OK, "get_height failed: %08x\n", hres);
1399 ok_(__FILE__,line) (found == exp, "height=%d\n", found);
1402 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1403 static void _test_img_put_height(unsigned line, IHTMLImgElement *img, const LONG height)
1407 hres = IHTMLImgElement_put_height(img, height);
1408 ok(hres == S_OK, "put_height failed: %08x\n", hres);
1410 _test_img_height(line, img, height);
1413 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1414 static IHTMLImgElement *_create_img_elem(unsigned line, IHTMLDocument2 *doc,
1415 LONG wdth, LONG hght)
1417 IHTMLImageElementFactory *factory;
1418 IHTMLImgElement *img;
1419 IHTMLWindow2 *window;
1420 VARIANT width, height;
1424 hres = IHTMLDocument2_get_parentWindow(doc, &window);
1425 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1427 hres = IHTMLWindow2_get_Image(window, &factory);
1428 IHTMLWindow2_Release(window);
1429 ok_(__FILE__,line) (hres == S_OK, "get_Image failed: %08x\n", hres);
1431 test_ifaces((IUnknown*)factory, img_factory_iids);
1432 test_disp((IUnknown*)factory, &IID_IHTMLImageElementFactory, "[object]");
1435 snprintf(buf, 16, "%d", wdth);
1436 V_VT(&width) = VT_BSTR;
1437 V_BSTR(&width) = a2bstr(buf);
1439 V_VT(&width) = VT_EMPTY;
1444 snprintf(buf, 16, "%d", hght);
1445 V_VT(&height) = VT_BSTR;
1446 V_BSTR(&height) = a2bstr(buf);
1448 V_VT(&height) = VT_EMPTY;
1452 hres = IHTMLImageElementFactory_create(factory, width, height, &img);
1453 ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
1455 IHTMLImageElementFactory_Release(factory);
1456 VariantClear(&width);
1457 VariantClear(&height);
1459 if(SUCCEEDED(hres)) {
1460 _test_img_width(line, img, wdth);
1461 _test_img_height(line, img, hght);
1468 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1469 static void _test_select_length(unsigned line, IHTMLSelectElement *select, LONG length)
1471 LONG len = 0xdeadbeef;
1474 hres = IHTMLSelectElement_get_length(select, &len);
1475 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1476 ok_(__FILE__,line) (len == length, "len=%d, expected %d\n", len, length);
1479 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1480 static void _test_select_put_length(unsigned line, IUnknown *unk, LONG length)
1482 IHTMLSelectElement *select = _get_select_iface(line, unk);
1485 hres = IHTMLSelectElement_put_length(select, length);
1486 ok_(__FILE__,line) (hres == S_OK, "put_length failed: %08x\n", hres);
1487 _test_select_length(line, select, length);
1488 IHTMLSelectElement_Release(select);
1491 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1492 static void _test_select_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1494 LONG idx = 0xdeadbeef;
1497 hres = IHTMLSelectElement_get_selectedIndex(select, &idx);
1498 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1499 ok_(__FILE__,line) (idx == index, "idx=%d, expected %d\n", idx, index);
1502 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1503 static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, LONG index)
1507 hres = IHTMLSelectElement_put_selectedIndex(select, index);
1508 ok_(__FILE__,line) (hres == S_OK, "get_selectedIndex failed: %08x\n", hres);
1509 _test_select_selidx(line, select, index);
1512 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1513 static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval)
1518 hres = IHTMLSelectElement_get_value(select, &val);
1519 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
1521 ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", wine_dbgstr_w(val));
1523 ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", wine_dbgstr_w(val));
1527 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1528 static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val)
1534 hres = IHTMLSelectElement_put_value(select, bstr);
1535 SysFreeString(bstr);
1536 ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres);
1539 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1540 static void _test_select_type(unsigned line, IHTMLSelectElement *select, const char *extype)
1545 hres = IHTMLSelectElement_get_type(select, &type);
1546 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
1547 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
1548 SysFreeString(type);
1551 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
1552 static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext)
1557 hres = IHTMLTxtRange_get_text(range, &text);
1558 ok_(__FILE__, line) (hres == S_OK, "get_text failed: %08x\n", hres);
1561 ok_(__FILE__, line) (text != NULL, "text == NULL\n");
1562 ok_(__FILE__, line) (!strcmp_wa(text, extext), "text=%s, expected %s\n", wine_dbgstr_w(text), extext);
1564 ok_(__FILE__, line) (text == NULL, "text=%s, expected NULL\n", wine_dbgstr_w(text));
1567 SysFreeString(text);
1571 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
1572 static void _test_range_collapse(unsigned line, IHTMLTxtRange *range, BOOL b)
1576 hres = IHTMLTxtRange_collapse(range, b);
1577 ok_(__FILE__, line) (hres == S_OK, "collapse failed: %08x\n", hres);
1578 _test_range_text(line, range, NULL);
1581 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
1582 static void _test_range_expand(unsigned line, IHTMLTxtRange *range, LPWSTR unit,
1583 VARIANT_BOOL exb, const char *extext)
1585 VARIANT_BOOL b = 0xe0e0;
1588 hres = IHTMLTxtRange_expand(range, unit, &b);
1589 ok_(__FILE__,line) (hres == S_OK, "expand failed: %08x\n", hres);
1590 ok_(__FILE__,line) (b == exb, "b=%x, expected %x\n", b, exb);
1591 _test_range_text(line, range, extext);
1594 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
1595 static void _test_range_move(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1597 LONG c = 0xdeadbeef;
1600 hres = IHTMLTxtRange_move(range, unit, cnt, &c);
1601 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1602 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1603 _test_range_text(line, range, NULL);
1606 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
1607 static void _test_range_movestart(unsigned line, IHTMLTxtRange *range,
1608 LPWSTR unit, LONG cnt, LONG excnt)
1610 LONG c = 0xdeadbeef;
1613 hres = IHTMLTxtRange_moveStart(range, unit, cnt, &c);
1614 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1615 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1618 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
1619 static void _test_range_moveend(unsigned line, IHTMLTxtRange *range, LPWSTR unit, LONG cnt, LONG excnt)
1621 LONG c = 0xdeadbeef;
1624 hres = IHTMLTxtRange_moveEnd(range, unit, cnt, &c);
1625 ok_(__FILE__,line) (hres == S_OK, "move failed: %08x\n", hres);
1626 ok_(__FILE__,line) (c == excnt, "count=%d, expected %d\n", c, excnt);
1629 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
1630 static void _test_range_put_text(unsigned line, IHTMLTxtRange *range, const char *text)
1633 BSTR bstr = a2bstr(text);
1635 hres = IHTMLTxtRange_put_text(range, bstr);
1636 ok_(__FILE__,line) (hres == S_OK, "put_text failed: %08x\n", hres);
1637 SysFreeString(bstr);
1638 _test_range_text(line, range, NULL);
1641 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
1642 static void _test_range_inrange(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1648 hres = IHTMLTxtRange_inRange(range1, range2, &b);
1649 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1650 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1653 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
1654 static void _test_range_isequal(unsigned line, IHTMLTxtRange *range1, IHTMLTxtRange *range2, VARIANT_BOOL exb)
1660 hres = IHTMLTxtRange_isEqual(range1, range2, &b);
1661 ok_(__FILE__,line) (hres == S_OK, "(1->2) isEqual failed: %08x\n", hres);
1662 ok_(__FILE__,line) (b == exb, "(1->2) b=%x, expected %x\n", b, exb);
1665 hres = IHTMLTxtRange_isEqual(range2, range1, &b);
1666 ok_(__FILE__,line) (hres == S_OK, "(2->1) isEqual failed: %08x\n", hres);
1667 ok_(__FILE__,line) (b == exb, "(2->1) b=%x, expected %x\n", b, exb);
1670 test_range_inrange(range1, range2, VARIANT_TRUE);
1671 test_range_inrange(range2, range1, VARIANT_TRUE);
1675 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
1676 static void _test_range_parent(unsigned line, IHTMLTxtRange *range, elem_type_t type)
1681 hres = IHTMLTxtRange_parentElement(range, &elem);
1682 ok_(__FILE__,line) (hres == S_OK, "parentElement failed: %08x\n", hres);
1684 _test_elem_type(line, (IUnknown*)elem, type);
1686 IHTMLElement_Release(elem);
1689 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1690 static void _test_elem_collection(unsigned line, IUnknown *unk,
1691 const elem_type_t *elem_types, LONG exlen)
1693 IHTMLElementCollection *col;
1696 VARIANT name, index;
1697 IDispatch *disp, *disp2;
1700 hres = IUnknown_QueryInterface(unk, &IID_IHTMLElementCollection, (void**)&col);
1701 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLElementCollection: %08x\n", hres);
1703 test_disp((IUnknown*)col, &DIID_DispHTMLElementCollection, "[object]");
1705 hres = IHTMLElementCollection_get_length(col, &len);
1706 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
1707 ok_(__FILE__,line) (len == exlen, "len=%d, expected %d\n", len, exlen);
1712 V_VT(&index) = VT_EMPTY;
1714 for(i=0; i<len; i++) {
1715 V_VT(&name) = VT_I4;
1717 disp = (void*)0xdeadbeef;
1718 hres = IHTMLElementCollection_item(col, name, index, &disp);
1719 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1720 ok_(__FILE__,line) (disp != NULL, "item returned NULL\n");
1721 if(FAILED(hres) || !disp)
1724 _test_elem_type(line, (IUnknown*)disp, elem_types[i]);
1727 V_VT(&name) = VT_UINT;
1729 disp2 = (void*)0xdeadbeef;
1730 hres = IHTMLElementCollection_item(col, name, index, &disp2);
1731 ok_(__FILE__,line) (hres == S_OK, "item(%d) failed: %08x\n", i, hres);
1732 ok_(__FILE__,line) (iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
1734 IDispatch_Release(disp2);
1737 IDispatch_Release(disp);
1740 V_VT(&name) = VT_I4;
1742 disp = (void*)0xdeadbeef;
1743 hres = IHTMLElementCollection_item(col, name, index, &disp);
1744 ok_(__FILE__,line) (hres == S_OK, "item failed: %08x\n", hres);
1745 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1747 V_VT(&name) = VT_I4;
1749 disp = (void*)0xdeadbeef;
1750 hres = IHTMLElementCollection_item(col, name, index, &disp);
1751 ok_(__FILE__,line) (hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
1752 ok_(__FILE__,line) (disp == NULL, "disp != NULL\n");
1754 IHTMLElementCollection_Release(col);
1757 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
1758 static void _test_elem_all(unsigned line, IUnknown *unk, const elem_type_t *elem_types, LONG exlen)
1760 IHTMLElement *elem = _get_elem_iface(line, unk);
1764 hres = IHTMLElement_get_all(elem, &disp);
1765 IHTMLElement_Release(elem);
1766 ok_(__FILE__,line)(hres == S_OK, "get_all failed: %08x\n", hres);
1768 _test_elem_collection(line, (IUnknown*)disp, elem_types, exlen);
1769 IDispatch_Release(disp);
1772 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1773 static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t type, LONG exlen)
1775 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
1776 IHTMLElementCollection *col = NULL;
1777 elem_type_t *types = NULL;
1782 tmp = a2bstr(elem_type_infos[type].tag);
1783 hres = IHTMLElement2_getElementsByTagName(elem, tmp, &col);
1785 IHTMLElement2_Release(elem);
1786 ok_(__FILE__,line) (hres == S_OK, "getElementByTagName failed: %08x\n", hres);
1787 ok_(__FILE__,line) (col != NULL, "col == NULL\n");
1790 types = HeapAlloc(GetProcessHeap(), 0, exlen*sizeof(elem_type_t));
1791 for(i=0; i<exlen; i++)
1795 _test_elem_collection(line, (IUnknown*)col, types, exlen);
1797 HeapFree(GetProcessHeap(), 0, types);
1800 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1801 static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
1806 hres = IHTMLElement_get_innerText(elem, &text);
1807 ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
1808 ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
1809 wine_dbgstr_w(text), extext);
1810 SysFreeString(text);
1813 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1814 static void _test_elem_set_innertext(unsigned line, IHTMLElement *elem, const char *text)
1816 IHTMLDOMChildrenCollection *col;
1821 hres = IHTMLElement_put_innerText(elem, str);
1822 ok_(__FILE__,line) (hres == S_OK, "put_innerText failed: %08x\n", hres);
1825 _test_elem_innertext(line, elem, text);
1828 col = _get_child_nodes(line, (IUnknown*)elem);
1829 ok(col != NULL, "col == NULL\n");
1831 LONG length = 0, type;
1834 hres = IHTMLDOMChildrenCollection_get_length(col, &length);
1835 ok(hres == S_OK, "get_length failed: %08x\n", hres);
1836 ok(length == 1, "length = %d\n", length);
1838 node = _get_child_item(line, col, 0);
1839 ok(node != NULL, "node == NULL\n");
1841 type = _get_node_type(line, (IUnknown*)node);
1842 ok(type == 3, "type=%d\n", type);
1843 IHTMLDOMNode_Release(node);
1846 IHTMLDOMChildrenCollection_Release(col);
1851 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
1852 static void _test_elem_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1854 IHTMLElement *elem = _get_elem_iface(line, unk);
1858 hres = IHTMLElement_get_innerHTML(elem, &html);
1859 ok_(__FILE__,line)(hres == S_OK, "get_innerHTML failed: %08x\n", hres);
1861 ok_(__FILE__,line)(!strcmp_wa(html, inner_html), "unexpected innerHTML: %s\n", wine_dbgstr_w(html));
1863 ok_(__FILE__,line)(!html, "innerHTML = %s\n", wine_dbgstr_w(html));
1865 IHTMLElement_Release(elem);
1866 SysFreeString(html);
1869 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
1870 static void _test_elem_set_innerhtml(unsigned line, IUnknown *unk, const char *inner_html)
1872 IHTMLElement *elem = _get_elem_iface(line, unk);
1876 html = a2bstr(inner_html);
1877 hres = IHTMLElement_put_innerHTML(elem, html);
1878 ok_(__FILE__,line)(hres == S_OK, "put_innerHTML failed: %08x\n", hres);
1880 IHTMLElement_Release(elem);
1881 SysFreeString(html);
1884 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
1885 static void _test_elem_set_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1887 IHTMLElement *elem = _get_elem_iface(line, unk);
1891 html = a2bstr(outer_html);
1892 hres = IHTMLElement_put_outerHTML(elem, html);
1893 ok_(__FILE__,line)(hres == S_OK, "put_outerHTML failed: %08x\n", hres);
1895 IHTMLElement_Release(elem);
1896 SysFreeString(html);
1899 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
1900 static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer_html)
1902 IHTMLElement *elem = _get_elem_iface(line, unk);
1906 hres = IHTMLElement_get_outerHTML(elem, &html);
1907 ok_(__FILE__,line)(hres == S_OK, "get_outerHTML failed: %08x\n", hres);
1908 ok_(__FILE__,line)(!strcmp_wa(html, outer_html), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html), outer_html);
1910 IHTMLElement_Release(elem);
1911 SysFreeString(html);
1914 #define get_first_child(n) _get_first_child(__LINE__,n)
1915 static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
1917 IHTMLDOMNode *node = _get_node_iface(line, unk);
1918 IHTMLDOMNode *child = NULL;
1921 hres = IHTMLDOMNode_get_firstChild(node, &child);
1922 IHTMLDOMNode_Release(node);
1923 ok_(__FILE__,line) (hres == S_OK, "get_firstChild failed: %08x\n", hres);
1928 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1929 static void _test_node_has_child(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1931 IHTMLDOMNode *node = _get_node_iface(line, unk);
1932 VARIANT_BOOL b = 0xdead;
1935 hres = IHTMLDOMNode_hasChildNodes(node, &b);
1936 ok_(__FILE__,line) (hres == S_OK, "hasChildNodes failed: %08x\n", hres);
1937 ok_(__FILE__,line) (b == exb, "hasChildNodes=%x, expected %x\n", b, exb);
1939 IHTMLDOMNode_Release(node);
1942 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1943 static IHTMLDOMNode *_test_node_get_parent(unsigned line, IUnknown *unk)
1945 IHTMLDOMNode *node = _get_node_iface(line, unk);
1946 IHTMLDOMNode *parent;
1949 hres = IHTMLDOMNode_get_parentNode(node, &parent);
1950 IHTMLDOMNode_Release(node);
1951 ok_(__FILE__,line) (hres == S_OK, "get_parentNode failed: %08x\n", hres);
1956 #define node_get_next(u) _node_get_next(__LINE__,u)
1957 static IHTMLDOMNode *_node_get_next(unsigned line, IUnknown *unk)
1959 IHTMLDOMNode *node = _get_node_iface(line, unk);
1963 hres = IHTMLDOMNode_get_nextSibling(node, &next);
1964 IHTMLDOMNode_Release(node);
1965 ok_(__FILE__,line) (hres == S_OK, "get_nextSiblibg failed: %08x\n", hres);
1970 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1971 static IHTMLElement *_test_elem_get_parent(unsigned line, IUnknown *unk)
1973 IHTMLElement *elem = _get_elem_iface(line, unk);
1974 IHTMLElement *parent;
1977 hres = IHTMLElement_get_parentElement(elem, &parent);
1978 IHTMLElement_Release(elem);
1979 ok_(__FILE__,line) (hres == S_OK, "get_parentElement failed: %08x\n", hres);
1984 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1985 static void _test_elem3_get_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL exb)
1987 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
1988 VARIANT_BOOL disabled = 100;
1992 hres = IHTMLElement3_get_disabled(elem3, &disabled);
1993 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
1994 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
1995 IHTMLElement3_Release(elem3);
1998 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1999 static void _test_elem3_set_disabled(unsigned line, IUnknown *unk, VARIANT_BOOL b)
2001 IHTMLElement3 *elem3 = _get_elem3_iface(line, unk);
2005 hres = IHTMLElement3_put_disabled(elem3, b);
2006 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2008 IHTMLElement3_Release(elem3);
2009 _test_elem3_get_disabled(line, unk, b);
2012 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2013 static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL exb)
2015 VARIANT_BOOL disabled = 100;
2018 hres = IHTMLSelectElement_get_disabled(select, &disabled);
2019 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2020 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2022 _test_elem3_get_disabled(line, (IUnknown*)select, exb);
2025 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2026 static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
2028 IHTMLDOMTextNode *text = _get_text_iface(line, unk);
2032 hres = IHTMLDOMTextNode_get_length(text, &length);
2033 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2034 ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
2035 IHTMLDOMTextNode_Release(text);
2038 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2039 static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
2043 hres = IHTMLSelectElement_put_disabled(select, b);
2044 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2046 _test_select_get_disabled(line, select, b);
2049 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2050 static LONG _elem_get_scroll_height(unsigned line, IUnknown *unk)
2052 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2053 IHTMLTextContainer *txtcont;
2054 LONG l = -1, l2 = -1;
2057 hres = IHTMLElement2_get_scrollHeight(elem, &l);
2058 ok_(__FILE__,line) (hres == S_OK, "get_scrollHeight failed: %08x\n", hres);
2059 IHTMLElement2_Release(elem);
2061 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2062 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2064 hres = IHTMLTextContainer_get_scrollHeight(txtcont, &l2);
2065 IHTMLTextContainer_Release(txtcont);
2066 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2);
2067 ok_(__FILE__,line) (l == l2, "unexpected height %d, expected %d\n", l2, l);
2072 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2073 static LONG _elem_get_scroll_width(unsigned line, IUnknown *unk)
2075 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2076 IHTMLTextContainer *txtcont;
2077 LONG l = -1, l2 = -1;
2080 hres = IHTMLElement2_get_scrollWidth(elem, &l);
2081 ok_(__FILE__,line) (hres == S_OK, "get_scrollWidth failed: %08x\n", hres);
2082 IHTMLElement2_Release(elem);
2084 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2085 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2087 hres = IHTMLTextContainer_get_scrollWidth(txtcont, &l2);
2088 IHTMLTextContainer_Release(txtcont);
2089 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2);
2090 ok_(__FILE__,line) (l == l2, "unexpected width %d, expected %d\n", l2, l);
2095 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2096 static LONG _elem_get_scroll_top(unsigned line, IUnknown *unk)
2098 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2099 IHTMLTextContainer *txtcont;
2100 LONG l = -1, l2 = -1;
2103 hres = IHTMLElement2_get_scrollTop(elem, &l);
2104 ok_(__FILE__,line) (hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2105 IHTMLElement2_Release(elem);
2107 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2108 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2110 hres = IHTMLTextContainer_get_scrollTop(txtcont, &l2);
2111 IHTMLTextContainer_Release(txtcont);
2112 ok_(__FILE__,line) (hres == S_OK, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2);
2113 ok_(__FILE__,line) (l == l2, "unexpected top %d, expected %d\n", l2, l);
2118 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2119 static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
2121 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2122 IHTMLTextContainer *txtcont;
2123 LONG l = -1, l2 = -1;
2126 hres = IHTMLElement2_get_scrollLeft(elem, NULL);
2127 ok(hres == E_INVALIDARG, "expect E_INVALIDARG got 0x%08x\n", hres);
2129 hres = IHTMLElement2_get_scrollLeft(elem, &l);
2130 ok(hres == S_OK, "get_scrollTop failed: %08x\n", hres);
2131 IHTMLElement2_Release(elem);
2133 hres = IUnknown_QueryInterface(unk, &IID_IHTMLTextContainer, (void**)&txtcont);
2134 ok(hres == S_OK, "Could not get IHTMLTextContainer: %08x\n", hres);
2136 hres = IHTMLTextContainer_get_scrollLeft(txtcont, &l2);
2137 IHTMLTextContainer_Release(txtcont);
2138 ok(hres == S_OK, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2);
2139 ok(l == l2, "unexpected left %d, expected %d\n", l2, l);
2142 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
2143 static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
2145 IHTMLImgElement *img = _get_img_iface(line, unk);
2149 hres = IHTMLImgElement_get_src(img, &src);
2150 IHTMLImgElement_Release(img);
2151 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2152 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2156 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2157 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
2159 IHTMLImgElement *img = _get_img_iface(line, unk);
2164 hres = IHTMLImgElement_put_src(img, tmp);
2165 IHTMLImgElement_Release(img);
2167 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2169 _test_img_src(line, unk, src);
2172 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2173 static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
2175 IHTMLImgElement *img = _get_img_iface(line, unk);
2179 hres = IHTMLImgElement_get_alt(img, &alt);
2180 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2182 ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", wine_dbgstr_w(alt));
2184 ok_(__FILE__,line) (!alt, "alt != NULL\n");
2188 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2189 static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
2191 IHTMLImgElement *img = _get_img_iface(line, unk);
2196 hres = IHTMLImgElement_put_alt(img, tmp);
2197 ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
2200 _test_img_alt(line, unk, alt);
2203 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2204 static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue)
2206 IHTMLImgElement *img = _get_img_iface(line, unk);
2210 hres = IHTMLImgElement_get_name(img, &sName);
2211 ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
2212 ok_(__FILE__,line) (!strcmp_wa (sName, pValue), "expected '%s' got '%s'\n", pValue, wine_dbgstr_w(sName));
2213 IHTMLImgElement_Release(img);
2214 SysFreeString(sName);
2217 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
2218 static void _test_input_type(unsigned line, IHTMLInputElement *input, const char *extype)
2223 hres = IHTMLInputElement_get_type(input, &type);
2224 ok_(__FILE__,line) (hres == S_OK, "get_type failed: %08x\n", hres);
2225 ok_(__FILE__,line) (!strcmp_wa(type, extype), "type=%s, expected %s\n", wine_dbgstr_w(type), extype);
2226 SysFreeString(type);
2229 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
2230 static void _test_input_name(unsigned line, IHTMLInputElement *input, const char *exname)
2232 BSTR name = (BSTR)0xdeadbeef;
2235 hres = IHTMLInputElement_get_name(input, &name);
2236 ok_(__FILE__,line) (hres == S_OK, "get_name failed: %08x\n", hres);
2238 ok_(__FILE__,line) (!strcmp_wa (name, exname), "name=%s, expected %s\n", wine_dbgstr_w(name), exname);
2240 ok_(__FILE__,line) (!name, "name=%p, expected NULL\n", name);
2241 SysFreeString(name);
2244 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
2245 static void _test_input_set_name(unsigned line, IHTMLInputElement *input, const char *name)
2247 BSTR tmp = a2bstr(name);
2250 hres = IHTMLInputElement_put_name(input, tmp);
2251 ok_(__FILE__,line) (hres == S_OK, "put_name failed: %08x\n", hres);
2254 _test_input_name(line, input, name);
2257 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
2258 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2260 VARIANT_BOOL disabled = 100;
2263 hres = IHTMLInputElement_get_disabled(input, &disabled);
2264 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2265 ok_(__FILE__,line) (disabled == exb, "disabled=%x, expected %x\n", disabled, exb);
2267 _test_elem3_get_disabled(line, (IUnknown*)input, exb);
2270 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
2271 static void _test_input_set_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2275 hres = IHTMLInputElement_put_disabled(input, b);
2276 ok_(__FILE__,line) (hres == S_OK, "get_disabled failed: %08x\n", hres);
2278 _test_input_get_disabled(line, input, b);
2281 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
2282 static void _test_input_get_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2284 VARIANT_BOOL checked = 100;
2287 hres = IHTMLInputElement_get_defaultChecked(input, &checked);
2288 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2289 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2292 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
2293 static void _test_input_set_defaultchecked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2297 hres = IHTMLInputElement_put_defaultChecked(input, b);
2298 ok_(__FILE__,line) (hres == S_OK, "get_defaultChecked failed: %08x\n", hres);
2300 _test_input_get_defaultchecked(line, input, b);
2303 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
2304 static void _test_input_get_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
2306 VARIANT_BOOL checked = 100;
2309 hres = IHTMLInputElement_get_checked(input, &checked);
2310 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2311 ok_(__FILE__,line) (checked == exb, "checked=%x, expected %x\n", checked, exb);
2314 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
2315 static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VARIANT_BOOL b)
2319 hres = IHTMLInputElement_put_checked(input, b);
2320 ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
2322 _test_input_get_checked(line, input, b);
2325 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
2326 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
2328 IHTMLInputElement *input;
2332 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2333 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2337 hres = IHTMLInputElement_get_value(input, &bstr);
2338 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2340 ok_(__FILE__,line) (!strcmp_wa(bstr, exval), "value=%s\n", wine_dbgstr_w(bstr));
2342 ok_(__FILE__,line) (!bstr, "exval != NULL\n");
2343 SysFreeString(bstr);
2344 IHTMLInputElement_Release(input);
2347 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
2348 static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
2350 IHTMLInputElement *input;
2354 hres = IUnknown_QueryInterface(unk, &IID_IHTMLInputElement, (void**)&input);
2355 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
2360 hres = IHTMLInputElement_put_value(input, bstr);
2361 ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres);
2362 SysFreeString(bstr);
2363 IHTMLInputElement_Release(input);
2365 _test_input_value(line, unk, val);
2368 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
2369 static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc)
2374 hres = IHTMLInputElement_get_src(input, &src);
2375 ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
2377 ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc);
2379 ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src));
2383 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
2384 static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src)
2390 hres = IHTMLInputElement_put_src(input, tmp);
2392 ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
2394 _test_input_src(line, input, src);
2397 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
2398 static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
2400 IHTMLElement *elem = _get_elem_iface(line, unk);
2401 BSTR class = (void*)0xdeadbeef;
2404 hres = IHTMLElement_get_className(elem, &class);
2405 IHTMLElement_Release(elem);
2406 ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
2408 ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", wine_dbgstr_w(class));
2410 ok_(__FILE__,line) (!class, "class != NULL\n");
2411 SysFreeString(class);
2414 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
2415 static void _test_elem_tabindex(unsigned line, IUnknown *unk, short exindex)
2417 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2421 hres = IHTMLElement2_get_tabIndex(elem2, &index);
2422 IHTMLElement2_Release(elem2);
2423 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2424 ok_(__FILE__,line) (index == exindex, "unexpected index %d\n", index);
2427 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
2428 static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
2430 IHTMLElement2 *elem2 = _get_elem2_iface(line, unk);
2433 hres = IHTMLElement2_put_tabIndex(elem2, index);
2434 IHTMLElement2_Release(elem2);
2435 ok_(__FILE__,line) (hres == S_OK, "get_tabIndex failed: %08x\n", hres);
2437 _test_elem_tabindex(line, unk, index);
2440 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
2441 static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
2443 IHTMLStyleElement *style = _get_style_iface(line, unk);
2447 hres = IHTMLStyleElement_get_media(style, &media);
2448 ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
2450 ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
2452 ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
2454 IHTMLStyleElement_Release(style);
2455 SysFreeString(media);
2458 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
2459 static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
2461 IHTMLStyleElement *style = _get_style_iface(line, unk);
2465 str = a2bstr(media);
2466 hres = IHTMLStyleElement_put_media(style, str);
2467 ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
2468 IHTMLStyleElement_Release(style);
2471 _test_style_media(line, unk, media);
2474 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
2475 static void _test_style_type(unsigned line, IUnknown *unk, const char *extype)
2477 IHTMLStyleElement *style = _get_style_iface(line, unk);
2481 hres = IHTMLStyleElement_get_type(style, &type);
2482 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08x\n", hres);
2484 ok_(__FILE__,line)(!strcmp_wa(type, extype), "type = %s, expected %s\n", wine_dbgstr_w(type), extype);
2486 ok_(__FILE__,line)(!type, "type = %s, expected NULL\n", wine_dbgstr_w(type));
2488 IHTMLStyleElement_Release(style);
2489 SysFreeString(type);
2492 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
2493 static void _test_style_put_type(unsigned line, IUnknown *unk, const char *type)
2495 IHTMLStyleElement *style = _get_style_iface(line, unk);
2500 hres = IHTMLStyleElement_put_type(style, str);
2501 ok_(__FILE__,line)(hres == S_OK, "put_type failed: %08x\n", hres);
2502 IHTMLStyleElement_Release(style);
2505 _test_style_type(line, unk, type);
2508 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
2509 static void _test_elem_filters(unsigned line, IUnknown *unk)
2511 IHTMLElement *elem = _get_elem_iface(line, unk);
2513 IHTMLFiltersCollection *filters;
2515 hres = IHTMLElement_get_filters(elem, &filters);
2516 ok_(__FILE__,line) (hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG) /* NT4 */,
2517 "get_filters failed: %08x\n", hres);
2521 IDispatchEx *dispex;
2523 hres = IHTMLFiltersCollection_get_length(filters, &len);
2524 ok_(__FILE__,line) (hres == S_OK, "get_length failed: %08x\n", hres);
2525 ok_(__FILE__,line) (len == 0, "expect 0 got %d\n", len);
2527 hres = IHTMLFiltersCollection_QueryInterface(filters, &IID_IDispatchEx, (void**)&dispex);
2528 ok_(__FILE__,line) (hres == S_OK || broken(hres == E_NOINTERFACE),
2529 "Could not get IDispatchEx interface: %08x\n", hres);
2530 if(SUCCEEDED(hres)) {
2531 test_disp((IUnknown*)filters, &IID_IHTMLFiltersCollection, "[object]");
2532 IDispatchEx_Release(dispex);
2535 IHTMLFiltersCollection_Release(filters);
2538 IHTMLElement_Release(elem);
2541 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
2542 static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class)
2544 IHTMLElement *elem = _get_elem_iface(line, unk);
2548 tmp = class ? a2bstr(class) : NULL;
2549 hres = IHTMLElement_put_className(elem, tmp);
2550 IHTMLElement_Release(elem);
2551 ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres);
2554 _test_elem_class(line, unk, class);
2557 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
2558 static void _test_elem_id(unsigned line, IUnknown *unk, const char *exid)
2560 IHTMLElement *elem = _get_elem_iface(line, unk);
2561 BSTR id = (void*)0xdeadbeef;
2564 hres = IHTMLElement_get_id(elem, &id);
2565 IHTMLElement_Release(elem);
2566 ok_(__FILE__,line) (hres == S_OK, "get_id failed: %08x\n", hres);
2569 ok_(__FILE__,line) (!strcmp_wa(id, exid), "unexpected id %s\n", wine_dbgstr_w(id));
2571 ok_(__FILE__,line) (!id, "id=%s\n", wine_dbgstr_w(id));
2576 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
2577 static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id)
2579 IHTMLElement *elem = _get_elem_iface(line, unk);
2580 BSTR tmp = a2bstr(new_id);
2583 hres = IHTMLElement_put_id(elem, tmp);
2584 IHTMLElement_Release(elem);
2586 ok_(__FILE__,line) (hres == S_OK, "put_id failed: %08x\n", hres);
2588 _test_elem_id(line, unk, new_id);
2591 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
2592 static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle)
2594 IHTMLElement *elem = _get_elem_iface(line, unk);
2598 hres = IHTMLElement_get_title(elem, &title);
2599 IHTMLElement_Release(elem);
2600 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2602 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
2604 ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", wine_dbgstr_w(title));
2606 SysFreeString(title);
2609 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
2610 static void _test_elem_set_title(unsigned line, IUnknown *unk, const char *title)
2612 IHTMLElement *elem = _get_elem_iface(line, unk);
2616 tmp = a2bstr(title);
2617 hres = IHTMLElement_put_title(elem, tmp);
2618 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
2620 IHTMLElement_Release(elem);
2624 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
2625 static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval)
2627 IHTMLDOMNode *node = _get_node_iface(line, unk);
2631 hres = IHTMLDOMNode_get_nodeValue(node, &var);
2632 IHTMLDOMNode_Release(node);
2633 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2636 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2637 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2639 ok_(__FILE__,line) (V_VT(&var) == VT_NULL, "vt=%d, expected VT_NULL\n", V_VT(&var));
2645 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
2646 static void _test_node_put_value_str(unsigned line, IUnknown *unk, const char *val)
2648 IHTMLDOMNode *node = _get_node_iface(line, unk);
2652 V_VT(&var) = VT_BSTR;
2653 V_BSTR(&var) = a2bstr(val);
2655 hres = IHTMLDOMNode_put_nodeValue(node, var);
2656 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2657 IHTMLDOMNode_Release(node);
2661 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
2662 static void _test_elem_client_size(unsigned line, IUnknown *unk)
2664 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2668 hres = IHTMLElement2_get_clientWidth(elem, &l);
2669 ok_(__FILE__,line) (hres == S_OK, "get_clientWidth failed: %08x\n", hres);
2670 hres = IHTMLElement2_get_clientHeight(elem, &l);
2671 ok_(__FILE__,line) (hres == S_OK, "get_clientHeight failed: %08x\n", hres);
2673 IHTMLElement2_Release(elem);
2676 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
2677 static void _test_elem_client_rect(unsigned line, IUnknown *unk)
2679 IHTMLElement2 *elem = _get_elem2_iface(line, unk);
2683 hres = IHTMLElement2_get_clientLeft(elem, &l);
2684 ok_(__FILE__,line) (hres == S_OK, "get_clientLeft failed: %08x\n", hres);
2685 ok_(__FILE__,line) (!l, "clientLeft = %d\n", l);
2687 hres = IHTMLElement2_get_clientTop(elem, &l);
2688 ok_(__FILE__,line) (hres == S_OK, "get_clientTop failed: %08x\n", hres);
2689 ok_(__FILE__,line) (!l, "clientTop = %d\n", l);
2691 IHTMLElement2_Release(elem);
2694 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
2695 static void _test_form_length(unsigned line, IUnknown *unk, LONG exlen)
2697 IHTMLFormElement *form = _get_form_iface(line, unk);
2698 LONG len = 0xdeadbeef;
2701 hres = IHTMLFormElement_get_length(form, &len);
2702 ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
2703 ok_(__FILE__,line)(len == exlen, "length=%d, expected %d\n", len, exlen);
2705 IHTMLFormElement_Release(form);
2708 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
2709 static void _test_form_action(unsigned line, IUnknown *unk, const char *ex)
2711 IHTMLFormElement *form = _get_form_iface(line, unk);
2712 BSTR action = (void*)0xdeadbeef;
2715 hres = IHTMLFormElement_get_action(form, &action);
2716 ok_(__FILE__,line)(hres == S_OK, "get_action failed: %08x\n", hres);
2718 ok_(__FILE__,line)(!strcmp_wa(action, ex), "action=%s, expected %s\n", wine_dbgstr_w(action), ex);
2720 ok_(__FILE__,line)(!action, "action=%p\n", action);
2722 SysFreeString(action);
2723 IHTMLFormElement_Release(form);
2726 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
2727 static void _test_form_put_action(unsigned line, IUnknown *unk, const char *action)
2729 IHTMLFormElement *form = _get_form_iface(line, unk);
2730 BSTR tmp = a2bstr(action);
2733 hres = IHTMLFormElement_put_action(form, tmp);
2734 ok_(__FILE__,line)(hres == S_OK, "put_action failed: %08x\n", hres);
2736 IHTMLFormElement_Release(form);
2738 _test_form_action(line, unk, action);
2741 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
2742 static void _test_form_method(unsigned line, IUnknown *unk, const char *ex)
2744 IHTMLFormElement *form = _get_form_iface(line, unk);
2745 BSTR method = (void*)0xdeadbeef;
2748 hres = IHTMLFormElement_get_method(form, &method);
2749 ok_(__FILE__,line)(hres == S_OK, "get_method failed: %08x\n", hres);
2751 ok_(__FILE__,line)(!strcmp_wa(method, ex), "method=%s, expected %s\n", wine_dbgstr_w(method), ex);
2753 ok_(__FILE__,line)(!method, "method=%p\n", method);
2755 SysFreeString(method);
2756 IHTMLFormElement_Release(form);
2759 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
2760 static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *method)
2762 IHTMLFormElement *form = _get_form_iface(line, unk);
2763 BSTR tmp = a2bstr(method);
2766 hres = IHTMLFormElement_put_method(form, tmp);
2767 ok_(__FILE__,line)(hres == exp_hres, "put_method returned: %08x, expected %08x\n", hres, exp_hres);
2769 IHTMLFormElement_Release(form);
2771 if(exp_hres == S_OK)
2772 _test_form_method(line, unk, method);
2775 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
2776 static void _test_form_name(unsigned line, IUnknown *unk, const char *ex)
2778 IHTMLFormElement *form = _get_form_iface(line, unk);
2779 BSTR name = (void*)0xdeadbeef;
2782 hres = IHTMLFormElement_get_name(form, &name);
2783 ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres);
2785 ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex);
2787 ok_(__FILE__,line)(!name, "name=%p\n", name);
2789 SysFreeString(name);
2790 IHTMLFormElement_Release(form);
2793 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
2794 static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name)
2796 IHTMLFormElement *form = _get_form_iface(line, unk);
2797 BSTR tmp = a2bstr(name);
2800 hres = IHTMLFormElement_put_name(form, tmp);
2801 ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres);
2803 IHTMLFormElement_Release(form);
2805 _test_form_name(line, unk, name);
2808 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
2809 static void _test_form_encoding(unsigned line, IUnknown *unk, const char *ex)
2811 IHTMLFormElement *form = _get_form_iface(line, unk);
2812 BSTR encoding = (void*)0xdeadbeef;
2815 hres = IHTMLFormElement_get_encoding(form, &encoding);
2816 ok_(__FILE__,line)(hres == S_OK, "get_encoding failed: %08x\n", hres);
2818 ok_(__FILE__,line)(!strcmp_wa(encoding, ex), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding), ex);
2820 ok_(__FILE__,line)(!encoding, "encoding=%p\n", encoding);
2822 SysFreeString(encoding);
2823 IHTMLFormElement_Release(form);
2826 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
2827 static void _test_form_put_encoding(unsigned line, IUnknown *unk, HRESULT exp_hres, const char *encoding)
2829 IHTMLFormElement *form = _get_form_iface(line, unk);
2830 BSTR tmp = a2bstr(encoding);
2833 hres = IHTMLFormElement_put_encoding(form, tmp);
2834 ok_(__FILE__,line)(hres == exp_hres, "put_encoding returned: %08x, expected %08x\n", hres, exp_hres);
2836 IHTMLFormElement_Release(form);
2838 if(exp_hres == S_OK)
2839 _test_form_encoding(line, unk, encoding);
2842 #define test_form_elements(a) _test_form_elements(__LINE__,a)
2843 static void _test_form_elements(unsigned line, IUnknown *unk)
2845 IHTMLFormElement *form = _get_form_iface(line, unk);
2850 hres = IHTMLFormElement_get_elements(form, &disp);
2851 ok_(__FILE__,line)(hres == S_OK, "get_elements failed: %08x\n", hres);
2852 ok_(__FILE__,line)(disp != NULL, "disp = NULL\n");
2853 ok_(__FILE__,line)(iface_cmp((IUnknown*)form, (IUnknown*)disp), "disp != form\n");
2855 IDispatch_Release(disp);
2856 IHTMLFormElement_Release(form);
2859 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
2860 static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
2862 IHTMLElement *elem = _get_elem_iface(line, unk);
2863 IHTMLDocument2 *doc;
2868 hres = IHTMLElement_get_document(elem, &disp);
2869 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2870 ok(disp != NULL, "disp == NULL\n");
2872 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&doc);
2873 IDispatch_Release(disp);
2874 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
2879 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
2880 static IHTMLDOMAttribute *_get_elem_attr_node(unsigned line, IUnknown *unk, const char *attr_name, BOOL expect_success)
2882 IHTMLElement4 *elem = _get_elem4_iface(line, unk);
2883 BSTR str = a2bstr(attr_name);
2884 IHTMLDOMAttribute *attr;
2887 attr = (void*)0xdeadbeef;
2888 hres = IHTMLElement4_getAttributeNode(elem, str, &attr);
2889 ok_(__FILE__,line)(hres == S_OK, "getAttributeNode failed: %08x\n", hres);
2891 ok_(__FILE__,line)(attr != NULL, "attr = NULL\n");
2893 ok_(__FILE__,line)(!attr, "attr = %p\n", attr);
2895 IHTMLElement4_Release(elem);
2900 #define test_attr_node_value(a,b) _test_attr_node_value(__LINE__,a,b)
2901 static void _test_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, const char *exval)
2906 hres = IHTMLDOMAttribute_get_nodeValue(attr, &var);
2907 ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
2908 ok_(__FILE__,line) (V_VT(&var) == VT_BSTR, "vt=%d\n", V_VT(&var));
2910 ok_(__FILE__,line) (!strcmp_wa(V_BSTR(&var), exval), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var)));
2912 ok_(__FILE__,line) (!V_BSTR(&var), "nodeValue = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&var)));
2917 #define get_window_doc(e) _get_window_doc(__LINE__,e)
2918 static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
2920 IHTMLDocument2 *doc;
2924 hres = IHTMLWindow2_get_document(window, &doc);
2925 ok(hres == S_OK, "get_document failed: %08x\n", hres);
2926 ok(doc != NULL, "disp == NULL\n");
2931 #define doc_get_body(d) _doc_get_body(__LINE__,d)
2932 static IHTMLElement *_doc_get_body(unsigned line, IHTMLDocument2 *doc)
2937 hres = IHTMLDocument2_get_body(doc, &elem);
2938 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2939 ok_(__FILE__,line)(elem != NULL, "body == NULL\n");
2944 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
2945 static IHTMLElement *_test_create_elem(unsigned line, IHTMLDocument2 *doc, const char *tag)
2947 IHTMLElement *elem = NULL;
2952 hres = IHTMLDocument2_createElement(doc, tmp, &elem);
2953 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2954 ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
2960 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
2961 static IHTMLDOMNode *_test_create_text(unsigned line, IHTMLDocument2 *doc, const char *text)
2963 IHTMLDocument3 *doc3;
2964 IHTMLDOMNode *node = NULL;
2968 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
2969 ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDocument3: %08x\n", hres);
2972 hres = IHTMLDocument3_createTextNode(doc3, tmp, &node);
2973 IHTMLDocument3_Release(doc3);
2975 ok_(__FILE__,line) (hres == S_OK, "createElement failed: %08x\n", hres);
2976 ok_(__FILE__,line) (node != NULL, "node == NULL\n");
2981 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
2982 static IHTMLDOMNode *_test_node_append_child(unsigned line, IUnknown *node_unk, IUnknown *child_unk)
2984 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
2985 IHTMLDOMNode *child = _get_node_iface(line, child_unk);
2986 IHTMLDOMNode *new_child = NULL;
2989 hres = IHTMLDOMNode_appendChild(node, child, &new_child);
2990 ok_(__FILE__,line) (hres == S_OK, "appendChild failed: %08x\n", hres);
2991 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
2992 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
2994 IHTMLDOMNode_Release(node);
2995 IHTMLDOMNode_Release(child);
3000 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
3001 static IHTMLDOMNode *_test_node_insertbefore(unsigned line, IUnknown *node_unk, IHTMLDOMNode *child, VARIANT *var)
3003 IHTMLDOMNode *node = _get_node_iface(line, node_unk);
3004 IHTMLDOMNode *new_child = NULL;
3007 hres = IHTMLDOMNode_insertBefore(node, child, *var, &new_child);
3008 ok_(__FILE__,line) (hres == S_OK, "insertBefore failed: %08x\n", hres);
3009 ok_(__FILE__,line) (new_child != NULL, "new_child == NULL\n");
3010 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
3012 IHTMLDOMNode_Release(node);
3017 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
3018 static void _test_node_remove_child(unsigned line, IUnknown *unk, IHTMLDOMNode *child)
3020 IHTMLDOMNode *node = _get_node_iface(line, unk);
3021 IHTMLDOMNode *new_node = NULL;
3024 hres = IHTMLDOMNode_removeChild(node, child, &new_node);
3025 ok_(__FILE__,line) (hres == S_OK, "removeChild failed: %08x\n", hres);
3026 ok_(__FILE__,line) (new_node != NULL, "new_node == NULL\n");
3027 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
3029 IHTMLDOMNode_Release(node);
3030 IHTMLDOMNode_Release(new_node);
3033 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
3034 static void _test_doc_title(unsigned line, IHTMLDocument2 *doc, const char *extitle)
3039 hres = IHTMLDocument2_get_title(doc, &title);
3040 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3041 ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", wine_dbgstr_w(title));
3042 SysFreeString(title);
3045 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
3046 static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char *title)
3051 tmp = a2bstr(title);
3052 hres = IHTMLDocument2_put_title(doc, tmp);
3053 ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres);
3057 #define test_border_styles(p, n) _test_border_styles(__LINE__, p, n)
3058 static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name)
3063 hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, &Name, 1,
3064 LOCALE_USER_DEFAULT, &dispid);
3065 ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres);
3068 DISPPARAMS params = {NULL,NULL,0,0};
3069 DISPID dispidNamed = DISPID_PROPERTYPUT;
3074 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3075 DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL);
3076 ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres);
3079 params.cNamedArgs = 1;
3080 params.rgdispidNamedArgs = &dispidNamed;
3081 V_VT(&arg) = VT_BSTR;
3082 V_BSTR(&arg) = a2bstr("none");
3083 params.rgvarg = &arg;
3084 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3085 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3086 ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres);
3089 V_VT(&arg) = VT_BSTR;
3090 V_BSTR(&arg) = a2bstr("dotted");
3091 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3092 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3093 ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres);
3096 V_VT(&arg) = VT_BSTR;
3097 V_BSTR(&arg) = a2bstr("dashed");
3098 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3099 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3100 ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres);
3103 V_VT(&arg) = VT_BSTR;
3104 V_BSTR(&arg) = a2bstr("solid");
3105 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3106 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3107 ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres);
3110 V_VT(&arg) = VT_BSTR;
3111 V_BSTR(&arg) = a2bstr("double");
3112 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3113 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3114 ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres);
3117 V_VT(&arg) = VT_BSTR;
3118 V_BSTR(&arg) = a2bstr("groove");
3119 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3120 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3121 ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres);
3124 V_VT(&arg) = VT_BSTR;
3125 V_BSTR(&arg) = a2bstr("ridge");
3126 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3127 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3128 ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres);
3131 V_VT(&arg) = VT_BSTR;
3132 V_BSTR(&arg) = a2bstr("inset");
3133 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3134 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3135 ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres);
3138 V_VT(&arg) = VT_BSTR;
3139 V_BSTR(&arg) = a2bstr("outset");
3140 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3141 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3142 ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres);
3145 V_VT(&arg) = VT_BSTR;
3146 V_BSTR(&arg) = a2bstr("invalid");
3147 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3148 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3149 ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n");
3152 params.rgvarg = &vDefault;
3153 hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
3154 DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL);
3155 ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres);
3156 VariantClear(&vDefault);
3160 #define test_style_csstext(s,t) _test_style_csstext(__LINE__,s,t)
3161 static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *extext)
3163 BSTR text = (void*)0xdeadbeef;
3166 hres = IHTMLStyle_get_cssText(style, &text);
3167 ok_(__FILE__,line)(hres == S_OK, "get_cssText failed: %08x\n", hres);
3169 ok_(__FILE__,line)(!strcmp_wa(text, extext), "cssText = %s\n", wine_dbgstr_w(text));
3171 ok_(__FILE__,line)(!text, "cssText = %s\n", wine_dbgstr_w(text));
3173 SysFreeString(text);
3176 #define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t)
3177 static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text)
3183 hres = IHTMLStyle_put_cssText(style, tmp);
3184 ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres);
3188 static void test_elem_bounding_client_rect(IUnknown *unk)
3190 IHTMLRect *rect, *rect2;
3191 IHTMLElement2 *elem2;
3195 elem2 = get_elem2_iface(unk);
3196 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect);
3197 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3198 hres = IHTMLElement2_getBoundingClientRect(elem2, &rect2);
3199 IHTMLElement2_Release(elem2);
3200 ok(hres == S_OK, "getBoundingClientRect failed: %08x\n", hres);
3201 ok(rect != NULL, "rect == NULL\n");
3202 ok(rect != rect2, "rect == rect2\n");
3203 IHTMLRect_Release(rect2);
3205 test_disp((IUnknown*)rect, &IID_IHTMLRect, "[object]");
3208 hres = IHTMLRect_get_top(rect, &l);
3209 ok(hres == S_OK, "get_top failed: %08x\n", hres);
3210 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3213 hres = IHTMLRect_get_left(rect, &l);
3214 ok(hres == S_OK, "get_left failed: %08x\n", hres);
3215 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3218 hres = IHTMLRect_get_bottom(rect, &l);
3219 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
3220 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3223 hres = IHTMLRect_get_right(rect, &l);
3224 ok(hres == S_OK, "get_right failed: %08x\n", hres);
3225 ok(l != 0xdeadbeef, "l = 0xdeadbeef\n");
3227 IHTMLRect_Release(rect);
3230 static void test_elem_col_item(IHTMLElementCollection *col, const char *n,
3231 const elem_type_t *elem_types, LONG len)
3234 VARIANT name, index;
3238 V_VT(&index) = VT_EMPTY;
3239 V_VT(&name) = VT_BSTR;
3240 V_BSTR(&name) = a2bstr(n);
3242 hres = IHTMLElementCollection_item(col, name, index, &disp);
3243 ok(hres == S_OK, "item failed: %08x\n", hres);
3245 test_elem_collection((IUnknown*)disp, elem_types, len);
3246 IDispatch_Release(disp);
3247 ok(hres == S_OK, "Could not get IHTMLElementCollection interface: %08x\n", hres);
3251 V_VT(&index) = VT_I4;
3253 for(i=0; i<len; i++) {
3255 disp = (void*)0xdeadbeef;
3256 hres = IHTMLElementCollection_item(col, name, index, &disp);
3257 ok(hres == S_OK, "item failed: %08x\n", hres);
3258 ok(disp != NULL, "disp == NULL\n");
3259 if(FAILED(hres) || !disp)
3262 test_elem_type((IUnknown*)disp, elem_types[i]);
3264 IDispatch_Release(disp);
3268 disp = (void*)0xdeadbeef;
3269 hres = IHTMLElementCollection_item(col, name, index, &disp);
3270 ok(hres == S_OK, "item failed: %08x\n", hres);
3271 ok(disp == NULL, "disp != NULL\n");
3274 disp = (void*)0xdeadbeef;
3275 hres = IHTMLElementCollection_item(col, name, index, &disp);
3276 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3277 ok(disp == NULL, "disp != NULL\n");
3280 SysFreeString(V_BSTR(&name));
3283 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const char *id, BOOL expect_success)
3285 IHTMLElementCollection *col;
3287 IDispatch *disp = (void*)0xdeadbeef;
3288 VARIANT name, index;
3291 hres = IHTMLDocument2_get_all(doc, &col);
3292 ok(hres == S_OK, "get_all failed: %08x\n", hres);
3293 ok(col != NULL, "col == NULL\n");
3294 if(FAILED(hres) || !col)
3297 V_VT(&index) = VT_EMPTY;
3298 V_VT(&name) = VT_BSTR;
3299 V_BSTR(&name) = a2bstr(id);
3301 hres = IHTMLElementCollection_item(col, name, index, &disp);
3302 IHTMLElementCollection_Release(col);
3303 SysFreeString(V_BSTR(&name));
3304 ok(hres == S_OK, "item failed: %08x\n", hres);
3305 if(!expect_success) {
3306 ok(disp == NULL, "disp != NULL\n");
3310 ok(disp != NULL, "disp == NULL\n");
3314 elem = get_elem_iface((IUnknown*)disp);
3315 IDispatch_Release(disp);
3320 static IHTMLElement *get_doc_elem_by_id(IHTMLDocument2 *doc, const char *id)
3322 IHTMLDocument3 *doc3;
3327 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
3328 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3331 hres = IHTMLDocument3_getElementById(doc3, tmp, &elem);
3333 ok(hres == S_OK, "getElementById(%s) failed: %08x\n", id, hres);
3335 IHTMLDocument3_Release(doc3);
3340 static void test_select_elem(IHTMLSelectElement *select)
3342 IDispatch *disp, *disp2;
3343 VARIANT name, index;
3346 test_select_type(select, "select-one");
3347 test_select_length(select, 2);
3348 test_select_selidx(select, 0);
3349 test_select_put_selidx(select, 1);
3351 test_select_set_value(select, "val1");
3352 test_select_value(select, "val1");
3354 test_select_get_disabled(select, VARIANT_FALSE);
3355 test_select_set_disabled(select, VARIANT_TRUE);
3356 test_select_set_disabled(select, VARIANT_FALSE);
3359 hres = IHTMLSelectElement_get_options(select, &disp);
3360 ok(hres == S_OK, "get_options failed: %08x\n", hres);
3361 ok(disp != NULL, "options == NULL\n");
3362 ok(iface_cmp((IUnknown*)disp, (IUnknown*)select), "disp != select\n");
3363 IDispatch_Release(disp);
3365 V_VT(&index) = VT_EMPTY;
3366 V_VT(&name) = VT_I4;
3368 disp = (void*)0xdeadbeef;
3369 hres = IHTMLSelectElement_item(select, name, index, &disp);
3370 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3371 ok(!disp, "disp = %p\n", disp);
3374 disp = (void*)0xdeadbeef;
3375 hres = IHTMLSelectElement_item(select, name, index, &disp);
3376 ok(hres == S_OK, "item failed: %08x\n", hres);
3377 ok(!disp, "disp = %p\n", disp);
3380 hres = IHTMLSelectElement_item(select, name, index, NULL);
3381 ok(hres == E_POINTER || broken(hres == E_INVALIDARG), "item failed: %08x, expected E_POINTER\n", hres);
3384 hres = IHTMLSelectElement_item(select, name, index, &disp);
3385 ok(hres == S_OK, "item failed: %08x\n", hres);
3386 ok(disp != NULL, "disp = NULL\n");
3387 test_disp((IUnknown*)disp, &DIID_DispHTMLOptionElement, NULL);
3389 V_VT(&index) = VT_I4;
3392 hres = IHTMLSelectElement_item(select, name, index, &disp2);
3393 ok(hres == S_OK, "item failed: %08x\n", hres);
3394 ok(disp2 != NULL, "disp = NULL\n");
3395 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3396 IDispatch_Release(disp2);
3397 IDispatch_Release(disp);
3400 static void test_form_item(IHTMLElement *elem)
3402 IHTMLFormElement *form = get_form_iface((IUnknown*)elem);
3403 IDispatch *disp, *disp2;
3404 VARIANT name, index;
3407 V_VT(&index) = VT_EMPTY;
3408 V_VT(&name) = VT_I4;
3410 disp = (void*)0xdeadbeef;
3411 hres = IHTMLFormElement_item(form, name, index, &disp);
3412 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3413 ok(!disp, "disp = %p\n", disp);
3416 disp = (void*)0xdeadbeef;
3417 hres = IHTMLFormElement_item(form, name, index, &disp);
3418 ok(hres == S_OK, "item failed: %08x\n", hres);
3419 ok(!disp, "disp = %p\n", disp);
3422 hres = IHTMLFormElement_item(form, name, index, NULL);
3423 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
3426 hres = IHTMLFormElement_item(form, name, index, &disp);
3427 ok(hres == S_OK, "item failed: %08x\n", hres);
3428 ok(disp != NULL, "disp = NULL\n");
3429 test_disp((IUnknown*)disp, &DIID_DispHTMLInputElement, NULL);
3431 V_VT(&index) = VT_I4;
3434 hres = IHTMLFormElement_item(form, name, index, &disp2);
3435 ok(hres == S_OK, "item failed: %08x\n", hres);
3436 ok(disp2 != NULL, "disp = NULL\n");
3437 ok(iface_cmp((IUnknown*)disp, (IUnknown*)disp2), "disp != disp2\n");
3438 IDispatch_Release(disp2);
3439 IDispatch_Release(disp);
3442 static void test_create_option_elem(IHTMLDocument2 *doc)
3444 IHTMLOptionElement *option;
3446 option = create_option_elem(doc, "test text", "test value");
3448 test_option_put_text(option, "new text");
3449 test_option_put_value(option, "new value");
3450 test_option_put_selected(option, VARIANT_TRUE);
3451 test_option_put_selected(option, VARIANT_FALSE);
3453 IHTMLOptionElement_Release(option);
3456 static void test_create_img_elem(IHTMLDocument2 *doc)
3458 IHTMLImgElement *img;
3460 img = create_img_elem(doc, 10, 15);
3463 test_img_put_width(img, 5);
3464 test_img_put_height(img, 20);
3466 IHTMLImgElement_Release(img);
3470 img = create_img_elem(doc, -1, -1);
3473 test_img_put_width(img, 5);
3474 test_img_put_height(img, 20);
3476 IHTMLImgElement_Release(img);
3480 static IHTMLTxtRange *test_create_body_range(IHTMLDocument2 *doc)
3482 IHTMLBodyElement *body;
3483 IHTMLTxtRange *range;
3487 elem = doc_get_body(doc);
3488 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
3489 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3490 IHTMLElement_Release(elem);
3492 hres = IHTMLBodyElement_createTextRange(body, &range);
3493 IHTMLBodyElement_Release(body);
3494 ok(hres == S_OK, "createTextRange failed: %08x\n", hres);
3499 static void test_txtrange(IHTMLDocument2 *doc)
3501 IHTMLTxtRange *body_range, *range, *range2;
3502 IHTMLSelectionObject *selection;
3503 IDispatch *disp_range;
3506 body_range = test_create_body_range(doc);
3508 test_range_text(body_range, "test abc 123\r\nit's text");
3510 hres = IHTMLTxtRange_duplicate(body_range, &range);
3511 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3513 hres = IHTMLTxtRange_duplicate(body_range, &range2);
3514 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3515 test_range_isequal(range, range2, VARIANT_TRUE);
3517 test_range_text(range, "test abc 123\r\nit's text");
3518 test_range_text(body_range, "test abc 123\r\nit's text");
3520 test_range_collapse(range, TRUE);
3521 test_range_isequal(range, range2, VARIANT_FALSE);
3522 test_range_inrange(range, range2, VARIANT_FALSE);
3523 test_range_inrange(range2, range, VARIANT_TRUE);
3524 IHTMLTxtRange_Release(range2);
3526 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3527 test_range_expand(range, wordW, VARIANT_FALSE, "test ");
3528 test_range_move(range, characterW, 2, 2);
3529 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3531 test_range_collapse(range, FALSE);
3532 test_range_expand(range, wordW, VARIANT_TRUE, "abc ");
3534 test_range_collapse(range, FALSE);
3535 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3536 test_range_expand(range, wordW, VARIANT_FALSE, "123");
3537 test_range_move(range, characterW, 2, 2);
3538 test_range_expand(range, wordW, VARIANT_TRUE, "123");
3539 test_range_moveend(range, characterW, -5, -5);
3540 test_range_text(range, NULL);
3541 test_range_moveend(range, characterW, 3, 3);
3542 test_range_text(range, "c 1");
3543 test_range_expand(range, texteditW, VARIANT_TRUE, "test abc 123\r\nit's text");
3544 test_range_collapse(range, TRUE);
3545 test_range_move(range, characterW, 4, 4);
3546 test_range_moveend(range, characterW, 1, 1);
3547 test_range_text(range, " ");
3548 test_range_move(range, wordW, 1, 1);
3549 test_range_moveend(range, characterW, 2, 2);
3550 test_range_text(range, "ab");
3552 IHTMLTxtRange_Release(range);
3554 hres = IHTMLTxtRange_duplicate(body_range, &range);
3555 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3557 test_range_text(range, "test abc 123\r\nit's text");
3558 test_range_move(range, characterW, 3, 3);
3559 test_range_moveend(range, characterW, 1, 1);
3560 test_range_text(range, "t");
3561 test_range_moveend(range, characterW, 3, 3);
3562 test_range_text(range, "t ab");
3563 test_range_moveend(range, characterW, -2, -2);
3564 test_range_text(range, "t ");
3565 test_range_move(range, characterW, 6, 6);
3566 test_range_moveend(range, characterW, 3, 3);
3567 test_range_text(range, "123");
3568 test_range_moveend(range, characterW, 2, 2);
3569 test_range_text(range, "123\r\ni");
3571 IHTMLTxtRange_Release(range);
3573 hres = IHTMLTxtRange_duplicate(body_range, &range);
3574 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3576 test_range_move(range, wordW, 1, 1);
3577 test_range_moveend(range, characterW, 2, 2);
3578 test_range_text(range, "ab");
3580 test_range_move(range, characterW, -2, -2);
3581 test_range_moveend(range, characterW, 2, 2);
3582 test_range_text(range, "t ");
3584 test_range_move(range, wordW, 3, 3);
3585 test_range_move(range, wordW, -2, -2);
3586 test_range_moveend(range, characterW, 2, 2);
3587 test_range_text(range, "ab");
3589 test_range_move(range, characterW, -6, -5);
3590 test_range_moveend(range, characterW, -1, 0);
3591 test_range_moveend(range, characterW, -6, 0);
3592 test_range_move(range, characterW, 2, 2);
3593 test_range_moveend(range, characterW, 2, 2);
3594 test_range_text(range, "st");
3595 test_range_moveend(range, characterW, -6, -4);
3596 test_range_moveend(range, characterW, 2, 2);
3598 IHTMLTxtRange_Release(range);
3600 hres = IHTMLTxtRange_duplicate(body_range, &range);
3601 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3603 test_range_move(range, wordW, 2, 2);
3604 test_range_moveend(range, characterW, 2, 2);
3605 test_range_text(range, "12");
3607 test_range_move(range, characterW, 15, 14);
3608 test_range_move(range, characterW, -2, -2);
3609 test_range_moveend(range, characterW, 3, 2);
3610 test_range_text(range, "t");
3611 test_range_moveend(range, characterW, -1, -1);
3612 test_range_text(range, "t");
3613 test_range_expand(range, wordW, VARIANT_TRUE, "text");
3614 test_range_move(range, characterW, -2, -2);
3615 test_range_moveend(range, characterW, 2, 2);
3616 test_range_text(range, "s ");
3617 test_range_move(range, characterW, 100, 7);
3618 test_range_move(range, wordW, 1, 0);
3619 test_range_move(range, characterW, -2, -2);
3620 test_range_moveend(range, characterW, 3, 2);
3621 test_range_text(range, "t");
3623 IHTMLTxtRange_Release(range);
3625 hres = IHTMLTxtRange_duplicate(body_range, &range);
3626 ok(hres == S_OK, "duplicate failed: %08x\n", hres);
3628 test_range_collapse(range, TRUE);
3629 test_range_expand(range, wordW, VARIANT_TRUE, "test ");
3630 test_range_put_text(range, "word");
3631 test_range_text(body_range, "wordabc 123\r\nit's text");
3632 test_range_text(range, NULL);
3633 test_range_moveend(range, characterW, 3, 3);
3634 test_range_text(range, "abc");
3635 test_range_movestart(range, characterW, -2, -2);
3636 test_range_text(range, "rdabc");
3637 test_range_movestart(range, characterW, 3, 3);
3638 test_range_text(range, "bc");
3639 test_range_movestart(range, characterW, 4, 4);
3640 test_range_text(range, NULL);
3641 test_range_movestart(range, characterW, -3, -3);
3642 test_range_text(range, "c 1");
3643 test_range_movestart(range, characterW, -7, -6);
3644 test_range_text(range, "wordabc 1");
3645 test_range_movestart(range, characterW, 100, 22);
3646 test_range_text(range, NULL);
3648 IHTMLTxtRange_Release(range);
3649 IHTMLTxtRange_Release(body_range);
3651 hres = IHTMLDocument2_get_selection(doc, &selection);
3652 ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
3654 hres = IHTMLSelectionObject_createRange(selection, &disp_range);
3655 ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
3656 IHTMLSelectionObject_Release(selection);
3658 hres = IDispatch_QueryInterface(disp_range, &IID_IHTMLTxtRange, (void **)&range);
3659 ok(hres == S_OK, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres);
3660 IDispatch_Release(disp_range);
3662 test_range_text(range, NULL);
3663 test_range_moveend(range, characterW, 3, 3);
3664 test_range_text(range, "wor");
3665 test_range_parent(range, ET_BODY);
3666 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3667 test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
3668 test_range_move(range, characterW, 3, 3);
3669 test_range_expand(range, wordW, VARIANT_TRUE, "wordabc ");
3670 test_range_moveend(range, characterW, -4, -4);
3671 test_range_put_text(range, "abc def ");
3672 test_range_expand(range, texteditW, VARIANT_TRUE, "abc def abc 123\r\nit's text");
3673 test_range_move(range, wordW, 1, 1);
3674 test_range_movestart(range, characterW, -1, -1);
3675 test_range_text(range, " ");
3676 test_range_move(range, wordW, 1, 1);
3677 test_range_moveend(range, characterW, 3, 3);
3678 test_range_text(range, "def");
3679 test_range_put_text(range, "xyz");
3680 test_range_moveend(range, characterW, 1, 1);
3681 test_range_move(range, wordW, 1, 1);
3682 test_range_moveend(range, characterW, 2, 2);
3683 test_range_text(range, "ab");
3685 IHTMLTxtRange_Release(range);
3688 static void test_txtrange2(IHTMLDocument2 *doc)
3690 IHTMLTxtRange *range;
3692 range = test_create_body_range(doc);
3694 test_range_text(range, "abc\r\n\r\n123\r\n\r\n\r\ndef");
3695 test_range_move(range, characterW, 5, 5);
3696 test_range_moveend(range, characterW, 1, 1);
3697 test_range_text(range, "2");
3698 test_range_move(range, characterW, -3, -3);
3699 test_range_moveend(range, characterW, 3, 3);
3700 test_range_text(range, "c\r\n\r\n1");
3701 test_range_collapse(range, VARIANT_FALSE);
3702 test_range_moveend(range, characterW, 4, 4);
3703 test_range_text(range, "23");
3704 test_range_moveend(range, characterW, 1, 1);
3705 test_range_text(range, "23\r\n\r\n\r\nd");
3706 test_range_moveend(range, characterW, -1, -1);
3707 test_range_text(range, "23");
3708 test_range_moveend(range, characterW, -1, -1);
3709 test_range_text(range, "23");
3710 test_range_moveend(range, characterW, -2, -2);
3711 test_range_text(range, "2");
3713 IHTMLTxtRange_Release(range);
3716 static void test_compatmode(IHTMLDocument2 *doc)
3718 IHTMLDocument5 *doc5;
3722 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
3723 ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres);
3727 hres = IHTMLDocument5_get_compatMode(doc5, &mode);
3728 IHTMLDocument5_Release(doc5);
3729 ok(hres == S_OK, "get_compatMode failed: %08x\n", hres);
3730 ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", wine_dbgstr_w(mode));
3731 SysFreeString(mode);
3734 static void test_location(IHTMLDocument2 *doc)
3736 IHTMLLocation *location, *location2;
3737 IHTMLWindow2 *window;
3742 hres = IHTMLDocument2_get_location(doc, &location);
3743 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3745 hres = IHTMLDocument2_get_location(doc, &location2);
3746 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3748 ok(location == location2, "location != location2\n");
3749 IHTMLLocation_Release(location2);
3751 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3752 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3754 hres = IHTMLWindow2_get_location(window, &location2);
3755 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3756 ok(location == location2, "location != location2\n");
3757 IHTMLLocation_Release(location2);
3759 test_ifaces((IUnknown*)location, location_iids);
3760 test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation, "about:blank");
3762 hres = IHTMLLocation_get_pathname(location, &str);
3763 ok(hres == S_OK, "get_pathname failed: %08x\n", hres);
3764 ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str));
3767 hres = IHTMLLocation_get_href(location, NULL);
3768 ok(hres == E_POINTER, "get_href passed: %08x\n", hres);
3770 hres = IHTMLLocation_get_href(location, &str);
3771 ok(hres == S_OK, "get_href failed: %08x\n", hres);
3772 ok(!strcmp_wa(str, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
3775 ref = IHTMLLocation_Release(location);
3776 ok(!ref, "location chould be destroyed here\n");
3779 static void test_plugins_col(IOmNavigator *nav)
3781 IHTMLPluginsCollection *col, *col2;
3785 hres = IOmNavigator_get_plugins(nav, &col);
3786 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3788 hres = IOmNavigator_get_plugins(nav, &col2);
3789 ok(hres == S_OK, "get_plugins failed: %08x\n", hres);
3790 ok(iface_cmp((IUnknown*)col, (IUnknown*)col2), "col != col2\n");
3791 IHTMLPluginsCollection_Release(col2);
3793 test_disp2((IUnknown*)col, &DIID_DispCPlugins, &IID_IHTMLPluginsCollection, "[object]");
3795 ref = IHTMLPluginsCollection_Release(col);
3796 ok(!ref, "ref=%d\n", ref);
3799 static void test_navigator(IHTMLDocument2 *doc)
3801 IHTMLWindow2 *window;
3802 IOmNavigator *navigator, *navigator2;
3809 static const WCHAR v40[] = {'4','.','0'};
3811 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3812 ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
3814 hres = IHTMLWindow2_get_navigator(window, &navigator);
3815 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3816 ok(navigator != NULL, "navigator == NULL\n");
3817 test_disp2((IUnknown*)navigator, &DIID_DispHTMLNavigator, &IID_IOmNavigator, "[object]");
3819 hres = IHTMLWindow2_get_navigator(window, &navigator2);
3820 ok(hres == S_OK, "get_navigator failed: %08x\n", hres);
3821 ok(navigator != navigator2, "navigator2 != navihgator\n");
3823 IHTMLWindow2_Release(window);
3824 IOmNavigator_Release(navigator2);
3826 hres = IOmNavigator_get_appCodeName(navigator, &bstr);
3827 ok(hres == S_OK, "get_appCodeName failed: %08x\n", hres);
3828 ok(!strcmp_wa(bstr, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3829 SysFreeString(bstr);
3832 hres = IOmNavigator_get_appName(navigator, &bstr);
3833 ok(hres == S_OK, "get_appName failed: %08x\n", hres);
3834 ok(!strcmp_wa(bstr, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr));
3835 SysFreeString(bstr);
3838 hres = IOmNavigator_get_platform(navigator, &bstr);
3839 ok(hres == S_OK, "get_platform failed: %08x\n", hres);
3841 ok(!strcmp_wa(bstr, "Win64") || broken(!strcmp_wa(bstr, "Win32") /* IE6 */), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3843 ok(!strcmp_wa(bstr, "Win32"), "unexpected platform %s\n", wine_dbgstr_w(bstr));
3845 SysFreeString(bstr);
3848 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3849 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3850 ok(!memcmp(bstr, v40, sizeof(v40)), "appVersion is %s\n", wine_dbgstr_w(bstr));
3851 SysFreeString(bstr);
3853 hres = IOmNavigator_toString(navigator, NULL);
3854 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
3857 hres = IOmNavigator_toString(navigator, &bstr);
3858 ok(hres == S_OK, "toString failed: %08x\n", hres);
3859 ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
3860 SysFreeString(bstr);
3863 hres = ObtainUserAgentString(0, buf, &size);
3864 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
3867 hres = IOmNavigator_get_userAgent(navigator, &bstr);
3868 ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
3869 ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
3870 SysFreeString(bstr);
3872 if(!strncmp(buf, "Mozilla/", 8)) {
3874 hres = IOmNavigator_get_appVersion(navigator, &bstr);
3875 ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
3876 ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
3877 SysFreeString(bstr);
3879 skip("nonstandard user agent\n");
3882 test_plugins_col(navigator);
3884 ref = IOmNavigator_Release(navigator);
3885 ok(!ref, "navigator should be destroyed here\n");
3888 static void test_screen(IHTMLWindow2 *window)
3890 IHTMLScreen *screen, *screen2;
3891 IDispatchEx *dispex;
3897 hres = IHTMLWindow2_get_screen(window, &screen);
3898 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3899 ok(screen != NULL, "screen == NULL\n");
3902 hres = IHTMLWindow2_get_screen(window, &screen2);
3903 ok(hres == S_OK, "get_screen failed: %08x\n", hres);
3904 ok(screen2 != NULL, "screen == NULL\n");
3905 ok(iface_cmp((IUnknown*)screen2, (IUnknown*)screen), "screen2 != screen\n");
3906 IHTMLScreen_Release(screen2);
3908 hres = IHTMLScreen_QueryInterface(screen, &IID_IDispatchEx, (void**)&dispex);
3909 ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IDispatchEx interface: %08x\n", hres);
3910 if(SUCCEEDED(hres)) {
3911 test_disp((IUnknown*)screen, &DIID_DispHTMLScreen, "[object]");
3912 IDispatchEx_Release(dispex);
3915 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
3917 exl = GetDeviceCaps(hdc, HORZRES);
3919 hres = IHTMLScreen_get_width(screen, &l);
3920 ok(hres == S_OK, "get_width failed: %08x\n", hres);
3921 ok(l == exl, "width = %d, expected %d\n", l, exl);
3923 exl = GetDeviceCaps(hdc, VERTRES);
3925 hres = IHTMLScreen_get_height(screen, &l);
3926 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3927 ok(l == exl, "height = %d, expected %d\n", l, exl);
3929 exl = GetDeviceCaps(hdc, BITSPIXEL);
3931 hres = IHTMLScreen_get_colorDepth(screen, &l);
3932 ok(hres == S_OK, "get_height failed: %08x\n", hres);
3933 ok(l == exl, "height = %d, expected %d\n", l, exl);
3937 IHTMLScreen_Release(screen);
3940 static void test_current_style(IHTMLCurrentStyle *current_style)
3946 test_disp((IUnknown*)current_style, &DIID_DispHTMLCurrentStyle, "[object]");
3947 test_ifaces((IUnknown*)current_style, cstyle_iids);
3949 hres = IHTMLCurrentStyle_get_display(current_style, &str);
3950 ok(hres == S_OK, "get_display failed: %08x\n", hres);
3951 ok(!strcmp_wa(str, "block"), "get_display returned %s\n", wine_dbgstr_w(str));
3954 hres = IHTMLCurrentStyle_get_position(current_style, &str);
3955 ok(hres == S_OK, "get_position failed: %08x\n", hres);
3956 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
3959 hres = IHTMLCurrentStyle_get_fontFamily(current_style, &str);
3960 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
3963 hres = IHTMLCurrentStyle_get_fontStyle(current_style, &str);
3964 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
3965 ok(!strcmp_wa(str, "normal"), "get_fontStyle returned %s\n", wine_dbgstr_w(str));
3968 hres = IHTMLCurrentStyle_get_backgroundImage(current_style, &str);
3969 ok(hres == S_OK, "get_backgroundImage failed: %08x\n", hres);
3970 ok(!strcmp_wa(str, "none"), "get_backgroundImage returned %s\n", wine_dbgstr_w(str));
3973 hres = IHTMLCurrentStyle_get_fontVariant(current_style, &str);
3974 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
3975 ok(!strcmp_wa(str, "normal"), "get_fontVariant returned %s\n", wine_dbgstr_w(str));
3978 hres = IHTMLCurrentStyle_get_borderTopStyle(current_style, &str);
3979 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
3980 ok(!strcmp_wa(str, "none"), "get_borderTopStyle returned %s\n", wine_dbgstr_w(str));
3983 hres = IHTMLCurrentStyle_get_borderRightStyle(current_style, &str);
3984 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
3985 ok(!strcmp_wa(str, "none"), "get_borderRightStyle returned %s\n", wine_dbgstr_w(str));
3988 hres = IHTMLCurrentStyle_get_borderBottomStyle(current_style, &str);
3989 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
3990 ok(!strcmp_wa(str, "none"), "get_borderBottomStyle returned %s\n", wine_dbgstr_w(str));
3993 hres = IHTMLCurrentStyle_get_borderLeftStyle(current_style, &str);
3994 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
3995 ok(!strcmp_wa(str, "none"), "get_borderLeftStyle returned %s\n", wine_dbgstr_w(str));
3998 hres = IHTMLCurrentStyle_get_textAlign(current_style, &str);
3999 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4000 ok(!strcmp_wa(str, "center"), "get_textAlign returned %s\n", wine_dbgstr_w(str));
4003 hres = IHTMLCurrentStyle_get_textDecoration(current_style, &str);
4004 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4005 ok(!strcmp_wa(str, "none"), "get_textDecoration returned %s\n", wine_dbgstr_w(str));
4008 hres = IHTMLCurrentStyle_get_cursor(current_style, &str);
4009 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4010 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4013 hres = IHTMLCurrentStyle_get_backgroundRepeat(current_style, &str);
4014 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
4015 ok(!strcmp_wa(str, "repeat"), "get_backgroundRepeat returned %s\n", wine_dbgstr_w(str));
4018 hres = IHTMLCurrentStyle_get_borderColor(current_style, &str);
4019 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
4022 hres = IHTMLCurrentStyle_get_borderStyle(current_style, &str);
4023 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
4026 hres = IHTMLCurrentStyle_get_visibility(current_style, &str);
4027 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4030 hres = IHTMLCurrentStyle_get_overflow(current_style, &str);
4031 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4034 hres = IHTMLCurrentStyle_get_borderWidth(current_style, &str);
4035 ok(hres == S_OK, "get_borderWidth failed: %08x\n", hres);
4038 hres = IHTMLCurrentStyle_get_margin(current_style, &str);
4039 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4042 hres = IHTMLCurrentStyle_get_padding(current_style, &str);
4043 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
4046 hres = IHTMLCurrentStyle_get_fontWeight(current_style, &v);
4047 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4048 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4049 ok( V_I4(&v) == 400, "expect 400 got (%d)\n", V_I4(&v));
4052 hres = IHTMLCurrentStyle_get_fontSize(current_style, &v);
4053 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4054 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4057 hres = IHTMLCurrentStyle_get_left(current_style, &v);
4058 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4059 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4062 hres = IHTMLCurrentStyle_get_top(current_style, &v);
4063 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4064 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4067 hres = IHTMLCurrentStyle_get_width(current_style, &v);
4068 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4069 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4072 hres = IHTMLCurrentStyle_get_height(current_style, &v);
4073 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4074 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4077 hres = IHTMLCurrentStyle_get_paddingLeft(current_style, &v);
4078 ok(hres == S_OK, "get_paddingLeft failed: %08x\n", hres);
4079 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4082 hres = IHTMLCurrentStyle_get_zIndex(current_style, &v);
4083 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4084 ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
4085 ok( V_I4(&v) == 1, "expect 1 got (%d)\n", V_I4(&v));
4088 hres = IHTMLCurrentStyle_get_verticalAlign(current_style, &v);
4089 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4090 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4091 ok(!strcmp_wa(V_BSTR(&v), "middle"), "get_verticalAlign returned %s\n", wine_dbgstr_w(V_BSTR(&v)));
4094 hres = IHTMLCurrentStyle_get_marginRight(current_style, &v);
4095 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4096 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4099 hres = IHTMLCurrentStyle_get_marginLeft(current_style, &v);
4100 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4101 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4104 hres = IHTMLCurrentStyle_get_borderLeftWidth(current_style, &v);
4105 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
4106 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4110 hres = IHTMLCurrentStyle_get_borderRightWidth(current_style, &v);
4111 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
4112 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4115 hres = IHTMLCurrentStyle_get_borderBottomWidth(current_style, &v);
4116 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
4117 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4120 hres = IHTMLCurrentStyle_get_borderTopWidth(current_style, &v);
4121 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
4122 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4125 hres = IHTMLCurrentStyle_get_color(current_style, &v);
4126 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4127 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4130 hres = IHTMLCurrentStyle_get_backgroundColor(current_style, &v);
4131 ok(hres == S_OK, "get_backgroundColor failed: %08x\n", hres);
4132 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4135 hres = IHTMLCurrentStyle_get_borderLeftColor(current_style, &v);
4136 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
4137 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4140 hres = IHTMLCurrentStyle_get_borderTopColor(current_style, &v);
4141 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
4142 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4145 hres = IHTMLCurrentStyle_get_borderRightColor(current_style, &v);
4146 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
4147 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4150 hres = IHTMLCurrentStyle_get_borderBottomColor(current_style, &v);
4151 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
4152 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4155 hres = IHTMLCurrentStyle_get_paddingTop(current_style, &v);
4156 ok(hres == S_OK, "get_paddingTop failed: %08x\n", hres);
4157 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4160 hres = IHTMLCurrentStyle_get_paddingRight(current_style, &v);
4161 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4162 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4165 hres = IHTMLCurrentStyle_get_paddingBottom(current_style, &v);
4166 ok(hres == S_OK, "get_paddingRight failed: %08x\n", hres);
4167 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4170 hres = IHTMLCurrentStyle_get_letterSpacing(current_style, &v);
4171 ok(hres == S_OK, "get_letterSpacing failed: %08x\n", hres);
4172 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4175 hres = IHTMLCurrentStyle_get_marginTop(current_style, &v);
4176 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4177 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4180 hres = IHTMLCurrentStyle_get_marginBottom(current_style, &v);
4181 ok(hres == S_OK, "get_marginBottom failed: %08x\n", hres);
4182 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4185 hres = IHTMLCurrentStyle_get_right(current_style, &v);
4186 ok(hres == S_OK, "get_Right failed: %08x\n", hres);
4187 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4190 hres = IHTMLCurrentStyle_get_bottom(current_style, &v);
4191 ok(hres == S_OK, "get_bottom failed: %08x\n", hres);
4192 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4195 hres = IHTMLCurrentStyle_get_lineHeight(current_style, &v);
4196 ok(hres == S_OK, "get_lineHeight failed: %08x\n", hres);
4197 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4200 hres = IHTMLCurrentStyle_get_textIndent(current_style, &v);
4201 ok(hres == S_OK, "get_textIndent failed: %08x\n", hres);
4202 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4206 static void test_style2(IHTMLStyle2 *style2)
4212 str = (void*)0xdeadbeef;
4213 hres = IHTMLStyle2_get_position(style2, &str);
4214 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4215 ok(!str, "str != NULL\n");
4217 str = a2bstr("absolute");
4218 hres = IHTMLStyle2_put_position(style2, str);
4219 ok(hres == S_OK, "put_position failed: %08x\n", hres);
4223 hres = IHTMLStyle2_get_position(style2, &str);
4224 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4225 ok(!strcmp_wa(str, "absolute"), "get_position returned %s\n", wine_dbgstr_w(str));
4229 V_VT(&v) = VT_EMPTY;
4230 hres = IHTMLStyle2_get_right(style2, &v);
4231 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4232 ok(V_VT(&v) == VT_BSTR, "V_VT(right)=%d\n", V_VT(&v));
4233 ok(!V_BSTR(&v), "V_BSTR(right) != NULL\n");
4237 V_BSTR(&v) = a2bstr("3px");
4238 hres = IHTMLStyle2_put_right(style2, v);
4239 ok(hres == S_OK, "put_right failed: %08x\n", hres);
4242 V_VT(&v) = VT_EMPTY;
4243 hres = IHTMLStyle2_get_right(style2, &v);
4244 ok(hres == S_OK, "get_right failed: %08x\n", hres);
4245 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4246 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4250 static void test_style3(IHTMLStyle3 *style3)
4255 str = (void*)0xdeadbeef;
4256 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4257 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4258 ok(!str, "str != NULL\n");
4260 str = a2bstr("break-word");
4261 hres = IHTMLStyle3_put_wordWrap(style3, str);
4262 ok(hres == S_OK, "put_wordWrap failed: %08x\n", hres);
4266 hres = IHTMLStyle3_get_wordWrap(style3, &str);
4267 ok(hres == S_OK, "get_wordWrap failed: %08x\n", hres);
4268 ok(!strcmp_wa(str, "break-word"), "get_wordWrap returned %s\n", wine_dbgstr_w(str));
4272 static void test_style4(IHTMLStyle4 *style4)
4278 hres = IHTMLStyle4_get_minHeight(style4, &vdefault);
4279 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4282 V_BSTR(&v) = a2bstr("10px");
4283 hres = IHTMLStyle4_put_minHeight(style4, v);
4284 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4287 hres = IHTMLStyle4_get_minHeight(style4, &v);
4288 ok(hres == S_OK, "get_minHeight failed: %08x\n", hres);
4289 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
4290 ok( !strcmp_wa(V_BSTR(&v), "10px"), "expect 10px got (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
4293 hres = IHTMLStyle4_put_minHeight(style4, vdefault);
4294 ok(hres == S_OK, "put_minHeight failed: %08x\n", hres);
4295 VariantClear(&vdefault);
4298 static void test_default_style(IHTMLStyle *style)
4300 IHTMLStyle2 *style2;
4301 IHTMLStyle3 *style3;
4302 IHTMLStyle4 *style4;
4308 BSTR sOverflowDefault;
4312 test_disp((IUnknown*)style, &DIID_DispHTMLStyle, "[object]");
4313 test_ifaces((IUnknown*)style, style_iids);
4315 test_style_csstext(style, NULL);
4317 hres = IHTMLStyle_get_position(style, &str);
4318 ok(hres == S_OK, "get_position failed: %08x\n", hres);
4319 ok(!str, "str=%s\n", wine_dbgstr_w(str));
4322 hres = IHTMLStyle_get_marginRight(style, &v);
4323 ok(hres == S_OK, "get_marginRight failed: %08x\n", hres);
4324 ok(V_VT(&v) == VT_BSTR, "V_VT(marginRight) = %d\n", V_VT(&v));
4325 ok(!V_BSTR(&v), "V_BSTR(marginRight) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4328 hres = IHTMLStyle_get_marginLeft(style, &v);
4329 ok(hres == S_OK, "get_marginLeft failed: %08x\n", hres);
4330 ok(V_VT(&v) == VT_BSTR, "V_VT(marginLeft) = %d\n", V_VT(&v));
4331 ok(!V_BSTR(&v), "V_BSTR(marginLeft) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4333 str = (void*)0xdeadbeef;
4334 hres = IHTMLStyle_get_fontFamily(style, &str);
4335 ok(hres == S_OK, "get_fontFamily failed: %08x\n", hres);
4336 ok(!str, "fontFamily = %s\n", wine_dbgstr_w(str));
4338 str = (void*)0xdeadbeef;
4339 hres = IHTMLStyle_get_fontWeight(style, &str);
4340 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4341 ok(!str, "fontWeight = %s\n", wine_dbgstr_w(str));
4343 hres = IHTMLStyle_get_fontWeight(style, &sDefault);
4344 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4346 str = a2bstr("test");
4347 hres = IHTMLStyle_put_fontWeight(style, str);
4348 ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres);
4351 str = a2bstr("bold");
4352 hres = IHTMLStyle_put_fontWeight(style, str);
4353 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4356 str = a2bstr("bolder");
4357 hres = IHTMLStyle_put_fontWeight(style, str);
4358 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4361 str = a2bstr("lighter");
4362 hres = IHTMLStyle_put_fontWeight(style, str);
4363 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4366 str = a2bstr("100");
4367 hres = IHTMLStyle_put_fontWeight(style, str);
4368 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4371 str = a2bstr("200");
4372 hres = IHTMLStyle_put_fontWeight(style, str);
4373 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4376 str = a2bstr("300");
4377 hres = IHTMLStyle_put_fontWeight(style, str);
4378 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4381 str = a2bstr("400");
4382 hres = IHTMLStyle_put_fontWeight(style, str);
4383 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4386 str = a2bstr("500");
4387 hres = IHTMLStyle_put_fontWeight(style, str);
4388 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4391 str = a2bstr("600");
4392 hres = IHTMLStyle_put_fontWeight(style, str);
4393 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4396 str = a2bstr("700");
4397 hres = IHTMLStyle_put_fontWeight(style, str);
4398 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4401 str = a2bstr("800");
4402 hres = IHTMLStyle_put_fontWeight(style, str);
4403 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4406 str = a2bstr("900");
4407 hres = IHTMLStyle_put_fontWeight(style, str);
4408 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4411 hres = IHTMLStyle_get_fontWeight(style, &str);
4412 ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres);
4413 ok(!strcmp_wa(str, "900"), "str != style900\n");
4416 hres = IHTMLStyle_put_fontWeight(style, sDefault);
4417 ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres);
4418 SysFreeString(sDefault);
4421 hres = IHTMLStyle_get_fontVariant(style, NULL);
4422 ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);
4424 hres = IHTMLStyle_get_fontVariant(style, &sDefault);
4425 ok(hres == S_OK, "get_fontVariant failed: %08x\n", hres);
4427 str = a2bstr("test");
4428 hres = IHTMLStyle_put_fontVariant(style, str);
4429 ok(hres == E_INVALIDARG, "fontVariant failed: %08x\n", hres);
4432 str = a2bstr("small-caps");
4433 hres = IHTMLStyle_put_fontVariant(style, str);
4434 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4437 str = a2bstr("normal");
4438 hres = IHTMLStyle_put_fontVariant(style, str);
4439 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4442 hres = IHTMLStyle_put_fontVariant(style, sDefault);
4443 ok(hres == S_OK, "fontVariant failed: %08x\n", hres);
4444 SysFreeString(sDefault);
4446 str = (void*)0xdeadbeef;
4447 hres = IHTMLStyle_get_display(style, &str);
4448 ok(hres == S_OK, "get_display failed: %08x\n", hres);
4449 ok(!str, "display = %s\n", wine_dbgstr_w(str));
4451 str = (void*)0xdeadbeef;
4452 hres = IHTMLStyle_get_visibility(style, &str);
4453 ok(hres == S_OK, "get_visibility failed: %08x\n", hres);
4454 ok(!str, "visibility = %s\n", wine_dbgstr_w(str));
4457 hres = IHTMLStyle_get_fontSize(style, &v);
4458 ok(hres == S_OK, "get_fontSize failed: %08x\n", hres);
4459 ok(V_VT(&v) == VT_BSTR, "V_VT(fontSize) = %d\n", V_VT(&v));
4460 ok(!V_BSTR(&v), "V_BSTR(fontSize) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4463 hres = IHTMLStyle_get_color(style, &v);
4464 ok(hres == S_OK, "get_color failed: %08x\n", hres);
4465 ok(V_VT(&v) == VT_BSTR, "V_VT(color) = %d\n", V_VT(&v));
4466 ok(!V_BSTR(&v), "V_BSTR(color) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4469 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4470 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4471 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4473 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_TRUE);
4474 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4475 ok(b == VARIANT_FALSE, "textDecorationUnderline = %x\n", b);
4477 hres = IHTMLStyle_get_textDecorationUnderline(style, &b);
4478 ok(hres == S_OK, "get_textDecorationUnderline failed: %08x\n", hres);
4479 ok(b == VARIANT_TRUE, "textDecorationUnderline = %x\n", b);
4481 hres = IHTMLStyle_put_textDecorationUnderline(style, VARIANT_FALSE);
4482 ok(hres == S_OK, "put_textDecorationUnderline failed: %08x\n", hres);
4485 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4486 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4487 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4489 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_TRUE);
4490 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4491 ok(b == VARIANT_FALSE, "textDecorationLineThrough = %x\n", b);
4493 hres = IHTMLStyle_get_textDecorationLineThrough(style, &b);
4494 ok(hres == S_OK, "get_textDecorationLineThrough failed: %08x\n", hres);
4495 ok(b == VARIANT_TRUE, "textDecorationLineThrough = %x\n", b);
4497 hres = IHTMLStyle_put_textDecorationLineThrough(style, VARIANT_FALSE);
4498 ok(hres == S_OK, "put_textDecorationLineThrough failed: %08x\n", hres);
4501 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4502 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4503 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4505 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_TRUE);
4506 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4507 ok(b == VARIANT_FALSE, "textDecorationNone = %x\n", b);
4509 hres = IHTMLStyle_get_textDecorationNone(style, &b);
4510 ok(hres == S_OK, "get_textDecorationNone failed: %08x\n", hres);
4511 ok(b == VARIANT_TRUE, "textDecorationNone = %x\n", b);
4513 hres = IHTMLStyle_put_textDecorationNone(style, VARIANT_FALSE);
4514 ok(hres == S_OK, "put_textDecorationNone failed: %08x\n", hres);
4517 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4518 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4519 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4521 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_TRUE);
4522 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4523 ok(b == VARIANT_FALSE, "textDecorationOverline = %x\n", b);
4525 hres = IHTMLStyle_get_textDecorationOverline(style, &b);
4526 ok(hres == S_OK, "get_textDecorationOverline failed: %08x\n", hres);
4527 ok(b == VARIANT_TRUE, "textDecorationOverline = %x\n", b);
4529 hres = IHTMLStyle_put_textDecorationOverline(style, VARIANT_FALSE);
4530 ok(hres == S_OK, "put_textDecorationOverline failed: %08x\n", hres);
4533 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4534 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4535 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4537 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_TRUE);
4538 ok(hres == S_OK, "put_textDecorationBlink failed: %08x\n", hres);
4539 ok(b == VARIANT_FALSE, "textDecorationBlink = %x\n", b);
4541 hres = IHTMLStyle_get_textDecorationBlink(style, &b);
4542 ok(hres == S_OK, "get_textDecorationBlink failed: %08x\n", hres);
4543 ok(b == VARIANT_TRUE, "textDecorationBlink = %x\n", b);
4545 hres = IHTMLStyle_put_textDecorationBlink(style, VARIANT_FALSE);
4546 ok(hres == S_OK, "textDecorationBlink failed: %08x\n", hres);
4548 hres = IHTMLStyle_get_textDecoration(style, &sDefault);
4549 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4551 str = a2bstr("invalid");
4552 hres = IHTMLStyle_put_textDecoration(style, str);
4553 ok(hres == E_INVALIDARG, "put_textDecoration failed: %08x\n", hres);
4556 str = a2bstr("none");
4557 hres = IHTMLStyle_put_textDecoration(style, str);
4558 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4561 str = a2bstr("underline");
4562 hres = IHTMLStyle_put_textDecoration(style, str);
4563 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4566 str = a2bstr("overline");
4567 hres = IHTMLStyle_put_textDecoration(style, str);
4568 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4571 str = a2bstr("line-through");
4572 hres = IHTMLStyle_put_textDecoration(style, str);
4573 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4576 str = a2bstr("blink");
4577 hres = IHTMLStyle_put_textDecoration(style, str);
4578 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4581 hres = IHTMLStyle_get_textDecoration(style, &str);
4582 ok(hres == S_OK, "get_textDecoration failed: %08x\n", hres);
4583 ok(!strcmp_wa(str, "blink"), "str != blink\n");
4586 hres = IHTMLStyle_put_textDecoration(style, sDefault);
4587 ok(hres == S_OK, "put_textDecoration failed: %08x\n", hres);
4588 SysFreeString(sDefault);
4590 hres = IHTMLStyle_get_posWidth(style, NULL);
4591 ok(hres == E_POINTER, "get_posWidth failed: %08x\n", hres);
4593 hres = IHTMLStyle_get_posWidth(style, &f);
4594 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4595 ok(f == 0.0f, "f = %f\n", f);
4597 V_VT(&v) = VT_EMPTY;
4598 hres = IHTMLStyle_get_width(style, &v);
4599 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4600 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4601 ok(!V_BSTR(&v), "V_BSTR(v)=%p\n", V_BSTR(&v));
4603 hres = IHTMLStyle_put_posWidth(style, 2.2);
4604 ok(hres == S_OK, "put_posWidth failed: %08x\n", hres);
4606 hres = IHTMLStyle_get_posWidth(style, &f);
4607 ok(hres == S_OK, "get_posWidth failed: %08x\n", hres);
4609 f == 2.2f, /* IE8 */
4613 V_BSTR(&v) = a2bstr("auto");
4614 hres = IHTMLStyle_put_width(style, v);
4615 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4618 V_VT(&v) = VT_EMPTY;
4619 hres = IHTMLStyle_get_width(style, &v);
4620 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4621 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4622 ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4627 hres = IHTMLStyle_put_width(style, v);
4628 ok(hres == S_OK, "put_width failed: %08x\n", hres);
4630 V_VT(&v) = VT_EMPTY;
4631 hres = IHTMLStyle_get_width(style, &v);
4632 ok(hres == S_OK, "get_width failed: %08x\n", hres);
4633 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4634 ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
4638 str = (void*)0xdeadbeef;
4639 hres = IHTMLStyle_get_margin(style, &str);
4640 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4641 ok(!str, "margin = %s\n", wine_dbgstr_w(str));
4644 hres = IHTMLStyle_put_margin(style, str);
4645 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4648 hres = IHTMLStyle_get_margin(style, &str);
4649 ok(hres == S_OK, "get_margin failed: %08x\n", hres);
4650 ok(!strcmp_wa(str, "1px"), "margin = %s\n", wine_dbgstr_w(str));
4653 hres = IHTMLStyle_put_margin(style, NULL);
4654 ok(hres == S_OK, "put_margin failed: %08x\n", hres);
4656 str = (void*)0xdeadbeef;
4657 hres = IHTMLStyle_get_marginTop(style, &v);
4658 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4659 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4660 ok(!V_BSTR(&v), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4663 V_BSTR(&v) = a2bstr("6px");
4664 hres = IHTMLStyle_put_marginTop(style, v);
4665 SysFreeString(V_BSTR(&v));
4666 ok(hres == S_OK, "put_marginTop failed: %08x\n", hres);
4668 str = (void*)0xdeadbeef;
4669 hres = IHTMLStyle_get_marginTop(style, &v);
4670 ok(hres == S_OK, "get_marginTop failed: %08x\n", hres);
4671 ok(V_VT(&v) == VT_BSTR, "V_VT(marginTop) = %d\n", V_VT(&v));
4672 ok(!strcmp_wa(V_BSTR(&v), "6px"), "V_BSTR(marginTop) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4676 hres = IHTMLStyle_get_border(style, &str);
4677 ok(hres == S_OK, "get_border failed: %08x\n", hres);
4678 ok(!str || !*str, "str is not empty\n");
4681 str = a2bstr("1px");
4682 hres = IHTMLStyle_put_border(style, str);
4683 ok(hres == S_OK, "put_border failed: %08x\n", hres);
4686 V_VT(&v) = VT_EMPTY;
4687 hres = IHTMLStyle_get_left(style, &v);
4688 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4689 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4690 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4694 hres = IHTMLStyle_get_posLeft(style, NULL);
4695 ok(hres == E_POINTER, "get_posLeft failed: %08x\n", hres);
4698 hres = IHTMLStyle_get_posLeft(style, &f);
4699 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4700 ok(f == 0.0, "expected 0.0 got %f\n", f);
4702 hres = IHTMLStyle_put_posLeft(style, 4.9f);
4703 ok(hres == S_OK, "put_posLeft failed: %08x\n", hres);
4705 hres = IHTMLStyle_get_posLeft(style, &f);
4706 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4708 f == 4.9f, /* IE8 */
4709 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4711 /* Ensure left is updated correctly. */
4712 V_VT(&v) = VT_EMPTY;
4713 hres = IHTMLStyle_get_left(style, &v);
4714 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4715 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4716 ok(!strcmp_wa(V_BSTR(&v), "4px") ||
4717 !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */
4718 "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4723 V_BSTR(&v) = a2bstr("3px");
4724 hres = IHTMLStyle_put_left(style, v);
4725 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4728 hres = IHTMLStyle_get_posLeft(style, &f);
4729 ok(hres == S_OK, "get_posLeft failed: %08x\n", hres);
4730 ok(f == 3.0, "expected 3.0 got %f\n", f);
4732 V_VT(&v) = VT_EMPTY;
4733 hres = IHTMLStyle_get_left(style, &v);
4734 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4735 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4736 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4740 hres = IHTMLStyle_put_left(style, v);
4741 ok(hres == S_OK, "put_left failed: %08x\n", hres);
4743 V_VT(&v) = VT_EMPTY;
4744 hres = IHTMLStyle_get_left(style, &v);
4745 ok(hres == S_OK, "get_left failed: %08x\n", hres);
4746 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4747 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4750 V_VT(&v) = VT_EMPTY;
4751 hres = IHTMLStyle_get_top(style, &v);
4752 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4753 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4754 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4758 hres = IHTMLStyle_get_posTop(style, NULL);
4759 ok(hres == E_POINTER, "get_posTop failed: %08x\n", hres);
4762 hres = IHTMLStyle_get_posTop(style, &f);
4763 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4764 ok(f == 0.0, "expected 0.0 got %f\n", f);
4766 hres = IHTMLStyle_put_posTop(style, 4.9f);
4767 ok(hres == S_OK, "put_posTop failed: %08x\n", hres);
4769 hres = IHTMLStyle_get_posTop(style, &f);
4770 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4772 f == 4.9f, /* IE8 */
4773 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4776 V_BSTR(&v) = a2bstr("3px");
4777 hres = IHTMLStyle_put_top(style, v);
4778 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4781 V_VT(&v) = VT_EMPTY;
4782 hres = IHTMLStyle_get_top(style, &v);
4783 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4784 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4785 ok(!strcmp_wa(V_BSTR(&v), "3px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4788 hres = IHTMLStyle_get_posTop(style, &f);
4789 ok(hres == S_OK, "get_posTop failed: %08x\n", hres);
4790 ok(f == 3.0, "expected 3.0 got %f\n", f);
4793 hres = IHTMLStyle_put_top(style, v);
4794 ok(hres == S_OK, "put_top failed: %08x\n", hres);
4796 V_VT(&v) = VT_EMPTY;
4797 hres = IHTMLStyle_get_top(style, &v);
4798 ok(hres == S_OK, "get_top failed: %08x\n", hres);
4799 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4800 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4803 /* Test posHeight */
4804 hres = IHTMLStyle_get_posHeight(style, NULL);
4805 ok(hres == E_POINTER, "get_posHeight failed: %08x\n", hres);
4807 V_VT(&v) = VT_EMPTY;
4808 hres = IHTMLStyle_get_height(style, &v);
4809 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4810 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4811 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4815 hres = IHTMLStyle_get_posHeight(style, &f);
4816 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4817 ok(f == 0.0, "expected 0.0 got %f\n", f);
4819 hres = IHTMLStyle_put_posHeight(style, 4.9f);
4820 ok(hres == S_OK, "put_posHeight failed: %08x\n", hres);
4822 hres = IHTMLStyle_get_posHeight(style, &f);
4823 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4825 f == 4.9f, /* IE8 */
4826 "expected 4.0 or 4.9 (IE8) got %f\n", f);
4829 V_BSTR(&v) = a2bstr("64px");
4830 hres = IHTMLStyle_put_height(style, v);
4831 ok(hres == S_OK, "put_height failed: %08x\n", hres);
4834 V_VT(&v) = VT_EMPTY;
4835 hres = IHTMLStyle_get_height(style, &v);
4836 ok(hres == S_OK, "get_height failed: %08x\n", hres);
4837 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4838 ok(!strcmp_wa(V_BSTR(&v), "64px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4841 hres = IHTMLStyle_get_posHeight(style, &f);
4842 ok(hres == S_OK, "get_posHeight failed: %08x\n", hres);
4843 ok(f == 64.0, "expected 64.0 got %f\n", f);
4845 str = (void*)0xdeadbeef;
4846 hres = IHTMLStyle_get_cursor(style, &str);
4847 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4848 ok(!str, "get_cursor != NULL\n");
4851 str = a2bstr("default");
4852 hres = IHTMLStyle_put_cursor(style, str);
4853 ok(hres == S_OK, "put_cursor failed: %08x\n", hres);
4857 hres = IHTMLStyle_get_cursor(style, &str);
4858 ok(hres == S_OK, "get_cursor failed: %08x\n", hres);
4859 ok(!strcmp_wa(str, "default"), "get_cursor returned %s\n", wine_dbgstr_w(str));
4862 V_VT(&v) = VT_EMPTY;
4863 hres = IHTMLStyle_get_verticalAlign(style, &v);
4864 ok(hres == S_OK, "get_vertivalAlign failed: %08x\n", hres);
4865 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4866 ok(!V_BSTR(&v), "V_BSTR(v) != NULL\n");
4870 V_BSTR(&v) = a2bstr("middle");
4871 hres = IHTMLStyle_put_verticalAlign(style, v);
4872 ok(hres == S_OK, "put_vertivalAlign failed: %08x\n", hres);
4875 V_VT(&v) = VT_EMPTY;
4876 hres = IHTMLStyle_get_verticalAlign(style, &v);
4877 ok(hres == S_OK, "get_verticalAlign failed: %08x\n", hres);
4878 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
4879 ok(!strcmp_wa(V_BSTR(&v), "middle"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4882 str = (void*)0xdeadbeef;
4883 hres = IHTMLStyle_get_textAlign(style, &str);
4884 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4885 ok(!str, "textAlign != NULL\n");
4887 str = a2bstr("center");
4888 hres = IHTMLStyle_put_textAlign(style, str);
4889 ok(hres == S_OK, "put_textAlign failed: %08x\n", hres);
4893 hres = IHTMLStyle_get_textAlign(style, &str);
4894 ok(hres == S_OK, "get_textAlign failed: %08x\n", hres);
4895 ok(!strcmp_wa(str, "center"), "textAlign = %s\n", wine_dbgstr_w(V_BSTR(&v)));
4898 str = (void*)0xdeadbeef;
4899 hres = IHTMLStyle_get_filter(style, &str);
4900 ok(hres == S_OK, "get_filter failed: %08x\n", hres);
4901 ok(!str, "filter != NULL\n");
4903 str = a2bstr("alpha(opacity=100)");
4904 hres = IHTMLStyle_put_filter(style, str);
4905 ok(hres == S_OK, "put_filter failed: %08x\n", hres);
4908 V_VT(&v) = VT_EMPTY;
4909 hres = IHTMLStyle_get_zIndex(style, &v);
4910 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4911 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4912 ok(!V_I4(&v), "V_I4(v) != 0\n");
4916 V_BSTR(&v) = a2bstr("1");
4917 hres = IHTMLStyle_put_zIndex(style, v);
4918 ok(hres == S_OK, "put_zIndex failed: %08x\n", hres);
4921 V_VT(&v) = VT_EMPTY;
4922 hres = IHTMLStyle_get_zIndex(style, &v);
4923 ok(hres == S_OK, "get_zIndex failed: %08x\n", hres);
4924 ok(V_VT(&v) == VT_I4, "V_VT(v)=%d\n", V_VT(&v));
4925 ok(V_I4(&v) == 1, "V_I4(v) = %d\n", V_I4(&v));
4929 hres = IHTMLStyle_get_fontStyle(style, &sDefault);
4930 ok(hres == S_OK, "get_fontStyle failed: %08x\n", hres);
4932 str = a2bstr("test");
4933 hres = IHTMLStyle_put_fontStyle(style, str);
4934 ok(hres == E_INVALIDARG, "put_fontStyle failed: %08x\n", hres);
4937 str = a2bstr("italic");
4938 hres = IHTMLStyle_put_fontStyle(style, str);
4939 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4942 str = a2bstr("oblique");
4943 hres = IHTMLStyle_put_fontStyle(style, str);
4944 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4947 str = a2bstr("normal");
4948 hres = IHTMLStyle_put_fontStyle(style, str);
4949 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4952 hres = IHTMLStyle_put_fontStyle(style, sDefault);
4953 ok(hres == S_OK, "put_fontStyle failed: %08x\n", hres);
4954 SysFreeString(sDefault);
4957 hres = IHTMLStyle_get_overflow(style, NULL);
4958 ok(hres == E_INVALIDARG, "get_overflow failed: %08x\n", hres);
4960 hres = IHTMLStyle_get_overflow(style, &sOverflowDefault);
4961 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4963 str = a2bstr("test");
4964 hres = IHTMLStyle_put_overflow(style, str);
4965 ok(hres == E_INVALIDARG, "put_overflow failed: %08x\n", hres);
4968 str = a2bstr("visible");
4969 hres = IHTMLStyle_put_overflow(style, str);
4970 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4973 str = a2bstr("scroll");
4974 hres = IHTMLStyle_put_overflow(style, str);
4975 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4978 str = a2bstr("hidden");
4979 hres = IHTMLStyle_put_overflow(style, str);
4980 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4983 str = a2bstr("auto");
4984 hres = IHTMLStyle_put_overflow(style, str);
4985 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4988 hres = IHTMLStyle_get_overflow(style, &str);
4989 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
4990 ok(!strcmp_wa(str, "auto"), "str=%s\n", wine_dbgstr_w(str));
4994 hres = IHTMLStyle_put_overflow(style, str);
4995 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
4998 hres = IHTMLStyle_get_overflow(style, &str);
4999 ok(hres == S_OK, "get_overflow failed: %08x\n", hres);
5000 ok(!str, "str=%s\n", wine_dbgstr_w(str));
5003 /* restore overflow default */
5004 hres = IHTMLStyle_put_overflow(style, sOverflowDefault);
5005 ok(hres == S_OK, "put_overflow failed: %08x\n", hres);
5006 SysFreeString(sOverflowDefault);
5008 /* Attribute Tests*/
5009 hres = IHTMLStyle_getAttribute(style, NULL, 1, &v);
5010 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
5012 str = a2bstr("position");
5013 hres = IHTMLStyle_getAttribute(style, str, 1, NULL);
5014 ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres);
5016 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
5017 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
5018 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5021 hres = IHTMLStyle_setAttribute(style, NULL, v, 1);
5022 ok(hres == E_INVALIDARG, "setAttribute failed: %08x\n", hres);
5025 V_BSTR(&v) = a2bstr("absolute");
5026 hres = IHTMLStyle_setAttribute(style, str, v, 1);
5027 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
5030 hres = IHTMLStyle_getAttribute(style, str, 1, &v);
5031 ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
5032 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5033 ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5038 hres = IHTMLStyle_setAttribute(style, str, v, 1);
5039 ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
5044 str = a2bstr("borderLeftStyle");
5045 test_border_styles(style, str);
5048 str = a2bstr("borderbottomstyle");
5049 test_border_styles(style, str);
5052 str = a2bstr("borderrightstyle");
5053 test_border_styles(style, str);
5056 str = a2bstr("bordertopstyle");
5057 test_border_styles(style, str);
5060 hres = IHTMLStyle_get_borderStyle(style, &sDefault);
5061 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5063 str = a2bstr("none dotted dashed solid");
5064 hres = IHTMLStyle_put_borderStyle(style, str);
5065 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5068 str = a2bstr("none dotted dashed solid");
5069 hres = IHTMLStyle_get_borderStyle(style, &str);
5070 ok(hres == S_OK, "get_borderStyle failed: %08x\n", hres);
5071 ok(!strcmp_wa(str, "none dotted dashed solid"),
5072 "expected (none dotted dashed solid) = (%s)\n", wine_dbgstr_w(V_BSTR(&v)));
5075 str = a2bstr("double groove ridge inset");
5076 hres = IHTMLStyle_put_borderStyle(style, str);
5077 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5080 str = a2bstr("window-inset outset ridge inset");
5081 hres = IHTMLStyle_put_borderStyle(style, str);
5082 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5085 str = a2bstr("window-inset");
5086 hres = IHTMLStyle_put_borderStyle(style, str);
5087 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5090 str = a2bstr("none none none none none");
5091 hres = IHTMLStyle_put_borderStyle(style, str);
5092 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5095 str = a2bstr("invalid none none none");
5096 hres = IHTMLStyle_put_borderStyle(style, str);
5097 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5100 str = a2bstr("none invalid none none");
5101 hres = IHTMLStyle_put_borderStyle(style, str);
5102 ok(hres == E_INVALIDARG, "put_borderStyle failed: %08x\n", hres);
5105 hres = IHTMLStyle_put_borderStyle(style, sDefault);
5106 ok(hres == S_OK, "put_borderStyle failed: %08x\n", hres);
5107 SysFreeString(sDefault);
5109 /* backgoundColor */
5110 hres = IHTMLStyle_get_backgroundColor(style, &v);
5111 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5112 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5113 ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5117 hres = IHTMLStyle_get_padding(style, &str);
5118 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5119 ok(!str, "padding = %s\n", wine_dbgstr_w(str));
5123 hres = IHTMLStyle_put_padding(style, str);
5124 ok(hres == S_OK, "put_padding failed: %08x\n", hres);
5127 hres = IHTMLStyle_get_padding(style, &str);
5128 ok(hres == S_OK, "get_padding failed: %08x\n", hres);
5129 ok(!strcmp_wa(str, "1px"), "padding = %s\n", wine_dbgstr_w(str));
5133 hres = IHTMLStyle_get_paddingLeft(style, &vDefault);
5134 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5137 V_BSTR(&v) = a2bstr("10");
5138 hres = IHTMLStyle_put_paddingLeft(style, v);
5139 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5142 hres = IHTMLStyle_get_paddingLeft(style, &v);
5143 ok(hres == S_OK, "get_paddingLeft: %08x\n", hres);
5144 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expecte 10 = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5147 hres = IHTMLStyle_put_paddingLeft(style, vDefault);
5148 ok(hres == S_OK, "put_paddingLeft: %08x\n", hres);
5150 /* BackgroundRepeat */
5151 hres = IHTMLStyle_get_backgroundRepeat(style, &sDefault);
5152 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5154 str = a2bstr("invalid");
5155 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5156 ok(hres == E_INVALIDARG, "put_backgroundRepeat failed: %08x\n", hres);
5159 str = a2bstr("repeat");
5160 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5161 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5164 str = a2bstr("no-repeat");
5165 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5166 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5169 str = a2bstr("repeat-x");
5170 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5171 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5174 str = a2bstr("repeat-y");
5175 hres = IHTMLStyle_put_backgroundRepeat(style, str);
5176 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5179 hres = IHTMLStyle_get_backgroundRepeat(style, &str);
5180 ok(hres == S_OK, "get_backgroundRepeat failed: %08x\n", hres);
5181 ok(!strcmp_wa(str, "repeat-y"), "str=%s\n", wine_dbgstr_w(str));
5184 hres = IHTMLStyle_put_backgroundRepeat(style, sDefault);
5185 ok(hres == S_OK, "put_backgroundRepeat failed: %08x\n", hres);
5186 SysFreeString(sDefault);
5189 hres = IHTMLStyle_get_borderColor(style, &sDefault);
5190 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5192 str = a2bstr("red green red blue");
5193 hres = IHTMLStyle_put_borderColor(style, str);
5194 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5197 hres = IHTMLStyle_get_borderColor(style, &str);
5198 ok(hres == S_OK, "get_borderColor failed: %08x\n", hres);
5199 ok(!strcmp_wa(str, "red green red blue"), "str=%s\n", wine_dbgstr_w(str));
5202 hres = IHTMLStyle_put_borderColor(style, sDefault);
5203 ok(hres == S_OK, "put_borderColor failed: %08x\n", hres);
5204 SysFreeString(sDefault);
5207 hres = IHTMLStyle_get_borderRight(style, &sDefault);
5208 ok(hres == S_OK, "get_borderRight failed: %08x\n", hres);
5210 str = a2bstr("thick dotted red");
5211 hres = IHTMLStyle_put_borderRight(style, str);
5212 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5215 /* IHTMLStyle_get_borderRight appears to have a bug where
5216 it returns the first letter of the color. So we check
5217 each style individually.
5220 hres = IHTMLStyle_get_borderRightColor(style, &v);
5221 ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres);
5222 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5226 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5227 ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres);
5228 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5231 hres = IHTMLStyle_get_borderRightStyle(style, &str);
5232 ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres);
5233 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5236 hres = IHTMLStyle_put_borderRight(style, sDefault);
5237 ok(hres == S_OK, "put_borderRight failed: %08x\n", hres);
5238 SysFreeString(sDefault);
5241 hres = IHTMLStyle_get_borderTop(style, &sDefault);
5242 ok(hres == S_OK, "get_borderTop failed: %08x\n", hres);
5244 str = a2bstr("thick dotted red");
5245 hres = IHTMLStyle_put_borderTop(style, str);
5246 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5249 /* IHTMLStyle_get_borderTop appears to have a bug where
5250 it returns the first letter of the color. So we check
5251 each style individually.
5254 hres = IHTMLStyle_get_borderTopColor(style, &v);
5255 ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres);
5256 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5260 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5261 ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres);
5262 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5265 hres = IHTMLStyle_get_borderTopStyle(style, &str);
5266 ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres);
5267 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5270 hres = IHTMLStyle_put_borderTop(style, sDefault);
5271 ok(hres == S_OK, "put_borderTop failed: %08x\n", hres);
5272 SysFreeString(sDefault);
5275 hres = IHTMLStyle_get_borderBottom(style, &sDefault);
5276 ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres);
5278 str = a2bstr("thick dotted red");
5279 hres = IHTMLStyle_put_borderBottom(style, str);
5280 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5283 /* IHTMLStyle_get_borderBottom appears to have a bug where
5284 it returns the first letter of the color. So we check
5285 each style individually.
5288 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5289 ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres);
5290 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5294 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5295 ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres);
5296 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5299 hres = IHTMLStyle_get_borderBottomStyle(style, &str);
5300 ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres);
5301 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5304 hres = IHTMLStyle_put_borderBottom(style, sDefault);
5305 ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres);
5306 SysFreeString(sDefault);
5309 hres = IHTMLStyle_get_borderLeft(style, &sDefault);
5310 ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);
5312 str = a2bstr("thick dotted red");
5313 hres = IHTMLStyle_put_borderLeft(style, str);
5314 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5317 /* IHTMLStyle_get_borderLeft appears to have a bug where
5318 it returns the first letter of the color. So we check
5319 each style individually.
5322 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5323 ok(hres == S_OK, "get_borderLeftColor failed: %08x\n", hres);
5324 ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5328 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5329 ok(hres == S_OK, "get_borderLeftWidth failed: %08x\n", hres);
5330 ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5333 hres = IHTMLStyle_get_borderLeftStyle(style, &str);
5334 ok(hres == S_OK, "get_borderLeftStyle failed: %08x\n", hres);
5335 ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str));
5338 hres = IHTMLStyle_put_borderLeft(style, sDefault);
5339 ok(hres == S_OK, "put_borderLeft failed: %08x\n", hres);
5340 SysFreeString(sDefault);
5342 /* backgroundPositionX */
5343 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5344 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5345 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5346 ok(!V_BSTR(&v), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5350 V_BSTR(&v) = a2bstr("10px");
5351 hres = IHTMLStyle_put_backgroundPositionX(style, v);
5352 ok(hres == S_OK, "put_backgroundPositionX failed: %08x\n", hres);
5355 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5356 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5357 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5358 ok(!strcmp_wa(V_BSTR(&v), "10px"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5361 /* backgroundPositionY */
5362 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5363 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5364 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5368 V_BSTR(&v) = a2bstr("15px");
5369 hres = IHTMLStyle_put_backgroundPositionY(style, v);
5370 ok(hres == S_OK, "put_backgroundPositionY failed: %08x\n", hres);
5373 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5374 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5375 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5376 ok(!strcmp_wa(V_BSTR(&v), "15px"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5379 /* backgroundPosition */
5381 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5382 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5383 ok(!strcmp_wa(str, "10px 15px"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5386 str = a2bstr("center 20%");
5387 hres = IHTMLStyle_put_backgroundPosition(style, str);
5388 ok(hres == S_OK, "put_backgroundPosition failed: %08x\n", hres);
5392 hres = IHTMLStyle_get_backgroundPosition(style, &str);
5393 ok(hres == S_OK, "get_backgroundPosition failed: %08x\n", hres);
5394 ok(!strcmp_wa(str, "center 20%"), "backgroundPosition = %s\n", wine_dbgstr_w(str));
5397 hres = IHTMLStyle_get_backgroundPositionX(style, &v);
5398 ok(hres == S_OK, "get_backgroundPositionX failed: %08x\n", hres);
5399 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5400 ok(!strcmp_wa(V_BSTR(&v), "center"), "backgroundPositionX = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5403 hres = IHTMLStyle_get_backgroundPositionY(style, &v);
5404 ok(hres == S_OK, "get_backgroundPositionY failed: %08x\n", hres);
5405 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5406 ok(!strcmp_wa(V_BSTR(&v), "20%"), "backgroundPositionY = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5409 /* borderTopWidth */
5410 hres = IHTMLStyle_get_borderTopWidth(style, &vDefault);
5411 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5414 V_BSTR(&v) = a2bstr("10px");
5415 hres = IHTMLStyle_put_borderTopWidth(style, v);
5416 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5419 hres = IHTMLStyle_get_borderTopWidth(style, &v);
5420 ok(hres == S_OK, "get_borderTopWidth: %08x\n", hres);
5421 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5424 hres = IHTMLStyle_put_borderTopWidth(style, vDefault);
5425 ok(hres == S_OK, "put_borderTopWidth: %08x\n", hres);
5426 VariantClear(&vDefault);
5428 /* borderRightWidth */
5429 hres = IHTMLStyle_get_borderRightWidth(style, &vDefault);
5430 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5433 V_BSTR(&v) = a2bstr("10");
5434 hres = IHTMLStyle_put_borderRightWidth(style, v);
5435 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5438 hres = IHTMLStyle_get_borderRightWidth(style, &v);
5439 ok(hres == S_OK, "get_borderRightWidth: %08x\n", hres);
5440 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5443 hres = IHTMLStyle_put_borderRightWidth(style, vDefault);
5444 ok(hres == S_OK, "put_borderRightWidth: %08x\n", hres);
5445 VariantClear(&vDefault);
5447 /* borderBottomWidth */
5448 hres = IHTMLStyle_get_borderBottomWidth(style, &vDefault);
5449 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5452 V_BSTR(&v) = a2bstr("10");
5453 hres = IHTMLStyle_put_borderBottomWidth(style, v);
5454 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5457 hres = IHTMLStyle_get_borderBottomWidth(style, &v);
5458 ok(hres == S_OK, "get_borderBottomWidth: %08x\n", hres);
5459 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5462 hres = IHTMLStyle_put_borderBottomWidth(style, vDefault);
5463 ok(hres == S_OK, "put_borderBottomWidth: %08x\n", hres);
5464 VariantClear(&vDefault);
5466 /* borderLeftWidth */
5467 hres = IHTMLStyle_get_borderLeftWidth(style, &vDefault);
5468 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5471 V_BSTR(&v) = a2bstr("10");
5472 hres = IHTMLStyle_put_borderLeftWidth(style, v);
5473 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5476 hres = IHTMLStyle_get_borderLeftWidth(style, &v);
5477 ok(hres == S_OK, "get_borderLeftWidth: %08x\n", hres);
5478 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5481 hres = IHTMLStyle_put_borderLeftWidth(style, vDefault);
5482 ok(hres == S_OK, "put_borderLeftWidth: %08x\n", hres);
5483 VariantClear(&vDefault);
5486 hres = IHTMLStyle_get_wordSpacing(style, &vDefault);
5487 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5490 V_BSTR(&v) = a2bstr("10");
5491 hres = IHTMLStyle_put_wordSpacing(style, v);
5492 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5495 hres = IHTMLStyle_get_wordSpacing(style, &v);
5496 ok(hres == S_OK, "get_wordSpacing: %08x\n", hres);
5497 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5498 ok(!strcmp_wa(V_BSTR(&v), "10px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5501 hres = IHTMLStyle_put_wordSpacing(style, vDefault);
5502 ok(hres == S_OK, "put_wordSpacing: %08x\n", hres);
5503 VariantClear(&vDefault);
5506 hres = IHTMLStyle_get_letterSpacing(style, &vDefault);
5507 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5510 V_BSTR(&v) = a2bstr("11");
5511 hres = IHTMLStyle_put_letterSpacing(style, v);
5512 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5515 hres = IHTMLStyle_get_letterSpacing(style, &v);
5516 ok(hres == S_OK, "get_letterSpacing: %08x\n", hres);
5517 ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
5518 ok(!strcmp_wa(V_BSTR(&v), "11px"), "expected 10px = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5521 hres = IHTMLStyle_put_letterSpacing(style, vDefault);
5522 ok(hres == S_OK, "put_letterSpacing: %08x\n", hres);
5523 VariantClear(&vDefault);
5525 /* borderTopColor */
5526 hres = IHTMLStyle_get_borderTopColor(style, &vDefault);
5527 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5530 V_BSTR(&v) = a2bstr("red");
5531 hres = IHTMLStyle_put_borderTopColor(style, v);
5532 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5535 hres = IHTMLStyle_get_borderTopColor(style, &v);
5536 ok(hres == S_OK, "get_borderTopColor: %08x\n", hres);
5537 ok(!strcmp_wa(V_BSTR(&v), "red"), "expecte red = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5540 hres = IHTMLStyle_put_borderTopColor(style, vDefault);
5541 ok(hres == S_OK, "put_borderTopColor: %08x\n", hres);
5543 /* borderRightColor */
5544 hres = IHTMLStyle_get_borderRightColor(style, &vDefault);
5545 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5548 V_BSTR(&v) = a2bstr("blue");
5549 hres = IHTMLStyle_put_borderRightColor(style, v);
5550 ok(hres == S_OK, "put_borderRightColor: %08x\n", hres);
5553 hres = IHTMLStyle_get_borderRightColor(style, &v);
5554 ok(hres == S_OK, "get_borderRightColor: %08x\n", hres);
5555 ok(!strcmp_wa(V_BSTR(&v), "blue"), "expected blue = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5558 hres = IHTMLStyle_put_borderRightColor(style, vDefault);
5559 ok(hres == S_OK, "putborderRightColorr: %08x\n", hres);
5561 /* borderBottomColor */
5562 hres = IHTMLStyle_get_borderBottomColor(style, &vDefault);
5563 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5566 V_BSTR(&v) = a2bstr("cyan");
5567 hres = IHTMLStyle_put_borderBottomColor(style, v);
5568 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5571 hres = IHTMLStyle_get_borderBottomColor(style, &v);
5572 ok(hres == S_OK, "get_borderBottomColor: %08x\n", hres);
5573 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5576 hres = IHTMLStyle_put_borderBottomColor(style, vDefault);
5577 ok(hres == S_OK, "put_borderBottomColor: %08x\n", hres);
5579 /* borderLeftColor */
5580 hres = IHTMLStyle_get_borderLeftColor(style, &vDefault);
5581 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5584 V_BSTR(&v) = a2bstr("cyan");
5585 hres = IHTMLStyle_put_borderLeftColor(style, v);
5586 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5589 hres = IHTMLStyle_get_borderLeftColor(style, &v);
5590 ok(hres == S_OK, "get_borderLeftColor: %08x\n", hres);
5591 ok(!strcmp_wa(V_BSTR(&v), "cyan"), "expected cyan = %s\n", wine_dbgstr_w(V_BSTR(&v)));
5594 hres = IHTMLStyle_put_borderLeftColor(style, vDefault);
5595 ok(hres == S_OK, "put_borderLeftColor: %08x\n", hres);
5597 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2);
5598 ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres);
5599 if(SUCCEEDED(hres)) {
5600 test_style2(style2);
5601 IHTMLStyle2_Release(style2);
5604 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle3, (void**)&style3);
5605 ok(hres == S_OK, "Could not get IHTMLStyle3 iface: %08x\n", hres);
5606 if(SUCCEEDED(hres)) {
5607 test_style3(style3);
5608 IHTMLStyle3_Release(style3);
5611 hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle4, (void**)&style4);
5612 ok(hres == S_OK, "Could not get IHTMLStyle4 iface: %08x\n", hres);
5613 if(SUCCEEDED(hres)) {
5614 test_style4(style4);
5615 IHTMLStyle4_Release(style4);
5619 #define test_style_filter(a,b) _test_style_filter(__LINE__,a,b)
5620 static void _test_style_filter(unsigned line, IHTMLStyle *style, const char *exval)
5625 str = (void*)0xdeadbeef;
5626 hres = IHTMLStyle_get_filter(style, &str);
5627 ok_(__FILE__,line)(hres == S_OK, "get_filter failed: %08x\n", hres);
5629 ok_(__FILE__,line)(str && !strcmp_wa(str, exval), "filter = %s, expected %s\n", wine_dbgstr_w(str), exval);
5631 ok_(__FILE__,line)(!str, "str = %s, expected NULL\n", wine_dbgstr_w(str));
5636 #define set_style_filter(a,b) _set_style_filter(__LINE__,a,b)
5637 static void _set_style_filter(unsigned line, IHTMLStyle *style, const char *val)
5639 BSTR str = a2bstr(val);
5642 hres = IHTMLStyle_put_filter(style, str);
5643 ok_(__FILE__,line)(hres == S_OK, "put_filter failed: %08x\n", hres);
5646 _test_style_filter(line, style, val);
5649 static void test_style_filters(IHTMLElement *elem)
5654 hres = IHTMLElement_get_style(elem, &style);
5655 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5657 test_style_filter(style, NULL);
5658 set_style_filter(style, "alpha(opacity=50.0040)");
5659 set_style_filter(style, "alpha(opacity=100)");
5661 IHTMLStyle_Release(style);
5663 hres = IHTMLElement_get_style(elem, &style);
5664 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5666 test_style_filter(style, "alpha(opacity=100)");
5667 set_style_filter(style, "xxx(a,b,c) alpha(opacity=100)");
5668 set_style_filter(style, NULL);
5670 IHTMLStyle_Release(style);
5673 static void test_set_csstext(IHTMLStyle *style)
5678 test_style_set_csstext(style, "background-color: black;");
5680 hres = IHTMLStyle_get_backgroundColor(style, &v);
5681 ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
5682 ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
5683 ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
5687 static void test_default_selection(IHTMLDocument2 *doc)
5689 IHTMLSelectionObject *selection;
5690 IHTMLTxtRange *range;
5695 hres = IHTMLDocument2_get_selection(doc, &selection);
5696 ok(hres == S_OK, "get_selection failed: %08x\n", hres);
5698 hres = IHTMLSelectionObject_get_type(selection, &str);
5699 ok(hres == S_OK, "get_type failed: %08x\n", hres);
5700 ok(!strcmp_wa(str, "None"), "type = %s\n", wine_dbgstr_w(str));
5703 hres = IHTMLSelectionObject_createRange(selection, &disp);
5704 IHTMLSelectionObject_Release(selection);
5705 ok(hres == S_OK, "createRange failed: %08x\n", hres);
5707 hres = IDispatch_QueryInterface(disp, &IID_IHTMLTxtRange, (void**)&range);
5708 IDispatch_Release(disp);
5709 ok(hres == S_OK, "Could not get IHTMLTxtRange interface: %08x\n", hres);
5711 test_range_text(range, NULL);
5712 IHTMLTxtRange_Release(range);
5715 static void test_doc_elem(IHTMLDocument2 *doc)
5717 IHTMLDocument2 *doc_node, *owner_doc;
5719 IHTMLDocument3 *doc3;
5722 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
5723 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres);
5725 hres = IHTMLDocument3_get_documentElement(doc3, &elem);
5726 IHTMLDocument3_Release(doc3);
5727 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
5729 test_node_name((IUnknown*)elem, "HTML");
5730 test_elem_tag((IUnknown*)elem, "HTML");
5732 doc_node = get_doc_node(doc);
5733 owner_doc = get_owner_doc((IUnknown*)elem);
5734 ok(iface_cmp((IUnknown *)doc_node, (IUnknown *)owner_doc), "doc_node != owner_doc\n");
5735 IHTMLDocument2_Release(owner_doc);
5737 owner_doc = get_owner_doc((IUnknown*)doc_node);
5738 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
5739 IHTMLDocument2_Release(doc_node);
5741 test_elem_client_rect((IUnknown*)elem);
5743 IHTMLElement_Release(elem);
5746 static void test_default_body(IHTMLBodyElement *body)
5753 bstr = (void*)0xdeadbeef;
5754 hres = IHTMLBodyElement_get_background(body, &bstr);
5755 ok(hres == S_OK, "get_background failed: %08x\n", hres);
5756 ok(bstr == NULL, "bstr != NULL\n");
5758 l = elem_get_scroll_height((IUnknown*)body);
5759 ok(l != -1, "scrollHeight == -1\n");
5760 l = elem_get_scroll_width((IUnknown*)body);
5761 ok(l != -1, "scrollWidth == -1\n");
5762 l = elem_get_scroll_top((IUnknown*)body);
5763 ok(!l, "scrollTop = %d\n", l);
5764 elem_get_scroll_left((IUnknown*)body);
5766 /* get_text tests */
5767 hres = IHTMLBodyElement_get_text(body, &v);
5768 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5769 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5770 ok(bstr == NULL, "bstr != NULL\n");
5772 /* get_text - Invalid Text */
5774 V_BSTR(&v) = a2bstr("Invalid");
5775 hres = IHTMLBodyElement_put_text(body, v);
5776 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5780 hres = IHTMLBodyElement_get_text(body, &v);
5781 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5782 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5783 ok(!strcmp_wa(V_BSTR(&v), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v)));
5786 /* get_text - Valid Text */
5788 V_BSTR(&v) = a2bstr("#FF0000");
5789 hres = IHTMLBodyElement_put_text(body, v);
5790 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5794 hres = IHTMLBodyElement_get_text(body, &v);
5795 ok(hres == S_OK, "expect S_OK got 0x%08d\n", hres);
5796 ok(V_VT(&v) == VT_BSTR, "Expected VT_BSTR got %d\n", V_VT(&v));
5797 ok(!strcmp_wa(V_BSTR(&v), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v)));
5801 static void test_body_funs(IHTMLBodyElement *body)
5803 VARIANT vbg, vDefaultbg;
5806 hres = IHTMLBodyElement_get_bgColor(body, &vDefaultbg);
5807 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5808 ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n");
5809 ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg)));
5811 V_VT(&vbg) = VT_BSTR;
5812 V_BSTR(&vbg) = a2bstr("red");
5813 hres = IHTMLBodyElement_put_bgColor(body, vbg);
5814 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5817 hres = IHTMLBodyElement_get_bgColor(body, &vbg);
5818 ok(hres == S_OK, "get_bgColor failed: %08x\n", hres);
5819 ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n");
5820 ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
5823 /* Restore Originial */
5824 hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg);
5825 ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
5826 VariantClear(&vDefaultbg);
5829 static void test_window(IHTMLDocument2 *doc)
5831 IHTMLWindow2 *window, *window2, *self;
5832 IHTMLDocument2 *doc2 = NULL;
5838 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5839 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5840 test_ifaces((IUnknown*)window, window_iids);
5841 test_disp((IUnknown*)window, &DIID_DispHTMLWindow2, "[object]");
5843 hres = IHTMLWindow2_get_document(window, &doc2);
5844 ok(hres == S_OK, "get_document failed: %08x\n", hres);
5845 ok(doc2 != NULL, "doc2 == NULL\n");
5847 test_ifaces((IUnknown*)doc2, doc_node_iids);
5848 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5850 test_ifaces((IUnknown*)doc, doc_obj_iids);
5851 test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
5853 unk = (void*)0xdeadbeef;
5854 hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
5855 ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
5856 ok(!unk, "unk = %p\n", unk);
5858 IHTMLDocument_Release(doc2);
5860 hres = IHTMLWindow2_get_window(window, &window2);
5861 ok(hres == S_OK, "get_window failed: %08x\n", hres);
5862 ok(window2 != NULL, "window2 == NULL\n");
5864 hres = IHTMLWindow2_get_self(window, &self);
5865 ok(hres == S_OK, "get_self failed: %08x\n", hres);
5866 ok(window2 != NULL, "self == NULL\n");
5868 ok(self == window2, "self != window2\n");
5870 IHTMLWindow2_Release(window2);
5871 IHTMLWindow2_Release(self);
5874 hres = IHTMLDocument2_get_Script(doc, &disp);
5875 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
5876 ok(disp == (void*)window, "disp != window\n");
5877 IDispatch_Release(disp);
5879 hres = IHTMLWindow2_toString(window, NULL);
5880 ok(hres == E_INVALIDARG, "toString failed: %08x\n", hres);
5883 hres = IHTMLWindow2_toString(window, &str);
5884 ok(hres == S_OK, "toString failed: %08x\n", hres);
5885 ok(!strcmp_wa(str, "[object]"), "toString returned %s\n", wine_dbgstr_w(str));
5888 test_window_name(window, NULL);
5889 set_window_name(window, "test");
5890 test_window_length(window, 0);
5891 test_screen(window);
5893 IHTMLWindow2_Release(window);
5896 static void test_defaults(IHTMLDocument2 *doc)
5898 IHTMLStyleSheetsCollection *stylesheetcol;
5899 IHTMLCurrentStyle *cstyle;
5900 IHTMLBodyElement *body;
5901 IHTMLElement2 *elem2;
5906 IHTMLElementCollection *collection;
5908 elem = doc_get_body(doc);
5910 hres = IHTMLDocument2_get_images(doc, NULL);
5911 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5913 hres = IHTMLDocument2_get_images(doc, &collection);
5914 ok(hres == S_OK, "get_images failed: %08x\n", hres);
5917 test_elem_collection((IUnknown*)collection, NULL, 0);
5918 IHTMLElementCollection_Release(collection);
5921 hres = IHTMLDocument2_get_applets(doc, NULL);
5922 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5924 hres = IHTMLDocument2_get_applets(doc, &collection);
5925 ok(hres == S_OK, "get_applets failed: %08x\n", hres);
5928 test_elem_collection((IUnknown*)collection, NULL, 0);
5929 IHTMLElementCollection_Release(collection);
5932 hres = IHTMLDocument2_get_links(doc, NULL);
5933 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5935 hres = IHTMLDocument2_get_links(doc, &collection);
5936 ok(hres == S_OK, "get_links failed: %08x\n", hres);
5939 test_elem_collection((IUnknown*)collection, NULL, 0);
5940 IHTMLElementCollection_Release(collection);
5943 hres = IHTMLDocument2_get_forms(doc, NULL);
5944 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5946 hres = IHTMLDocument2_get_forms(doc, &collection);
5947 ok(hres == S_OK, "get_forms failed: %08x\n", hres);
5950 test_elem_collection((IUnknown*)collection, NULL, 0);
5951 IHTMLElementCollection_Release(collection);
5954 hres = IHTMLDocument2_get_anchors(doc, NULL);
5955 ok(hres == E_INVALIDARG, "hres %08x\n", hres);
5957 hres = IHTMLDocument2_get_anchors(doc, &collection);
5958 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
5961 test_elem_collection((IUnknown*)collection, NULL, 0);
5962 IHTMLElementCollection_Release(collection);
5965 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
5966 ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
5967 test_default_body(body);
5968 test_body_funs(body);
5969 IHTMLBodyElement_Release(body);
5971 hres = IHTMLElement_get_style(elem, &style);
5972 ok(hres == S_OK, "get_style failed: %08x\n", hres);
5974 test_default_style(style);
5976 test_compatmode(doc);
5978 test_navigator(doc);
5980 elem2 = get_elem2_iface((IUnknown*)elem);
5981 hres = IHTMLElement2_get_currentStyle(elem2, &cstyle);
5982 ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres);
5983 if(SUCCEEDED(hres)) {
5984 test_current_style(cstyle);
5985 IHTMLCurrentStyle_Release(cstyle);
5987 IHTMLElement2_Release(elem2);
5989 IHTMLElement_Release(elem);
5991 test_set_csstext(style);
5992 IHTMLStyle_Release(style);
5994 hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol);
5995 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
5998 hres = IHTMLStyleSheetsCollection_get_length(stylesheetcol, &l);
5999 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6000 ok(l == 0, "length = %d\n", l);
6002 IHTMLStyleSheetsCollection_Release(stylesheetcol);
6004 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFiltersCollection, (void**)&body);
6005 ok(hres == E_NOINTERFACE, "got interface IHTMLFiltersCollection\n");
6007 test_default_selection(doc);
6008 test_doc_title(doc, "");
6011 static void test_tr_elem(IHTMLElement *elem)
6013 IHTMLElementCollection *col;
6017 static const elem_type_t cell_types[] = {ET_TD,ET_TD};
6019 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
6020 ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
6025 hres = IHTMLTableRow_get_cells(row, &col);
6026 ok(hres == S_OK, "get_cells failed: %08x\n", hres);
6027 ok(col != NULL, "get_cells returned NULL\n");
6029 test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
6030 IHTMLElementCollection_Release(col);
6032 IHTMLTable_Release(row);
6035 static void test_table_elem(IHTMLElement *elem)
6037 IHTMLElementCollection *col;
6042 static const elem_type_t row_types[] = {ET_TR,ET_TR};
6043 static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD};
6045 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table);
6046 ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres);
6051 hres = IHTMLTable_get_rows(table, &col);
6052 ok(hres == S_OK, "get_rows failed: %08x\n", hres);
6053 ok(col != NULL, "get_ros returned NULL\n");
6055 test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types));
6056 IHTMLElementCollection_Release(col);
6058 test_elem_all((IUnknown*)table, all_types, sizeof(all_types)/sizeof(*all_types));
6060 node = clone_node((IUnknown*)table, VARIANT_TRUE);
6061 test_elem_tag((IUnknown*)node, "TABLE");
6062 test_elem_all((IUnknown*)node, all_types, sizeof(all_types)/sizeof(*all_types));
6063 IHTMLDOMNode_Release(node);
6065 node = clone_node((IUnknown*)table, VARIANT_FALSE);
6066 test_elem_tag((IUnknown*)node, "TABLE");
6067 test_elem_all((IUnknown*)node, NULL, 0);
6068 IHTMLDOMNode_Release(node);
6070 IHTMLTable_Release(table);
6073 static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
6082 sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
6083 SafeArrayAccessData(sa, (void**)&var);
6084 V_VT(var) = VT_BSTR;
6085 V_BSTR(var) = a2bstr(text);
6086 SafeArrayUnaccessData(sa);
6089 hres = IHTMLDocument2_writeln(doc, sa);
6091 hres = IHTMLDocument2_write(doc, sa);
6092 ok(hres == S_OK, "write failed: %08x\n", hres);
6094 SafeArrayDestroy(sa);
6097 static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
6099 IHTMLDocument2 *window_doc, *elem_doc;
6100 IHTMLFrameElement3 *frame_elem3;
6101 IHTMLWindow2 *content_window;
6104 content_window = get_frame_content_window(frame_elem);
6105 window_doc = get_window_doc(content_window);
6106 IHTMLWindow2_Release(content_window);
6108 elem_doc = get_elem_doc(frame_elem);
6109 ok(iface_cmp((IUnknown*)window_doc, (IUnknown*)elem_doc), "content_doc != elem_doc\n");
6112 hres = IUnknown_QueryInterface(frame_elem, &IID_IHTMLFrameElement3, (void**)&frame_elem3);
6113 if(SUCCEEDED(hres)) {
6114 IDispatch *disp = NULL;
6116 hres = IHTMLFrameElement3_get_contentDocument(frame_elem3, &disp);
6117 ok(hres == S_OK, "get_contentDocument failed: %08x\n", hres);
6118 ok(disp != NULL, "contentDocument == NULL\n");
6119 ok(iface_cmp((IUnknown*)disp, (IUnknown*)window_doc), "contentDocument != contentWindow.document\n");
6121 IDispatch_Release(disp);
6122 IHTMLFrameElement3_Release(frame_elem3);
6124 win_skip("IHTMLFrameElement3 not supported\n");
6128 IHTMLDocument2_Release(elem_doc);
6129 IHTMLDocument2_Release(window_doc);
6132 static void test_iframe_elem(IHTMLElement *elem)
6134 IHTMLDocument2 *content_doc, *owner_doc;
6135 IHTMLElementCollection *col;
6136 IHTMLWindow2 *content_window;
6142 static const elem_type_t all_types[] = {
6150 test_frame_doc((IUnknown*)elem, TRUE);
6152 content_window = get_frame_content_window((IUnknown*)elem);
6153 test_window_length(content_window, 0);
6155 content_doc = get_window_doc(content_window);
6156 IHTMLWindow2_Release(content_window);
6158 str = a2bstr("text/html");
6159 V_VT(&errv) = VT_ERROR;
6161 hres = IHTMLDocument2_open(content_doc, str, errv, errv, errv, &disp);
6163 ok(hres == S_OK, "open failed: %08x\n", hres);
6164 ok(disp != NULL, "disp == NULL\n");
6165 ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
6166 IDispatch_Release(disp);
6168 doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
6169 doc_write(content_doc, TRUE, "</html>");
6171 hres = IHTMLDocument2_get_all(content_doc, &col);
6172 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6173 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6174 IHTMLElementCollection_Release(col);
6176 hres = IHTMLDocument2_close(content_doc);
6177 ok(hres == S_OK, "close failed: %08x\n", hres);
6179 owner_doc = get_owner_doc((IUnknown*)content_doc);
6180 ok(!owner_doc, "owner_doc = %p\n", owner_doc);
6182 IHTMLDocument2_Release(content_doc);
6185 static void test_stylesheet(IDispatch *disp)
6187 IHTMLStyleSheetRulesCollection *col = NULL;
6188 IHTMLStyleSheet *stylesheet;
6191 hres = IDispatch_QueryInterface(disp, &IID_IHTMLStyleSheet, (void**)&stylesheet);
6192 ok(hres == S_OK, "Could not get IHTMLStyleSheet: %08x\n", hres);
6194 hres = IHTMLStyleSheet_get_rules(stylesheet, &col);
6195 ok(hres == S_OK, "get_rules failed: %08x\n", hres);
6196 ok(col != NULL, "col == NULL\n");
6198 IHTMLStyleSheetRulesCollection_Release(col);
6199 IHTMLStyleSheet_Release(stylesheet);
6202 static void test_stylesheets(IHTMLDocument2 *doc)
6204 IHTMLStyleSheetsCollection *col = NULL;
6209 hres = IHTMLDocument2_get_styleSheets(doc, &col);
6210 ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);
6211 ok(col != NULL, "col == NULL\n");
6213 test_disp2((IUnknown*)col, &DIID_DispHTMLStyleSheetsCollection, &IID_IHTMLStyleSheetsCollection, "[object]");
6215 hres = IHTMLStyleSheetsCollection_get_length(col, &len);
6216 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6217 ok(len == 1, "len=%d\n", len);
6223 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6224 ok(hres == S_OK, "item failed: %08x\n", hres);
6225 ok(V_VT(&res) == VT_DISPATCH, "V_VT(res) = %d\n", V_VT(&res));
6226 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6227 test_stylesheet(V_DISPATCH(&res));
6234 hres = IHTMLStyleSheetsCollection_item(col, &idx, &res);
6235 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6236 ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
6237 ok(V_DISPATCH(&res) != NULL, "V_DISPATCH(&res) == NULL\n");
6240 IHTMLStyleSheetsCollection_Release(col);
6243 static void test_child_col_disp(IHTMLDOMChildrenCollection *col)
6245 IDispatchEx *dispex;
6247 DISPPARAMS dp = {NULL, NULL, 0, 0};
6255 static const WCHAR w0[] = {'0',0};
6256 static const WCHAR w100[] = {'1','0','0',0};
6258 hres = IHTMLDOMChildrenCollection_QueryInterface(col, &IID_IDispatchEx, (void**)&dispex);
6259 ok(hres == S_OK, "Could not get IDispatchEx: %08x\n", hres);
6261 bstr = SysAllocString(w0);
6262 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6263 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6264 SysFreeString(bstr);
6267 hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, INVOKE_PROPERTYGET, &dp, &var, &ei, NULL);
6268 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
6269 ok(V_VT(&var) == VT_DISPATCH, "V_VT(var)=%d\n", V_VT(&var));
6270 ok(V_DISPATCH(&var) != NULL, "V_DISPATCH(var) == NULL\n");
6271 node = get_node_iface((IUnknown*)V_DISPATCH(&var));
6272 type = get_node_type((IUnknown*)node);
6273 ok(type == 3, "type=%d\n", type);
6274 IHTMLDOMNode_Release(node);
6277 bstr = SysAllocString(w100);
6278 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &id);
6279 ok(hres == DISP_E_UNKNOWNNAME, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres);
6280 SysFreeString(bstr);
6282 IDispatchEx_Release(dispex);
6287 static void test_elems(IHTMLDocument2 *doc)
6289 IHTMLElementCollection *col;
6290 IHTMLDOMChildrenCollection *child_col;
6291 IHTMLElement *elem, *elem2, *elem3;
6292 IHTMLDOMNode *node, *node2;
6293 IHTMLWindow2 *window;
6297 IHTMLElementCollection *collection;
6298 IHTMLDocument3 *doc3;
6301 static const elem_type_t all_types[] = {
6329 static const elem_type_t item_types[] = {
6335 hres = IHTMLDocument2_get_all(doc, &col);
6336 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6337 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
6338 test_elem_col_item(col, "x", item_types, sizeof(item_types)/sizeof(item_types[0]));
6339 IHTMLElementCollection_Release(col);
6341 hres = IHTMLDocument2_get_images(doc, &collection);
6342 ok(hres == S_OK, "get_images failed: %08x\n", hres);
6345 static const elem_type_t images_types[] = {ET_IMG};
6346 test_elem_collection((IUnknown*)collection, images_types, 1);
6348 IHTMLElementCollection_Release(collection);
6351 hres = IHTMLDocument2_get_links(doc, &collection);
6352 ok(hres == S_OK, "get_links failed: %08x\n", hres);
6355 static const elem_type_t images_types[] = {ET_A};
6356 test_elem_collection((IUnknown*)collection, images_types, 1);
6358 IHTMLElementCollection_Release(collection);
6361 hres = IHTMLDocument2_get_anchors(doc, &collection);
6362 ok(hres == S_OK, "get_anchors failed: %08x\n", hres);
6365 static const elem_type_t anchor_types[] = {ET_A};
6366 test_elem_collection((IUnknown*)collection, anchor_types, 1);
6368 IHTMLElementCollection_Release(collection);
6371 elem = get_doc_elem(doc);
6372 test_elem_all((IUnknown*)elem, all_types+1, sizeof(all_types)/sizeof(all_types[0])-1);
6373 IHTMLElement_Release(elem);
6375 get_elem_by_id(doc, "xxx", FALSE);
6376 elem = get_doc_elem_by_id(doc, "xxx");
6377 ok(!elem, "elem != NULL\n");
6379 elem = get_doc_elem_by_id(doc, "s");
6380 ok(elem != NULL, "elem == NULL\n");
6382 test_elem_type((IUnknown*)elem, ET_SELECT);
6383 test_elem_attr(elem, "xxx", NULL);
6384 test_elem_attr(elem, "id", "s");
6385 test_elem_class((IUnknown*)elem, NULL);
6386 test_elem_set_class((IUnknown*)elem, "cl");
6387 test_elem_set_class((IUnknown*)elem, NULL);
6388 test_elem_tabindex((IUnknown*)elem, 0);
6389 test_elem_set_tabindex((IUnknown*)elem, 1);
6390 test_elem_filters((IUnknown*)elem);
6392 node = test_node_get_parent((IUnknown*)elem);
6393 ok(node != NULL, "node == NULL\n");
6394 test_node_name((IUnknown*)node, "BODY");
6395 node2 = test_node_get_parent((IUnknown*)node);
6396 IHTMLDOMNode_Release(node);
6397 ok(node2 != NULL, "node == NULL\n");
6398 test_node_name((IUnknown*)node2, "HTML");
6399 node = test_node_get_parent((IUnknown*)node2);
6400 IHTMLDOMNode_Release(node2);
6401 ok(node != NULL, "node == NULL\n");
6404 test_node_name((IUnknown*)node, "#document");
6405 type = get_node_type((IUnknown*)node);
6406 ok(type == 9, "type=%d, expected 9\n", type);
6407 node2 = test_node_get_parent((IUnknown*)node);
6408 IHTMLDOMNode_Release(node);
6409 ok(node2 == NULL, "node != NULL\n");
6412 elem2 = test_elem_get_parent((IUnknown*)elem);
6413 ok(elem2 != NULL, "elem2 == NULL\n");
6414 test_node_name((IUnknown*)elem2, "BODY");
6415 elem3 = test_elem_get_parent((IUnknown*)elem2);
6416 IHTMLElement_Release(elem2);
6417 ok(elem3 != NULL, "elem3 == NULL\n");
6418 test_node_name((IUnknown*)elem3, "HTML");
6419 elem2 = test_elem_get_parent((IUnknown*)elem3);
6420 IHTMLElement_Release(elem3);
6421 ok(elem2 == NULL, "elem2 != NULL\n");
6423 test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
6424 test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
6425 test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
6427 test_elem_innertext(elem, "opt1opt2");
6429 IHTMLElement_Release(elem);
6432 elem = get_elem_by_id(doc, "s", TRUE);
6434 IHTMLSelectElement *select = get_select_iface((IUnknown*)elem);
6435 IHTMLDocument2 *doc_node, *elem_doc;
6437 test_select_elem(select);
6439 test_elem_title((IUnknown*)select, NULL);
6440 test_elem_set_title((IUnknown*)select, "Title");
6441 test_elem_title((IUnknown*)select, "Title");
6442 test_elem_offset((IUnknown*)select);
6443 test_elem_bounding_client_rect((IUnknown*)select);
6445 node = get_first_child((IUnknown*)select);
6446 ok(node != NULL, "node == NULL\n");
6448 test_elem_type((IUnknown*)node, ET_OPTION);
6449 IHTMLDOMNode_Release(node);
6452 type = get_node_type((IUnknown*)select);
6453 ok(type == 1, "type=%d\n", type);
6455 IHTMLSelectElement_Release(select);
6457 elem_doc = get_elem_doc((IUnknown*)elem);
6459 doc_node = get_doc_node(doc);
6460 ok(iface_cmp((IUnknown*)elem_doc, (IUnknown*)doc_node), "disp != doc\n");
6461 IHTMLDocument2_Release(doc_node);
6462 IHTMLDocument2_Release(elem_doc);
6464 IHTMLElement_Release(elem);
6467 elem = get_elem_by_id(doc, "sc", TRUE);
6469 IHTMLScriptElement *script;
6472 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script);
6473 ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres);
6479 hres = IHTMLScriptElement_put_type (script, NULL);
6480 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6481 hres = IHTMLScriptElement_get_type(script, &type);
6482 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6483 ok(type == NULL, "Unexpected type %s\n", wine_dbgstr_w(type));
6485 hres = IHTMLScriptElement_put_type (script, a2bstr ("text/javascript"));
6486 ok(hres == S_OK, "put_type failed: %08x\n", hres);
6487 hres = IHTMLScriptElement_get_type(script, &type);
6488 ok(hres == S_OK, "get_type failed: %08x\n", hres);
6489 ok(!strcmp_wa(type, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type));
6491 SysFreeString(type);
6494 hres = IHTMLScriptElement_put_defer(script, VARIANT_TRUE);
6495 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6497 hres = IHTMLScriptElement_get_defer(script, &vb);
6498 ok(hres == S_OK, "get_defer failed: %08x\n", hres);
6499 ok(vb == VARIANT_TRUE, "get_defer result is %08x\n", hres);
6501 hres = IHTMLScriptElement_put_defer(script, VARIANT_FALSE);
6502 ok(hres == S_OK, "put_defer failed: %08x\n", hres);
6504 str = (BSTR)0xdeadbeef;
6505 hres = IHTMLScriptElement_get_src(script, &str);
6506 ok(hres == S_OK, "get_src failed: %08x\n", hres);
6507 ok(!str, "src = %s\n", wine_dbgstr_w(str));
6510 IHTMLScriptElement_Release(script);
6513 elem = get_elem_by_id(doc, "in", TRUE);
6515 IHTMLInputElement *input;
6517 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
6518 ok(hres == S_OK, "Could not get IHTMLInputElement: %08x\n", hres);
6520 test_elem_id((IUnknown*)elem, "in");
6521 test_elem_put_id((IUnknown*)elem, "newin");
6522 test_input_get_disabled(input, VARIANT_FALSE);
6523 test_input_set_disabled(input, VARIANT_TRUE);
6524 test_input_set_disabled(input, VARIANT_FALSE);
6525 test_elem3_set_disabled((IUnknown*)input, VARIANT_TRUE);
6526 test_input_get_disabled(input, VARIANT_TRUE);
6527 test_elem3_set_disabled((IUnknown*)input, VARIANT_FALSE);
6528 test_input_get_disabled(input, VARIANT_FALSE);
6529 test_elem_client_size((IUnknown*)elem);
6530 test_input_type(input, "text");
6532 test_node_get_value_str((IUnknown*)elem, NULL);
6533 test_node_put_value_str((IUnknown*)elem, "test");
6534 test_node_get_value_str((IUnknown*)elem, NULL);
6535 test_input_value((IUnknown*)elem, NULL);
6536 test_input_put_value((IUnknown*)elem, "test");
6537 test_elem_class((IUnknown*)elem, "testclass");
6538 test_elem_tabindex((IUnknown*)elem, 2);
6539 test_elem_set_tabindex((IUnknown*)elem, 3);
6540 test_elem_title((IUnknown*)elem, "test title");
6542 test_input_get_defaultchecked(input, VARIANT_FALSE);
6543 test_input_set_defaultchecked(input, VARIANT_TRUE);
6544 test_input_set_defaultchecked(input, VARIANT_FALSE);
6546 test_input_get_checked(input, VARIANT_FALSE);
6547 test_input_set_checked(input, VARIANT_TRUE);
6548 test_input_set_checked(input, VARIANT_FALSE);
6550 test_input_name(input, NULL);
6551 test_input_set_name(input, "test");
6553 test_input_src(input, NULL);
6554 test_input_set_src(input, "about:blank");
6556 IHTMLInputElement_Release(input);
6557 IHTMLElement_Release(elem);
6560 elem = get_elem_by_id(doc, "imgid", TRUE);
6562 test_img_src((IUnknown*)elem, "");
6563 test_img_set_src((IUnknown*)elem, "about:blank");
6564 test_img_alt((IUnknown*)elem, NULL);
6565 test_img_set_alt((IUnknown*)elem, "alt test");
6566 test_img_name((IUnknown*)elem, "WineImg");
6567 IHTMLElement_Release(elem);
6570 elem = get_elem_by_id(doc, "styleid", TRUE);
6572 test_style_media((IUnknown*)elem, NULL);
6573 test_style_put_media((IUnknown*)elem, "screen");
6574 test_style_type((IUnknown*)elem, NULL);
6575 test_style_put_type((IUnknown*)elem, "text/css");
6576 IHTMLElement_Release(elem);
6579 elem = get_doc_elem_by_id(doc, "tbl");
6580 ok(elem != NULL, "elem == NULL\n");
6582 test_table_elem(elem);
6583 IHTMLElement_Release(elem);
6586 elem = get_doc_elem_by_id(doc, "row2");
6587 ok(elem != NULL, "elem == NULL\n");
6590 IHTMLElement_Release(elem);
6593 elem = get_doc_elem_by_id(doc, "ifr");
6594 ok(elem != NULL, "elem == NULL\n");
6596 test_iframe_elem(elem);
6597 IHTMLElement_Release(elem);
6600 elem = get_doc_elem_by_id(doc, "objid");
6601 ok(elem != NULL, "elem == NULL\n");
6603 test_object_vspace((IUnknown*)elem, 100);
6604 IHTMLElement_Release(elem);
6607 elem = get_elem_by_id(doc, "a", TRUE);
6609 test_anchor_href((IUnknown*)elem, "http://test/");
6611 /* Change the href */
6612 test_anchor_put_href((IUnknown*)elem, "http://test1/");
6613 test_anchor_href((IUnknown*)elem, "http://test1/");
6615 /* Restore the href */
6616 test_anchor_put_href((IUnknown*)elem, "http://test/");
6617 test_anchor_href((IUnknown*)elem, "http://test/");
6620 test_anchor_get_target((IUnknown*)elem, NULL);
6622 /* Change the target */
6623 test_anchor_put_target((IUnknown*)elem, "wine");
6624 test_anchor_get_target((IUnknown*)elem, "wine");
6626 /* Restore the target */
6627 test_anchor_put_target((IUnknown*)elem, NULL);
6628 test_anchor_get_target((IUnknown*)elem, NULL);
6630 IHTMLElement_Release(elem);
6633 elem = doc_get_body(doc);
6635 node = get_first_child((IUnknown*)elem);
6636 ok(node != NULL, "node == NULL\n");
6638 test_ifaces((IUnknown*)node, text_iids);
6639 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6641 node2 = get_first_child((IUnknown*)node);
6642 ok(!node2, "node2 != NULL\n");
6644 type = get_node_type((IUnknown*)node);
6645 ok(type == 3, "type=%d\n", type);
6647 test_node_get_value_str((IUnknown*)node, "text test");
6648 test_node_put_value_str((IUnknown*)elem, "test text");
6649 test_node_get_value_str((IUnknown*)node, "text test");
6651 IHTMLDOMNode_Release(node);
6654 child_col = get_child_nodes((IUnknown*)elem);
6655 ok(child_col != NULL, "child_coll == NULL\n");
6659 test_disp((IUnknown*)child_col, &DIID_DispDOMChildrenCollection, "[object]");
6661 hres = IHTMLDOMChildrenCollection_get_length(child_col, &length);
6662 ok(hres == S_OK, "get_length failed: %08x\n", hres);
6663 ok(length, "length=0\n");
6666 node = get_child_item(child_col, 0);
6667 ok(node != NULL, "node == NULL\n");
6669 type = get_node_type((IUnknown*)node);
6670 ok(type == 3, "type=%d\n", type);
6671 node2 = node_get_next((IUnknown*)node);
6672 IHTMLDOMNode_Release(node);
6675 node = get_child_item(child_col, 1);
6676 ok(node != NULL, "node == NULL\n");
6678 type = get_node_type((IUnknown*)node);
6679 ok(type == 8, "type=%d\n", type);
6681 test_elem_id((IUnknown*)node, NULL);
6682 ok(iface_cmp((IUnknown*)node2, (IUnknown*)node), "node2 != node\n");
6683 IHTMLDOMNode_Release(node2);
6684 IHTMLDOMNode_Release(node);
6687 hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL);
6688 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6690 hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL);
6691 ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres);
6693 hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp);
6694 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6696 hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp);
6697 ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres);
6699 test_child_col_disp(child_col);
6701 IHTMLDOMChildrenCollection_Release(child_col);
6704 test_elem3_get_disabled((IUnknown*)elem, VARIANT_FALSE);
6705 test_elem3_set_disabled((IUnknown*)elem, VARIANT_TRUE);
6706 test_elem3_set_disabled((IUnknown*)elem, VARIANT_FALSE);
6708 IHTMLElement_Release(elem);
6710 elem = get_doc_elem_by_id(doc, "frm");
6711 ok(elem != NULL, "elem == NULL\n");
6713 test_form_length((IUnknown*)elem, 0);
6714 test_form_elements((IUnknown*)elem);
6715 IHTMLElement_Release(elem);
6718 test_stylesheets(doc);
6719 test_create_option_elem(doc);
6720 test_create_img_elem(doc);
6722 elem = get_doc_elem_by_id(doc, "tbl");
6723 ok(elem != NULL, "elem = NULL\n");
6724 test_elem_set_innertext(elem, "inner text");
6725 IHTMLElement_Release(elem);
6727 test_doc_title(doc, "test");
6728 test_doc_set_title(doc, "test title");
6729 test_doc_title(doc, "test title");
6732 hres = IHTMLDocument2_get_Script(doc, &disp);
6733 ok(hres == S_OK, "get_Script failed: %08x\n", hres);
6736 IDispatchEx *dispex;
6737 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
6738 ok(hres == S_OK, "IDispatch_QueryInterface failed: %08x\n", hres);
6742 BSTR str = a2bstr("Testing");
6743 hres = IDispatchEx_GetDispID(dispex, str, 1, &pid);
6744 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
6745 ok(pid != -1, "pid == -1\n");
6747 IDispatchEx_Release(dispex);
6750 IDispatch_Release(disp);
6752 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
6753 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
6755 str = a2bstr("img");
6756 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
6757 ok(hres == S_OK, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str), hres);
6761 static const elem_type_t img_types[] = { ET_IMG };
6763 test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
6764 IHTMLElementCollection_Release(col);
6767 elem = get_doc_elem_by_id(doc, "y");
6768 test_elem_set_innerhtml((IUnknown*)elem, "inner html");
6769 test_elem_innerhtml((IUnknown*)elem, "inner html");
6770 test_elem_set_innerhtml((IUnknown*)elem, "");
6771 test_elem_innerhtml((IUnknown*)elem, NULL);
6772 node = node_get_next((IUnknown*)elem);
6773 ok(!node, "node = %p\n", node);
6775 elem2 = get_doc_elem_by_id(doc, "x");
6776 test_elem_tag((IUnknown*)elem2, "A");
6777 node = node_get_next((IUnknown*)elem2);
6778 IHTMLDOMNode_Release(node);
6779 IHTMLElement_Release(elem2);
6780 IHTMLElement_Release(elem);
6782 IHTMLDocument3_Release(doc3);
6784 elem = get_elem_by_id(doc, "s", TRUE);
6786 static const elem_type_t select_types[] = { ET_OPTION, ET_OPTION, ET_OPTION };
6788 test_select_put_length((IUnknown*)elem, 3);
6789 test_elem_all((IUnknown*)elem, select_types, sizeof(select_types)/sizeof(*select_types));
6790 test_select_put_length((IUnknown*)elem, 1);
6791 test_elem_all((IUnknown*)elem, select_types, 1);
6792 IHTMLElement_Release(elem);
6795 window = get_doc_window(doc);
6796 test_window_name(window, NULL);
6797 set_window_name(window, "test name");
6798 test_window_length(window, 1);
6799 IHTMLWindow2_Release(window);
6802 static void test_attr(IHTMLElement *elem)
6804 IHTMLDOMAttribute *attr, *attr2;
6806 get_elem_attr_node((IUnknown*)elem, "noattr", FALSE);
6808 attr = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6810 test_disp((IUnknown*)attr, &DIID_DispHTMLDOMAttribute, "[object]");
6811 test_ifaces((IUnknown*)attr, attr_iids);
6812 test_no_iface((IUnknown*)attr, &IID_IHTMLDOMNode);
6814 attr2 = get_elem_attr_node((IUnknown*)elem, "id", TRUE);
6816 ok(iface_cmp((IUnknown*)attr, (IUnknown*)attr2), "attr != attr2\n");
6817 IHTMLDOMAttribute_Release(attr2);
6819 test_attr_node_value(attr, "divid");
6821 IHTMLDOMAttribute_Release(attr);
6823 attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
6824 test_attr_node_value(attr, NULL);
6825 IHTMLDOMAttribute_Release(attr);
6828 static void test_elems2(IHTMLDocument2 *doc)
6830 IHTMLElement *elem, *elem2, *div;
6832 static const elem_type_t outer_types[] = {
6837 div = get_doc_elem_by_id(doc, "divid");
6839 test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
6840 elem2 = get_doc_elem_by_id(doc, "innerid");
6841 ok(elem2 != NULL, "elem2 == NULL\n");
6842 test_elem_set_outerhtml((IUnknown*)elem2, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
6843 test_elem_all((IUnknown*)div, outer_types, sizeof(outer_types)/sizeof(*outer_types));
6844 IHTMLElement_Release(elem2);
6846 elem2 = get_doc_elem_by_id(doc, "aid");
6847 ok(elem2 != NULL, "elem2 == NULL\n");
6848 test_elem_set_outerhtml((IUnknown*)elem2, "");
6849 test_elem_all((IUnknown*)div, outer_types, 1);
6850 IHTMLElement_Release(elem2);
6852 test_elem_set_innerhtml((IUnknown*)div, "<textarea id=\"ta\"></textarea>");
6853 elem = get_elem_by_id(doc, "ta", TRUE);
6855 test_textarea_value((IUnknown*)elem, NULL);
6856 test_textarea_put_value((IUnknown*)elem, "test");
6857 test_textarea_readonly((IUnknown*)elem, VARIANT_FALSE);
6858 test_textarea_put_readonly((IUnknown*)elem, VARIANT_TRUE);
6859 test_textarea_put_readonly((IUnknown*)elem, VARIANT_FALSE);
6860 test_textarea_type((IUnknown*)elem);
6861 IHTMLElement_Release(elem);
6864 test_elem_set_innerhtml((IUnknown*)div,
6865 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" /></div></textarea>");
6866 elem = get_elem_by_id(doc, "form", TRUE);
6868 test_form_length((IUnknown*)elem, 2);
6869 test_form_item(elem);
6870 test_form_action((IUnknown*)elem, NULL);
6871 test_form_put_action((IUnknown*)elem, "about:blank");
6872 test_form_method((IUnknown*)elem, "get");
6873 test_form_put_method((IUnknown*)elem, S_OK, "post");
6874 test_form_put_method((IUnknown*)elem, E_INVALIDARG, "put");
6875 test_form_method((IUnknown*)elem, "post");
6876 test_form_name((IUnknown*)elem, NULL);
6877 test_form_put_name((IUnknown*)elem, "Name");
6878 test_form_encoding((IUnknown*)elem, "application/x-www-form-urlencoded");
6879 test_form_put_encoding((IUnknown*)elem, S_OK, "text/plain");
6880 test_form_put_encoding((IUnknown*)elem, S_OK, "multipart/form-data");
6881 test_form_put_encoding((IUnknown*)elem, E_INVALIDARG, "image/png");
6882 test_form_encoding((IUnknown*)elem, "multipart/form-data");
6883 test_form_elements((IUnknown*)elem);
6884 IHTMLElement_Release(elem);
6888 test_style_filters(div);
6890 IHTMLElement_Release(div);
6893 static void test_create_elems(IHTMLDocument2 *doc)
6895 IHTMLElement *elem, *body, *elem2;
6896 IHTMLDOMNode *node, *node2, *node3, *comment;
6897 IHTMLDocument5 *doc5;
6904 static const elem_type_t types1[] = { ET_TESTG };
6906 elem = test_create_elem(doc, "TEST");
6907 test_elem_tag((IUnknown*)elem, "TEST");
6908 type = get_node_type((IUnknown*)elem);
6909 ok(type == 1, "type=%d\n", type);
6910 test_ifaces((IUnknown*)elem, elem_iids);
6911 test_disp((IUnknown*)elem, &DIID_DispHTMLGenericElement, "[object]");
6913 body = doc_get_body(doc);
6914 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6916 node = test_node_append_child((IUnknown*)body, (IUnknown*)elem);
6917 test_node_has_child((IUnknown*)body, VARIANT_TRUE);
6918 elem2 = get_elem_iface((IUnknown*)node);
6919 IHTMLElement_Release(elem2);
6921 hres = IHTMLElement_get_all(body, &disp);
6922 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6923 test_elem_collection((IUnknown*)disp, types1, sizeof(types1)/sizeof(types1[0]));
6924 IDispatch_Release(disp);
6926 test_node_remove_child((IUnknown*)body, node);
6928 hres = IHTMLElement_get_all(body, &disp);
6929 ok(hres == S_OK, "get_all failed: %08x\n", hres);
6930 test_elem_collection((IUnknown*)disp, NULL, 0);
6931 IDispatch_Release(disp);
6932 test_node_has_child((IUnknown*)body, VARIANT_FALSE);
6934 IHTMLElement_Release(elem);
6935 IHTMLDOMNode_Release(node);
6937 node = test_create_text(doc, "test");
6938 test_ifaces((IUnknown*)node, text_iids);
6939 test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
6940 test_text_length((IUnknown*)node, 4);
6942 V_VT(&var) = VT_NULL;
6943 node2 = test_node_insertbefore((IUnknown*)body, node, &var);
6944 IHTMLDOMNode_Release(node);
6946 node = test_create_text(doc, "insert ");
6948 V_VT(&var) = VT_DISPATCH;
6949 V_DISPATCH(&var) = (IDispatch*)node2;
6950 node3 = test_node_insertbefore((IUnknown*)body, node, &var);
6951 IHTMLDOMNode_Release(node);
6952 IHTMLDOMNode_Release(node2);
6953 IHTMLDOMNode_Release(node3);
6955 test_elem_innertext(body, "insert test");
6956 test_elem_innerhtml((IUnknown*)body, "insert test");
6958 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6961 str = a2bstr("testing");
6962 hres = IHTMLDocument5_createComment(doc5, str, &comment);
6964 ok(hres == S_OK, "createComment failed: %08x\n", hres);
6967 type = get_node_type((IUnknown*)comment);
6968 ok(type == 8, "type=%d, expected 8\n", type);
6970 test_node_get_value_str((IUnknown*)comment, "testing");
6971 test_elem_title((IUnknown*)comment, NULL);
6972 test_elem_set_title((IUnknown*)comment, "comment title");
6973 test_elem_title((IUnknown*)comment, "comment title");
6974 test_comment_text((IUnknown*)comment, "<!--testing-->");
6975 test_elem_outerhtml((IUnknown*)comment, "<!--testing-->");
6977 IHTMLDOMNode_Release(comment);
6980 IHTMLDocument5_Release(doc5);
6983 IHTMLElement_Release(body);
6986 static void test_null_write(IHTMLDocument2 *doc)
6990 doc_write(doc, FALSE, NULL);
6991 doc_write(doc, TRUE, NULL);
6993 hres = IHTMLDocument2_write(doc, NULL);
6995 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres);
6997 hres = IHTMLDocument2_writeln(doc, NULL);
6999 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres);
7002 static void test_exec(IUnknown *unk, const GUID *grpid, DWORD cmdid, VARIANT *in, VARIANT *out)
7004 IOleCommandTarget *cmdtrg;
7007 hres = IHTMLTxtRange_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
7008 ok(hres == S_OK, "Could not get IOleCommandTarget interface: %08x\n", hres);
7010 hres = IOleCommandTarget_Exec(cmdtrg, grpid, cmdid, 0, in, out);
7011 ok(hres == S_OK, "Exec failed: %08x\n", hres);
7013 IOleCommandTarget_Release(cmdtrg);
7016 static void test_indent(IHTMLDocument2 *doc)
7018 IHTMLElementCollection *col;
7019 IHTMLTxtRange *range;
7022 static const elem_type_t all_types[] = {
7031 static const elem_type_t indent_types[] = {
7042 hres = IHTMLDocument2_get_all(doc, &col);
7043 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7044 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7045 IHTMLElementCollection_Release(col);
7047 range = test_create_body_range(doc);
7048 test_exec((IUnknown*)range, &CGID_MSHTML, IDM_INDENT, NULL, NULL);
7049 IHTMLTxtRange_Release(range);
7051 hres = IHTMLDocument2_get_all(doc, &col);
7052 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7053 test_elem_collection((IUnknown*)col, indent_types, sizeof(indent_types)/sizeof(indent_types[0]));
7054 IHTMLElementCollection_Release(col);
7057 static void test_cond_comment(IHTMLDocument2 *doc)
7059 IHTMLElementCollection *col;
7062 static const elem_type_t all_types[] = {
7070 hres = IHTMLDocument2_get_all(doc, &col);
7071 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7072 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7073 IHTMLElementCollection_Release(col);
7076 static void test_frame(IDispatch *disp, const char *exp_id)
7078 IHTMLWindow2 *frame2, *parent, *top;
7079 IHTMLDocument2 *parent_doc, *top_doc;
7080 IHTMLWindow4 *frame;
7081 IHTMLFrameBase *frame_elem;
7084 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow4, (void**)&frame);
7085 ok(hres == S_OK, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres);
7089 hres = IHTMLWindow4_get_frameElement(frame, &frame_elem);
7090 ok(hres == S_OK, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres);
7091 IHTMLWindow4_Release(frame);
7095 test_elem_type((IUnknown*)frame_elem, ET_FRAME);
7096 test_frame_doc((IUnknown*)frame_elem, FALSE);
7097 test_elem_id((IUnknown*)frame_elem, exp_id);
7098 IHTMLElement_Release(frame_elem);
7100 hres = IDispatch_QueryInterface(disp, &IID_IHTMLWindow2, (void**)&frame2);
7101 ok(hres == S_OK, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres);
7105 hres = IHTMLWindow2_get_parent(frame2, &parent);
7106 ok(hres == S_OK, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres);
7108 IHTMLWindow2_Release(frame2);
7112 hres = IHTMLWindow2_get_document(parent, &parent_doc);
7113 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7114 IHTMLWindow2_Release(parent);
7116 IHTMLWindow2_Release(frame2);
7120 test_doc_title(parent_doc, "frameset test");
7121 IHTMLDocument2_Release(parent_doc);
7124 hres = IHTMLWindow2_get_top(frame2, &top);
7125 ok(hres == S_OK, "IHTMLWindow2_get_top failed: 0x%08x\n", hres);
7126 IHTMLWindow2_Release(frame2);
7130 hres = IHTMLWindow2_get_document(top, &top_doc);
7131 ok(hres == S_OK, "IHTMLWindow2_get_document failed: 0x%08x\n", hres);
7132 IHTMLWindow2_Release(top);
7136 test_doc_title(top_doc, "frameset test");
7137 IHTMLDocument2_Release(top_doc);
7140 static void test_frameset(IHTMLDocument2 *doc)
7142 IHTMLWindow2 *window;
7143 IHTMLFramesCollection2 *frames;
7145 IHTMLFrameBase *fbase;
7147 VARIANT index_var, result_var;
7151 window = get_doc_window(doc);
7153 /* test using IHTMLFramesCollection object */
7155 hres = IHTMLWindow2_get_frames(window, &frames);
7156 ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
7157 IHTMLWindow2_Release(window);
7161 /* test result length */
7162 hres = IHTMLFramesCollection2_get_length(frames, &length);
7163 ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
7164 ok(length == 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length);
7166 /* test first frame */
7167 V_VT(&index_var) = VT_I4;
7168 V_I4(&index_var) = 0;
7169 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7170 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7171 if(SUCCEEDED(hres)) {
7172 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7173 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7175 VariantClear(&result_var);
7177 /* test second frame */
7178 V_I4(&index_var) = 1;
7179 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7180 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7181 if(SUCCEEDED(hres)) {
7182 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7183 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7185 VariantClear(&result_var);
7187 /* fail on next frame */
7188 V_I4(&index_var) = 3;
7189 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7190 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLFramesCollection2_item should have"
7191 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7192 VariantClear(&result_var);
7194 /* string argument (element id lookup) */
7195 V_VT(&index_var) = VT_BSTR;
7196 V_BSTR(&index_var) = a2bstr("fr1");
7197 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7198 ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
7199 if(SUCCEEDED(hres)) {
7200 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7201 test_frame(V_DISPATCH(&result_var), "fr1");
7203 VariantClear(&result_var);
7204 VariantClear(&index_var);
7206 /* invalid argument */
7207 V_VT(&index_var) = VT_BOOL;
7208 V_BOOL(&index_var) = VARIANT_TRUE;
7209 hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
7210 ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
7211 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7212 VariantClear(&result_var);
7214 IHTMLFramesCollection2_Release(frames);
7216 /* test using IHTMLWindow2 inheritance */
7218 /* test result length */
7219 hres = IHTMLWindow2_get_length(window, &length);
7220 ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres);
7221 ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length);
7223 /* test first frame */
7224 V_VT(&index_var) = VT_I4;
7225 V_I4(&index_var) = 0;
7226 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7227 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7228 if(SUCCEEDED(hres)) {
7229 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7230 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
7232 VariantClear(&result_var);
7234 /* test second frame */
7235 V_I4(&index_var) = 1;
7236 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7237 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7238 if(SUCCEEDED(hres)) {
7239 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7240 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7242 VariantClear(&result_var);
7244 /* fail on next frame */
7245 V_I4(&index_var) = 3;
7246 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7247 ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have"
7248 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
7249 VariantClear(&result_var);
7251 /* string argument (element id lookup) */
7252 V_VT(&index_var) = VT_BSTR;
7253 V_BSTR(&index_var) = a2bstr("fr2");
7254 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7255 ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
7256 if(SUCCEEDED(hres)) {
7257 ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
7258 test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
7260 VariantClear(&result_var);
7261 VariantClear(&index_var);
7263 /* invalid argument */
7264 V_VT(&index_var) = VT_BOOL;
7265 V_BOOL(&index_var) = VARIANT_TRUE;
7266 hres = IHTMLWindow2_item(window, &index_var, &result_var);
7267 ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
7268 "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
7269 VariantClear(&result_var);
7271 /* getElementById with node name attributes */
7272 elem = get_doc_elem_by_id(doc, "nm1");
7273 test_elem_id((IUnknown*)elem, "fr1");
7275 /* get/put scrolling */
7276 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7277 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7279 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7280 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7281 ok(!strcmp_wa(str, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str));
7285 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7286 ok(hres == S_OK, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres);
7289 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7290 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7291 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7294 str = a2bstr("junk");
7295 hres = IHTMLFrameBase_put_scrolling(fbase, str);
7296 ok(hres == E_INVALIDARG, "IHTMLFrameBase_put_scrolling should have failed "
7297 "with E_INVALIDARG, instead: 0x%08x\n", hres);
7300 hres = IHTMLFrameBase_get_scrolling(fbase, &str);
7301 ok(hres == S_OK, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres);
7302 ok(!strcmp_wa(str, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str));
7306 hres = IHTMLFrameBase_get_name(fbase, &str);
7307 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7308 ok(!strcmp_wa(str, "nm1"), "get_name should have given 'nm1', gave: %s\n", wine_dbgstr_w(str));
7311 IHTMLFrameBase_Release(fbase);
7312 IHTMLElement_Release(elem);
7314 /* get_name with no name attr */
7315 elem = get_doc_elem_by_id(doc, "fr3");
7316 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase);
7317 ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres);
7319 hres = IHTMLFrameBase_get_name(fbase, &str);
7320 ok(hres == S_OK, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres);
7321 ok(str == NULL, "get_name should have given 'null', gave: %s\n", wine_dbgstr_w(str));
7324 IHTMLFrameBase_Release(fbase);
7325 IHTMLElement_Release(elem);
7328 static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
7330 IHTMLDocument2 *frag;
7331 IHTMLDocument3 *doc3;
7334 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
7335 ok(hres == S_OK, "Coult not get IHTMLDocument3 iface: %08x\n", hres);
7337 hres = IHTMLDocument3_createDocumentFragment(doc3, &frag);
7338 IHTMLDocument3_Release(doc3);
7339 ok(hres == S_OK, "createDocumentFragment failed: %08x\n", hres);
7340 ok(frag != NULL, "frag == NULL\n");
7345 static void test_docfrag(IHTMLDocument2 *doc)
7347 IHTMLElement *div, *body, *br;
7348 IHTMLElementCollection *col;
7349 IHTMLLocation *location;
7350 IHTMLDocument2 *frag;
7353 static const elem_type_t all_types[] = {
7362 frag = create_docfrag(doc);
7364 test_disp((IUnknown*)frag, &DIID_DispHTMLDocument, "[object]");
7366 body = (void*)0xdeadbeef;
7367 hres = IHTMLDocument2_get_body(frag, &body);
7368 ok(hres == S_OK, "get_body failed: %08x\n", hres);
7369 ok(!body, "body != NULL\n");
7371 location = (void*)0xdeadbeef;
7372 hres = IHTMLDocument2_get_location(frag, &location);
7373 ok(hres == E_UNEXPECTED, "get_location failed: %08x\n", hres);
7374 ok(location == (void*)0xdeadbeef, "location changed\n");
7376 br = test_create_elem(doc, "BR");
7377 test_node_append_child((IUnknown*)frag, (IUnknown*)br);
7378 IHTMLElement_Release(br);
7380 div = get_elem_by_id(doc, "divid", TRUE);
7381 test_node_append_child((IUnknown*)div, (IUnknown*)frag);
7382 IHTMLElement_Release(div);
7384 hres = IHTMLDocument2_get_all(doc, &col);
7385 ok(hres == S_OK, "get_all failed: %08x\n", hres);
7386 test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
7387 IHTMLElementCollection_Release(col);
7389 IHTMLDocument2_Release(frag);
7392 static IHTMLDocument2 *notif_doc;
7393 static BOOL doc_complete;
7395 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
7396 REFIID riid, void**ppv)
7398 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
7403 ok(0, "unexpected call\n");
7404 return E_NOINTERFACE;
7407 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
7412 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
7417 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
7419 if(dispID == DISPID_READYSTATE){
7423 hres = IHTMLDocument2_get_readyState(notif_doc, &state);
7424 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
7426 if(!strcmp_wa(state, "complete"))
7427 doc_complete = TRUE;
7429 SysFreeString(state);
7435 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
7437 ok(0, "unexpected call\n");
7441 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
7442 PropertyNotifySink_QueryInterface,
7443 PropertyNotifySink_AddRef,
7444 PropertyNotifySink_Release,
7445 PropertyNotifySink_OnChanged,
7446 PropertyNotifySink_OnRequestEdit
7449 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
7451 static IHTMLDocument2 *create_doc_with_string(const char *str)
7453 IPersistStreamInit *init;
7455 IHTMLDocument2 *doc;
7459 notif_doc = doc = create_document();
7463 doc_complete = FALSE;
7465 mem = GlobalAlloc(0, len);
7466 memcpy(mem, str, len);
7467 CreateStreamOnHGlobal(mem, TRUE, &stream);
7469 IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
7471 IPersistStreamInit_Load(init, stream);
7472 IPersistStreamInit_Release(init);
7473 IStream_Release(stream);
7478 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
7480 IConnectionPointContainer *container;
7481 IConnectionPoint *cp;
7485 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
7486 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
7488 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
7489 IConnectionPointContainer_Release(container);
7490 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
7492 hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
7493 IConnectionPoint_Release(cp);
7494 ok(hres == S_OK, "Advise failed: %08x\n", hres);
7497 typedef void (*domtest_t)(IHTMLDocument2*);
7499 static void run_domtest(const char *str, domtest_t test)
7501 IHTMLDocument2 *doc;
7505 doc = create_doc_with_string(str);
7509 do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
7511 while(!doc_complete && GetMessage(&msg, NULL, 0, 0)) {
7512 TranslateMessage(&msg);
7513 DispatchMessage(&msg);
7518 ref = IHTMLDocument2_Release(doc);
7519 ok(!ref || broken(ref == 1), /* Vista */
7527 run_domtest(doc_str1, test_doc_elem);
7528 run_domtest(doc_str1, test_get_set_attr);
7529 run_domtest(range_test_str, test_txtrange);
7530 run_domtest(range_test2_str, test_txtrange2);
7531 if (winetest_interactive || ! is_ie_hardened()) {
7532 run_domtest(elem_test_str, test_elems);
7534 skip("IE running in Enhanced Security Configuration\n");
7536 run_domtest(elem_test2_str, test_elems2);
7537 run_domtest(doc_blank, test_create_elems);
7538 run_domtest(doc_blank, test_defaults);
7539 run_domtest(doc_blank, test_null_write);
7540 run_domtest(indent_test_str, test_indent);
7541 run_domtest(cond_comment_str, test_cond_comment);
7542 run_domtest(frameset_str, test_frameset);
7543 run_domtest(emptydiv_str, test_docfrag);