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"
39 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
40 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
42 static const char doc_blank
[] = "<html></html>";
43 static const char doc_str1
[] = "<html><body>test</body></html>";
44 static const char range_test_str
[] =
45 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
46 static const char range_test2_str
[] =
47 "<html><body>abc<hr />123<br /><hr />def</body></html>";
48 static const char elem_test_str
[] =
49 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
50 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
51 "<link id=\"linkid\"></head>"
52 "<body onload=\"Testing()\">text test<!-- a comment -->"
53 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
54 "<label for=\"in\" id=\"labelid\">Label:</label>"
55 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
56 "<button id=\"btnid\"></button>"
57 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
58 "<textarea id=\"X\">text text</textarea>"
59 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
60 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
61 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
62 "<img id=\"imgid\" name=\"WineImg\"/>"
63 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
64 "<form id=\"frm\"></form>"
65 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
67 static const char elem_test2_str
[] =
68 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
69 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
70 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
73 static const char indent_test_str
[] =
74 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
75 static const char cond_comment_str
[] =
76 "<html><head><title>test</title></head><body>"
77 "<!--[if gte IE 4]> <br> <![endif]-->"
79 static const char frameset_str
[] =
80 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
81 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
82 "<frame src=\"about:blank\" id=\"fr3\">"
84 static const char emptydiv_str
[] =
85 "<html><head><title>emptydiv test</title></head>"
86 "<body><div id=\"divid\"></div></body></html>";
87 static const char noscript_str
[] =
88 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
89 "<body><noscript><div>test</div></noscript></body></html>";
90 static const char doctype_str
[] =
92 "<html><head><title>emptydiv test</title></head>"
93 "<body><div id=\"divid\"></div></body></html>";
95 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
96 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
97 static WCHAR wordW
[] = {'w','o','r','d',0};
136 static const IID
* const none_iids
[] = {
141 static const IID
* const doc_node_iids
[] = {
150 &IID_IConnectionPointContainer
,
151 &IID_IInternetHostSecurityManager
,
154 &IID_IProvideClassInfo
,
158 static const IID
* const doc_obj_iids
[] = {
165 &IID_IConnectionPointContainer
,
169 &IID_IProvideClassInfo
,
170 &IID_ITargetContainer
,
174 #define ELEM_IFACES \
176 &IID_IHTMLDOMNode2, \
178 &IID_IHTMLElement2, \
179 &IID_IHTMLElement3, \
180 &IID_IHTMLElement4, \
183 static const IID
* const elem_iids
[] = {
185 &IID_IConnectionPointContainer
,
189 static const IID
* const body_iids
[] = {
191 &IID_IHTMLTextContainer
,
192 &IID_IHTMLBodyElement
,
193 &IID_IConnectionPointContainer
,
197 static const IID
* const anchor_iids
[] = {
199 &IID_IHTMLAnchorElement
,
200 &IID_IConnectionPointContainer
,
204 static const IID
* const input_iids
[] = {
206 &IID_IHTMLInputElement
,
207 &IID_IHTMLInputTextElement
,
208 &IID_IConnectionPointContainer
,
212 static const IID
*const button_iids
[] = {
214 &IID_IHTMLButtonElement
,
215 &IID_IConnectionPointContainer
,
219 static const IID
* const label_iids
[] = {
221 &IID_IHTMLLabelElement
,
222 &IID_IConnectionPointContainer
,
226 static const IID
* const select_iids
[] = {
228 &IID_IHTMLSelectElement
,
229 &IID_IConnectionPointContainer
,
233 static const IID
* const textarea_iids
[] = {
235 &IID_IHTMLTextAreaElement
,
236 &IID_IConnectionPointContainer
,
240 static const IID
* const option_iids
[] = {
242 &IID_IHTMLOptionElement
,
243 &IID_IConnectionPointContainer
,
247 static const IID
* const table_iids
[] = {
252 &IID_IConnectionPointContainer
,
256 static const IID
* const script_iids
[] = {
258 &IID_IHTMLScriptElement
,
259 &IID_IConnectionPointContainer
,
263 static const IID
* const text_iids
[] = {
266 &IID_IHTMLDOMTextNode
,
267 &IID_IHTMLDOMTextNode2
,
271 static const IID
* const attr_iids
[] = {
272 &IID_IHTMLDOMAttribute
,
277 static const IID
* const location_iids
[] = {
283 static const IID
* const window_iids
[] = {
288 &IID_IServiceProvider
,
292 static const IID
* const comment_iids
[] = {
294 &IID_IHTMLCommentElement
,
295 &IID_IConnectionPointContainer
,
299 static const IID
* const img_iids
[] = {
301 &IID_IHTMLImgElement
,
302 &IID_IConnectionPointContainer
,
306 static const IID
* const tr_iids
[] = {
309 &IID_IConnectionPointContainer
,
313 static const IID
* const td_iids
[] = {
316 &IID_IConnectionPointContainer
,
320 static const IID
* const frame_iids
[] = {
323 &IID_IHTMLFrameBase2
,
324 &IID_IConnectionPointContainer
,
328 static const IID
* const head_iids
[] = {
330 &IID_IHTMLHeadElement
,
331 &IID_IConnectionPointContainer
,
335 static const IID
* const title_iids
[] = {
337 &IID_IHTMLTitleElement
,
338 &IID_IConnectionPointContainer
,
342 static const IID
* const meta_iids
[] = {
344 &IID_IHTMLMetaElement
,
345 &IID_IConnectionPointContainer
,
349 static const IID
* const link_iids
[] = {
351 &IID_IHTMLLinkElement
,
352 &IID_IConnectionPointContainer
,
356 static const IID
* const object_iids
[] = {
358 &IID_IHTMLObjectElement
,
359 &IID_IHTMLObjectElement2
,
360 /* FIXME: No IConnectionPointContainer */
364 static const IID
* const embed_iids
[] = {
366 &IID_IHTMLEmbedElement
,
367 /* FIXME: No IConnectionPointContainer */
371 static const IID
* const iframe_iids
[] = {
374 &IID_IHTMLFrameBase2
,
375 &IID_IHTMLIFrameElement
,
376 &IID_IHTMLIFrameElement2
,
377 &IID_IConnectionPointContainer
,
381 static const IID
* const form_iids
[] = {
383 &IID_IHTMLFormElement
,
384 &IID_IConnectionPointContainer
,
385 &DIID_DispHTMLFormElement
,
389 static const IID
* const styleelem_iids
[] = {
391 &IID_IHTMLStyleElement
,
392 &IID_IConnectionPointContainer
,
396 static const IID
* const generic_iids
[] = {
398 &IID_IHTMLGenericElement
,
399 &IID_IConnectionPointContainer
,
403 static const IID
* const style_iids
[] = {
414 static const IID
* const cstyle_iids
[] = {
418 &IID_IHTMLCurrentStyle
,
419 &IID_IHTMLCurrentStyle2
,
420 &IID_IHTMLCurrentStyle3
,
424 static const IID
* const img_factory_iids
[] = {
428 &IID_IHTMLImageElementFactory
,
438 static const elem_type_info_t elem_type_infos
[] = {
439 {"", none_iids
, NULL
},
440 {"HTML", elem_iids
, NULL
},
441 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
442 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
443 {"BODY", body_iids
, &DIID_DispHTMLBody
},
444 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
445 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
446 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
447 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
448 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
449 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
450 {"BLOCKQUOTE",elem_iids
, NULL
},
451 {"P", elem_iids
, NULL
},
452 {"BR", elem_iids
, NULL
},
453 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
454 {"TBODY", elem_iids
, NULL
},
455 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
456 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
457 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
458 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
459 {"IMG", img_iids
, &DIID_DispHTMLImg
},
460 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
461 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
462 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
463 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
464 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
465 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
466 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
467 {"DIV", elem_iids
, NULL
},
468 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
469 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
470 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
471 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
472 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
475 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
478 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
479 return lstrcmpA(stra
, buf
);
482 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
487 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
488 prefix_len
= lstrlenA(prefix
);
493 return !lstrcmpA(buf
, prefix
);
496 static BSTR
a2bstr(const char *str
)
504 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
505 ret
= SysAllocStringLen(NULL
, len
);
506 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
511 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
513 IUnknown
*unk1
, *unk2
;
518 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
519 IUnknown_Release(unk1
);
520 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
521 IUnknown_Release(unk2
);
526 static IHTMLDocument2
*create_document(void)
529 IHTMLDocument5
*doc5
;
532 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
533 &IID_IHTMLDocument2
, (void**)&doc
);
534 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
538 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
540 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
541 IHTMLDocument2_Release(doc
);
545 IHTMLDocument5_Release(doc5
);
549 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
550 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
555 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
556 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
560 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
561 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
563 const IID
* const *piid
;
567 for(piid
= iids
; *piid
; piid
++) {
568 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
569 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
571 IUnknown_Release(unk
);
575 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
576 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
581 unk
= (void*)0xdeadbeef;
582 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
583 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
584 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
587 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
588 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
590 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
597 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
598 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
599 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
601 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
602 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
604 if(SUCCEEDED(hres
)) {
607 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
608 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
610 *iid
= type_attr
->guid
;
614 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
615 ITypeInfo_Release(typeinfo
);
618 IDispatchEx_Release(dispex
);
622 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
623 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
625 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
626 DISPPARAMS dp
= {NULL
,NULL
,0,0};
631 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
632 IDispatchEx_Release(dispex
);
633 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
635 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
636 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
640 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
641 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
645 if(_test_get_dispid(line
, unk
, &iid
))
646 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
649 _test_disp_value(line
, unk
, val
);
652 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
653 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
657 if(_test_get_dispid(line
, unk
, &iid
))
658 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
659 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
662 _test_disp_value(line
, unk
, val
);
665 #define test_class_info(u) _test_class_info(__LINE__,u)
666 static void _test_class_info(unsigned line
, IUnknown
*unk
)
668 IProvideClassInfo
*classinfo
;
673 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
674 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
678 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
679 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
682 IProvideClassInfo_Release(classinfo
);
686 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
687 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
690 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
691 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
692 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
693 "unexpected typekind %d\n", type_attr
->typekind
);
694 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
697 ITypeInfo_Release(typeinfo
);
698 IProvideClassInfo_Release(classinfo
);
701 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
702 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
704 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
705 DISPPARAMS dp
= {val
, NULL
, 1, 0};
712 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
714 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
716 memset(&ei
, 0, sizeof(ei
));
717 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
718 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
722 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
723 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
728 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
729 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
733 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
734 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
739 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
740 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
744 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
745 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
750 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
751 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
755 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
756 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
761 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
762 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
766 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
767 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
769 IHTMLDocument3
*doc3
;
772 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
773 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
778 #define get_node_iface(u) _get_node_iface(__LINE__,u)
779 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
784 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
785 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
789 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
790 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
795 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
796 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
800 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
801 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
806 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
807 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
811 #define get_img_iface(u) _get_img_iface(__LINE__,u)
812 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
814 IHTMLImgElement
*img
;
817 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
818 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
822 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
823 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
825 IHTMLAnchorElement
*anchor
;
828 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
829 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
833 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
834 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
836 IHTMLTextAreaElement
*textarea
;
839 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
840 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
844 #define get_select_iface(u) _get_select_iface(__LINE__,u)
845 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
847 IHTMLSelectElement
*select
;
850 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
851 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
855 #define get_form_iface(u) _get_form_iface(__LINE__,u)
856 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
858 IHTMLFormElement
*form
;
861 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
862 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
866 #define get_text_iface(u) _get_text_iface(__LINE__,u)
867 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
869 IHTMLDOMTextNode
*text
;
872 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
873 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
877 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
878 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
880 IHTMLDOMTextNode2
*text2
;
883 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
884 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
888 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
889 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
891 IHTMLCommentElement
*comment
;
894 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
895 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
899 #define get_object_iface(u) _get_object_iface(__LINE__,u)
900 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
902 IHTMLObjectElement
*obj
;
905 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
906 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
910 #define get_style_iface(u) _get_style_iface(__LINE__,u)
911 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
913 IHTMLStyleElement
*obj
;
916 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
917 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
921 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
922 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
924 IHTMLMetaElement
*ret
;
927 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
928 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
932 #define get_link_iface(u) _get_link_iface(__LINE__,u)
933 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
935 IHTMLLinkElement
*ret
;
938 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
939 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
943 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
944 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
946 IHTMLIFrameElement2
*ret
;
949 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
950 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
954 #define get_button_iface(u) _get_button_iface(__LINE__,u)
955 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
957 IHTMLButtonElement
*ret
;
960 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
961 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
965 #define get_label_iface(u) _get_label_iface(__LINE__,u)
966 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
968 IHTMLLabelElement
*ret
;
971 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
972 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
976 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
977 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
979 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
983 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
984 IHTMLDOMNode_Release(node
);
985 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
986 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
991 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
992 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
994 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
995 IDispatch
*disp
= (void*)0xdeadbeef;
996 IHTMLDocument2
*doc
= NULL
;
999 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1000 IHTMLDOMNode2_Release(node
);
1001 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1004 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1005 IDispatch_Release(disp
);
1006 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1012 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1013 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1015 IHTMLWindow2
*window
;
1019 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1020 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1021 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1026 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1027 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1029 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1030 IHTMLDOMNode
*ret
= NULL
;
1033 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1034 IHTMLDOMNode_Release(node
);
1035 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1036 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1042 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1043 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1045 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1049 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1050 IHTMLElement_Release(elem
);
1051 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1052 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1057 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1058 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1060 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1061 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1063 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1064 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1067 #define get_node_type(n) _get_node_type(__LINE__,n)
1068 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1070 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1074 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1075 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1077 IHTMLDOMNode_Release(node
);
1082 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1083 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1085 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1086 IHTMLDOMChildrenCollection
*col
= NULL
;
1090 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1091 IHTMLDOMNode_Release(node
);
1092 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1096 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1097 IDispatch_Release(disp
);
1098 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1103 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1104 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1106 IHTMLDOMNode
*node
= NULL
;
1110 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1111 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1113 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1114 IDispatch_Release(disp
);
1119 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1120 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1126 VariantInit(&value
);
1129 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1131 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1134 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1135 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1137 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1140 VariantClear(&value
);
1143 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1144 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1146 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1147 IHTMLElement
*off_parent
;
1151 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1152 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1154 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1155 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1157 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1158 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1160 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1161 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1163 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1164 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1166 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1167 IHTMLElement_Release(off_parent
);
1169 IHTMLElement_Release(elem
);
1172 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1173 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1175 LONG l
= 0xdeadbeef;
1178 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1179 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1180 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1183 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1184 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1186 IHTMLWindow2
*window
;
1187 IHTMLDocument2
*ret
;
1190 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1191 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1193 hres
= IHTMLWindow2_get_document(window
, &ret
);
1194 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1195 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1200 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1201 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1206 hres
= IHTMLWindow2_get_name(window
, &name
);
1207 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1209 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1211 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1212 SysFreeString(name
);
1215 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1216 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1222 hres
= IHTMLWindow2_put_name(window
, str
);
1224 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1226 _test_window_name(line
, window
, name
);
1229 #define test_window_status(d) _test_window_status(__LINE__,d)
1230 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1235 status
= (void*)0xdeadbeef;
1236 hres
= IHTMLWindow2_get_status(window
, &status
);
1237 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1238 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1239 SysFreeString(status
);
1242 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1243 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1248 str
= a2bstr(status
);
1249 hres
= IHTMLWindow2_put_status(window
, str
);
1251 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1254 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1255 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1260 hres
= IHTMLWindow2_get_length(window
, &length
);
1261 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1262 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1265 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1266 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1268 IHTMLFrameBase2
*base2
;
1269 IHTMLWindow2
*window
;
1272 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1273 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1276 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1277 IHTMLFrameBase2_Release(base2
);
1278 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1279 ok(window
!= NULL
, "contentWindow = NULL\n");
1284 static void test_get_set_attr(IHTMLDocument2
*doc
)
1287 IHTMLDocument3
*doc3
;
1292 /* grab an element to test with */
1293 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1294 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1296 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1297 IHTMLDocument3_Release(doc3
);
1298 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1300 /* get a non-present attribute */
1301 bstr
= a2bstr("notAnAttribute");
1302 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1303 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1304 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1306 SysFreeString(bstr
);
1308 /* get a present attribute */
1309 bstr
= a2bstr("scrollHeight");
1310 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1311 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1312 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1314 SysFreeString(bstr
);
1316 /* create a new BSTR attribute */
1317 bstr
= a2bstr("newAttribute");
1319 V_VT(&val
) = VT_BSTR
;
1320 V_BSTR(&val
) = a2bstr("the value");
1321 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1322 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1325 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1326 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1327 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1328 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
)));
1331 /* overwrite the attribute with a BOOL */
1332 V_VT(&val
) = VT_BOOL
;
1333 V_BOOL(&val
) = VARIANT_TRUE
;
1334 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1335 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1338 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1339 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1340 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1341 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1344 SysFreeString(bstr
);
1346 /* case-insensitive */
1347 bstr
= a2bstr("newattribute");
1348 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1349 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1350 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1351 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1353 SysFreeString(bstr
);
1355 IHTMLElement_Release(elem
);
1358 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1359 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1362 IHTMLDocument3
*doc3
;
1365 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1366 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1367 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1368 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1369 IHTMLDocument3_Release(doc3
);
1374 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1375 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1377 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1381 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1382 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1383 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1386 _test_disp_value(line
, unk
, exhref
);
1389 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1390 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1392 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1396 str
= a2bstr(exhref
);
1397 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1398 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1401 _test_disp_value(line
, unk
, exhref
);
1404 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1405 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1407 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1411 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1412 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1414 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1416 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1420 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1421 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1423 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1427 str
= a2bstr(exrel
);
1428 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1429 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1433 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1434 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1436 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1440 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1441 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1443 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1445 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1449 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1450 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1452 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1456 str
= target
? a2bstr(target
) : NULL
;
1457 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1458 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1462 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1463 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1465 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1469 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1470 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1472 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1474 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1478 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1479 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1481 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1485 str
= name
? a2bstr(name
) : NULL
;
1486 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1487 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1490 _test_anchor_name(line
, unk
, name
);
1493 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1494 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1496 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1500 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1501 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1503 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1505 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1509 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1510 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1512 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1516 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1517 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1518 if ( ! str
&& allowbroken
)
1519 win_skip("skip ie6 incorrect behavior\n");
1521 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1523 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1527 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1528 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1530 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1534 str
= search
? a2bstr(search
) : NULL
;
1535 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1536 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1540 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1541 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1543 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1547 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1548 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1550 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1552 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1556 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1557 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1562 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1563 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1564 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1565 SysFreeString(bstr
);
1568 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1569 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1574 bstr
= a2bstr(text
);
1575 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1576 SysFreeString(bstr
);
1577 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1579 _test_option_text(line
, option
, text
);
1582 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1583 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1588 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1589 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1590 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1591 SysFreeString(bstr
);
1594 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1595 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1600 bstr
= a2bstr(value
);
1601 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1602 SysFreeString(bstr
);
1603 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1605 _test_option_value(line
, option
, value
);
1608 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1609 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1611 VARIANT_BOOL b
= 0x100;
1614 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1615 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1616 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1619 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1620 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1624 hres
= IHTMLOptionElement_put_selected(option
, b
);
1625 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1626 _test_option_selected(line
, option
, b
);
1629 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1630 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1632 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1633 BSTR value
= (void*)0xdeadbeef;
1636 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1637 IHTMLTextAreaElement_Release(textarea
);
1638 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1640 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1642 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1643 SysFreeString(value
);
1646 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1647 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1649 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1650 BSTR tmp
= a2bstr(value
);
1653 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1654 IHTMLTextAreaElement_Release(textarea
);
1655 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1658 _test_textarea_value(line
, unk
, value
);
1661 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1662 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1664 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1665 VARIANT_BOOL b
= 0x100;
1668 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1669 IHTMLTextAreaElement_Release(textarea
);
1670 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1671 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1674 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1675 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1677 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1680 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1681 IHTMLTextAreaElement_Release(textarea
);
1682 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1684 _test_textarea_readonly(line
, unk
, b
);
1687 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1688 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1690 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1691 BSTR type
= (void*)0xdeadbeef;
1694 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1695 IHTMLTextAreaElement_Release(textarea
);
1696 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1697 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1698 SysFreeString(type
);
1701 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1702 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1704 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1705 IHTMLFormElement
*form
;
1708 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1709 IHTMLTextAreaElement_Release(textarea
);
1710 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1715 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1716 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1718 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1722 text
= a2bstr(extext
);
1723 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1724 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1725 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1727 IHTMLCommentElement_Release(comment
);
1728 SysFreeString(text
);
1731 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1732 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1734 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1735 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1736 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1737 IHTMLDOMAttribute
*attr
;
1738 BSTR name
= a2bstr("test");
1742 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1743 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1744 ok(attr
== NULL
, "attr != NULL\n");
1748 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1749 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1751 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1752 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1753 ok(attr
!= NULL
, "attr == NULL\n");
1755 IHTMLDOMAttribute_Release(attr
);
1756 IHTMLCommentElement_Release(comment
);
1757 IHTMLElement_Release(elem
);
1758 IHTMLElement4_Release(elem4
);
1759 SysFreeString(name
);
1762 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1763 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1765 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1770 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1771 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1772 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1773 IHTMLObjectElement_Release(object
);
1776 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
1777 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
1779 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1783 str
= (void*)0xdeadbeef;
1784 hres
= IHTMLObjectElement_get_name(object
, &str
);
1785 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1787 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
1789 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
1791 IHTMLObjectElement_Release(object
);
1794 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
1795 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
1797 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1802 hres
= IHTMLObjectElement_put_name(object
, str
);
1803 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1805 IHTMLObjectElement_Release(object
);
1807 _test_object_name(line
, elem
, name
);
1810 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1811 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1812 const char *txt
, const char *val
)
1814 IHTMLOptionElementFactory
*factory
;
1815 IHTMLOptionElement
*option
;
1816 IHTMLWindow2
*window
;
1817 VARIANT text
, value
, empty
;
1820 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1821 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1823 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1824 IHTMLWindow2_Release(window
);
1825 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1827 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
1829 V_VT(&text
) = VT_BSTR
;
1830 V_BSTR(&text
) = a2bstr(txt
);
1831 V_VT(&value
) = VT_BSTR
;
1832 V_BSTR(&value
) = a2bstr(val
);
1833 V_VT(&empty
) = VT_EMPTY
;
1835 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1836 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1838 IHTMLOptionElementFactory_Release(factory
);
1839 VariantClear(&text
);
1840 VariantClear(&value
);
1842 _test_option_text(line
, option
, txt
);
1843 _test_option_value(line
, option
, val
);
1844 _test_option_selected(line
, option
, VARIANT_FALSE
);
1849 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1850 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1855 hres
= IHTMLImgElement_get_width(img
, &found
);
1856 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1857 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1860 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1861 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1865 hres
= IHTMLImgElement_put_width(img
, width
);
1866 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1868 _test_img_width(line
, img
, width
);
1871 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1872 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1877 hres
= IHTMLImgElement_get_height(img
, &found
);
1878 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1879 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1882 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1883 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1887 hres
= IHTMLImgElement_put_height(img
, height
);
1888 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1890 _test_img_height(line
, img
, height
);
1893 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1894 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1895 LONG wdth
, LONG hght
)
1897 IHTMLImageElementFactory
*factory
;
1898 IHTMLImgElement
*img
;
1899 IHTMLWindow2
*window
;
1900 VARIANT width
, height
;
1904 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1905 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1907 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1908 IHTMLWindow2_Release(window
);
1909 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1911 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1912 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1915 snprintf(buf
, 16, "%d", wdth
);
1916 V_VT(&width
) = VT_BSTR
;
1917 V_BSTR(&width
) = a2bstr(buf
);
1919 V_VT(&width
) = VT_EMPTY
;
1924 snprintf(buf
, 16, "%d", hght
);
1925 V_VT(&height
) = VT_BSTR
;
1926 V_BSTR(&height
) = a2bstr(buf
);
1928 V_VT(&height
) = VT_EMPTY
;
1932 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1933 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1935 IHTMLImageElementFactory_Release(factory
);
1936 VariantClear(&width
);
1937 VariantClear(&height
);
1939 if(SUCCEEDED(hres
)) {
1940 _test_img_width(line
, img
, wdth
);
1941 _test_img_height(line
, img
, hght
);
1948 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1949 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1951 LONG len
= 0xdeadbeef;
1954 hres
= IHTMLSelectElement_get_length(select
, &len
);
1955 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1956 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1959 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1960 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1962 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1965 hres
= IHTMLSelectElement_put_length(select
, length
);
1966 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1967 _test_select_length(line
, select
, length
);
1968 IHTMLSelectElement_Release(select
);
1971 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1972 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1974 LONG idx
= 0xdeadbeef;
1977 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1978 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1979 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1982 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1983 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1987 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1988 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1989 _test_select_selidx(line
, select
, index
);
1992 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1993 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1998 hres
= IHTMLSelectElement_get_value(select
, &val
);
1999 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2001 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2003 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2007 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2008 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2014 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2015 SysFreeString(bstr
);
2016 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2019 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2020 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2025 hres
= IHTMLSelectElement_get_type(select
, &type
);
2026 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2027 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2028 SysFreeString(type
);
2031 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2032 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2034 VARIANT_BOOL b
= 100;
2037 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2038 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2039 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2042 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2043 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2047 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2048 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2050 _test_select_multiple(line
, select
, val
);
2053 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2054 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2059 hres
= IHTMLTxtRange_get_text(range
, &text
);
2060 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2063 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2064 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2066 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2069 SysFreeString(text
);
2073 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2074 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2078 hres
= IHTMLTxtRange_collapse(range
, b
);
2079 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2080 _test_range_text(line
, range
, NULL
);
2083 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2084 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2085 VARIANT_BOOL exb
, const char *extext
)
2087 VARIANT_BOOL b
= 0xe0e0;
2090 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2091 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2092 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2093 _test_range_text(line
, range
, extext
);
2096 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2097 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2099 LONG c
= 0xdeadbeef;
2102 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2103 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2104 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2105 _test_range_text(line
, range
, NULL
);
2108 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2109 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2110 LPWSTR unit
, LONG cnt
, LONG excnt
)
2112 LONG c
= 0xdeadbeef;
2115 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2116 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2117 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2120 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2121 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2123 LONG c
= 0xdeadbeef;
2126 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2127 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2128 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2131 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2132 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2135 BSTR bstr
= a2bstr(text
);
2137 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2138 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2139 SysFreeString(bstr
);
2140 _test_range_text(line
, range
, NULL
);
2143 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2144 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2150 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2151 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2152 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2155 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2156 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2162 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2163 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2164 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2167 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2168 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2169 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2172 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2173 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2177 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2178 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2180 BSTR str
= a2bstr(html
);
2183 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2184 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2188 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2189 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2194 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2195 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2197 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2199 IHTMLElement_Release(elem
);
2202 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2203 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2205 VARIANT name
, index
;
2210 V_VT(&index
) = VT_EMPTY
;
2211 V_VT(&name
) = VT_I4
;
2213 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2214 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2215 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2217 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2218 IDispatch_Release(disp
);
2222 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2223 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2224 const elem_type_t
*elem_types
, LONG exlen
)
2226 IHTMLElementCollection
*col
;
2227 IEnumVARIANT
*enum_var
;
2232 VARIANT name
, index
, v
, vs
[5];
2233 IDispatch
*disp
, *disp2
;
2236 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2237 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2239 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2241 hres
= IHTMLElementCollection_get_length(col
, &len
);
2242 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2243 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2248 V_VT(&index
) = VT_EMPTY
;
2250 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2251 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2253 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2254 IUnknown_Release(enum_unk
);
2255 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2257 for(i
=0; i
<len
; i
++) {
2258 V_VT(&name
) = VT_I4
;
2260 disp
= (void*)0xdeadbeef;
2261 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2262 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2263 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2264 if(FAILED(hres
) || !disp
)
2267 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2270 V_VT(&name
) = VT_UINT
;
2272 disp2
= (void*)0xdeadbeef;
2273 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2274 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2275 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2277 IDispatch_Release(disp2
);
2281 V_VT(&v
) = VT_ERROR
;
2282 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2283 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2285 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2286 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2287 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2288 IDispatch_Release(V_DISPATCH(&v
));
2290 IDispatch_Release(disp
);
2293 fetched
= 0xdeadbeef;
2295 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2296 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2297 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2298 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2300 hres
= IEnumVARIANT_Reset(enum_var
);
2301 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2303 fetched
= 0xdeadbeef;
2305 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2306 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2307 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2308 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2310 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2311 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2313 memset(vs
, 0, sizeof(vs
));
2315 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2316 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2317 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2319 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2320 IDispatch_Release(V_DISPATCH(vs
));
2323 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2324 IDispatch_Release(V_DISPATCH(vs
+1));
2327 hres
= IEnumVARIANT_Reset(enum_var
);
2328 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2330 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2331 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2333 IEnumVARIANT_Release(enum_var
);
2335 V_VT(&name
) = VT_I4
;
2337 disp
= (void*)0xdeadbeef;
2338 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2339 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2340 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2342 V_VT(&name
) = VT_I4
;
2344 disp
= (void*)0xdeadbeef;
2345 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2346 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2347 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2349 IHTMLElementCollection_Release(col
);
2352 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2353 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2355 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2359 hres
= IHTMLElement_get_all(elem
, &disp
);
2360 IHTMLElement_Release(elem
);
2361 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2363 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2364 IDispatch_Release(disp
);
2367 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2368 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2370 IHTMLElementCollection
*col
;
2373 hres
= IHTMLDocument2_get_all(doc
, &col
);
2374 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2376 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2377 IHTMLElementCollection_Release(col
);
2380 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2381 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2383 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2384 IHTMLElementCollection
*col
= NULL
;
2385 elem_type_t
*types
= NULL
;
2390 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2391 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2393 IHTMLElement2_Release(elem
);
2394 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2395 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2398 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2399 for(i
=0; i
<exlen
; i
++)
2403 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2405 HeapFree(GetProcessHeap(), 0, types
);
2408 *ret
= get_elem_col_item_idx(col
, 0);
2409 IHTMLElementCollection_Release(col
);
2412 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2413 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2418 hres
= IHTMLElement_get_innerText(elem
, &text
);
2419 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2421 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2422 wine_dbgstr_w(text
), extext
);
2424 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2425 SysFreeString(text
);
2428 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2429 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2431 IHTMLDOMChildrenCollection
*col
;
2436 hres
= IHTMLElement_put_innerText(elem
, str
);
2437 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2440 _test_elem_innertext(line
, elem
, text
);
2443 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2444 ok(col
!= NULL
, "col == NULL\n");
2446 LONG length
= 0, type
;
2449 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2450 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2451 ok(length
== 1, "length = %d\n", length
);
2453 node
= _get_child_item(line
, col
, 0);
2454 ok(node
!= NULL
, "node == NULL\n");
2456 type
= _get_node_type(line
, (IUnknown
*)node
);
2457 ok(type
== 3, "type=%d\n", type
);
2458 IHTMLDOMNode_Release(node
);
2461 IHTMLDOMChildrenCollection_Release(col
);
2466 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2467 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2469 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2473 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2474 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2476 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2478 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2480 IHTMLElement_Release(elem
);
2481 SysFreeString(html
);
2484 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2485 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2487 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2491 html
= a2bstr(inner_html
);
2492 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2493 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2495 IHTMLElement_Release(elem
);
2496 SysFreeString(html
);
2499 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2500 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2502 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2506 html
= a2bstr(outer_html
);
2507 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2508 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2510 IHTMLElement_Release(elem
);
2511 SysFreeString(html
);
2514 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2515 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2517 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2521 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2522 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2523 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2525 IHTMLElement_Release(elem
);
2526 SysFreeString(html
);
2529 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2530 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2536 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2537 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2538 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2541 #define get_first_child(n) _get_first_child(__LINE__,n)
2542 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2544 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2545 IHTMLDOMNode
*child
= NULL
;
2548 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2549 IHTMLDOMNode_Release(node
);
2550 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2555 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2556 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2558 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2559 VARIANT_BOOL b
= 0xdead;
2562 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2563 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2564 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2566 IHTMLDOMNode_Release(node
);
2569 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2570 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2572 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2573 IHTMLDOMNode
*parent
;
2576 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2577 IHTMLDOMNode_Release(node
);
2578 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2583 #define node_get_next(u) _node_get_next(__LINE__,u)
2584 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2586 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2590 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2591 IHTMLDOMNode_Release(node
);
2592 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2597 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2598 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2600 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2604 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2605 IHTMLDOMNode_Release(node
);
2606 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2611 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2612 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2614 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2615 IHTMLElement
*parent
;
2618 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2619 IHTMLElement_Release(elem
);
2620 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2625 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2626 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2628 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2629 VARIANT_BOOL disabled
= 100;
2633 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2634 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2635 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2636 IHTMLElement3_Release(elem3
);
2639 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2640 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2642 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2646 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2647 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2649 IHTMLElement3_Release(elem3
);
2650 _test_elem3_get_disabled(line
, unk
, b
);
2653 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2654 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2656 VARIANT_BOOL disabled
= 100;
2659 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2660 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2661 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2663 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2666 static void test_select_remove(IHTMLSelectElement
*select
)
2670 hres
= IHTMLSelectElement_remove(select
, 3);
2671 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
2672 test_select_length(select
, 2);
2674 hres
= IHTMLSelectElement_remove(select
, -1);
2676 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
2677 test_select_length(select
, 2);
2679 hres
= IHTMLSelectElement_remove(select
, 0);
2680 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
2681 test_select_length(select
, 1);
2684 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2685 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
2687 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2691 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
2692 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2693 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
2694 IHTMLDOMTextNode_Release(text
);
2697 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
2698 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
2700 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2704 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
2705 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2706 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
2707 IHTMLDOMTextNode_Release(text
);
2711 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
2712 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
2714 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2715 BSTR str
= a2bstr(data
);
2718 hres
= IHTMLDOMTextNode_put_data(text
, str
);
2719 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2720 IHTMLDOMTextNode_Release(text
);
2724 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
2725 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
2727 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
2728 BSTR str
= a2bstr(data
);
2731 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
2732 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
2733 IHTMLDOMTextNode2_Release(text
);
2737 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2738 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
2742 hres
= IHTMLSelectElement_put_disabled(select
, b
);
2743 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2745 _test_select_get_disabled(line
, select
, b
);
2748 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
2749 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
2751 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2755 hres
= IHTMLElement2_get_dir(elem
, &dir
);
2756 IHTMLElement2_Release(elem
);
2757 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
2759 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
2761 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
2766 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
2767 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
2769 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2770 BSTR dir
= a2bstr(dira
);
2773 hres
= IHTMLElement2_put_dir(elem
, dir
);
2774 IHTMLElement2_Release(elem
);
2775 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
2778 _test_elem_dir(line
, unk
, dira
);
2781 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2782 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
2784 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2785 IHTMLTextContainer
*txtcont
;
2786 LONG l
= -1, l2
= -1;
2789 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
2790 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
2791 IHTMLElement2_Release(elem
);
2793 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2794 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2796 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
2797 IHTMLTextContainer_Release(txtcont
);
2798 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
2799 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
2804 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2805 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
2807 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2808 IHTMLTextContainer
*txtcont
;
2809 LONG l
= -1, l2
= -1;
2812 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
2813 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
2814 IHTMLElement2_Release(elem
);
2816 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2817 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2819 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
2820 IHTMLTextContainer_Release(txtcont
);
2821 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
2822 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
2827 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2828 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
2830 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2831 IHTMLTextContainer
*txtcont
;
2832 LONG l
= -1, l2
= -1;
2835 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
2836 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2837 IHTMLElement2_Release(elem
);
2839 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2840 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2842 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
2843 IHTMLTextContainer_Release(txtcont
);
2844 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
2845 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2850 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2851 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2853 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2854 IHTMLTextContainer
*txtcont
;
2855 LONG l
= -1, l2
= -1;
2858 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2859 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2861 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2862 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2863 IHTMLElement2_Release(elem
);
2865 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2866 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2868 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2869 IHTMLTextContainer_Release(txtcont
);
2870 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2871 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2874 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2875 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
2877 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2881 hres
= IHTMLImgElement_get_src(img
, &src
);
2882 IHTMLImgElement_Release(img
);
2883 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2884 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
2885 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2889 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2890 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2892 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2897 hres
= IHTMLImgElement_put_src(img
, tmp
);
2898 IHTMLImgElement_Release(img
);
2900 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2903 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2904 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2906 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2910 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2911 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2913 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2915 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2919 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2920 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2922 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2927 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2928 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2931 _test_img_alt(line
, unk
, alt
);
2934 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
2935 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
2937 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2941 tmp
= a2bstr(align
);
2942 hres
= IHTMLImgElement_put_align(img
, tmp
);
2943 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2946 hres
= IHTMLImgElement_get_align(img
, &tmp
);
2947 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2948 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
2952 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2953 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2955 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2959 hres
= IHTMLImgElement_get_name(img
, &sName
);
2960 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2961 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2962 IHTMLImgElement_Release(img
);
2963 SysFreeString(sName
);
2966 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
2967 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
2969 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
2970 VARIANT_BOOL b
= 100;
2973 hres
= IHTMLImgElement_get_complete(img
, &b
);
2974 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
2975 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
2976 IHTMLImgElement_Release(img
);
2979 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
2980 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
2982 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2983 VARIANT_BOOL b
= 100;
2986 hres
= IHTMLImgElement_put_isMap(img
, v
);
2987 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
2989 hres
= IHTMLImgElement_get_isMap(img
, &b
);
2990 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
2991 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
2993 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
2994 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
2995 IHTMLImgElement_Release(img
);
2998 static void test_dynamic_properties(IHTMLElement
*elem
)
3000 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3001 IDispatchEx
*dispex
;
3002 BSTR name
, attr1
= SysAllocString(attr1W
);
3006 DISPID id
= DISPID_STARTENUM
;
3009 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3010 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3012 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3013 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3014 ok(succ
, "removeAttribute set succ to FALSE\n");
3017 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3018 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3022 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3023 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3025 if(!strcmp_wa(name
, "attr1"))
3026 ok(0, "attr1 should be removed\n");
3027 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3029 SysFreeString(name
);
3031 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3032 IDispatchEx_Release(dispex
);
3034 V_VT(&val
) = VT_BSTR
;
3035 V_BSTR(&val
) = attr1
;
3036 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3037 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3038 SysFreeString(attr1
);
3041 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3042 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3047 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3048 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3049 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3053 static void test_attr_collection_disp(IDispatch
*disp
)
3055 IDispatchEx
*dispex
;
3056 IHTMLDOMAttribute
*attr
;
3057 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3064 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3065 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3068 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3069 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3070 SysFreeString(bstr
);
3073 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3074 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3075 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3076 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3079 bstr
= a2bstr("attr1");
3080 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3081 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3082 SysFreeString(bstr
);
3085 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3086 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3087 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3088 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3089 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3090 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3092 test_attr_node_name(attr
, "attr1");
3094 IHTMLDOMAttribute_Release(attr
);
3097 IDispatchEx_Release(dispex
);
3100 static void test_attr_collection(IHTMLElement
*elem
)
3102 static const WCHAR testW
[] = {'t','e','s','t',0};
3105 IDispatch
*disp
, *attr
;
3106 IHTMLDOMAttribute
*dom_attr
;
3107 IHTMLAttributeCollection
*attr_col
;
3108 BSTR name
= SysAllocString(testW
);
3110 LONG i
, len
, checked
;
3113 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3114 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3116 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3117 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3119 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3120 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3121 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3122 IDispatch_Release(attr
);
3123 IHTMLDOMNode_Release(node
);
3125 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3126 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3128 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3129 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3133 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3134 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3135 SysFreeString(name
);
3137 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3138 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3139 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3142 for(i
=0; i
<len
; i
++) {
3145 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3146 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3148 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3149 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3150 IDispatch_Release(attr
);
3152 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3153 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3155 if(!strcmp_wa(name
, "id")) {
3157 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3158 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3159 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3160 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3161 } else if(!strcmp_wa(name
, "attr1")) {
3163 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3164 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3165 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3166 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3167 } else if(!strcmp_wa(name
, "attr2")) {
3169 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3170 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3171 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3172 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3173 } else if(!strcmp_wa(name
, "attr3")) {
3175 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3176 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3177 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3178 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3179 } else if(!strcmp_wa(name
, "test")) {
3181 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3182 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3183 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3184 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3187 IHTMLDOMAttribute_Release(dom_attr
);
3188 SysFreeString(name
);
3191 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3194 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3195 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3197 V_VT(&id
) = VT_BSTR
;
3198 V_BSTR(&id
) = a2bstr("nonexisting");
3199 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3200 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3203 test_attr_collection_disp(disp
);
3205 IDispatch_Release(disp
);
3206 IHTMLAttributeCollection_Release(attr_col
);
3209 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
3210 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
3212 VARIANT_BOOL specified
;
3215 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
3216 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
3217 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
3220 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3221 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3223 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3224 BSTR id
= (void*)0xdeadbeef;
3227 hres
= IHTMLElement_get_id(elem
, &id
);
3228 IHTMLElement_Release(elem
);
3229 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3232 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3234 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3239 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3240 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3242 BSTR lang
= (void*)0xdeadbeef;
3245 hres
= IHTMLElement_get_language(elem
, &lang
);
3246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3249 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3251 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3253 SysFreeString(lang
);
3256 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3257 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3259 BSTR str
= a2bstr(lang
);
3262 hres
= IHTMLElement_put_language(elem
, str
);
3263 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3266 _test_elem_language(line
, elem
, lang
);
3269 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3270 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3272 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3273 BSTR tmp
= a2bstr(new_id
);
3276 hres
= IHTMLElement_put_id(elem
, tmp
);
3277 IHTMLElement_Release(elem
);
3279 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3281 _test_elem_id(line
, unk
, new_id
);
3284 static void test_contenteditable(IUnknown
*unk
)
3286 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3288 BSTR str
, strDefault
;
3290 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3291 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3293 str
= a2bstr("true");
3294 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3295 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3297 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3298 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3299 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3301 /* Restore origin contentEditable */
3302 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3303 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3304 SysFreeString(strDefault
);
3306 IHTMLElement3_Release(elem3
);
3309 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3310 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3315 hres
= IHTMLInputElement_get_type(input
, &type
);
3316 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3317 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3318 SysFreeString(type
);
3321 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3322 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3324 BSTR name
= (BSTR
)0xdeadbeef;
3327 hres
= IHTMLInputElement_get_name(input
, &name
);
3328 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3330 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3332 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3333 SysFreeString(name
);
3336 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3337 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3339 BSTR tmp
= a2bstr(name
);
3342 hres
= IHTMLInputElement_put_name(input
, tmp
);
3343 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3346 _test_input_name(line
, input
, name
);
3349 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3350 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3352 VARIANT_BOOL disabled
= 100;
3355 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3356 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3357 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3359 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3362 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3363 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3367 hres
= IHTMLInputElement_put_disabled(input
, b
);
3368 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3370 _test_input_get_disabled(line
, input
, b
);
3373 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3374 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3376 VARIANT_BOOL checked
= 100;
3379 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3380 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3381 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3384 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3385 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3389 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3390 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3392 _test_input_get_defaultchecked(line
, input
, b
);
3395 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3396 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3398 VARIANT_BOOL checked
= 100;
3401 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3402 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3403 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3406 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3407 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3411 hres
= IHTMLInputElement_put_checked(input
, b
);
3412 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3414 _test_input_get_checked(line
, input
, b
);
3417 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3418 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3420 LONG maxlength
= 0xdeadbeef;
3423 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3424 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3425 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3428 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3429 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3433 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3434 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3436 _test_input_maxlength(line
, input
, l
);
3439 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3440 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3442 IHTMLInputElement
*input
;
3446 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3447 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3451 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3452 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3454 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3456 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3457 SysFreeString(bstr
);
3458 IHTMLInputElement_Release(input
);
3461 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3462 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3464 IHTMLInputElement
*input
;
3465 IHTMLFormElement
*form
;
3469 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3470 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3471 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3472 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3473 if(FAILED(hres
) || input
== NULL
)
3476 hres
= IHTMLInputElement_get_form(input
, &form
);
3477 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3478 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3479 if(FAILED(hres
) || form
== NULL
){
3480 IHTMLInputElement_Release(input
);
3484 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3485 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3486 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3487 if(FAILED(hres
) || elem
== NULL
){
3488 IHTMLInputElement_Release(input
);
3489 IHTMLFormElement_Release(form
);
3493 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3495 IHTMLInputElement_Release(input
);
3496 IHTMLFormElement_Release(form
);
3497 IHTMLElement_Release(elem
);
3500 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3501 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3503 IHTMLInputElement
*input
;
3507 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3508 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3513 hres
= IHTMLInputElement_put_value(input
, bstr
);
3514 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3515 SysFreeString(bstr
);
3516 IHTMLInputElement_Release(input
);
3518 _test_input_value(line
, unk
, val
);
3521 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3522 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3524 IHTMLInputElement
*input
;
3528 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3529 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3533 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3534 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3536 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3538 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3540 IHTMLInputElement_Release(input
);
3543 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3544 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3546 IHTMLInputElement
*input
;
3550 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3551 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3556 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3557 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3559 IHTMLInputElement_Release(input
);
3561 _test_input_defaultValue(line
, unk
, val
);
3564 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
3565 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
3570 hres
= IHTMLInputElement_get_src(input
, &src
);
3571 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3573 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3575 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
3579 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
3580 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
3586 hres
= IHTMLInputElement_put_src(input
, tmp
);
3588 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3590 _test_input_src(line
, input
, src
);
3593 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
3594 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
3598 hres
= IHTMLInputElement_put_size(input
, size
);
3599 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
3602 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
3603 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
3608 hres
= IHTMLInputElement_get_size(input
, &size
);
3609 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
3610 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
3612 hres
= IHTMLInputElement_get_size(input
, NULL
);
3613 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
3616 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
3617 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
3620 VARIANT_BOOL b
= 100;
3622 hres
= IHTMLInputElement_put_readOnly(input
, v
);
3623 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
3625 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
3626 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
3627 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
3630 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
3631 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
3633 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3634 BSTR
class = (void*)0xdeadbeef;
3637 hres
= IHTMLElement_get_className(elem
, &class);
3638 IHTMLElement_Release(elem
);
3639 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
3641 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
3643 ok_(__FILE__
,line
) (!class, "class != NULL\n");
3644 SysFreeString(class);
3647 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
3648 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
3650 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3654 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
3655 IHTMLElement2_Release(elem2
);
3656 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3657 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
3660 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
3661 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
3663 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3666 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
3667 IHTMLElement2_Release(elem2
);
3668 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3670 _test_elem_tabindex(line
, unk
, index
);
3673 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
3674 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
3676 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3680 hres
= IHTMLStyleElement_get_media(style
, &media
);
3681 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
3683 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
3685 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
3687 IHTMLStyleElement_Release(style
);
3688 SysFreeString(media
);
3691 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
3692 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
3694 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3698 str
= a2bstr(media
);
3699 hres
= IHTMLStyleElement_put_media(style
, str
);
3700 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
3701 IHTMLStyleElement_Release(style
);
3704 _test_style_media(line
, unk
, media
);
3707 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
3708 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
3710 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3714 hres
= IHTMLStyleElement_get_type(style
, &type
);
3715 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3717 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
3719 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
3721 IHTMLStyleElement_Release(style
);
3722 SysFreeString(type
);
3725 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
3726 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
3728 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3733 hres
= IHTMLStyleElement_put_type(style
, str
);
3734 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
3735 IHTMLStyleElement_Release(style
);
3738 _test_style_type(line
, unk
, type
);
3741 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
3742 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
3744 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3746 IHTMLFiltersCollection
*filters
;
3748 hres
= IHTMLElement_get_filters(elem
, &filters
);
3749 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
3750 "get_filters failed: %08x\n", hres
);
3754 IDispatchEx
*dispex
;
3756 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
3757 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
3758 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
3760 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
3761 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
3762 "Could not get IDispatchEx interface: %08x\n", hres
);
3763 if(SUCCEEDED(hres
)) {
3764 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
3765 IDispatchEx_Release(dispex
);
3768 IHTMLFiltersCollection_Release(filters
);
3771 IHTMLElement_Release(elem
);
3774 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
3775 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
3777 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3781 tmp
= class ? a2bstr(class) : NULL
;
3782 hres
= IHTMLElement_put_className(elem
, tmp
);
3783 IHTMLElement_Release(elem
);
3784 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
3787 _test_elem_class(line
, unk
, class);
3790 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
3791 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
3793 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3797 hres
= IHTMLElement_get_title(elem
, &title
);
3798 IHTMLElement_Release(elem
);
3799 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3801 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
3803 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
3805 SysFreeString(title
);
3808 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
3809 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
3811 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3815 tmp
= a2bstr(title
);
3816 hres
= IHTMLElement_put_title(elem
, tmp
);
3817 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3819 IHTMLElement_Release(elem
);
3823 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
3824 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
3826 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3830 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
3831 IHTMLDOMNode_Release(node
);
3832 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3835 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
3836 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
3838 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
3844 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
3845 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
3847 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3851 V_VT(&var
) = VT_BSTR
;
3852 V_BSTR(&var
) = a2bstr(val
);
3854 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
3855 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3856 IHTMLDOMNode_Release(node
);
3860 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
3861 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
3863 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3867 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
3868 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
3869 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
3870 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
3872 IHTMLElement2_Release(elem
);
3875 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
3876 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
3878 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3882 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
3883 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
3884 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
3886 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
3887 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
3888 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
3890 IHTMLElement2_Release(elem
);
3893 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
3894 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
3896 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3897 LONG len
= 0xdeadbeef;
3900 hres
= IHTMLFormElement_get_length(form
, &len
);
3901 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3902 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
3904 IHTMLFormElement_Release(form
);
3907 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
3908 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
3910 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3911 BSTR action
= (void*)0xdeadbeef;
3914 hres
= IHTMLFormElement_get_action(form
, &action
);
3915 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
3917 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
3919 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
3921 SysFreeString(action
);
3922 IHTMLFormElement_Release(form
);
3925 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
3926 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
3928 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3929 BSTR tmp
= a2bstr(action
);
3932 hres
= IHTMLFormElement_put_action(form
, tmp
);
3933 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
3935 IHTMLFormElement_Release(form
);
3937 _test_form_action(line
, unk
, action
);
3940 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
3941 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
3943 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3944 BSTR method
= (void*)0xdeadbeef;
3947 hres
= IHTMLFormElement_get_method(form
, &method
);
3948 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
3950 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
3952 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
3954 SysFreeString(method
);
3955 IHTMLFormElement_Release(form
);
3958 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
3959 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
3961 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3962 BSTR tmp
= a2bstr(method
);
3965 hres
= IHTMLFormElement_put_method(form
, tmp
);
3966 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
3968 IHTMLFormElement_Release(form
);
3970 if(exp_hres
== S_OK
)
3971 _test_form_method(line
, unk
, method
);
3974 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
3975 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
3977 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3978 BSTR name
= (void*)0xdeadbeef;
3981 hres
= IHTMLFormElement_get_name(form
, &name
);
3982 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3984 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
3986 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
3988 SysFreeString(name
);
3989 IHTMLFormElement_Release(form
);
3992 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
3993 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
3995 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3996 BSTR tmp
= a2bstr(name
);
3999 hres
= IHTMLFormElement_put_name(form
, tmp
);
4000 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4002 IHTMLFormElement_Release(form
);
4004 _test_form_name(line
, unk
, name
);
4007 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4008 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4010 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4011 BSTR encoding
= (void*)0xdeadbeef;
4014 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4015 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4017 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4019 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4021 SysFreeString(encoding
);
4022 IHTMLFormElement_Release(form
);
4025 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4026 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4028 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4029 BSTR tmp
= a2bstr(encoding
);
4032 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4033 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4035 IHTMLFormElement_Release(form
);
4037 if(exp_hres
== S_OK
)
4038 _test_form_encoding(line
, unk
, encoding
);
4041 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4042 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4044 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4049 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4050 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4051 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4052 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4054 IDispatch_Release(disp
);
4055 IHTMLFormElement_Release(form
);
4058 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4059 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4061 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4064 hres
= IHTMLFormElement_reset(form
);
4065 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4067 IHTMLFormElement_Release(form
);
4070 static void test_form_target(IUnknown
*unk
)
4072 IHTMLFormElement
*form
= get_form_iface(unk
);
4075 static const char target
[] = "_blank";
4077 str
= a2bstr(target
);
4078 hres
= IHTMLFormElement_put_target(form
, str
);
4079 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4082 hres
= IHTMLFormElement_get_target(form
, &str
);
4083 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4084 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4087 IHTMLFormElement_Release(form
);
4090 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4091 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4093 IHTMLMetaElement
*meta
;
4097 meta
= _get_metaelem_iface(line
, unk
);
4098 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4099 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4100 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4101 SysFreeString(name
);
4102 IHTMLMetaElement_Release(meta
);
4105 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4106 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4108 IHTMLMetaElement
*meta
;
4109 BSTR content
= NULL
;
4112 meta
= _get_metaelem_iface(line
, unk
);
4113 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4114 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4115 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4116 SysFreeString(content
);
4117 IHTMLMetaElement_Release(meta
);
4120 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4121 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4123 IHTMLMetaElement
*meta
;
4127 meta
= _get_metaelem_iface(line
, unk
);
4128 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4129 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4130 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4132 IHTMLMetaElement_Release(meta
);
4135 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4136 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4138 IHTMLMetaElement
*meta
;
4142 meta
= _get_metaelem_iface(line
, unk
);
4143 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4144 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4146 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4148 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4150 IHTMLMetaElement_Release(meta
);
4153 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4154 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4156 BSTR val
= a2bstr(vala
);
4157 IHTMLMetaElement
*meta
;
4160 meta
= _get_metaelem_iface(line
, unk
);
4161 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4162 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4164 IHTMLMetaElement_Release(meta
);
4166 _test_meta_charset(line
, unk
, vala
);
4169 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4170 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4172 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4176 str
= a2bstr(exval
);
4177 hres
= IHTMLLinkElement_put_media(link
, str
);
4178 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4181 hres
= IHTMLLinkElement_get_media(link
, &str
);
4182 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4183 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4185 IHTMLLinkElement_Release(link
);
4188 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4189 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4191 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4192 VARIANT_BOOL b
= 10;
4195 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4196 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4197 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4199 IHTMLLinkElement_Release(link
);
4202 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4203 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4205 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4208 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4209 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4210 IHTMLLinkElement_Release(link
);
4211 _test_link_disabled(line
, elem
, v
);
4214 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4215 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4217 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4221 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4222 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4224 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4226 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4228 IHTMLLinkElement_Release(link
);
4231 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4232 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4234 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4235 BSTR str
= a2bstr(v
);
4238 hres
= IHTMLLinkElement_put_rel(link
, str
);
4239 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4241 IHTMLLinkElement_Release(link
);
4242 _test_link_rel(line
, elem
, v
);
4245 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4246 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4248 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4252 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4253 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4255 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4257 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4259 IHTMLLinkElement_Release(link
);
4262 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4263 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4265 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4266 BSTR str
= a2bstr(v
);
4269 hres
= IHTMLLinkElement_put_rev(link
, str
);
4270 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4272 IHTMLLinkElement_Release(link
);
4273 _test_link_rev(line
, elem
, v
);
4276 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4277 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4279 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4283 hres
= IHTMLLinkElement_get_type(link
, &type
);
4284 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4286 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4288 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4290 IHTMLLinkElement_Release(link
);
4293 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4294 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4299 str
= (void*)0xdeadbeef;
4300 hres
= IHTMLScriptElement_get_text(script
, &str
);
4301 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4302 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4306 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4307 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4309 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4310 BSTR str
= a2bstr(v
);
4313 hres
= IHTMLLinkElement_put_type(link
, str
);
4314 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4316 IHTMLLinkElement_Release(link
);
4317 _test_link_type(line
, elem
, v
);
4320 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4321 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4323 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4327 hres
= IHTMLLinkElement_get_href(link
, &href
);
4328 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4330 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4332 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4334 IHTMLLinkElement_Release(link
);
4337 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4338 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4340 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4341 BSTR str
= a2bstr(v
);
4344 hres
= IHTMLLinkElement_put_href(link
, str
);
4345 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4347 IHTMLLinkElement_Release(link
);
4348 _test_link_href(line
, elem
, v
);
4351 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4352 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4354 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4355 IHTMLDocument2
*doc
;
4360 hres
= IHTMLElement_get_document(elem
, &disp
);
4361 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4362 ok(disp
!= NULL
, "disp == NULL\n");
4364 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4365 IDispatch_Release(disp
);
4366 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4371 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4372 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4374 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4375 BSTR str
= a2bstr(attr_name
);
4376 IHTMLDOMAttribute
*attr
;
4379 attr
= (void*)0xdeadbeef;
4380 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4381 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4383 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4385 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4387 IHTMLElement4_Release(elem
);
4392 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4393 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4397 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4398 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4399 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4402 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4403 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4407 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4408 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4411 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4412 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4414 IHTMLDocument2
*doc
;
4418 hres
= IHTMLWindow2_get_document(window
, &doc
);
4419 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4420 ok(doc
!= NULL
, "disp == NULL\n");
4425 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4426 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4431 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4432 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4433 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4438 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4439 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4441 IHTMLElement
*elem
= NULL
;
4446 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4447 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4448 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4454 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4455 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4457 IHTMLDocument3
*doc3
;
4458 IHTMLDOMNode
*node
= NULL
;
4462 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4463 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4466 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4467 IHTMLDocument3_Release(doc3
);
4469 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4470 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4475 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4476 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4478 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4479 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4480 IHTMLDOMNode
*new_child
= NULL
;
4483 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4484 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4485 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4486 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4488 IHTMLDOMNode_Release(node
);
4489 IHTMLDOMNode_Release(child
);
4494 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4495 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4497 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4498 IHTMLDOMNode
*new_child
= NULL
;
4501 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4502 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4503 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4504 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4506 IHTMLDOMNode_Release(node
);
4511 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4512 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4514 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4515 IHTMLDOMNode
*new_node
= NULL
;
4518 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
4519 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
4520 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
4521 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
4523 IHTMLDOMNode_Release(node
);
4524 IHTMLDOMNode_Release(new_node
);
4527 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
4528 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
4533 hres
= IHTMLDocument2_get_title(doc
, &title
);
4534 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4535 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4536 SysFreeString(title
);
4539 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
4540 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
4545 tmp
= a2bstr(title
);
4546 hres
= IHTMLDocument2_put_title(doc
, tmp
);
4547 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4551 static void test_elem_bounding_client_rect(IUnknown
*unk
)
4553 IHTMLRect
*rect
, *rect2
;
4554 IHTMLElement2
*elem2
;
4558 elem2
= get_elem2_iface(unk
);
4559 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
4560 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4561 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
4562 IHTMLElement2_Release(elem2
);
4563 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4564 ok(rect
!= NULL
, "rect == NULL\n");
4565 ok(rect
!= rect2
, "rect == rect2\n");
4566 IHTMLRect_Release(rect2
);
4568 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
4571 hres
= IHTMLRect_get_top(rect
, &l
);
4572 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4573 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4576 hres
= IHTMLRect_get_left(rect
, &l
);
4577 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4578 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4581 hres
= IHTMLRect_get_bottom(rect
, &l
);
4582 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4583 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4586 hres
= IHTMLRect_get_right(rect
, &l
);
4587 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4588 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4590 IHTMLRect_Release(rect
);
4593 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
4594 const elem_type_t
*elem_types
, LONG len
)
4597 VARIANT name
, index
;
4601 V_VT(&index
) = VT_EMPTY
;
4602 V_VT(&name
) = VT_BSTR
;
4603 V_BSTR(&name
) = a2bstr(n
);
4605 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4606 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4608 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
4609 IDispatch_Release(disp
);
4611 V_VT(&index
) = VT_I4
;
4613 for(i
=0; i
<len
; i
++) {
4615 disp
= (void*)0xdeadbeef;
4616 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4617 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4618 ok(disp
!= NULL
, "disp == NULL\n");
4619 if(FAILED(hres
) || !disp
)
4622 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
4624 IDispatch_Release(disp
);
4628 disp
= (void*)0xdeadbeef;
4629 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4630 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4631 ok(disp
== NULL
, "disp != NULL\n");
4634 disp
= (void*)0xdeadbeef;
4635 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4636 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4637 ok(disp
== NULL
, "disp != NULL\n");
4639 SysFreeString(V_BSTR(&name
));
4642 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
4644 IHTMLElementCollection
*col
;
4646 IDispatch
*disp
= (void*)0xdeadbeef;
4647 VARIANT name
, index
;
4650 hres
= IHTMLDocument2_get_all(doc
, &col
);
4651 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
4652 ok(col
!= NULL
, "col == NULL\n");
4653 if(FAILED(hres
) || !col
)
4656 V_VT(&index
) = VT_EMPTY
;
4657 V_VT(&name
) = VT_BSTR
;
4658 V_BSTR(&name
) = a2bstr(id
);
4660 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4661 IHTMLElementCollection_Release(col
);
4662 SysFreeString(V_BSTR(&name
));
4663 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4664 if(!expect_success
) {
4665 ok(disp
== NULL
, "disp != NULL\n");
4669 ok(disp
!= NULL
, "disp == NULL\n");
4673 elem
= get_elem_iface((IUnknown
*)disp
);
4674 IDispatch_Release(disp
);
4679 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
4681 IHTMLDocument3
*doc3
;
4686 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4687 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
4690 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
4692 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
4694 IHTMLDocument3_Release(doc3
);
4699 static void test_select_elem(IHTMLSelectElement
*select
)
4701 IDispatch
*disp
, *disp2
;
4702 VARIANT name
, index
;
4705 test_select_type(select
, "select-one");
4706 test_select_length(select
, 2);
4707 test_select_selidx(select
, 0);
4708 test_select_put_selidx(select
, 1);
4710 test_select_set_value(select
, "val1");
4711 test_select_value(select
, "val1");
4713 test_select_get_disabled(select
, VARIANT_FALSE
);
4714 test_select_set_disabled(select
, VARIANT_TRUE
);
4715 test_select_set_disabled(select
, VARIANT_FALSE
);
4718 hres
= IHTMLSelectElement_get_options(select
, &disp
);
4719 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
4720 ok(disp
!= NULL
, "options == NULL\n");
4721 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
4722 IDispatch_Release(disp
);
4724 V_VT(&index
) = VT_EMPTY
;
4725 V_VT(&name
) = VT_I4
;
4727 disp
= (void*)0xdeadbeef;
4728 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4729 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4730 ok(!disp
, "disp = %p\n", disp
);
4733 disp
= (void*)0xdeadbeef;
4734 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4735 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4736 ok(!disp
, "disp = %p\n", disp
);
4739 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
4740 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
4743 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4744 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4745 ok(disp
!= NULL
, "disp = NULL\n");
4746 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
4748 V_VT(&index
) = VT_I4
;
4751 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
4752 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4753 ok(disp2
!= NULL
, "disp = NULL\n");
4754 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4755 IDispatch_Release(disp2
);
4756 IDispatch_Release(disp
);
4758 test_select_multiple(select
, VARIANT_FALSE
);
4759 test_select_set_multiple(select
, VARIANT_TRUE
);
4760 test_select_remove(select
);
4763 static void test_form_item(IHTMLElement
*elem
)
4765 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
4766 IDispatch
*disp
, *disp2
;
4767 VARIANT name
, index
;
4770 V_VT(&index
) = VT_EMPTY
;
4771 V_VT(&name
) = VT_I4
;
4773 disp
= (void*)0xdeadbeef;
4774 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4775 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4776 ok(!disp
, "disp = %p\n", disp
);
4779 disp
= (void*)0xdeadbeef;
4780 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4781 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4782 ok(!disp
, "disp = %p\n", disp
);
4785 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
4786 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4789 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4790 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4791 ok(disp
!= NULL
, "disp = NULL\n");
4792 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
4794 V_VT(&index
) = VT_I4
;
4797 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
4798 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4799 ok(disp2
!= NULL
, "disp = NULL\n");
4800 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4801 IDispatch_Release(disp2
);
4802 IDispatch_Release(disp
);
4805 static void test_create_option_elem(IHTMLDocument2
*doc
)
4807 IHTMLOptionElement
*option
;
4809 option
= create_option_elem(doc
, "test text", "test value");
4811 test_option_put_text(option
, "new text");
4812 test_option_put_value(option
, "new value");
4813 test_option_put_selected(option
, VARIANT_TRUE
);
4814 test_option_put_selected(option
, VARIANT_FALSE
);
4816 IHTMLOptionElement_Release(option
);
4819 static void test_create_img_elem(IHTMLDocument2
*doc
)
4821 IHTMLImgElement
*img
;
4823 img
= create_img_elem(doc
, 10, 15);
4826 test_img_put_width(img
, 5);
4827 test_img_put_height(img
, 20);
4829 IHTMLImgElement_Release(img
);
4833 img
= create_img_elem(doc
, -1, -1);
4836 test_img_put_width(img
, 5);
4837 test_img_put_height(img
, 20);
4839 IHTMLImgElement_Release(img
);
4843 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
4844 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
4846 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
4847 IHTMLElement
*ret_elem
= NULL
;
4848 BSTR str
= a2bstr(where
);
4851 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
4852 IHTMLElement2_Release(elem2
);
4854 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
4855 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
4856 IHTMLElement_Release(ret_elem
);
4859 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
4861 IHTMLElement
*elem
, *elem2
;
4863 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
4864 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
4866 elem
= test_create_elem(doc
, "BR");
4867 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
4868 IHTMLElement_Release(elem
);
4870 test_elem_all((IUnknown
*)parent
, br_br
, 1);
4872 elem
= test_create_elem(doc
, "BR");
4873 insert_adjacent_elem(parent
, "beforeend", elem
);
4875 test_elem_all((IUnknown
*)parent
, br_br
, 2);
4877 elem2
= test_create_elem(doc
, "DIV");
4878 insert_adjacent_elem(elem
, "beforebegin", elem2
);
4879 IHTMLElement_Release(elem2
);
4880 IHTMLElement_Release(elem
);
4882 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
4885 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
4887 IHTMLBodyElement
*body
;
4888 IHTMLTxtRange
*range
;
4892 elem
= doc_get_body(doc
);
4893 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
4894 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
4895 IHTMLElement_Release(elem
);
4897 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
4898 IHTMLBodyElement_Release(body
);
4899 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
4904 static void test_txtrange(IHTMLDocument2
*doc
)
4906 IHTMLTxtRange
*body_range
, *range
, *range2
;
4907 IHTMLSelectionObject
*selection
;
4908 IDispatch
*disp_range
;
4912 body_range
= test_create_body_range(doc
);
4914 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, "[object]");
4916 test_range_text(body_range
, "test abc 123\r\nit's text");
4918 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4919 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4921 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
4922 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4923 test_range_isequal(range
, range2
, VARIANT_TRUE
);
4925 test_range_text(range
, "test abc 123\r\nit's text");
4926 test_range_text(body_range
, "test abc 123\r\nit's text");
4928 test_range_collapse(range
, TRUE
);
4929 test_range_isequal(range
, range2
, VARIANT_FALSE
);
4930 test_range_inrange(range
, range2
, VARIANT_FALSE
);
4931 test_range_inrange(range2
, range
, VARIANT_TRUE
);
4932 IHTMLTxtRange_Release(range2
);
4934 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4935 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
4936 test_range_move(range
, characterW
, 2, 2);
4937 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4939 test_range_collapse(range
, FALSE
);
4940 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
4942 test_range_collapse(range
, FALSE
);
4943 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4944 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
4945 test_range_move(range
, characterW
, 2, 2);
4946 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4947 test_range_moveend(range
, characterW
, -5, -5);
4948 test_range_text(range
, NULL
);
4949 test_range_moveend(range
, characterW
, 3, 3);
4950 test_range_text(range
, "c 1");
4951 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
4952 test_range_collapse(range
, TRUE
);
4953 test_range_move(range
, characterW
, 4, 4);
4954 test_range_moveend(range
, characterW
, 1, 1);
4955 test_range_text(range
, " ");
4956 test_range_move(range
, wordW
, 1, 1);
4957 test_range_moveend(range
, characterW
, 2, 2);
4958 test_range_text(range
, "ab");
4960 IHTMLTxtRange_Release(range
);
4962 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4963 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4965 test_range_text(range
, "test abc 123\r\nit's text");
4966 test_range_move(range
, characterW
, 3, 3);
4967 test_range_moveend(range
, characterW
, 1, 1);
4968 test_range_text(range
, "t");
4969 test_range_moveend(range
, characterW
, 3, 3);
4970 test_range_text(range
, "t ab");
4971 test_range_moveend(range
, characterW
, -2, -2);
4972 test_range_text(range
, "t ");
4973 test_range_move(range
, characterW
, 6, 6);
4974 test_range_moveend(range
, characterW
, 3, 3);
4975 test_range_text(range
, "123");
4976 test_range_moveend(range
, characterW
, 2, 2);
4977 test_range_text(range
, "123\r\ni");
4979 IHTMLTxtRange_Release(range
);
4981 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4982 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4984 test_range_move(range
, wordW
, 1, 1);
4985 test_range_moveend(range
, characterW
, 2, 2);
4986 test_range_text(range
, "ab");
4988 test_range_move(range
, characterW
, -2, -2);
4989 test_range_moveend(range
, characterW
, 2, 2);
4990 test_range_text(range
, "t ");
4992 test_range_move(range
, wordW
, 3, 3);
4993 test_range_move(range
, wordW
, -2, -2);
4994 test_range_moveend(range
, characterW
, 2, 2);
4995 test_range_text(range
, "ab");
4997 test_range_move(range
, characterW
, -6, -5);
4998 test_range_moveend(range
, characterW
, -1, 0);
4999 test_range_moveend(range
, characterW
, -6, 0);
5000 test_range_move(range
, characterW
, 2, 2);
5001 test_range_moveend(range
, characterW
, 2, 2);
5002 test_range_text(range
, "st");
5003 test_range_moveend(range
, characterW
, -6, -4);
5004 test_range_moveend(range
, characterW
, 2, 2);
5006 IHTMLTxtRange_Release(range
);
5008 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
5009 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5011 test_range_move(range
, wordW
, 2, 2);
5012 test_range_moveend(range
, characterW
, 2, 2);
5013 test_range_text(range
, "12");
5015 test_range_move(range
, characterW
, 15, 14);
5016 test_range_move(range
, characterW
, -2, -2);
5017 test_range_moveend(range
, characterW
, 3, 2);
5018 test_range_text(range
, "t");
5019 test_range_moveend(range
, characterW
, -1, -1);
5020 test_range_text(range
, "t");
5021 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5022 test_range_move(range
, characterW
, -2, -2);
5023 test_range_moveend(range
, characterW
, 2, 2);
5024 test_range_text(range
, "s ");
5025 test_range_move(range
, characterW
, 100, 7);
5026 test_range_move(range
, wordW
, 1, 0);
5027 test_range_move(range
, characterW
, -2, -2);
5028 test_range_moveend(range
, characterW
, 3, 2);
5029 test_range_text(range
, "t");
5031 IHTMLTxtRange_Release(range
);
5033 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
5034 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5036 test_range_collapse(range
, TRUE
);
5037 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5038 test_range_put_text(range
, "word");
5039 test_range_text(body_range
, "wordabc 123\r\nit's text");
5040 test_range_text(range
, NULL
);
5041 test_range_moveend(range
, characterW
, 3, 3);
5042 test_range_text(range
, "abc");
5043 test_range_movestart(range
, characterW
, -2, -2);
5044 test_range_text(range
, "rdabc");
5045 test_range_movestart(range
, characterW
, 3, 3);
5046 test_range_text(range
, "bc");
5047 test_range_movestart(range
, characterW
, 4, 4);
5048 test_range_text(range
, NULL
);
5049 test_range_movestart(range
, characterW
, -3, -3);
5050 test_range_text(range
, "c 1");
5051 test_range_movestart(range
, characterW
, -7, -6);
5052 test_range_text(range
, "wordabc 1");
5053 test_range_movestart(range
, characterW
, 100, 22);
5054 test_range_text(range
, NULL
);
5056 IHTMLTxtRange_Release(range
);
5057 IHTMLTxtRange_Release(body_range
);
5059 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5060 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5062 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, "[object]");
5064 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5065 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5066 IHTMLSelectionObject_Release(selection
);
5068 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5069 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5070 IDispatch_Release(disp_range
);
5072 test_range_text(range
, NULL
);
5073 test_range_moveend(range
, characterW
, 3, 3);
5074 test_range_text(range
, "wor");
5075 test_range_parent(range
, ET_BODY
);
5076 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5077 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5078 test_range_move(range
, characterW
, 3, 3);
5079 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5080 test_range_moveend(range
, characterW
, -4, -4);
5081 test_range_put_text(range
, "abc def ");
5082 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5083 test_range_move(range
, wordW
, 1, 1);
5084 test_range_movestart(range
, characterW
, -1, -1);
5085 test_range_text(range
, " ");
5086 test_range_move(range
, wordW
, 1, 1);
5087 test_range_moveend(range
, characterW
, 3, 3);
5088 test_range_text(range
, "def");
5089 test_range_put_text(range
, "xyz");
5090 test_range_moveend(range
, characterW
, 1, 1);
5091 test_range_move(range
, wordW
, 1, 1);
5092 test_range_moveend(range
, characterW
, 2, 2);
5093 test_range_text(range
, "ab");
5095 body
= doc_get_body(doc
);
5097 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5098 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5100 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5101 test_range_parent(range
, ET_BODY
);
5103 test_range_move(range
, wordW
, 1, 1);
5104 test_range_moveend(range
, characterW
, 12, 12);
5105 test_range_text(range
, "xyz abc 123");
5107 test_range_collapse(range
, VARIANT_TRUE
);
5108 test_range_paste_html(range
, "<br>paste<br>");
5109 test_range_text(range
, NULL
);
5111 test_range_moveend(range
, characterW
, 3, 3);
5112 test_range_text(range
, "xyz");
5114 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5115 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5117 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5119 IHTMLElement_Release(body
);
5121 IHTMLTxtRange_Release(range
);
5124 static void test_txtrange2(IHTMLDocument2
*doc
)
5126 IHTMLTxtRange
*range
;
5128 range
= test_create_body_range(doc
);
5130 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5131 test_range_move(range
, characterW
, 5, 5);
5132 test_range_moveend(range
, characterW
, 1, 1);
5133 test_range_text(range
, "2");
5134 test_range_move(range
, characterW
, -3, -3);
5135 test_range_moveend(range
, characterW
, 3, 3);
5136 test_range_text(range
, "c\r\n\r\n1");
5137 test_range_collapse(range
, VARIANT_FALSE
);
5138 test_range_moveend(range
, characterW
, 4, 4);
5139 test_range_text(range
, "23");
5140 test_range_moveend(range
, characterW
, 1, 1);
5141 test_range_text(range
, "23\r\n\r\n\r\nd");
5142 test_range_moveend(range
, characterW
, -1, -1);
5143 test_range_text(range
, "23");
5144 test_range_moveend(range
, characterW
, -1, -1);
5145 test_range_text(range
, "23");
5146 test_range_moveend(range
, characterW
, -2, -2);
5147 test_range_text(range
, "2");
5149 IHTMLTxtRange_Release(range
);
5152 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5153 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5155 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5159 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5160 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5161 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5163 IHTMLDocument5_Release(doc
);
5166 static void test_location(IHTMLDocument2
*doc
)
5168 IHTMLLocation
*location
, *location2
;
5169 IHTMLWindow2
*window
;
5174 hres
= IHTMLDocument2_get_location(doc
, &location
);
5175 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5177 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5178 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5180 ok(location
== location2
, "location != location2\n");
5181 IHTMLLocation_Release(location2
);
5183 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5184 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5186 hres
= IHTMLWindow2_get_location(window
, &location2
);
5187 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5188 ok(location
== location2
, "location != location2\n");
5189 IHTMLLocation_Release(location2
);
5191 test_ifaces((IUnknown
*)location
, location_iids
);
5192 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5194 hres
= IHTMLLocation_get_pathname(location
, &str
);
5195 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5196 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5199 hres
= IHTMLLocation_get_href(location
, NULL
);
5200 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5202 hres
= IHTMLLocation_get_href(location
, &str
);
5203 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5204 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5207 ref
= IHTMLLocation_Release(location
);
5208 ok(!ref
, "location chould be destroyed here\n");
5211 static void test_plugins_col(IHTMLDocument2
*doc
)
5213 IHTMLPluginsCollection
*col
, *col2
;
5214 IHTMLWindow2
*window
;
5220 window
= get_doc_window(doc
);
5221 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5222 IHTMLWindow2_Release(window
);
5224 hres
= IOmNavigator_get_plugins(nav
, &col
);
5225 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5227 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5228 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5229 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5230 IHTMLPluginsCollection_Release(col2
);
5232 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5235 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5236 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5237 ok(!len
, "length = %d\n", len
);
5239 ref
= IHTMLPluginsCollection_Release(col
);
5240 ok(!ref
, "ref=%d\n", ref
);
5242 IOmNavigator_Release(nav
);
5245 static void test_mime_types_col(IOmNavigator
*nav
)
5247 IHTMLMimeTypesCollection
*col
, *col2
;
5252 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5253 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5255 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5256 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5257 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5258 IHTMLMimeTypesCollection_Release(col2
);
5260 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5262 length
= 0xdeadbeef;
5263 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5264 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5265 ok(!length
, "length = %d\n", length
);
5267 ref
= IHTMLMimeTypesCollection_Release(col
);
5268 ok(!ref
, "ref=%d\n", ref
);
5271 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5272 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5274 BSTR str
= (void*)0xdeadbeef;
5275 IHTMLFrameBase
*fbase
;
5278 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5279 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5281 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5282 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5284 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5286 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5289 IHTMLFrameBase_Release(fbase
);
5292 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5293 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5295 IHTMLFrameBase
*fbase
;
5299 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5300 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5302 str
= name
? a2bstr(name
) : NULL
;
5303 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5304 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5307 _test_framebase_name(line
, elem
, name
);
5308 IHTMLFrameBase_Release(fbase
);
5311 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
5312 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
5314 BSTR str
= (void*)0xdeadbeef;
5315 IHTMLFrameBase
*fbase
;
5318 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5319 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5321 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
5322 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
5324 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
5326 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
5329 IHTMLFrameBase_Release(fbase
);
5332 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5333 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5338 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5339 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5340 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5342 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5344 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5348 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5349 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5355 V_BSTR(&v
) = a2bstr(val
);
5356 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5357 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5361 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5362 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5367 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5368 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5369 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5371 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5373 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5377 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5378 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5384 V_BSTR(&v
) = a2bstr(val
);
5385 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5386 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5390 static void test_framebase(IUnknown
*unk
)
5392 IHTMLFrameBase
*fbase
;
5396 /* get/put scrolling */
5397 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5398 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5400 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5401 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5402 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5406 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5407 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5410 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5411 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5412 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5415 str
= a2bstr("junk");
5416 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5417 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5418 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5421 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5422 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5423 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5426 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5427 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5428 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
5431 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
5432 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
5435 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5436 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5437 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
5439 test_framebase_marginheight(fbase
, NULL
);
5440 set_framebase_marginheight(fbase
, "1px");
5441 test_framebase_marginheight(fbase
, "1");
5443 test_framebase_marginwidth(fbase
, NULL
);
5444 set_framebase_marginwidth(fbase
, "2px");
5445 test_framebase_marginwidth(fbase
, "2");
5447 IHTMLFrameBase_Release(fbase
);
5450 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
5451 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
5456 if(pLCIDToLocaleName
) {
5457 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
5458 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
5459 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
5461 win_skip("LCIDToLocaleName not available, unable to test language string\n");
5462 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
5466 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
5467 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
5469 IHTMLElementCollection
*col
;
5473 hres
= IHTMLTable_get_rows(table
, &col
);
5474 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5475 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
5476 if (hres
!= S_OK
|| col
== NULL
)
5478 hres
= IHTMLElementCollection_get_length(col
, &len
);
5479 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5480 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
5482 IHTMLElementCollection_Release(col
);
5485 static void test_navigator(IHTMLDocument2
*doc
)
5487 IHTMLWindow2
*window
;
5488 IOmNavigator
*navigator
, *navigator2
;
5496 static const WCHAR v40
[] = {'4','.','0'};
5498 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5499 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
5501 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
5502 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5503 ok(navigator
!= NULL
, "navigator == NULL\n");
5504 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
5506 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
5507 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5508 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
5510 IHTMLWindow2_Release(window
);
5511 IOmNavigator_Release(navigator2
);
5513 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
5514 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
5515 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5516 SysFreeString(bstr
);
5519 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
5520 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
5521 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5522 SysFreeString(bstr
);
5525 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
5526 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
5527 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
5528 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
5529 SysFreeString(bstr
);
5532 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
5533 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
5534 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
5535 SysFreeString(bstr
);
5538 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5539 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5540 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
5541 SysFreeString(bstr
);
5544 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
5545 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
5546 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
5547 SysFreeString(bstr
);
5549 if (pGetUserDefaultUILanguage
)
5552 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
5553 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
5554 test_language_string(bstr
, pGetUserDefaultUILanguage());
5555 SysFreeString(bstr
);
5558 win_skip("GetUserDefaultUILanguage not available\n");
5561 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
5562 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
5563 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
5564 SysFreeString(bstr
);
5566 hres
= IOmNavigator_toString(navigator
, NULL
);
5567 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5570 hres
= IOmNavigator_toString(navigator
, &bstr
);
5571 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5572 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
5573 SysFreeString(bstr
);
5576 hres
= IOmNavigator_get_onLine(navigator
, &b
);
5577 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
5578 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
5581 hres
= ObtainUserAgentString(0, buf
, &size
);
5582 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
5585 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
5586 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
5587 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
5588 SysFreeString(bstr
);
5590 if(!strncmp(buf
, "Mozilla/", 8)) {
5592 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5593 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5594 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
5595 SysFreeString(bstr
);
5597 skip("nonstandard user agent\n");
5601 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
5602 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
5603 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
5604 SysFreeString(bstr
);
5606 test_mime_types_col(navigator
);
5608 ref
= IOmNavigator_Release(navigator
);
5609 ok(!ref
, "navigator should be destroyed here\n");
5612 static void test_screen(IHTMLWindow2
*window
)
5614 IHTMLScreen
*screen
, *screen2
;
5615 IDispatchEx
*dispex
;
5622 hres
= IHTMLWindow2_get_screen(window
, &screen
);
5623 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5624 ok(screen
!= NULL
, "screen == NULL\n");
5627 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
5628 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5629 ok(screen2
!= NULL
, "screen == NULL\n");
5630 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
5631 IHTMLScreen_Release(screen2
);
5633 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
5634 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
5635 if(SUCCEEDED(hres
)) {
5636 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
5637 IDispatchEx_Release(dispex
);
5640 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
5642 exl
= GetDeviceCaps(hdc
, HORZRES
);
5644 hres
= IHTMLScreen_get_width(screen
, &l
);
5645 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
5646 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
5648 exl
= GetDeviceCaps(hdc
, VERTRES
);
5650 hres
= IHTMLScreen_get_height(screen
, &l
);
5651 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5652 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5654 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
5656 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
5657 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5658 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5662 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
5665 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
5666 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
5667 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
5670 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
5671 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
5672 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
5674 IHTMLScreen_Release(screen
);
5677 static void test_default_selection(IHTMLDocument2
*doc
)
5679 IHTMLSelectionObject
*selection
;
5680 IHTMLTxtRange
*range
;
5685 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5686 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5688 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5689 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5690 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
5693 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
5694 IHTMLSelectionObject_Release(selection
);
5695 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
5697 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
5698 IDispatch_Release(disp
);
5699 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
5701 test_range_text(range
, NULL
);
5702 IHTMLTxtRange_Release(range
);
5705 static void test_doc_elem(IHTMLDocument2
*doc
)
5707 IHTMLDocument2
*doc_node
, *owner_doc
;
5709 IHTMLDocument3
*doc3
;
5713 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5714 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
5716 hres
= IHTMLDocument2_toString(doc
, &bstr
);
5717 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5718 ok(!strcmp_wa(bstr
, "[object]"),
5719 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
5720 SysFreeString(bstr
);
5722 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
5723 IHTMLDocument3_Release(doc3
);
5724 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
5726 test_node_name((IUnknown
*)elem
, "HTML");
5727 test_elem_tag((IUnknown
*)elem
, "HTML");
5729 doc_node
= get_doc_node(doc
);
5730 owner_doc
= get_owner_doc((IUnknown
*)elem
);
5731 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
5732 IHTMLDocument2_Release(owner_doc
);
5734 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
5735 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5736 IHTMLDocument2_Release(doc_node
);
5738 test_elem_client_rect((IUnknown
*)elem
);
5740 IHTMLElement_Release(elem
);
5743 static void test_default_body(IHTMLBodyElement
*body
)
5750 bstr
= (void*)0xdeadbeef;
5751 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
5752 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
5753 ok(bstr
== NULL
, "bstr != NULL\n");
5755 l
= elem_get_scroll_height((IUnknown
*)body
);
5756 ok(l
!= -1, "scrollHeight == -1\n");
5757 l
= elem_get_scroll_width((IUnknown
*)body
);
5758 ok(l
!= -1, "scrollWidth == -1\n");
5759 l
= elem_get_scroll_top((IUnknown
*)body
);
5760 ok(!l
, "scrollTop = %d\n", l
);
5761 elem_get_scroll_left((IUnknown
*)body
);
5763 test_elem_dir((IUnknown
*)body
, NULL
);
5764 set_elem_dir((IUnknown
*)body
, "ltr");
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(V_BSTR(&v
) == 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 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
5802 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
5807 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
5808 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
5809 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
5813 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
5814 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
5816 BSTR str
= a2bstr(val
);
5819 hres
= IHTMLBodyElement_put_scroll(body
, str
);
5820 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
5823 _test_body_scroll(line
, body
, val
);
5826 static void test_body_funs(IHTMLBodyElement
*body
)
5828 VARIANT vbg
, vDefaultbg
;
5831 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5832 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5833 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5834 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5836 V_VT(&vbg
) = VT_BSTR
;
5837 V_BSTR(&vbg
) = a2bstr("red");
5838 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5839 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5842 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5843 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5844 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
5845 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5848 /* Restore Originial */
5849 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5850 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5851 VariantClear(&vDefaultbg
);
5853 test_body_scroll(body
, NULL
);
5854 set_body_scroll(body
, "yes");
5855 set_body_scroll(body
, "no");
5856 set_body_scroll(body
, "auto");
5859 static void test_history(IHTMLWindow2
*window
)
5861 IOmHistory
*history
, *history2
;
5865 hres
= IHTMLWindow2_get_history(window
, &history
);
5866 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5867 ok(history
!= NULL
, "history = NULL\n");
5869 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
5872 hres
= IHTMLWindow2_get_history(window
, &history2
);
5873 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5874 ok(history2
!= NULL
, "history2 = NULL\n");
5875 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
5877 IOmHistory_Release(history2
);
5878 IOmHistory_Release(history
);
5881 static void test_window(IHTMLDocument2
*doc
)
5883 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
5884 IHTMLDocument2
*doc2
= NULL
;
5891 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5892 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5893 test_ifaces((IUnknown
*)window
, window_iids
);
5894 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
5896 IUnknown_Release(unk
);
5898 win_skip("IID_ITravelLogClient not supported\n");
5900 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5902 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5903 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5904 ok(doc2
!= NULL
, "doc2 == NULL\n");
5906 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5907 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5908 test_class_info((IUnknown
*)doc2
);
5910 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5911 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
5912 test_class_info((IUnknown
*)doc
);
5914 unk
= (void*)0xdeadbeef;
5915 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5916 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5917 ok(!unk
, "unk = %p\n", unk
);
5919 IHTMLDocument2_Release(doc2
);
5921 hres
= IHTMLWindow2_get_window(window
, &window2
);
5922 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5923 ok(window2
!= NULL
, "window2 == NULL\n");
5925 hres
= IHTMLWindow2_get_self(window
, &self
);
5926 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5927 ok(window2
!= NULL
, "self == NULL\n");
5929 ok(self
== window2
, "self != window2\n");
5931 IHTMLWindow2_Release(window2
);
5934 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5935 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5936 ok(disp
== (void*)window
, "disp != window\n");
5937 IDispatch_Release(disp
);
5939 hres
= IHTMLWindow2_toString(window
, NULL
);
5940 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5943 hres
= IHTMLWindow2_toString(window
, &str
);
5944 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5945 ok(!strcmp_wa(str
, "[object]") ||
5946 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
5949 V_VT(&v
) = VT_ERROR
;
5950 hres
= IHTMLWindow2_get_opener(window
, &v
);
5951 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
5952 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
5955 hres
= IHTMLWindow2_get_parent(window
, &parent
);
5956 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
5957 ok(parent
!= NULL
, "parent == NULL\n");
5958 ok(parent
== self
, "parent != window\n");
5959 IHTMLWindow2_Release(parent
);
5960 IHTMLWindow2_Release(self
);
5962 test_window_name(window
, NULL
);
5963 set_window_name(window
, "test");
5964 test_window_length(window
, 0);
5965 test_screen(window
);
5966 test_window_status(window
);
5967 set_window_status(window
, "Test!");
5968 test_history(window
);
5970 IHTMLWindow2_Release(window
);
5973 static void test_dom_implementation(IHTMLDocument2
*doc
)
5975 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
5976 IHTMLDOMImplementation
*dom_implementation
;
5982 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
5983 IHTMLDocument5_Release(doc5
);
5984 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
5985 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
5987 str
= a2bstr("test");
5989 V_BSTR(&v
) = a2bstr("1.0");
5991 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
5994 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
5995 ok(!b
, "hasFeature returned %x\n", b
);
5997 IHTMLDOMImplementation_Release(dom_implementation
);
6000 static void test_defaults(IHTMLDocument2
*doc
)
6002 IHTMLStyleSheetsCollection
*stylesheetcol
;
6003 IHTMLCurrentStyle
*cstyle
;
6004 IHTMLBodyElement
*body
;
6005 IHTMLElement2
*elem2
;
6011 IHTMLElementCollection
*collection
;
6013 elem
= doc_get_body(doc
);
6015 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6016 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6018 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6019 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6022 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6023 IHTMLElementCollection_Release(collection
);
6026 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6027 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6029 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6030 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6033 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6034 IHTMLElementCollection_Release(collection
);
6037 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6038 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6040 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6041 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6044 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6045 IHTMLElementCollection_Release(collection
);
6048 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6049 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6051 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6052 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6055 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6056 IHTMLElementCollection_Release(collection
);
6059 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6060 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6062 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6063 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6066 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6067 IHTMLElementCollection_Release(collection
);
6070 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6071 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6072 test_default_body(body
);
6073 test_body_funs(body
);
6074 IHTMLBodyElement_Release(body
);
6076 hres
= IHTMLElement_get_style(elem
, &style
);
6077 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6079 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
6080 test_ifaces((IUnknown
*)style
, style_iids
);
6081 IHTMLStyle_Release(style
);
6084 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6085 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6086 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6090 test_compatmode(doc
, "BackCompat");
6092 test_navigator(doc
);
6093 test_plugins_col(doc
);
6095 elem2
= get_elem2_iface((IUnknown
*)elem
);
6096 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6097 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6098 if(SUCCEEDED(hres
)) {
6101 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
6102 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6104 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6106 IUnknown_Release(unk
);
6109 /*IE6 doesn't have interface */
6110 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6113 IHTMLCurrentStyle_Release(cstyle
);
6115 IHTMLElement2_Release(elem2
);
6117 IHTMLElement_Release(elem
);
6119 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6120 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6123 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6124 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6125 ok(l
== 0, "length = %d\n", l
);
6127 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6129 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6130 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6132 test_default_selection(doc
);
6133 test_doc_title(doc
, "");
6134 test_dom_implementation(doc
);
6137 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6138 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6140 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6144 str
= (void*)0xdeadbeef;
6145 hres
= IHTMLButtonElement_get_name(button
, &str
);
6146 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6148 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
6150 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6152 IHTMLButtonElement_Release(button
);
6155 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
6156 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6158 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6159 BSTR str
= a2bstr(name
);
6162 hres
= IHTMLButtonElement_put_name(button
, str
);
6163 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6165 IHTMLButtonElement_Release(button
);
6167 _test_button_name(line
, elem
, name
);
6170 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
6171 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
6173 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6174 VARIANT_BOOL disabled
= 100;
6177 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
6178 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
6179 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
6180 IHTMLButtonElement_Release(button
);
6182 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6185 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6186 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6188 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6191 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6192 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6193 IHTMLButtonElement_Release(button
);
6195 _test_button_get_disabled(line
, elem
, b
);
6198 static void test_button_elem(IHTMLElement
*elem
)
6200 test_button_name(elem
, NULL
);
6201 set_button_name(elem
, "button name");
6204 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6205 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6206 IHTMLTableRow
*row
, LONG len
, const char *id
)
6208 IHTMLElementCollection
*col
;
6214 hres
= IHTMLTableRow_get_cells(row
, &col
);
6215 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6216 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6218 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6219 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6220 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6222 V_VT(&var
) = VT_BSTR
;
6223 V_BSTR(&var
) = a2bstr(id
);
6224 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6225 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6226 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6229 IDispatch_Release(disp
);
6230 IHTMLElementCollection_Release(col
);
6233 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6237 IHTMLTableCell
*cell
;
6239 hres
= IHTMLTableRow_deleteCell(row
, 0);
6240 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6241 test_tr_possess(elem
, row
, 1, "td2");
6243 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6244 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6245 ok(disp
!= NULL
, "disp == NULL\n");
6246 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6247 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6248 ok(cell
!= NULL
, "cell == NULL\n");
6249 if (SUCCEEDED(hres
))
6250 IHTMLTableCell_Release(cell
);
6251 test_tr_possess(elem
, row
, 2, "td2");
6252 IDispatch_Release(disp
);
6255 static void test_tr_elem(IHTMLElement
*elem
)
6257 IHTMLElementCollection
*col
;
6262 VARIANT vbg
, vDefaultbg
;
6264 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6266 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6267 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6272 hres
= IHTMLTableRow_get_cells(row
, &col
);
6273 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6274 ok(col
!= NULL
, "get_cells returned NULL\n");
6276 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6277 IHTMLElementCollection_Release(col
);
6279 bstr
= a2bstr("left");
6280 hres
= IHTMLTableRow_put_align(row
, bstr
);
6281 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6282 SysFreeString(bstr
);
6285 hres
= IHTMLTableRow_get_align(row
, &bstr
);
6286 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6287 ok(bstr
!= NULL
, "get_align returned NULL\n");
6288 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6289 SysFreeString(bstr
);
6291 bstr
= a2bstr("top");
6292 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
6293 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
6294 SysFreeString(bstr
);
6297 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
6298 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
6299 ok(bstr
!= NULL
, "get_valign returned NULL\n");
6300 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
6301 SysFreeString(bstr
);
6304 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
6305 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6306 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
6309 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
6310 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
6311 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
6313 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
6314 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6315 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6316 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6318 V_VT(&vbg
) = VT_BSTR
;
6319 V_BSTR(&vbg
) = a2bstr("red");
6320 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6321 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6324 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6325 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6326 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6327 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6331 V_I4(&vbg
) = 0xff0000;
6332 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6333 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6336 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6337 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6338 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6339 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6342 /* Restore Originial */
6343 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
6344 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6345 VariantClear(&vDefaultbg
);
6347 test_tr_modify(elem
, row
);
6349 IHTMLTableRow_Release(row
);
6352 static void test_td_elem(IHTMLElement
*elem
)
6354 IHTMLTableCell
*cell
;
6358 VARIANT vbg
, vDefaultbg
;
6360 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
6361 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6366 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
6367 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
6368 ok(lval
== 1, "Expected 1, got %d\n", lval
);
6370 str
= a2bstr("left");
6371 hres
= IHTMLTableCell_put_align(cell
, str
);
6372 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
6376 hres
= IHTMLTableCell_get_align(cell
, &str
);
6377 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6378 ok(str
!= NULL
, "str is NULL\n");
6379 if (str
!= NULL
&& hres
== S_OK
) {
6380 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
6384 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
6385 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6386 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6387 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6389 V_VT(&vbg
) = VT_BSTR
;
6390 V_BSTR(&vbg
) = a2bstr("red");
6391 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6392 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6395 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6396 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6397 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6398 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6402 V_I4(&vbg
) = 0xff0000;
6403 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6404 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6407 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6408 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6409 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6410 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6413 /* Restore Originial */
6414 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
6415 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6416 VariantClear(&vDefaultbg
);
6418 IHTMLTableCell_Release(cell
);
6421 static void test_label_elem(IHTMLElement
*elem
)
6423 IHTMLLabelElement
*label
;
6427 label
= get_label_iface((IUnknown
*)elem
);
6430 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6431 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6432 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6436 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6437 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6440 str
= (void*)0xdeadbeef;
6441 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6442 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6443 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
6445 str
= a2bstr("abc");
6446 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6447 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6451 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6452 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6453 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6456 IHTMLLabelElement_Release(label
);
6459 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
6460 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
6465 V_VT(&v
) = VT_ERROR
;
6466 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
6467 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
6468 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
6470 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
6472 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6476 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
6477 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
6482 V_VT(&v
) = VT_ERROR
;
6483 hres
= IHTMLTable_get_cellPadding(table
, &v
);
6484 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
6485 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
6487 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
6489 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6493 static void test_table_modify(IHTMLTable
*table
)
6500 test_table_length(table
, 2);
6502 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
6503 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
6504 ok(disp
!= NULL
, "disp == NULL\n");
6505 test_table_length(table
, 3);
6506 if (hres
!= S_OK
|| disp
== NULL
)
6509 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
6510 IDispatch_Release(disp
);
6512 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
6513 ok(row
!= NULL
, "row == NULL\n");
6516 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
6517 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6518 ok(index
== 0, "index = %d, expected 0\n", index
);
6520 IHTMLTableRow_Release(row
);
6522 hres
= IHTMLTable_deleteRow(table
, 0);
6523 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
6524 test_table_length(table
, 2);
6527 static void test_table_elem(IHTMLElement
*elem
)
6529 IHTMLElementCollection
*col
;
6531 IHTMLTable3
*table3
;
6536 VARIANT vbg
, vDefaultbg
;
6538 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
6539 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
6540 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
6542 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
6543 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
6547 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
6548 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
6553 hres
= IHTMLTable_get_rows(table
, &col
);
6554 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6555 ok(col
!= NULL
, "get_rows returned NULL\n");
6557 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
6558 IHTMLElementCollection_Release(col
);
6560 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6562 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
6563 test_elem_tag((IUnknown
*)node
, "TABLE");
6564 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6565 IHTMLDOMNode_Release(node
);
6567 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
6568 test_elem_tag((IUnknown
*)node
, "TABLE");
6569 test_elem_all((IUnknown
*)node
, NULL
, 0);
6570 IHTMLDOMNode_Release(node
);
6573 hres
= IHTMLTable_get_tBodies(table
, &col
);
6574 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
6575 ok(col
!= NULL
, "get_tBodies returned NULL\n");
6577 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
6578 IHTMLElementCollection_Release(col
);
6580 test_table_cell_spacing(table
, NULL
);
6584 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6585 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6586 test_table_cell_spacing(table
, "10");
6589 V_BSTR(&v
) = a2bstr("11");
6590 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6591 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6592 test_table_cell_spacing(table
, "11");
6595 test_table_cell_padding(table
, NULL
);
6599 hres
= IHTMLTable_put_cellPadding(table
, v
);
6600 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
6601 test_table_cell_padding(table
, "10");
6604 V_BSTR(&v
) = a2bstr("11");
6605 hres
= IHTMLTable_put_cellPadding(table
, v
);
6606 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
6607 test_table_cell_padding(table
, "11");
6612 hres
= IHTMLTable_put_cellPadding(table
, v
);
6613 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
6614 test_table_cell_padding(table
, "5");
6616 bstr
= a2bstr("left");
6617 hres
= IHTMLTable_put_align(table
, bstr
);
6618 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6619 SysFreeString(bstr
);
6622 hres
= IHTMLTable_get_align(table
, &bstr
);
6623 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6624 ok(bstr
!= NULL
, "get_align returned NULL\n");
6625 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6626 SysFreeString(bstr
);
6628 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
6629 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6630 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6631 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6633 V_VT(&vbg
) = VT_BSTR
;
6634 V_BSTR(&vbg
) = a2bstr("red");
6635 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6636 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6639 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6640 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6641 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6642 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6646 V_I4(&vbg
) = 0xff0000;
6647 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6648 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6651 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6652 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6653 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6654 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6657 /* Restore Originial */
6658 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
6659 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6660 VariantClear(&vDefaultbg
);
6663 V_BSTR(&v
) = a2bstr("11");
6664 hres
= IHTMLTable_put_width(table
, v
);
6665 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6667 IHTMLTable_get_width(table
, &v
);
6668 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6669 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6673 V_BSTR(&v
) = a2bstr("11.9");
6674 hres
= IHTMLTable_put_width(table
, v
);
6675 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6677 IHTMLTable_get_width(table
, &v
);
6678 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6679 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6683 V_BSTR(&v
) = a2bstr("40.2%");
6684 hres
= IHTMLTable_put_width(table
, v
);
6685 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6687 IHTMLTable_get_width(table
, &v
);
6688 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6689 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6694 hres
= IHTMLTable_put_width(table
, v
);
6695 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6696 IHTMLTable_get_width(table
, &v
);
6697 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6698 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6703 hres
= IHTMLTable_put_width(table
, v
);
6704 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6705 IHTMLTable_get_width(table
, &v
);
6706 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6707 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6710 bstr
= a2bstr("box");
6711 hres
= IHTMLTable_put_frame(table
, bstr
);
6712 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
6713 SysFreeString(bstr
);
6714 hres
= IHTMLTable_get_frame(table
, &bstr
);
6715 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
6716 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
6717 SysFreeString(bstr
);
6719 test_table_modify(table
);
6720 bstr
= a2bstr("summary");
6721 hres
= IHTMLTable3_put_summary(table3
, bstr
);
6722 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
6723 SysFreeString(bstr
);
6725 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
6726 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
6727 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
6728 SysFreeString(bstr
);
6730 IHTMLTable3_Release(table3
);
6731 IHTMLTable_Release(table
);
6734 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
6743 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6744 SafeArrayAccessData(sa
, (void**)&var
);
6745 V_VT(var
) = VT_BSTR
;
6746 V_BSTR(var
) = a2bstr(text
);
6747 SafeArrayUnaccessData(sa
);
6750 hres
= IHTMLDocument2_writeln(doc
, sa
);
6752 hres
= IHTMLDocument2_write(doc
, sa
);
6753 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6755 SafeArrayDestroy(sa
);
6758 static void doc_complex_write(IHTMLDocument2
*doc
)
6760 SAFEARRAYBOUND dim
= {5, 0};
6765 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6766 SafeArrayAccessData(sa
, (void**)&args
);
6768 V_VT(args
) = VT_BSTR
;
6769 V_BSTR(args
) = a2bstr("<body i4val=\"");
6770 V_VT(args
+1) = VT_I4
;
6772 V_VT(args
+2) = VT_BSTR
;
6773 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
6774 V_VT(args
+3) = VT_R8
;
6775 V_R8(args
+3) = 3.14;
6776 V_VT(args
+4) = VT_BSTR
;
6777 V_BSTR(args
+4) = a2bstr("\">");
6778 SafeArrayUnaccessData(sa
);
6780 hres
= IHTMLDocument2_write(doc
, sa
);
6781 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6783 SafeArrayDestroy(sa
);
6786 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
6788 IHTMLDocument2
*window_doc
, *elem_doc
;
6789 IHTMLFrameElement3
*frame_elem3
;
6790 IHTMLWindow2
*content_window
;
6793 content_window
= get_frame_content_window(frame_elem
);
6794 test_ifaces((IUnknown
*)content_window
, window_iids
);
6795 window_doc
= get_window_doc(content_window
);
6796 IHTMLWindow2_Release(content_window
);
6798 elem_doc
= get_elem_doc(frame_elem
);
6799 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
6802 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
6803 if(SUCCEEDED(hres
)) {
6804 IDispatch
*disp
= NULL
;
6806 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
6807 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6808 ok(disp
!= NULL
, "contentDocument == NULL\n");
6809 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
6811 IDispatch_Release(disp
);
6812 IHTMLFrameElement3_Release(frame_elem3
);
6814 win_skip("IHTMLFrameElement3 not supported\n");
6818 IHTMLDocument2_Release(elem_doc
);
6819 IHTMLDocument2_Release(window_doc
);
6822 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
6823 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6825 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6829 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
6830 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6831 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
6833 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6835 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6837 IHTMLIFrameElement2_Release(iframe
);
6840 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
6841 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
6843 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6848 V_BSTR(&v
) = a2bstr(val
);
6849 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
6850 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
6852 IHTMLIFrameElement2_Release(iframe
);
6855 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
6856 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6858 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6862 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
6863 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6864 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
6866 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6868 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6870 IHTMLIFrameElement2_Release(iframe
);
6873 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
6874 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
6876 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6881 V_BSTR(&v
) = a2bstr(val
);
6882 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
6883 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
6885 IHTMLIFrameElement2_Release(iframe
);
6888 static void test_iframe_elem(IHTMLElement
*elem
)
6890 IHTMLDocument2
*content_doc
, *owner_doc
;
6891 IHTMLIFrameElement3
*iframe3
;
6892 IHTMLElementCollection
*col
;
6893 IHTMLWindow2
*content_window
;
6900 static const elem_type_t all_types
[] = {
6908 test_frame_doc((IUnknown
*)elem
, TRUE
);
6909 test_framebase((IUnknown
*)elem
);
6911 content_window
= get_frame_content_window((IUnknown
*)elem
);
6912 test_ifaces((IUnknown
*)content_window
, window_iids
);
6913 test_window_length(content_window
, 0);
6915 content_doc
= get_window_doc(content_window
);
6916 IHTMLWindow2_Release(content_window
);
6918 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
6919 if(SUCCEEDED(hres
)) {
6920 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
6921 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6922 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
6923 IDispatch_Release(disp
);
6925 IHTMLIFrameElement3_Release(iframe3
);
6927 win_skip("IHTMLIFrameElement3 not supported\n");
6930 test_iframe_height(elem
, NULL
);
6931 set_iframe_height(elem
, "100px");
6932 set_iframe_height(elem
, "50%");
6933 test_iframe_height(elem
, "50%");
6935 test_iframe_width(elem
, NULL
);
6936 set_iframe_width(elem
, "150px");
6937 set_iframe_width(elem
, "70%");
6938 test_iframe_width(elem
, "70%");
6939 test_framebase_src(elem
, "about:blank");
6941 str
= a2bstr("text/html");
6942 V_VT(&errv
) = VT_ERROR
;
6944 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
6946 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
6947 ok(disp
!= NULL
, "disp == NULL\n");
6948 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
6949 IDispatch_Release(disp
);
6951 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
6952 doc_complex_write(content_doc
);
6953 doc_write(content_doc
, TRUE
, "<br />");
6954 doc_write(content_doc
, TRUE
, "</html>");
6956 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
6957 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6958 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6959 IHTMLElementCollection_Release(col
);
6961 body
= doc_get_body(content_doc
);
6962 test_elem_attr(body
, "i4val", "4");
6963 test_elem_attr(body
, "r8val", "3.14");
6964 IHTMLElement_Release(body
);
6966 hres
= IHTMLDocument2_close(content_doc
);
6967 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
6969 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
6970 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6972 IHTMLDocument2_Release(content_doc
);
6975 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
6976 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
6981 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
6982 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
6985 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
6987 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
6990 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
6992 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
6998 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
6999 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7001 BSTR str
= a2bstr(csstext
);
7004 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7006 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7008 todo_wine
ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7012 static void test_stylesheet(IDispatch
*disp
)
7014 IHTMLStyleSheetRulesCollection
*col
= NULL
;
7015 IHTMLStyleSheet
*stylesheet
;
7019 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
7021 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
7022 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
7024 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
7025 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
7026 ok(col
!= NULL
, "col == NULL\n");
7028 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
7029 IHTMLStyleSheetRulesCollection_Release(col
);
7031 href
= (void*)0xdeadbeef;
7032 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
7033 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
7034 ok(href
== NULL
, "got href != NULL\n");
7035 SysFreeString(href
);
7037 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
7038 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
7039 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
7040 set_stylesheet_csstext(stylesheet
, "", FALSE
);
7041 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
7042 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
7043 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
7045 IHTMLStyleSheet_Release(stylesheet
);
7048 static void test_stylesheets(IHTMLDocument2
*doc
)
7050 IHTMLStyleSheetsCollection
*col
= NULL
;
7055 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
7056 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
7057 ok(col
!= NULL
, "col == NULL\n");
7059 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
7061 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
7062 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7063 ok(len
== 1, "len=%d\n", len
);
7069 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7070 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
7071 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
7072 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
7073 test_stylesheet(V_DISPATCH(&res
));
7080 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7081 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7082 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
7085 IHTMLStyleSheetsCollection_Release(col
);
7088 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
7090 IDispatchEx
*dispex
;
7092 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
7100 static const WCHAR w0
[] = {'0',0};
7101 static const WCHAR w100
[] = {'1','0','0',0};
7103 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
7104 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
7106 bstr
= SysAllocString(w0
);
7107 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7108 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7109 SysFreeString(bstr
);
7112 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
7113 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
7114 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
7115 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
7116 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
7117 type
= get_node_type((IUnknown
*)node
);
7118 ok(type
== 3, "type=%d\n", type
);
7119 IHTMLDOMNode_Release(node
);
7122 bstr
= SysAllocString(w100
);
7123 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7124 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
7125 SysFreeString(bstr
);
7127 IDispatchEx_Release(dispex
);
7130 static void test_enum_children(IUnknown
*unk
, unsigned len
)
7132 IEnumVARIANT
*enum_var
;
7137 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
7138 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
7140 for(i
=0; i
<len
; i
++) {
7142 V_VT(&v
) = VT_ERROR
;
7143 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
7144 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
7146 ok(fetched
== 1, "fetched = %d\n", fetched
);
7147 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
7148 IDispatch_Release(V_DISPATCH(&v
));
7151 fetched
= 0xdeadbeef;
7153 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
7154 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
7155 ok(fetched
== 0, "fetched = %d\n", fetched
);
7156 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7158 hres
= IEnumVARIANT_Reset(enum_var
);
7159 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7161 fetched
= 0xdeadbeef;
7163 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
7164 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
7165 ok(fetched
== 0, "fetched = %d\n", fetched
);
7166 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7168 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
7169 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
7171 hres
= IEnumVARIANT_Reset(enum_var
);
7172 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7174 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
7175 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
7177 IEnumVARIANT_Release(enum_var
);
7180 static void test_elems(IHTMLDocument2
*doc
)
7182 IHTMLElementCollection
*col
;
7183 IHTMLDOMChildrenCollection
*child_col
;
7184 IHTMLElement
*elem
, *elem2
, *elem3
;
7185 IHTMLDOMNode
*node
, *node2
;
7186 IHTMLWindow2
*window
;
7190 IHTMLElementCollection
*collection
;
7191 IHTMLDocument3
*doc3
;
7194 static const elem_type_t all_types
[] = {
7227 static const elem_type_t item_types
[] = {
7233 hres
= IHTMLDocument2_get_all(doc
, &col
);
7234 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7235 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7236 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
7238 elem
= get_elem_col_item_idx(col
, 0);
7239 test_elem_source_index(elem
, 0);
7240 IHTMLElement_Release(elem
);
7242 elem
= get_elem_col_item_idx(col
, 3);
7243 test_elem_source_index(elem
, 3);
7244 IHTMLElement_Release(elem
);
7246 IHTMLElementCollection_Release(col
);
7248 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7249 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
7252 static const elem_type_t images_types
[] = {ET_IMG
};
7253 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7255 IHTMLElementCollection_Release(collection
);
7258 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7259 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
7262 static const elem_type_t images_types
[] = {ET_A
};
7263 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7265 IHTMLElementCollection_Release(collection
);
7268 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7269 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7272 static const elem_type_t anchor_types
[] = {ET_A
};
7273 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7275 IHTMLElementCollection_Release(collection
);
7278 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7279 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7281 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7282 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7283 IHTMLElementCollection_Release(collection
);
7286 test_plugins_col(doc
);
7288 elem
= get_doc_elem(doc
);
7289 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
7290 IHTMLElement_Release(elem
);
7292 get_elem_by_id(doc
, "xxx", FALSE
);
7293 elem
= get_doc_elem_by_id(doc
, "xxx");
7294 ok(!elem
, "elem != NULL\n");
7296 elem
= get_doc_elem_by_id(doc
, "s");
7297 ok(elem
!= NULL
, "elem == NULL\n");
7299 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
7300 test_elem_attr(elem
, "xxx", NULL
);
7301 test_elem_attr(elem
, "id", "s");
7302 test_elem_class((IUnknown
*)elem
, NULL
);
7303 test_elem_set_class((IUnknown
*)elem
, "cl");
7304 test_elem_set_class((IUnknown
*)elem
, NULL
);
7305 test_elem_tabindex((IUnknown
*)elem
, 0);
7306 test_elem_set_tabindex((IUnknown
*)elem
, 1);
7307 test_elem_filters((IUnknown
*)elem
);
7309 node
= test_node_get_parent((IUnknown
*)elem
);
7310 ok(node
!= NULL
, "node == NULL\n");
7311 test_node_name((IUnknown
*)node
, "BODY");
7312 node2
= test_node_get_parent((IUnknown
*)node
);
7313 IHTMLDOMNode_Release(node
);
7314 ok(node2
!= NULL
, "node == NULL\n");
7315 test_node_name((IUnknown
*)node2
, "HTML");
7316 node
= test_node_get_parent((IUnknown
*)node2
);
7317 IHTMLDOMNode_Release(node2
);
7318 ok(node
!= NULL
, "node == NULL\n");
7321 test_node_name((IUnknown
*)node
, "#document");
7322 type
= get_node_type((IUnknown
*)node
);
7323 ok(type
== 9, "type=%d, expected 9\n", type
);
7324 node2
= test_node_get_parent((IUnknown
*)node
);
7325 IHTMLDOMNode_Release(node
);
7326 ok(node2
== NULL
, "node != NULL\n");
7329 elem2
= test_elem_get_parent((IUnknown
*)elem
);
7330 ok(elem2
!= NULL
, "elem2 == NULL\n");
7331 test_node_name((IUnknown
*)elem2
, "BODY");
7333 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
7334 ok(elem3
!= NULL
, "elem3 == NULL\n");
7335 test_node_name((IUnknown
*)elem3
, "HTML");
7337 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
7338 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
7339 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
7340 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
7341 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
7342 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
7343 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
7344 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
7345 IHTMLElement_Release(elem2
);
7347 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
7348 ok(elem2
== NULL
, "elem2 != NULL\n");
7349 test_elem_source_index(elem3
, 0);
7350 IHTMLElement_Release(elem3
);
7352 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
7353 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
7354 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
7356 test_elem_innertext(elem
, "opt1opt2");
7358 IHTMLElement_Release(elem
);
7361 elem
= get_elem_by_id(doc
, "s", TRUE
);
7363 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
7364 IHTMLDocument2
*doc_node
, *elem_doc
;
7366 test_select_elem(select
);
7368 test_elem_title((IUnknown
*)select
, NULL
);
7369 test_elem_set_title((IUnknown
*)select
, "Title");
7370 test_elem_title((IUnknown
*)select
, "Title");
7371 test_elem_offset((IUnknown
*)select
, "BODY");
7372 test_elem_bounding_client_rect((IUnknown
*)select
);
7374 node
= get_first_child((IUnknown
*)select
);
7375 ok(node
!= NULL
, "node == NULL\n");
7377 test_elem_type((IUnknown
*)node
, ET_OPTION
);
7378 IHTMLDOMNode_Release(node
);
7381 type
= get_node_type((IUnknown
*)select
);
7382 ok(type
== 1, "type=%d\n", type
);
7384 IHTMLSelectElement_Release(select
);
7386 elem_doc
= get_elem_doc((IUnknown
*)elem
);
7388 doc_node
= get_doc_node(doc
);
7389 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
7390 IHTMLDocument2_Release(doc_node
);
7391 IHTMLDocument2_Release(elem_doc
);
7393 IHTMLElement_Release(elem
);
7396 elem
= get_elem_by_id(doc
, "sc", TRUE
);
7398 IHTMLScriptElement
*script
;
7401 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
7402 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
7404 test_elem_language(elem
, NULL
);
7410 hres
= IHTMLScriptElement_put_type (script
, NULL
);
7411 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7412 hres
= IHTMLScriptElement_get_type(script
, &type
);
7413 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7414 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
7416 type
= a2bstr("text/javascript");
7417 hres
= IHTMLScriptElement_put_type (script
, type
);
7418 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7419 SysFreeString(type
);
7420 hres
= IHTMLScriptElement_get_type(script
, &type
);
7421 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7422 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
7423 SysFreeString(type
);
7425 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
7428 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
7429 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7431 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
7432 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
7433 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
7435 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
7436 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7438 str
= (BSTR
)0xdeadbeef;
7439 hres
= IHTMLScriptElement_get_src(script
, &str
);
7440 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
7441 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
7444 IHTMLScriptElement_Release(script
);
7446 set_elem_language(elem
, "vbscript");
7447 set_elem_language(elem
, "xxx");
7450 elem
= get_elem_by_id(doc
, "in", TRUE
);
7452 IHTMLInputElement
*input
;
7454 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
7455 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
7457 test_elem_id((IUnknown
*)elem
, "in");
7458 test_elem_put_id((IUnknown
*)elem
, "newin");
7459 test_input_get_disabled(input
, VARIANT_FALSE
);
7460 test_input_set_disabled(input
, VARIANT_TRUE
);
7461 test_input_set_disabled(input
, VARIANT_FALSE
);
7462 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
7463 test_input_get_disabled(input
, VARIANT_TRUE
);
7464 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
7465 test_input_get_disabled(input
, VARIANT_FALSE
);
7466 test_elem_client_size((IUnknown
*)elem
);
7467 test_input_type(input
, "text");
7469 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7470 test_node_put_value_str((IUnknown
*)elem
, "test");
7471 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7472 test_input_value((IUnknown
*)elem
, NULL
);
7473 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7474 test_input_put_value((IUnknown
*)elem
, "test");
7475 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7476 test_elem_class((IUnknown
*)elem
, "testclass");
7477 test_elem_tabindex((IUnknown
*)elem
, 2);
7478 test_elem_set_tabindex((IUnknown
*)elem
, 3);
7479 test_elem_title((IUnknown
*)elem
, "test title");
7481 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
7482 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
7483 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
7485 test_input_get_checked(input
, VARIANT_FALSE
);
7486 test_input_set_checked(input
, VARIANT_TRUE
);
7487 test_input_set_checked(input
, VARIANT_FALSE
);
7489 test_input_maxlength(input
, 0x7fffffff);
7490 test_input_set_maxlength(input
, 30);
7492 test_input_name(input
, NULL
);
7493 test_input_set_name(input
, "test");
7495 test_input_src(input
, NULL
);
7496 test_input_set_src(input
, "about:blank");
7498 test_input_set_size(input
, 15, S_OK
);
7499 test_input_get_size(input
, 15);
7500 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
7501 test_input_get_size(input
, 15);
7502 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
7503 test_input_get_size(input
, 15);
7505 test_input_readOnly(input
, VARIANT_TRUE
);
7506 test_input_readOnly(input
, VARIANT_FALSE
);
7508 IHTMLInputElement_Release(input
);
7509 IHTMLElement_Release(elem
);
7512 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7514 test_img_align((IUnknown
*)elem
, "left");
7515 test_img_name((IUnknown
*)elem
, "WineImg");
7516 test_img_src((IUnknown
*)elem
, "", NULL
);
7517 test_img_set_src((IUnknown
*)elem
, "about:blank");
7518 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
7519 test_img_alt((IUnknown
*)elem
, NULL
);
7520 test_img_set_alt((IUnknown
*)elem
, "alt test");
7521 test_img_name((IUnknown
*)elem
, "WineImg");
7522 test_img_complete(elem
, VARIANT_FALSE
);
7523 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
7524 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
7525 IHTMLElement_Release(elem
);
7528 elem
= get_elem_by_id(doc
, "attr", TRUE
);
7530 test_dynamic_properties(elem
);
7531 test_attr_collection(elem
);
7532 test_contenteditable((IUnknown
*)elem
);
7533 IHTMLElement_Release(elem
);
7536 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
7538 test_style_media((IUnknown
*)elem
, NULL
);
7539 test_style_put_media((IUnknown
*)elem
, "screen");
7540 test_style_type((IUnknown
*)elem
, NULL
);
7541 test_style_put_type((IUnknown
*)elem
, "text/css");
7542 IHTMLElement_Release(elem
);
7545 elem
= get_doc_elem_by_id(doc
, "tbl");
7546 ok(elem
!= NULL
, "elem == NULL\n");
7548 test_table_elem(elem
);
7549 IHTMLElement_Release(elem
);
7552 elem
= get_doc_elem_by_id(doc
, "labelid");
7553 ok(elem
!= NULL
, "elem == NULL\n");
7555 test_label_elem(elem
);
7556 IHTMLElement_Release(elem
);
7559 elem
= get_doc_elem_by_id(doc
, "td2");
7560 ok(elem
!= NULL
, "elem == NULL\n");
7563 IHTMLElement_Release(elem
);
7566 elem
= get_doc_elem_by_id(doc
, "row2");
7567 ok(elem
!= NULL
, "elem == NULL\n");
7570 IHTMLElement_Release(elem
);
7573 elem
= get_doc_elem_by_id(doc
, "ifr");
7574 ok(elem
!= NULL
, "elem == NULL\n");
7576 test_iframe_elem(elem
);
7577 IHTMLElement_Release(elem
);
7580 elem
= get_doc_elem_by_id(doc
, "btnid");
7581 ok(elem
!= NULL
, "elem == NULL\n");
7583 test_button_elem(elem
);
7584 test_button_get_disabled(elem
, VARIANT_FALSE
);
7585 test_button_set_disabled(elem
, VARIANT_TRUE
);
7586 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7587 test_button_get_disabled(elem
, VARIANT_FALSE
);
7588 IHTMLElement_Release(elem
);
7591 elem
= get_doc_elem_by_id(doc
, "objid");
7592 ok(elem
!= NULL
, "elem == NULL\n");
7594 test_object_vspace((IUnknown
*)elem
, 100);
7595 test_object_name(elem
, "objname");
7596 set_object_name(elem
, "test");
7597 set_object_name(elem
, NULL
);
7598 IHTMLElement_Release(elem
);
7601 elem
= get_elem_by_id(doc
, "a", TRUE
);
7603 test_anchor_href((IUnknown
*)elem
, "http://test/");
7605 /* Change the href */
7606 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
7607 test_anchor_href((IUnknown
*)elem
, "http://test1/");
7608 test_anchor_hostname((IUnknown
*)elem
, "test1");
7610 /* Restore the href */
7611 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
7612 test_anchor_href((IUnknown
*)elem
, "http://test/");
7613 test_anchor_hostname((IUnknown
*)elem
, "test");
7614 test_anchor_hash(elem
, NULL
);
7617 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7619 test_anchor_rel((IUnknown
*)elem
, NULL
);
7620 test_anchor_put_rel((IUnknown
*)elem
, "Next");
7621 test_anchor_rel((IUnknown
*)elem
, "Next");
7623 /* Change the target */
7624 test_anchor_put_target((IUnknown
*)elem
, "wine");
7625 test_anchor_get_target((IUnknown
*)elem
, "wine");
7627 /* Restore the target */
7628 test_anchor_put_target((IUnknown
*)elem
, NULL
);
7629 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7631 test_anchor_name((IUnknown
*)elem
, "x");
7632 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
7633 test_anchor_put_name((IUnknown
*)elem
, NULL
);
7634 test_anchor_put_name((IUnknown
*)elem
, "x");
7636 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
7637 test_anchor_hash(elem
, "#hash");
7638 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
7640 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
7641 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
7642 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
7643 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
7645 test_anchor_put_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD"); /* encoded cjk characters */
7646 test_anchor_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD", FALSE
);
7648 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
7649 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
7651 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
7652 as part of the pathname, and cannot be accessed by get_search. */
7653 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
7654 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
7656 IHTMLElement_Release(elem
);
7659 elem
= get_doc_elem_by_id(doc
, "metaid");
7661 test_meta_name((IUnknown
*)elem
, "meta name");
7662 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
7663 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
7664 test_meta_charset((IUnknown
*)elem
, NULL
);
7665 set_meta_charset((IUnknown
*)elem
, "utf-8");
7666 IHTMLElement_Release(elem
);
7669 elem
= doc_get_body(doc
);
7671 node
= get_first_child((IUnknown
*)elem
);
7672 ok(node
!= NULL
, "node == NULL\n");
7674 test_ifaces((IUnknown
*)node
, text_iids
);
7675 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
7677 node2
= get_first_child((IUnknown
*)node
);
7678 ok(!node2
, "node2 != NULL\n");
7680 type
= get_node_type((IUnknown
*)node
);
7681 ok(type
== 3, "type=%d\n", type
);
7683 test_node_get_value_str((IUnknown
*)node
, "text test");
7684 test_node_put_value_str((IUnknown
*)elem
, "test text");
7685 test_node_get_value_str((IUnknown
*)node
, "text test");
7687 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
7688 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
7689 ok(!disp
, "disp != NULL\n");
7691 IHTMLDOMNode_Release(node
);
7694 child_col
= get_child_nodes((IUnknown
*)elem
);
7695 ok(child_col
!= NULL
, "child_coll == NULL\n");
7700 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
7702 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
7703 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7704 ok(length
, "length=0\n");
7707 node
= get_child_item(child_col
, 0);
7708 ok(node
!= NULL
, "node == NULL\n");
7712 type
= get_node_type((IUnknown
*)node
);
7713 ok(type
== 3, "type=%d\n", type
);
7714 node2
= node_get_next((IUnknown
*)node
);
7716 prev
= node_get_prev((IUnknown
*)node2
);
7717 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
7718 IHTMLDOMNode_Release(prev
);
7720 IHTMLDOMNode_Release(node
);
7723 node
= get_child_item(child_col
, 1);
7724 ok(node
!= NULL
, "node == NULL\n");
7726 type
= get_node_type((IUnknown
*)node
);
7727 ok(type
== 8, "type=%d\n", type
);
7729 test_elem_id((IUnknown
*)node
, NULL
);
7730 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
7731 IHTMLDOMNode_Release(node2
);
7732 IHTMLDOMNode_Release(node
);
7735 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
7736 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7738 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
7739 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7741 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
7742 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7744 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
7745 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7747 test_child_col_disp(child_col
);
7749 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
7750 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
7752 test_enum_children(enum_unk
, length
);
7754 IUnknown_Release(enum_unk
);
7756 IHTMLDOMChildrenCollection_Release(child_col
);
7759 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7760 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
7761 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7763 IHTMLElement_Release(elem
);
7765 elem
= get_doc_elem_by_id(doc
, "frm");
7766 ok(elem
!= NULL
, "elem == NULL\n");
7768 test_form_length((IUnknown
*)elem
, 0);
7769 test_form_elements((IUnknown
*)elem
);
7770 IHTMLElement_Release(elem
);
7773 test_stylesheets(doc
);
7774 test_create_option_elem(doc
);
7775 test_create_img_elem(doc
);
7777 elem
= get_doc_elem_by_id(doc
, "tbl");
7778 ok(elem
!= NULL
, "elem = NULL\n");
7779 test_elem_set_innertext(elem
, "inner text");
7780 IHTMLElement_Release(elem
);
7782 test_doc_title(doc
, "test");
7783 test_doc_set_title(doc
, "test title");
7784 test_doc_title(doc
, "test title");
7787 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
7788 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
7791 IDispatchEx
*dispex
;
7792 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
7793 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
7797 BSTR str
= a2bstr("Testing");
7798 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
7799 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7800 ok(pid
!= -1, "pid == -1\n");
7802 IDispatchEx_Release(dispex
);
7805 IDispatch_Release(disp
);
7807 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
7808 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
7810 str
= a2bstr("Img");
7811 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
7812 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
7816 static const elem_type_t img_types
[] = { ET_IMG
};
7818 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
7819 IHTMLElementCollection_Release(col
);
7822 elem
= get_doc_elem_by_id(doc
, "y");
7823 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
7824 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
7825 test_elem_set_innerhtml((IUnknown
*)elem
, "");
7826 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
7827 node
= node_get_next((IUnknown
*)elem
);
7828 ok(!node
, "node = %p\n", node
);
7830 elem2
= get_doc_elem_by_id(doc
, "x");
7831 test_elem_tag((IUnknown
*)elem2
, "A");
7832 node
= node_get_next((IUnknown
*)elem2
);
7833 IHTMLDOMNode_Release(node
);
7834 IHTMLElement_Release(elem2
);
7835 IHTMLElement_Release(elem
);
7837 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
7838 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
7840 IHTMLDocument3_Release(doc3
);
7842 elem
= get_elem_by_id(doc
, "s", TRUE
);
7844 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
7846 test_select_put_length((IUnknown
*)elem
, 3);
7847 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
7848 test_select_put_length((IUnknown
*)elem
, 1);
7849 test_elem_all((IUnknown
*)elem
, select_types
, 1);
7850 IHTMLElement_Release(elem
);
7853 window
= get_doc_window(doc
);
7854 test_window_name(window
, NULL
);
7855 set_window_name(window
, "test name");
7856 test_window_length(window
, 1);
7857 IHTMLWindow2_Release(window
);
7860 static void test_attr(IHTMLElement
*elem
)
7862 IHTMLDOMAttribute
*attr
, *attr2
;
7865 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
7867 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7869 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
7870 test_ifaces((IUnknown
*)attr
, attr_iids
);
7871 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
7872 test_attr_specified(attr
, VARIANT_TRUE
);
7874 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7875 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
7876 IHTMLDOMAttribute_Release(attr2
);
7878 get_attr_node_value(attr
, &v
, VT_BSTR
);
7879 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7883 V_BSTR(&v
) = a2bstr("divid2");
7884 put_attr_node_value(attr
, v
);
7886 get_attr_node_value(attr
, &v
, VT_BSTR
);
7887 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7890 IHTMLDOMAttribute_Release(attr
);
7892 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7893 get_attr_node_value(attr
, &v
, VT_BSTR
);
7894 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7898 V_BSTR(&v
) = a2bstr("newvalue");
7899 put_attr_node_value(attr
, v
);
7902 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7903 get_attr_node_value(attr
, &v
, VT_BSTR
);
7904 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7907 test_attr_specified(attr
, VARIANT_TRUE
);
7908 IHTMLDOMAttribute_Release(attr
);
7912 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
7913 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
7914 get_attr_node_value(attr
, &v
, VT_I4
);
7915 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
7916 test_attr_specified(attr
, VARIANT_TRUE
);
7920 put_attr_node_value(attr
, v
);
7922 get_attr_node_value(attr
, &v
, VT_I4
);
7923 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
7925 IHTMLDOMAttribute_Release(attr
);
7927 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
7928 test_attr_specified(attr
, VARIANT_FALSE
);
7929 IHTMLDOMAttribute_Release(attr
);
7932 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
7936 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7937 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
7938 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7940 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7941 IHTMLElement_Release(elem
);
7944 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7945 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
7946 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7948 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
7949 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
7950 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
7951 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
7952 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7953 IHTMLElement_Release(elem
);
7957 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
7958 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
7960 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
7961 IHTMLElementCollection
*col
;
7962 BSTR str
= a2bstr(name
);
7965 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
7966 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
7967 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
7969 IHTMLDocument3_Release(doc3
);
7974 static void test_elem_names(IHTMLDocument2
*doc
)
7976 IHTMLElementCollection
*col
;
7981 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
7983 body
= doc_get_body(doc
);
7985 test_elem_set_innerhtml((IUnknown
*)body
,
7986 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
7987 col
= doc_get_elems_by_name(doc
, "test");
7988 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
7989 IHTMLElementCollection_Release(col
);
7991 col
= doc_get_elems_by_name(doc
, "yyy");
7992 test_elem_collection((IUnknown
*)col
, NULL
, 0);
7993 IHTMLElementCollection_Release(col
);
7995 /* case insensivity test */
7996 col
= doc_get_elems_by_name(doc
, "Xxx");
7997 hres
= IHTMLElementCollection_get_length(col
, &len
);
7998 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7999 todo_wine
ok(len
== 1, "len = %d\n", len
);
8000 IHTMLElementCollection_Release(col
);
8002 IHTMLElement_Release(body
);
8005 static void test_elems2(IHTMLDocument2
*doc
)
8007 IHTMLElement
*elem
, *elem2
, *div
;
8009 static const elem_type_t outer_types
[] = {
8014 div
= get_doc_elem_by_id(doc
, "divid");
8016 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
8018 test_link_disabled(elem
, VARIANT_FALSE
);
8019 test_link_rel(elem
, "stylesheet");
8020 test_link_rev(elem
, NULL
);
8021 test_link_type(elem
, "text/css");
8022 test_link_href(elem
, "about:blank");
8023 test_link_media(elem
, "all");
8024 link_put_disabled(elem
, VARIANT_TRUE
);
8025 link_put_rel(elem
, "prev");
8026 link_put_rev(elem
, "next");
8027 link_put_type(elem
, "text/plain");
8028 link_put_href(elem
, "about:prev");
8029 IHTMLElement_Release(elem
);
8032 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
8033 elem2
= get_doc_elem_by_id(doc
, "innerid");
8034 ok(elem2
!= NULL
, "elem2 == NULL\n");
8035 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
8036 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
8037 IHTMLElement_Release(elem2
);
8039 elem2
= get_doc_elem_by_id(doc
, "aid");
8040 ok(elem2
!= NULL
, "elem2 == NULL\n");
8041 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
8042 test_elem_all((IUnknown
*)div
, outer_types
, 1);
8043 IHTMLElement_Release(elem2
);
8045 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
8046 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8048 IHTMLFormElement
*form
;
8050 test_textarea_value((IUnknown
*)elem
, NULL
);
8051 test_textarea_put_value((IUnknown
*)elem
, "test");
8052 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8053 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
8054 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8055 test_textarea_type((IUnknown
*)elem
);
8057 form
= get_textarea_form((IUnknown
*)elem
);
8058 ok(!form
, "form = %p\n", form
);
8060 IHTMLElement_Release(elem
);
8063 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
8064 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8066 IHTMLFormElement
*form
;
8068 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
8069 ok(elem2
!= NULL
, "elem2 == NULL\n");
8071 form
= get_textarea_form((IUnknown
*)elem
);
8072 ok(form
!= NULL
, "form = NULL\n");
8073 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
8075 IHTMLFormElement_Release(form
);
8076 IHTMLElement_Release(elem2
);
8077 IHTMLElement_Release(elem
);
8080 test_elem_set_innerhtml((IUnknown
*)div
,
8081 "<input value=\"val\" id =\"inputid\" />");
8082 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8084 test_input_defaultValue((IUnknown
*)elem
, "val");
8085 test_input_put_value((IUnknown
*)elem
, "test");
8086 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
8087 test_input_value((IUnknown
*)elem
, "test");
8088 IHTMLElement_Release(elem
);
8091 test_elem_set_innerhtml((IUnknown
*)div
, "");
8092 test_insert_adjacent_elems(doc
, div
);
8094 test_elem_set_innerhtml((IUnknown
*)div
,
8095 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
8096 elem
= get_elem_by_id(doc
, "form", TRUE
);
8098 test_form_length((IUnknown
*)elem
, 2);
8099 test_form_item(elem
);
8100 test_form_action((IUnknown
*)elem
, NULL
);
8101 test_form_put_action((IUnknown
*)elem
, "about:blank");
8102 test_form_method((IUnknown
*)elem
, "get");
8103 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
8104 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
8105 test_form_method((IUnknown
*)elem
, "post");
8106 test_form_name((IUnknown
*)elem
, NULL
);
8107 test_form_put_name((IUnknown
*)elem
, "Name");
8108 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
8109 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
8110 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
8111 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
8112 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
8113 test_form_elements((IUnknown
*)elem
);
8114 test_form_reset((IUnknown
*)elem
);
8115 test_form_target((IUnknown
*)elem
);
8116 IHTMLElement_Release(elem
);
8118 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8119 test_input_get_form((IUnknown
*)elem
, "form");
8120 IHTMLElement_Release(elem
);
8124 test_blocked(doc
, div
);
8125 test_elem_names(doc
);
8127 IHTMLElement_Release(div
);
8130 static void test_create_elems(IHTMLDocument2
*doc
)
8132 IHTMLElement
*elem
, *body
, *elem2
;
8133 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
8134 IHTMLDOMAttribute
*attr
;
8135 IHTMLDocument5
*doc5
;
8142 static const elem_type_t types1
[] = { ET_TESTG
};
8144 elem
= test_create_elem(doc
, "TEST");
8145 test_elem_tag((IUnknown
*)elem
, "TEST");
8146 type
= get_node_type((IUnknown
*)elem
);
8147 ok(type
== 1, "type=%d\n", type
);
8148 test_ifaces((IUnknown
*)elem
, elem_iids
);
8149 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
8150 test_elem_source_index(elem
, -1);
8152 body
= doc_get_body(doc
);
8153 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8155 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
8156 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
8157 elem2
= get_elem_iface((IUnknown
*)node
);
8158 IHTMLElement_Release(elem2
);
8160 hres
= IHTMLElement_get_all(body
, &disp
);
8161 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8162 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
8163 IDispatch_Release(disp
);
8165 test_node_remove_child((IUnknown
*)body
, node
);
8167 hres
= IHTMLElement_get_all(body
, &disp
);
8168 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8169 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
8170 IDispatch_Release(disp
);
8171 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8173 IHTMLElement_Release(elem
);
8174 IHTMLDOMNode_Release(node
);
8176 node
= test_create_text(doc
, "abc");
8177 test_ifaces((IUnknown
*)node
, text_iids
);
8178 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8179 test_text_length((IUnknown
*)node
, 3);
8180 test_text_data((IUnknown
*)node
, "abc");
8181 set_text_data((IUnknown
*)node
, "test");
8182 test_text_data((IUnknown
*)node
, "test");
8183 text_append_data((IUnknown
*)node
, " append");
8184 test_text_data((IUnknown
*)node
, "test append");
8185 text_append_data((IUnknown
*)node
, NULL
);
8186 test_text_data((IUnknown
*)node
, "test append");
8187 set_text_data((IUnknown
*)node
, "test");
8189 V_VT(&var
) = VT_NULL
;
8190 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8191 IHTMLDOMNode_Release(node
);
8193 node
= test_create_text(doc
, "insert ");
8195 V_VT(&var
) = VT_DISPATCH
;
8196 V_DISPATCH(&var
) = (IDispatch
*)node2
;
8197 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8198 IHTMLDOMNode_Release(node
);
8199 IHTMLDOMNode_Release(node2
);
8200 IHTMLDOMNode_Release(node3
);
8202 test_elem_innertext(body
, "insert test");
8203 test_elem_innerhtml((IUnknown
*)body
, "insert test");
8205 node
= test_create_text(doc
, " Test");
8206 V_VT(&var
) = VT_DISPATCH
;
8207 V_DISPATCH(&var
) = NULL
;
8208 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8209 test_elem_innertext(body
, "insert test Test");
8210 IHTMLDOMNode_Release(node
);
8212 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
8214 str
= a2bstr("testing");
8215 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
8217 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
8220 type
= get_node_type((IUnknown
*)comment
);
8221 ok(type
== 8, "type=%d, expected 8\n", type
);
8223 test_node_get_value_str((IUnknown
*)comment
, "testing");
8224 test_elem_title((IUnknown
*)comment
, NULL
);
8225 test_elem_set_title((IUnknown
*)comment
, "comment title");
8226 test_elem_title((IUnknown
*)comment
, "comment title");
8227 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
8228 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
8229 test_comment_attrs((IUnknown
*)comment
);
8231 IHTMLDOMNode_Release(comment
);
8234 str
= a2bstr("Test");
8235 hres
= IHTMLDocument5_createAttribute(doc5
, str
, &attr
);
8236 ok(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
8238 if(SUCCEEDED(hres
)) {
8239 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8240 test_ifaces((IUnknown
*)attr
, attr_iids
);
8241 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8243 test_attr_node_name(attr
, "Test");
8245 IHTMLDOMAttribute_Release(attr
);
8248 IHTMLDocument5_Release(doc5
);
8251 IHTMLElement_Release(body
);
8254 static void test_replacechild_elems(IHTMLDocument2
*doc
)
8257 IHTMLDOMNode
*node
, *node2
, *node3
;
8258 IHTMLDOMNode
*nodeBody
, *nodeNew
;
8262 body
= doc_get_body(doc
);
8264 node
= test_create_text(doc
, "insert");
8266 V_VT(&var
) = VT_NULL
;
8267 V_DISPATCH(&var
) = NULL
;
8268 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8269 IHTMLDOMNode_Release(node
);
8271 test_elem_innertext(body
, "insert");
8273 node3
= test_create_text(doc
, "replaced");
8275 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
8277 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
8278 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
8280 test_elem_innertext(body
, "replaced");
8282 IHTMLDOMNode_Release(node2
);
8283 IHTMLDOMNode_Release(node3
);
8284 IHTMLDOMNode_Release(nodeBody
);
8286 IHTMLElement_Release(body
);
8289 static void test_noscript(IHTMLDocument2
*doc
)
8291 IHTMLElementCollection
*col
;
8295 static const elem_type_t all_types
[] = {
8304 static const elem_type_t body_all_types
[] = {
8309 hres
= IHTMLDocument2_get_all(doc
, &col
);
8310 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8311 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8312 IHTMLElementCollection_Release(col
);
8314 body
= doc_get_body(doc
);
8315 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
8316 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
8317 IHTMLElement_Release(body
);
8320 static void test_doctype(IHTMLDocument2
*doc
)
8322 IHTMLDocument2
*doc_node
;
8323 IHTMLDOMNode
*doctype
;
8326 doc_node
= get_doc_node(doc
);
8327 doctype
= get_first_child((IUnknown
*)doc_node
);
8328 IHTMLDocument2_Release(doc_node
);
8330 type
= get_node_type((IUnknown
*)doctype
);
8331 ok(type
== 8, "type = %d\n", type
);
8333 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
8334 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
8335 IHTMLDOMNode_Release(doctype
);
8338 static void test_null_write(IHTMLDocument2
*doc
)
8342 doc_write(doc
, FALSE
, NULL
);
8343 doc_write(doc
, TRUE
, NULL
);
8345 hres
= IHTMLDocument2_write(doc
, NULL
);
8347 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
8349 hres
= IHTMLDocument2_writeln(doc
, NULL
);
8351 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
8354 static void test_create_stylesheet(IHTMLDocument2
*doc
)
8356 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
8357 IHTMLStyleElement
*style_elem
;
8358 IHTMLElement
*doc_elem
, *elem
;
8361 static const elem_type_t all_types
[] = {
8369 static const elem_type_t all_types2
[] = {
8378 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
8380 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
8381 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
8383 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
8385 doc_elem
= get_doc_elem(doc
);
8387 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
8388 IHTMLElement_Release(doc_elem
);
8390 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
8391 IHTMLElement_Release(elem
);
8392 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
8395 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
8396 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
8397 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
8398 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
8400 IHTMLStyleSheet_Release(stylesheet2
);
8401 IHTMLStyleSheet_Release(stylesheet
);
8403 IHTMLStyleElement_Release(style_elem
);
8406 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
8408 IOleCommandTarget
*cmdtrg
;
8411 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
8412 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
8414 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
8415 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
8417 IOleCommandTarget_Release(cmdtrg
);
8420 static void test_indent(IHTMLDocument2
*doc
)
8422 IHTMLElementCollection
*col
;
8423 IHTMLTxtRange
*range
;
8426 static const elem_type_t all_types
[] = {
8435 static const elem_type_t indent_types
[] = {
8446 hres
= IHTMLDocument2_get_all(doc
, &col
);
8447 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8448 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8449 IHTMLElementCollection_Release(col
);
8451 range
= test_create_body_range(doc
);
8452 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
8453 IHTMLTxtRange_Release(range
);
8455 hres
= IHTMLDocument2_get_all(doc
, &col
);
8456 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8457 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
8458 IHTMLElementCollection_Release(col
);
8461 static void test_cond_comment(IHTMLDocument2
*doc
)
8463 IHTMLElementCollection
*col
;
8466 static const elem_type_t all_types
[] = {
8474 hres
= IHTMLDocument2_get_all(doc
, &col
);
8475 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8476 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8477 IHTMLElementCollection_Release(col
);
8480 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
8482 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
8483 return E_NOINTERFACE
;
8486 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
8491 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
8496 static const IUnknownVtbl UnknownVtbl
= {
8497 Unknown_QueryInterface
,
8501 static IUnknown obj_ident_test
= { &UnknownVtbl
};
8503 static void test_frame(IDispatch
*disp
, const char *exp_id
)
8505 IHTMLWindow2
*frame2
, *parent
, *top
;
8506 IHTMLDocument2
*parent_doc
, *top_doc
;
8507 IHTMLWindow4
*frame
;
8508 IHTMLFrameBase
*frame_elem
;
8509 IObjectIdentity
*obj_ident
;
8510 ITravelLogClient
*tlc
;
8513 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
8514 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
8518 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
8519 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
8520 IHTMLWindow4_Release(frame
);
8524 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
8525 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
8526 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
8527 IHTMLFrameBase_Release(frame_elem
);
8529 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
8530 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
8534 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
8535 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
8537 IHTMLWindow2_Release(frame2
);
8541 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
8542 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
8543 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
8544 if(hres
== E_NOINTERFACE
) {
8545 win_skip("IID_ITravelLogClient not available\n");
8548 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
8550 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
8551 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8552 ITravelLogClient_Release(tlc
);
8555 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
8556 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8557 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
8558 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
8559 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
8560 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
8562 IObjectIdentity_Release(obj_ident
);
8564 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
8565 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8566 IHTMLWindow2_Release(parent
);
8568 IHTMLWindow2_Release(frame2
);
8572 test_doc_title(parent_doc
, "frameset test");
8573 IHTMLDocument2_Release(parent_doc
);
8576 hres
= IHTMLWindow2_get_top(frame2
, &top
);
8577 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
8578 IHTMLWindow2_Release(frame2
);
8582 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
8583 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8584 IHTMLWindow2_Release(top
);
8588 test_doc_title(top_doc
, "frameset test");
8589 IHTMLDocument2_Release(top_doc
);
8592 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
8594 VARIANT index_var
, result_var
;
8598 /* test result length */
8599 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
8600 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
8601 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
8603 /* test first frame */
8604 V_VT(&index_var
) = VT_I4
;
8605 V_I4(&index_var
) = 0;
8606 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8607 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8608 if(SUCCEEDED(hres
)) {
8609 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8610 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
8612 VariantClear(&result_var
);
8614 /* test second frame */
8615 V_I4(&index_var
) = 1;
8616 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8617 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8618 if(SUCCEEDED(hres
)) {
8619 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8620 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
8622 VariantClear(&result_var
);
8624 /* fail on next frame */
8625 V_I4(&index_var
) = 3;
8626 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8627 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
8628 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
8629 VariantClear(&result_var
);
8631 /* string argument (element id lookup) */
8632 V_VT(&index_var
) = VT_BSTR
;
8633 V_BSTR(&index_var
) = a2bstr(frid
);
8634 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8635 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8636 if(SUCCEEDED(hres
)) {
8637 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8638 test_frame(V_DISPATCH(&result_var
), frid
);
8640 VariantClear(&result_var
);
8641 VariantClear(&index_var
);
8643 /* invalid argument */
8644 V_VT(&index_var
) = VT_BOOL
;
8645 V_BOOL(&index_var
) = VARIANT_TRUE
;
8646 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8647 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
8648 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
8649 VariantClear(&result_var
);
8652 static void test_frameset(IHTMLDocument2
*doc
)
8654 IHTMLWindow2
*window
;
8655 IHTMLFramesCollection2
*frames
;
8659 window
= get_doc_window(doc
);
8661 /* test using IHTMLFramesCollection object */
8663 hres
= IHTMLWindow2_get_frames(window
, &frames
);
8664 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
8668 test_frames_collection(frames
, "fr1");
8669 IHTMLFramesCollection2_Release(frames
);
8671 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
8672 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
8676 test_frames_collection(frames
, "fr1");
8677 IHTMLFramesCollection2_Release(frames
);
8679 /* test using IHTMLWindow2 inheritance */
8680 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
8682 /* getElementById with node name attributes */
8683 elem
= get_doc_elem_by_id(doc
, "nm1");
8684 test_elem_id((IUnknown
*)elem
, "fr1");
8686 test_framebase((IUnknown
*)elem
);
8687 test_framebase_name(elem
, "nm1");
8688 test_framebase_put_name(elem
, "frame name");
8689 test_framebase_put_name(elem
, NULL
);
8690 test_framebase_put_name(elem
, "nm1");
8691 test_framebase_src(elem
, "about:blank");
8692 IHTMLElement_Release(elem
);
8694 /* get_name with no name attr */
8695 elem
= get_doc_elem_by_id(doc
, "fr3");
8696 test_framebase_name(elem
, NULL
);
8697 test_framebase_put_name(elem
, "frame name");
8698 test_framebase_put_name(elem
, NULL
);
8699 IHTMLElement_Release(elem
);
8701 IHTMLWindow2_Release(window
);
8704 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
8706 IHTMLDocument2
*frag
;
8707 IHTMLDocument3
*doc3
;
8710 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8711 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8713 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
8714 IHTMLDocument3_Release(doc3
);
8715 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
8716 ok(frag
!= NULL
, "frag == NULL\n");
8721 static void test_docfrag(IHTMLDocument2
*doc
)
8723 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
8724 IHTMLElement
*div
, *body
, *br
;
8725 IHTMLElementCollection
*col
;
8726 IHTMLLocation
*location
;
8729 static const elem_type_t all_types
[] = {
8738 frag
= create_docfrag(doc
);
8740 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
8742 body
= (void*)0xdeadbeef;
8743 hres
= IHTMLDocument2_get_body(frag
, &body
);
8744 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
8745 ok(!body
, "body != NULL\n");
8747 location
= (void*)0xdeadbeef;
8748 hres
= IHTMLDocument2_get_location(frag
, &location
);
8749 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
8750 ok(location
== (void*)0xdeadbeef, "location changed\n");
8752 br
= test_create_elem(doc
, "BR");
8753 test_elem_source_index(br
, -1);
8754 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
8755 test_elem_source_index(br
, 0);
8756 IHTMLElement_Release(br
);
8758 div
= get_elem_by_id(doc
, "divid", TRUE
);
8759 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
8760 IHTMLElement_Release(div
);
8762 hres
= IHTMLDocument2_get_all(doc
, &col
);
8763 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8764 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8765 IHTMLElementCollection_Release(col
);
8767 div
= test_create_elem(frag
, "div");
8768 owner_doc
= get_owner_doc((IUnknown
*)div
);
8769 doc_node
= get_doc_node(doc
);
8770 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
8771 IHTMLDocument2_Release(doc_node
);
8772 IHTMLDocument2_Release(owner_doc
);
8773 IHTMLElement_Release(div
);
8775 IHTMLDocument2_Release(frag
);
8778 static void check_quirks_mode(IHTMLDocument2
*doc
)
8780 test_compatmode(doc
, "BackCompat");
8783 static void check_strict_mode(IHTMLDocument2
*doc
)
8785 test_compatmode(doc
, "CSS1Compat");
8788 static IHTMLDocument2
*notif_doc
;
8789 static BOOL doc_complete
;
8791 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
8792 REFIID riid
, void**ppv
)
8794 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
8799 ok(0, "unexpected call\n");
8800 return E_NOINTERFACE
;
8803 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
8808 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
8813 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
8815 if(dispID
== DISPID_READYSTATE
){
8819 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
8820 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
8822 if(!strcmp_wa(state
, "complete"))
8823 doc_complete
= TRUE
;
8825 SysFreeString(state
);
8831 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
8833 ok(0, "unexpected call\n");
8837 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
8838 PropertyNotifySink_QueryInterface
,
8839 PropertyNotifySink_AddRef
,
8840 PropertyNotifySink_Release
,
8841 PropertyNotifySink_OnChanged
,
8842 PropertyNotifySink_OnRequestEdit
8845 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
8847 static IHTMLDocument2
*create_doc_with_string(const char *str
)
8849 IPersistStreamInit
*init
;
8851 IHTMLDocument2
*doc
;
8855 notif_doc
= doc
= create_document();
8859 doc_complete
= FALSE
;
8861 mem
= GlobalAlloc(0, len
);
8862 memcpy(mem
, str
, len
);
8863 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
8865 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
8867 IPersistStreamInit_Load(init
, stream
);
8868 IPersistStreamInit_Release(init
);
8869 IStream_Release(stream
);
8874 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
8876 IConnectionPointContainer
*container
;
8877 IConnectionPoint
*cp
;
8881 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
8882 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
8884 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
8885 IConnectionPointContainer_Release(container
);
8886 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
8888 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
8889 IConnectionPoint_Release(cp
);
8890 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
8893 typedef void (*domtest_t
)(IHTMLDocument2
*);
8895 static void run_domtest(const char *str
, domtest_t test
)
8897 IHTMLDocument2
*doc
;
8901 doc
= create_doc_with_string(str
);
8905 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
8907 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
8908 TranslateMessage(&msg
);
8909 DispatchMessageW(&msg
);
8914 ref
= IHTMLDocument2_Release(doc
);
8915 ok(!ref
|| broken(ref
== 1), /* Vista */
8919 static void test_quirks_mode(void)
8921 run_domtest("<html></html>", check_quirks_mode
);
8922 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
8923 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
8928 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
8929 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
8930 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
8934 run_domtest(doc_str1
, test_doc_elem
);
8935 run_domtest(doc_str1
, test_get_set_attr
);
8936 run_domtest(range_test_str
, test_txtrange
);
8937 run_domtest(range_test2_str
, test_txtrange2
);
8938 if (winetest_interactive
|| ! is_ie_hardened()) {
8939 run_domtest(elem_test_str
, test_elems
);
8940 run_domtest(elem_test2_str
, test_elems2
);
8941 run_domtest(noscript_str
, test_noscript
);
8943 skip("IE running in Enhanced Security Configuration\n");
8945 run_domtest(doc_blank
, test_create_elems
);
8946 run_domtest(doc_blank
, test_defaults
);
8947 run_domtest(doc_blank
, test_null_write
);
8948 run_domtest(emptydiv_str
, test_create_stylesheet
);
8949 run_domtest(indent_test_str
, test_indent
);
8950 run_domtest(cond_comment_str
, test_cond_comment
);
8951 run_domtest(frameset_str
, test_frameset
);
8952 run_domtest(emptydiv_str
, test_docfrag
);
8953 run_domtest(doc_blank
, test_replacechild_elems
);
8954 run_domtest(doctype_str
, test_doctype
);