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>
35 #include "mshtml_test.h"
40 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
41 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
43 static const char doc_blank
[] = "<html></html>";
44 static const char doc_str1
[] = "<html><body>test</body></html>";
45 static const char range_test_str
[] =
46 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
47 static const char range_test2_str
[] =
48 "<html><body>abc<hr />123<br /><hr />def</body></html>";
49 static const char elem_test_str
[] =
50 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
51 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
52 "<link id=\"linkid\"></head>"
53 "<body onload=\"Testing()\">text test<!-- a comment -->"
54 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
55 "<label for=\"in\" id=\"labelid\">Label:</label>"
56 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
57 "<button id=\"btnid\"></button>"
58 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
59 "<textarea id=\"X\">text text</textarea>"
60 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
61 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
62 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
63 "<img id=\"imgid\" name=\"WineImg\"/>"
64 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
65 "<form id=\"frm\"></form>"
66 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
68 static const char elem_test2_str
[] =
69 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
70 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
71 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
74 static const char indent_test_str
[] =
75 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
76 static const char cond_comment_str
[] =
77 "<html><head><title>test</title></head><body>"
78 "<!--[if gte IE 4]> <br> <![endif]-->"
80 static const char frameset_str
[] =
81 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
82 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
83 "<frame src=\"about:blank\" id=\"fr3\">"
85 static const char emptydiv_str
[] =
86 "<html><head><title>emptydiv test</title></head>"
87 "<body><div id=\"divid\"></div></body></html>";
88 static const char noscript_str
[] =
89 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
90 "<body><noscript><div>test</div></noscript></body></html>";
91 static const char doctype_str
[] =
93 "<html><head><title>emptydiv test</title></head>"
94 "<body><div id=\"divid\"></div></body></html>";
96 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
97 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
98 static WCHAR wordW
[] = {'w','o','r','d',0};
137 static const IID
* const none_iids
[] = {
142 static const IID
* const doc_node_iids
[] = {
151 &IID_IConnectionPointContainer
,
152 &IID_IInternetHostSecurityManager
,
155 &IID_IProvideClassInfo
,
159 static const IID
* const doc_obj_iids
[] = {
166 &IID_IConnectionPointContainer
,
170 &IID_IProvideClassInfo
,
171 &IID_ITargetContainer
,
175 #define ELEM_IFACES \
177 &IID_IHTMLDOMNode2, \
179 &IID_IHTMLElement2, \
180 &IID_IHTMLElement3, \
181 &IID_IHTMLElement4, \
182 &IID_IHTMLUniqueName, \
185 static const IID
* const elem_iids
[] = {
187 &IID_IConnectionPointContainer
,
191 static const IID
* const body_iids
[] = {
193 &IID_IHTMLTextContainer
,
194 &IID_IHTMLBodyElement
,
195 &IID_IConnectionPointContainer
,
199 static const IID
* const anchor_iids
[] = {
201 &IID_IHTMLAnchorElement
,
202 &IID_IConnectionPointContainer
,
206 static const IID
* const input_iids
[] = {
208 &IID_IHTMLInputElement
,
209 &IID_IHTMLInputTextElement
,
210 &IID_IConnectionPointContainer
,
214 static const IID
*const button_iids
[] = {
216 &IID_IHTMLButtonElement
,
217 &IID_IConnectionPointContainer
,
221 static const IID
* const label_iids
[] = {
223 &IID_IHTMLLabelElement
,
224 &IID_IConnectionPointContainer
,
228 static const IID
* const select_iids
[] = {
230 &IID_IHTMLSelectElement
,
231 &IID_IConnectionPointContainer
,
235 static const IID
* const textarea_iids
[] = {
237 &IID_IHTMLTextAreaElement
,
238 &IID_IConnectionPointContainer
,
242 static const IID
* const option_iids
[] = {
244 &IID_IHTMLOptionElement
,
245 &IID_IConnectionPointContainer
,
249 static const IID
* const table_iids
[] = {
254 &IID_IConnectionPointContainer
,
258 static const IID
* const script_iids
[] = {
260 &IID_IHTMLScriptElement
,
261 &IID_IConnectionPointContainer
,
265 static const IID
* const text_iids
[] = {
268 &IID_IHTMLDOMTextNode
,
269 &IID_IHTMLDOMTextNode2
,
273 static const IID
* const attr_iids
[] = {
274 &IID_IHTMLDOMAttribute
,
275 &IID_IHTMLDOMAttribute2
,
280 static const IID
* const location_iids
[] = {
286 static const IID
* const window_iids
[] = {
291 &IID_IServiceProvider
,
295 static const IID
* const comment_iids
[] = {
297 &IID_IHTMLCommentElement
,
298 &IID_IConnectionPointContainer
,
302 static const IID
* const img_iids
[] = {
304 &IID_IHTMLImgElement
,
305 &IID_IConnectionPointContainer
,
309 static const IID
* const tr_iids
[] = {
312 &IID_IConnectionPointContainer
,
316 static const IID
* const td_iids
[] = {
319 &IID_IConnectionPointContainer
,
323 static const IID
* const frame_iids
[] = {
326 &IID_IHTMLFrameBase2
,
327 &IID_IConnectionPointContainer
,
331 static const IID
* const head_iids
[] = {
333 &IID_IHTMLHeadElement
,
334 &IID_IConnectionPointContainer
,
338 static const IID
* const title_iids
[] = {
340 &IID_IHTMLTitleElement
,
341 &IID_IConnectionPointContainer
,
345 static const IID
* const meta_iids
[] = {
347 &IID_IHTMLMetaElement
,
348 &IID_IConnectionPointContainer
,
352 static const IID
* const link_iids
[] = {
354 &IID_IHTMLLinkElement
,
355 &IID_IConnectionPointContainer
,
359 static const IID
* const object_iids
[] = {
361 &IID_IHTMLObjectElement
,
362 &IID_IHTMLObjectElement2
,
363 /* FIXME: No IConnectionPointContainer */
367 static const IID
* const embed_iids
[] = {
369 &IID_IHTMLEmbedElement
,
370 /* FIXME: No IConnectionPointContainer */
374 static const IID
* const iframe_iids
[] = {
377 &IID_IHTMLFrameBase2
,
378 &IID_IHTMLIFrameElement
,
379 &IID_IHTMLIFrameElement2
,
380 &IID_IConnectionPointContainer
,
384 static const IID
* const form_iids
[] = {
386 &IID_IHTMLFormElement
,
387 &IID_IConnectionPointContainer
,
388 &DIID_DispHTMLFormElement
,
392 static const IID
* const styleelem_iids
[] = {
394 &IID_IHTMLStyleElement
,
395 &IID_IConnectionPointContainer
,
399 static const IID
* const generic_iids
[] = {
401 &IID_IHTMLGenericElement
,
402 &IID_IConnectionPointContainer
,
406 static const IID
* const style_iids
[] = {
417 static const IID
* const cstyle_iids
[] = {
421 &IID_IHTMLCurrentStyle
,
422 &IID_IHTMLCurrentStyle2
,
423 &IID_IHTMLCurrentStyle3
,
427 static const IID
* const img_factory_iids
[] = {
431 &IID_IHTMLImageElementFactory
,
435 static const IID
* const selection_iids
[] = {
439 &IID_IHTMLSelectionObject
,
440 &IID_IHTMLSelectionObject2
,
450 static const elem_type_info_t elem_type_infos
[] = {
451 {"", none_iids
, NULL
},
452 {"HTML", elem_iids
, NULL
},
453 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
454 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
455 {"BODY", body_iids
, &DIID_DispHTMLBody
},
456 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
457 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
458 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
459 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
460 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
461 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
462 {"BLOCKQUOTE",elem_iids
, NULL
},
463 {"P", elem_iids
, NULL
},
464 {"BR", elem_iids
, NULL
},
465 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
466 {"TBODY", elem_iids
, NULL
},
467 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
468 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
469 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
470 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
471 {"IMG", img_iids
, &DIID_DispHTMLImg
},
472 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
473 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
474 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
475 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
476 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
477 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
478 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
479 {"DIV", elem_iids
, NULL
},
480 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
481 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
482 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
483 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
484 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
487 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
490 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
491 return lstrcmpA(stra
, buf
);
494 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
499 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
500 prefix_len
= lstrlenA(prefix
);
505 return !lstrcmpA(buf
, prefix
);
508 static BSTR
a2bstr(const char *str
)
516 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
517 ret
= SysAllocStringLen(NULL
, len
);
518 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
523 static const char *debugstr_variant(const VARIANT
*var
)
525 static char buf
[400];
535 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
538 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
541 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
544 sprintf(buf
, "{vt %d}", V_VT(var
));
551 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
553 IUnknown
*unk1
, *unk2
;
558 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
559 IUnknown_Release(unk1
);
560 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
561 IUnknown_Release(unk2
);
566 static IHTMLDocument2
*create_document(void)
569 IHTMLDocument5
*doc5
;
572 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
573 &IID_IHTMLDocument2
, (void**)&doc
);
574 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
578 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
580 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
581 IHTMLDocument2_Release(doc
);
585 IHTMLDocument5_Release(doc5
);
589 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
590 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
595 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
596 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
600 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
601 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
603 const IID
* const *piid
;
607 for(piid
= iids
; *piid
; piid
++) {
608 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
609 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
611 IUnknown_Release(unk
);
615 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
616 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
621 unk
= (void*)0xdeadbeef;
622 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
623 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
624 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
627 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
628 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
630 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
637 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
638 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
639 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
641 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
642 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
644 if(SUCCEEDED(hres
)) {
647 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
648 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
650 *iid
= type_attr
->guid
;
654 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
655 ITypeInfo_Release(typeinfo
);
658 IDispatchEx_Release(dispex
);
662 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
663 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
665 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
666 DISPPARAMS dp
= {NULL
,NULL
,0,0};
671 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
672 IDispatchEx_Release(dispex
);
673 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
675 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
676 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
680 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
681 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
685 if(_test_get_dispid(line
, unk
, &iid
))
686 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
689 _test_disp_value(line
, unk
, val
);
692 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
693 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
697 if(_test_get_dispid(line
, unk
, &iid
))
698 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
699 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
702 _test_disp_value(line
, unk
, val
);
705 #define test_class_info(u) _test_class_info(__LINE__,u)
706 static void _test_class_info(unsigned line
, IUnknown
*unk
)
708 IProvideClassInfo
*classinfo
;
713 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
714 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
718 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
719 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
722 IProvideClassInfo_Release(classinfo
);
726 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
727 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
730 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
731 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
732 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
733 "unexpected typekind %d\n", type_attr
->typekind
);
734 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
737 ITypeInfo_Release(typeinfo
);
738 IProvideClassInfo_Release(classinfo
);
741 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
742 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
744 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
745 DISPPARAMS dp
= {val
, NULL
, 1, 0};
752 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
754 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
756 memset(&ei
, 0, sizeof(ei
));
757 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
758 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
762 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
763 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
768 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
769 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
773 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
774 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
779 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
780 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
784 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
785 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
790 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
791 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
795 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
796 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
801 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
802 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
806 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
807 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
809 IHTMLDocument3
*doc3
;
812 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
813 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
818 #define get_node_iface(u) _get_node_iface(__LINE__,u)
819 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
824 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
825 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
829 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
830 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
835 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
836 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
840 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
841 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
846 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
847 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
851 #define get_img_iface(u) _get_img_iface(__LINE__,u)
852 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
854 IHTMLImgElement
*img
;
857 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
858 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
862 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
863 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
865 IHTMLAnchorElement
*anchor
;
868 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
869 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
873 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
874 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
876 IHTMLTextAreaElement
*textarea
;
879 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
880 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
884 #define get_select_iface(u) _get_select_iface(__LINE__,u)
885 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
887 IHTMLSelectElement
*select
;
890 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
891 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
895 #define get_option_iface(u) _get_option_iface(__LINE__,u)
896 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
898 IHTMLOptionElement
*option
;
901 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
902 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
906 #define get_form_iface(u) _get_form_iface(__LINE__,u)
907 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
909 IHTMLFormElement
*form
;
912 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
913 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
917 #define get_text_iface(u) _get_text_iface(__LINE__,u)
918 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
920 IHTMLDOMTextNode
*text
;
923 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
924 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
928 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
929 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
931 IHTMLDOMTextNode2
*text2
;
934 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
935 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
939 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
940 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
942 IHTMLCommentElement
*comment
;
945 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
946 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
950 #define get_object_iface(u) _get_object_iface(__LINE__,u)
951 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
953 IHTMLObjectElement
*obj
;
956 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
957 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
961 #define get_style_iface(u) _get_style_iface(__LINE__,u)
962 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
964 IHTMLStyleElement
*obj
;
967 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
968 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
972 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
973 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
975 IHTMLMetaElement
*ret
;
978 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
979 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
983 #define get_link_iface(u) _get_link_iface(__LINE__,u)
984 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
986 IHTMLLinkElement
*ret
;
989 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
990 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
994 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
995 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
997 IHTMLIFrameElement2
*ret
;
1000 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1001 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1005 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1006 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1008 IHTMLButtonElement
*ret
;
1011 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1012 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1016 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1017 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1019 IHTMLLabelElement
*ret
;
1022 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1023 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1027 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1028 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1030 IHTMLDOMAttribute2
*ret
;
1033 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1034 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1038 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1039 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1041 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1045 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1046 IHTMLDOMNode_Release(node
);
1047 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1048 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1050 SysFreeString(name
);
1053 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1054 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1056 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1057 IDispatch
*disp
= (void*)0xdeadbeef;
1058 IHTMLDocument2
*doc
= NULL
;
1061 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1062 IHTMLDOMNode2_Release(node
);
1063 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1066 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1067 IDispatch_Release(disp
);
1068 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1074 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1075 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1077 IHTMLWindow2
*window
;
1081 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1082 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1083 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1088 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1089 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1091 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1092 IHTMLDOMNode
*ret
= NULL
;
1095 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1096 IHTMLDOMNode_Release(node
);
1097 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1098 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1104 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1105 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1107 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1111 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1112 IHTMLElement_Release(elem
);
1113 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1114 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1119 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1120 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1122 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1123 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1125 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1126 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1129 #define get_node_type(n) _get_node_type(__LINE__,n)
1130 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1132 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1136 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1137 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1139 IHTMLDOMNode_Release(node
);
1144 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1145 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1147 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1148 IHTMLDOMChildrenCollection
*col
= NULL
;
1152 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1153 IHTMLDOMNode_Release(node
);
1154 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1158 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1159 IDispatch_Release(disp
);
1160 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1165 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1166 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1168 IHTMLDOMNode
*node
= NULL
;
1172 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1173 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1175 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1176 IDispatch_Release(disp
);
1181 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1182 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1188 VariantInit(&value
);
1191 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1193 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1196 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1197 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1199 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1202 VariantClear(&value
);
1205 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1206 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1208 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1209 IHTMLElement
*off_parent
;
1213 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1214 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1216 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1217 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1219 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1220 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1222 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1225 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1226 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1228 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1229 IHTMLElement_Release(off_parent
);
1231 IHTMLElement_Release(elem
);
1234 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1235 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1237 LONG l
= 0xdeadbeef;
1240 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1241 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1242 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1245 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1246 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1248 IHTMLWindow2
*window
;
1249 IHTMLDocument2
*ret
;
1252 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1253 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1255 hres
= IHTMLWindow2_get_document(window
, &ret
);
1256 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1257 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1262 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1263 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1268 hres
= IHTMLWindow2_get_name(window
, &name
);
1269 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1271 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1273 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1274 SysFreeString(name
);
1277 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1278 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1284 hres
= IHTMLWindow2_put_name(window
, str
);
1286 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1288 _test_window_name(line
, window
, name
);
1291 #define test_window_status(d) _test_window_status(__LINE__,d)
1292 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1297 status
= (void*)0xdeadbeef;
1298 hres
= IHTMLWindow2_get_status(window
, &status
);
1299 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1300 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1301 SysFreeString(status
);
1304 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1305 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1310 str
= a2bstr(status
);
1311 hres
= IHTMLWindow2_put_status(window
, str
);
1313 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1316 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1317 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1322 hres
= IHTMLWindow2_get_length(window
, &length
);
1323 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1324 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1327 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1328 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1330 IHTMLFrameBase2
*base2
;
1331 IHTMLWindow2
*window
;
1334 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1335 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1338 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1339 IHTMLFrameBase2_Release(base2
);
1340 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1341 ok(window
!= NULL
, "contentWindow = NULL\n");
1346 static void test_get_set_attr(IHTMLDocument2
*doc
)
1349 IHTMLDocument3
*doc3
;
1354 /* grab an element to test with */
1355 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1356 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1358 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1359 IHTMLDocument3_Release(doc3
);
1360 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1362 /* get a non-present attribute */
1363 bstr
= a2bstr("notAnAttribute");
1364 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1365 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1366 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1368 SysFreeString(bstr
);
1370 /* get a present attribute */
1371 bstr
= a2bstr("scrollHeight");
1372 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1373 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1374 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1376 SysFreeString(bstr
);
1378 /* create a new BSTR attribute */
1379 bstr
= a2bstr("newAttribute");
1381 V_VT(&val
) = VT_BSTR
;
1382 V_BSTR(&val
) = a2bstr("the value");
1383 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1384 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1387 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1388 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1389 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1390 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
)));
1393 /* overwrite the attribute with a BOOL */
1394 V_VT(&val
) = VT_BOOL
;
1395 V_BOOL(&val
) = VARIANT_TRUE
;
1396 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1397 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1400 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1401 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1402 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1403 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1406 SysFreeString(bstr
);
1408 /* case-insensitive */
1409 bstr
= a2bstr("newattribute");
1410 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1411 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1412 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1413 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1416 /* overwrite the attribute with null */
1417 V_VT(&val
) = VT_NULL
;
1418 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1419 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1421 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1422 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1423 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1424 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1427 SysFreeString(bstr
);
1428 IHTMLElement_Release(elem
);
1431 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1432 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1435 IHTMLDocument3
*doc3
;
1438 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1439 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1440 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1441 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1442 IHTMLDocument3_Release(doc3
);
1447 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1448 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1450 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1454 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1455 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1456 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1459 _test_disp_value(line
, unk
, exhref
);
1462 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1463 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1465 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1469 str
= a2bstr(exhref
);
1470 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1471 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1474 _test_disp_value(line
, unk
, exhref
);
1477 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1478 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1480 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1484 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1485 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1487 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1489 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1493 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1494 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1496 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1500 str
= a2bstr(exrel
);
1501 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1502 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1506 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1507 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1509 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1513 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1514 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1516 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1518 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1522 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1523 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1525 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1529 str
= target
? a2bstr(target
) : NULL
;
1530 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1531 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1535 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1536 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1538 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1542 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1543 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1545 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1547 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1551 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1552 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1554 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1558 str
= name
? a2bstr(name
) : NULL
;
1559 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1560 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1563 _test_anchor_name(line
, unk
, name
);
1566 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1567 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1569 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1573 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1574 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1576 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1578 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1582 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1583 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1585 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1589 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1590 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1591 if ( ! str
&& allowbroken
)
1592 win_skip("skip ie6 incorrect behavior\n");
1594 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1596 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1600 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1601 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1603 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1607 str
= search
? a2bstr(search
) : NULL
;
1608 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1609 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1613 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1614 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1616 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1620 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1621 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1623 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1625 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1629 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1630 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1635 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1636 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1637 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1638 SysFreeString(bstr
);
1641 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1642 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1647 bstr
= a2bstr(text
);
1648 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1649 SysFreeString(bstr
);
1650 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1652 _test_option_text(line
, option
, text
);
1655 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1656 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1661 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1662 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1663 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1664 SysFreeString(bstr
);
1667 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1668 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1673 bstr
= a2bstr(value
);
1674 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1675 SysFreeString(bstr
);
1676 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1678 _test_option_value(line
, option
, value
);
1681 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1682 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1684 VARIANT_BOOL b
= 0x100;
1687 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1688 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1689 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1692 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1693 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1697 hres
= IHTMLOptionElement_put_selected(option
, b
);
1698 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1699 _test_option_selected(line
, option
, b
);
1702 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1703 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1708 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1709 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1712 hres
= IHTMLOptionElement_get_index(option
, &val
);
1713 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1714 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1715 "value = %d, expected = %d\n", val
, exval
);
1718 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1719 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1723 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1724 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1727 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1728 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1733 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1734 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1737 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1738 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1739 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1742 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1744 test_option_defaultSelected(option
, VARIANT_FALSE
);
1745 test_option_selected(option
, VARIANT_FALSE
);
1747 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1748 test_option_defaultSelected(option
, VARIANT_FALSE
);
1749 test_option_selected(option
, VARIANT_FALSE
);
1751 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1752 test_option_defaultSelected(option
, VARIANT_TRUE
);
1753 test_option_selected(option
, VARIANT_FALSE
);
1755 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1756 test_option_defaultSelected(option
, VARIANT_FALSE
);
1757 test_option_selected(option
, VARIANT_FALSE
);
1759 test_option_put_selected(option
, VARIANT_TRUE
);
1760 test_option_selected(option
, VARIANT_TRUE
);
1761 test_option_defaultSelected(option
, VARIANT_FALSE
);
1763 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1764 test_option_defaultSelected(option
, VARIANT_TRUE
);
1765 test_option_selected(option
, VARIANT_TRUE
);
1767 /* Restore defaultSelected */
1768 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1769 test_option_put_selected(option
, VARIANT_FALSE
);
1772 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1773 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1775 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1776 BSTR value
= (void*)0xdeadbeef;
1779 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1780 IHTMLTextAreaElement_Release(textarea
);
1781 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1783 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1785 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1786 SysFreeString(value
);
1789 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1790 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1792 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1793 BSTR tmp
= a2bstr(value
);
1796 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1797 IHTMLTextAreaElement_Release(textarea
);
1798 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1801 _test_textarea_value(line
, unk
, value
);
1804 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1805 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1807 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1808 BSTR value
= (void*)0xdeadbeef;
1811 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1812 IHTMLTextAreaElement_Release(textarea
);
1813 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1815 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1817 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1818 SysFreeString(value
);
1821 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1822 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1824 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1825 BSTR tmp
= a2bstr(value
);
1828 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1829 IHTMLTextAreaElement_Release(textarea
);
1830 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1833 _test_textarea_defaultvalue(line
, unk
, value
);
1836 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1837 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1839 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1840 VARIANT_BOOL b
= 0x100;
1843 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1844 IHTMLTextAreaElement_Release(textarea
);
1845 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1846 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1849 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1850 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1852 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1855 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1856 IHTMLTextAreaElement_Release(textarea
);
1857 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1859 _test_textarea_readonly(line
, unk
, b
);
1862 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1863 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1865 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1866 BSTR type
= (void*)0xdeadbeef;
1869 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1870 IHTMLTextAreaElement_Release(textarea
);
1871 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1872 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1873 SysFreeString(type
);
1876 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1877 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1879 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1880 IHTMLFormElement
*form
;
1883 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1884 IHTMLTextAreaElement_Release(textarea
);
1885 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1890 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1891 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1893 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1897 text
= a2bstr(extext
);
1898 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1899 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1900 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1902 IHTMLCommentElement_Release(comment
);
1903 SysFreeString(text
);
1906 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
1907 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1909 VARIANT_BOOL specified
;
1912 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
1913 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
1914 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
1917 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
1918 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1920 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1921 VARIANT_BOOL expando
;
1924 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
1925 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
1926 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
1928 IHTMLDOMAttribute2_Release(attr2
);
1931 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
1932 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
1934 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1938 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
1939 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1941 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
1943 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
1945 IHTMLDOMAttribute2_Release(attr2
);
1949 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1950 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1952 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1953 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1954 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1955 IHTMLDOMAttribute
*attr
;
1956 BSTR name
= a2bstr("test");
1960 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1961 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1962 ok(attr
== NULL
, "attr != NULL\n");
1966 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1967 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1969 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1970 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1971 ok(attr
!= NULL
, "attr == NULL\n");
1973 test_attr_expando(attr
, VARIANT_TRUE
);
1975 IHTMLDOMAttribute_Release(attr
);
1976 IHTMLCommentElement_Release(comment
);
1977 IHTMLElement_Release(elem
);
1978 IHTMLElement4_Release(elem4
);
1979 SysFreeString(name
);
1982 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1983 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1985 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1990 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1991 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1992 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1993 IHTMLObjectElement_Release(object
);
1996 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
1997 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
1999 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2003 str
= (void*)0xdeadbeef;
2004 hres
= IHTMLObjectElement_get_name(object
, &str
);
2005 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2007 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2009 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2011 IHTMLObjectElement_Release(object
);
2014 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2015 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2017 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2022 hres
= IHTMLObjectElement_put_name(object
, str
);
2023 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2025 IHTMLObjectElement_Release(object
);
2027 _test_object_name(line
, elem
, name
);
2030 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2031 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2032 const char *txt
, const char *val
)
2034 IHTMLOptionElementFactory
*factory
;
2035 IHTMLOptionElement
*option
;
2036 IHTMLWindow2
*window
;
2037 VARIANT text
, value
, empty
;
2040 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2041 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2043 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2044 IHTMLWindow2_Release(window
);
2045 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2047 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
2049 V_VT(&text
) = VT_BSTR
;
2050 V_BSTR(&text
) = a2bstr(txt
);
2051 V_VT(&value
) = VT_BSTR
;
2052 V_BSTR(&value
) = a2bstr(val
);
2053 V_VT(&empty
) = VT_EMPTY
;
2055 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2056 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2058 IHTMLOptionElementFactory_Release(factory
);
2059 VariantClear(&text
);
2060 VariantClear(&value
);
2062 _test_option_text(line
, option
, txt
);
2063 _test_option_value(line
, option
, val
);
2064 _test_option_selected(line
, option
, VARIANT_FALSE
);
2069 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2070 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2075 hres
= IHTMLImgElement_get_width(img
, &found
);
2076 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2077 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2080 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2081 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2085 hres
= IHTMLImgElement_put_width(img
, width
);
2086 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2088 _test_img_width(line
, img
, width
);
2091 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2092 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2097 hres
= IHTMLImgElement_get_height(img
, &found
);
2098 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2099 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2102 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2103 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2107 hres
= IHTMLImgElement_put_height(img
, height
);
2108 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2110 _test_img_height(line
, img
, height
);
2113 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2114 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2115 LONG wdth
, LONG hght
)
2117 IHTMLImageElementFactory
*factory
;
2118 IHTMLImgElement
*img
;
2119 IHTMLWindow2
*window
;
2120 VARIANT width
, height
;
2124 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2125 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2127 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2128 IHTMLWindow2_Release(window
);
2129 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2131 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2132 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
2135 snprintf(buf
, 16, "%d", wdth
);
2136 V_VT(&width
) = VT_BSTR
;
2137 V_BSTR(&width
) = a2bstr(buf
);
2139 V_VT(&width
) = VT_EMPTY
;
2144 snprintf(buf
, 16, "%d", hght
);
2145 V_VT(&height
) = VT_BSTR
;
2146 V_BSTR(&height
) = a2bstr(buf
);
2148 V_VT(&height
) = VT_EMPTY
;
2152 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2153 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2155 IHTMLImageElementFactory_Release(factory
);
2156 VariantClear(&width
);
2157 VariantClear(&height
);
2159 if(SUCCEEDED(hres
)) {
2160 _test_img_width(line
, img
, wdth
);
2161 _test_img_height(line
, img
, hght
);
2168 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2169 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2171 LONG len
= 0xdeadbeef;
2174 hres
= IHTMLSelectElement_get_length(select
, &len
);
2175 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2176 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2179 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2180 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2182 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2185 hres
= IHTMLSelectElement_put_length(select
, length
);
2186 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2187 _test_select_length(line
, select
, length
);
2188 IHTMLSelectElement_Release(select
);
2191 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2192 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2194 LONG idx
= 0xdeadbeef;
2197 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2198 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2199 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2202 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2203 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2207 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2208 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2209 _test_select_selidx(line
, select
, index
);
2212 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2213 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2218 hres
= IHTMLSelectElement_get_value(select
, &val
);
2219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2221 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2223 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2227 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2228 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2234 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2235 SysFreeString(bstr
);
2236 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2239 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2240 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2245 hres
= IHTMLSelectElement_get_type(select
, &type
);
2246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2247 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2248 SysFreeString(type
);
2251 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2252 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2254 VARIANT_BOOL b
= 100;
2257 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2258 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2259 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2262 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2263 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2267 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2268 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2270 _test_select_multiple(line
, select
, val
);
2273 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2274 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2279 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2280 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2283 hres
= IHTMLSelectElement_get_size(select
, &val
);
2284 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2285 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2288 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2289 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2293 hres
= IHTMLSelectElement_put_size(select
, val
);
2294 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2297 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2298 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2304 hres
= IHTMLSelectElement_get_name(select
, &text
);
2305 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2307 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2308 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2309 wine_dbgstr_w(text
), extext
);
2310 SysFreeString(text
);
2312 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2315 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2316 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2321 bstr
= a2bstr(text
);
2323 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2324 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2325 SysFreeString(bstr
);
2328 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2329 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2334 hres
= IHTMLTxtRange_get_text(range
, &text
);
2335 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2338 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2339 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2341 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2344 SysFreeString(text
);
2348 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2349 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2353 hres
= IHTMLTxtRange_collapse(range
, b
);
2354 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2355 _test_range_text(line
, range
, NULL
);
2358 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2359 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2360 VARIANT_BOOL exb
, const char *extext
)
2362 VARIANT_BOOL b
= 0xe0e0;
2365 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2366 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2367 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2368 _test_range_text(line
, range
, extext
);
2371 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2372 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2374 LONG c
= 0xdeadbeef;
2377 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2378 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2379 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2380 _test_range_text(line
, range
, NULL
);
2383 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2384 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2385 LPWSTR unit
, LONG cnt
, LONG excnt
)
2387 LONG c
= 0xdeadbeef;
2390 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2391 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2392 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2395 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2396 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2398 LONG c
= 0xdeadbeef;
2401 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2402 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2403 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2406 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2407 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2410 BSTR bstr
= a2bstr(text
);
2412 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2413 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2414 SysFreeString(bstr
);
2415 _test_range_text(line
, range
, NULL
);
2418 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2419 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2425 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2426 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2427 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2430 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2431 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2437 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2438 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2439 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2442 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2443 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2444 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2447 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2448 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2452 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2453 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2455 BSTR str
= a2bstr(html
);
2458 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2459 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2463 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2464 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2469 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2470 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2472 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2474 IHTMLElement_Release(elem
);
2477 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2478 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2480 VARIANT name
, index
;
2485 V_VT(&index
) = VT_EMPTY
;
2486 V_VT(&name
) = VT_I4
;
2488 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2489 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2490 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2492 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2493 IDispatch_Release(disp
);
2497 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2498 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2499 const elem_type_t
*elem_types
, LONG exlen
)
2501 IHTMLElementCollection
*col
;
2502 IEnumVARIANT
*enum_var
;
2507 VARIANT name
, index
, v
, vs
[5];
2508 IDispatch
*disp
, *disp2
;
2511 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2512 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2514 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2516 hres
= IHTMLElementCollection_get_length(col
, &len
);
2517 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2518 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2523 V_VT(&index
) = VT_EMPTY
;
2525 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2526 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2528 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2529 IUnknown_Release(enum_unk
);
2530 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2532 for(i
=0; i
<len
; i
++) {
2533 V_VT(&name
) = VT_I4
;
2535 disp
= (void*)0xdeadbeef;
2536 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2537 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2538 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2539 if(FAILED(hres
) || !disp
)
2542 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2545 V_VT(&name
) = VT_UINT
;
2547 disp2
= (void*)0xdeadbeef;
2548 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2549 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2550 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2552 IDispatch_Release(disp2
);
2556 V_VT(&v
) = VT_ERROR
;
2557 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2558 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2560 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2561 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2562 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2563 IDispatch_Release(V_DISPATCH(&v
));
2565 IDispatch_Release(disp
);
2568 fetched
= 0xdeadbeef;
2570 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2571 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2572 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2573 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2575 hres
= IEnumVARIANT_Reset(enum_var
);
2576 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2578 fetched
= 0xdeadbeef;
2580 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2581 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2582 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2583 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2585 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2586 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2588 memset(vs
, 0, sizeof(vs
));
2590 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2591 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2592 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2594 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2595 IDispatch_Release(V_DISPATCH(vs
));
2598 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2599 IDispatch_Release(V_DISPATCH(vs
+1));
2602 hres
= IEnumVARIANT_Reset(enum_var
);
2603 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2605 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2606 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2608 IEnumVARIANT_Release(enum_var
);
2610 V_VT(&name
) = VT_I4
;
2612 disp
= (void*)0xdeadbeef;
2613 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2614 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2615 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2617 V_VT(&name
) = VT_UI4
;
2619 disp
= (void*)0xdeadbeef;
2620 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2621 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2622 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2624 V_VT(&name
) = VT_INT
;
2626 disp
= (void*)0xdeadbeef;
2627 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2628 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2629 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2631 V_VT(&name
) = VT_UINT
;
2633 disp
= (void*)0xdeadbeef;
2634 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2635 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2636 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2638 V_VT(&name
) = VT_I4
;
2640 disp
= (void*)0xdeadbeef;
2641 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2642 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2643 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2645 IHTMLElementCollection_Release(col
);
2648 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2649 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2651 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2655 hres
= IHTMLElement_get_all(elem
, &disp
);
2656 IHTMLElement_Release(elem
);
2657 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2659 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2660 IDispatch_Release(disp
);
2663 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2664 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2666 IHTMLElementCollection
*col
;
2669 hres
= IHTMLDocument2_get_all(doc
, &col
);
2670 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2672 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2673 IHTMLElementCollection_Release(col
);
2676 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2677 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2679 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2680 IHTMLElementCollection
*col
= NULL
;
2681 elem_type_t
*types
= NULL
;
2686 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2687 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2689 IHTMLElement2_Release(elem
);
2690 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2691 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2694 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2695 for(i
=0; i
<exlen
; i
++)
2699 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2701 HeapFree(GetProcessHeap(), 0, types
);
2704 *ret
= get_elem_col_item_idx(col
, 0);
2705 IHTMLElementCollection_Release(col
);
2708 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2709 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2711 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2712 IHTMLElementCollection
*col
= NULL
;
2713 elem_type_t
*types
= NULL
;
2718 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2719 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2721 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2722 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2725 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2726 for(i
=0; i
<exlen
; i
++)
2730 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2732 HeapFree(GetProcessHeap(), 0, types
);
2733 IHTMLElementCollection_Release(col
);
2734 IHTMLDocument3_Release(doc
);
2737 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2738 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2743 hres
= IHTMLElement_get_innerText(elem
, &text
);
2744 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2746 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2747 wine_dbgstr_w(text
), extext
);
2749 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2750 SysFreeString(text
);
2753 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2754 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2756 IHTMLDOMChildrenCollection
*col
;
2761 hres
= IHTMLElement_put_innerText(elem
, str
);
2762 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2765 _test_elem_innertext(line
, elem
, text
);
2768 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2769 ok(col
!= NULL
, "col == NULL\n");
2771 LONG length
= 0, type
;
2774 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2775 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2776 ok(length
== 1, "length = %d\n", length
);
2778 node
= _get_child_item(line
, col
, 0);
2779 ok(node
!= NULL
, "node == NULL\n");
2781 type
= _get_node_type(line
, (IUnknown
*)node
);
2782 ok(type
== 3, "type=%d\n", type
);
2783 IHTMLDOMNode_Release(node
);
2786 IHTMLDOMChildrenCollection_Release(col
);
2791 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2792 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2794 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2798 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2799 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2801 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2803 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2805 IHTMLElement_Release(elem
);
2806 SysFreeString(html
);
2809 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2810 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2812 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2816 html
= a2bstr(inner_html
);
2817 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2818 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2820 IHTMLElement_Release(elem
);
2821 SysFreeString(html
);
2824 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2825 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2827 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2831 html
= a2bstr(outer_html
);
2832 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2833 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2835 IHTMLElement_Release(elem
);
2836 SysFreeString(html
);
2839 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2840 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2842 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2846 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2847 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2848 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2850 IHTMLElement_Release(elem
);
2851 SysFreeString(html
);
2854 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2855 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2861 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2862 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2863 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2866 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
2867 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
2873 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
2874 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
2875 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
2878 #define get_first_child(n) _get_first_child(__LINE__,n)
2879 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2881 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2882 IHTMLDOMNode
*child
= NULL
;
2885 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2886 IHTMLDOMNode_Release(node
);
2887 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2892 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2893 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2895 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2896 VARIANT_BOOL b
= 0xdead;
2899 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2900 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2901 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2903 IHTMLDOMNode_Release(node
);
2906 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2907 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2909 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2910 IHTMLDOMNode
*parent
;
2913 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2914 IHTMLDOMNode_Release(node
);
2915 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2920 #define node_get_next(u) _node_get_next(__LINE__,u)
2921 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2923 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2927 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2928 IHTMLDOMNode_Release(node
);
2929 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2934 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2935 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2937 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2941 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2942 IHTMLDOMNode_Release(node
);
2943 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2948 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2949 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2951 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2952 IHTMLElement
*parent
;
2955 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2956 IHTMLElement_Release(elem
);
2957 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2962 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2963 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2965 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2966 VARIANT_BOOL disabled
= 100;
2970 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2971 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2972 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2973 IHTMLElement3_Release(elem3
);
2976 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2977 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2979 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2983 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2984 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2986 IHTMLElement3_Release(elem3
);
2987 _test_elem3_get_disabled(line
, unk
, b
);
2990 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2991 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2993 VARIANT_BOOL disabled
= 100;
2996 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2997 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2998 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3000 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3003 static void test_select_remove(IHTMLSelectElement
*select
)
3007 hres
= IHTMLSelectElement_remove(select
, 3);
3008 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3009 test_select_length(select
, 2);
3011 hres
= IHTMLSelectElement_remove(select
, -1);
3012 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3013 test_select_length(select
, 2);
3015 hres
= IHTMLSelectElement_remove(select
, 0);
3016 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3017 test_select_length(select
, 1);
3020 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3021 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3023 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3027 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3028 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3029 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3030 IHTMLDOMTextNode_Release(text
);
3033 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3034 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3036 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3040 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3041 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3042 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3043 IHTMLDOMTextNode_Release(text
);
3047 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3048 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3050 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3051 BSTR str
= a2bstr(data
);
3054 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3055 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3056 IHTMLDOMTextNode_Release(text
);
3060 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3061 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3063 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3064 BSTR str
= a2bstr(data
);
3067 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3068 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3069 IHTMLDOMTextNode2_Release(text
);
3073 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3074 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3078 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3079 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3081 _test_select_get_disabled(line
, select
, b
);
3084 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3085 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3087 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3091 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3092 IHTMLElement2_Release(elem
);
3093 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3095 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3097 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3102 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3103 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3105 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3106 BSTR dir
= a2bstr(dira
);
3109 hres
= IHTMLElement2_put_dir(elem
, dir
);
3110 IHTMLElement2_Release(elem
);
3111 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3114 _test_elem_dir(line
, unk
, dira
);
3117 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3118 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3120 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3121 IHTMLTextContainer
*txtcont
;
3122 LONG l
= -1, l2
= -1;
3125 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3126 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3127 IHTMLElement2_Release(elem
);
3129 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3130 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3132 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3133 IHTMLTextContainer_Release(txtcont
);
3134 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3135 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3140 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3141 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3143 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3144 IHTMLTextContainer
*txtcont
;
3145 LONG l
= -1, l2
= -1;
3148 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3149 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3150 IHTMLElement2_Release(elem
);
3152 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3153 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3155 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3156 IHTMLTextContainer_Release(txtcont
);
3157 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3158 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3163 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3164 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3166 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3167 IHTMLTextContainer
*txtcont
;
3168 LONG l
= -1, l2
= -1;
3171 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3172 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3173 IHTMLElement2_Release(elem
);
3175 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3176 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3178 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3179 IHTMLTextContainer_Release(txtcont
);
3180 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3181 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3186 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3187 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3189 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3190 IHTMLTextContainer
*txtcont
;
3191 LONG l
= -1, l2
= -1;
3194 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3195 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3197 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3198 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3199 IHTMLElement2_Release(elem
);
3201 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3202 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3204 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3205 IHTMLTextContainer_Release(txtcont
);
3206 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3207 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3210 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3211 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3213 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3217 hres
= IHTMLImgElement_get_src(img
, &src
);
3218 IHTMLImgElement_Release(img
);
3219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3220 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3221 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3225 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3226 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3228 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3233 hres
= IHTMLImgElement_put_src(img
, tmp
);
3234 IHTMLImgElement_Release(img
);
3236 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3239 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3240 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3242 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3246 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3247 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3249 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3251 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3255 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3256 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3258 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3263 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3264 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3267 _test_img_alt(line
, unk
, alt
);
3270 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3271 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3273 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3277 tmp
= a2bstr(align
);
3278 hres
= IHTMLImgElement_put_align(img
, tmp
);
3279 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3282 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3283 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3284 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3288 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3289 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3291 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3295 hres
= IHTMLImgElement_get_name(img
, &sName
);
3296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3297 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3298 IHTMLImgElement_Release(img
);
3299 SysFreeString(sName
);
3302 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3303 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3305 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3306 VARIANT_BOOL b
= 100;
3309 hres
= IHTMLImgElement_get_complete(img
, &b
);
3310 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3311 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3312 IHTMLImgElement_Release(img
);
3315 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3316 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3318 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3319 VARIANT_BOOL b
= 100;
3322 hres
= IHTMLImgElement_put_isMap(img
, v
);
3323 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3325 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3326 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3327 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3329 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3330 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3331 IHTMLImgElement_Release(img
);
3334 static void test_dynamic_properties(IHTMLElement
*elem
)
3336 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3337 IDispatchEx
*dispex
;
3338 BSTR name
, attr1
= SysAllocString(attr1W
);
3342 DISPID id
= DISPID_STARTENUM
;
3345 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3346 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3348 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3349 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3350 ok(succ
, "removeAttribute set succ to FALSE\n");
3353 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3354 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3358 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3359 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3361 if(!strcmp_wa(name
, "attr1"))
3362 ok(0, "attr1 should be removed\n");
3363 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3365 SysFreeString(name
);
3367 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3368 IDispatchEx_Release(dispex
);
3370 V_VT(&val
) = VT_BSTR
;
3371 V_BSTR(&val
) = attr1
;
3372 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3373 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3374 SysFreeString(attr1
);
3377 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3378 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3383 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3384 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3385 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3389 static void test_attr_collection_disp(IDispatch
*disp
)
3391 IDispatchEx
*dispex
;
3392 IHTMLDOMAttribute
*attr
;
3393 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3400 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3401 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3404 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3405 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3406 SysFreeString(bstr
);
3409 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3410 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3411 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3412 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3415 bstr
= a2bstr("attr1");
3416 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3417 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3418 SysFreeString(bstr
);
3421 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3422 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3423 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3424 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3425 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3426 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3428 test_attr_node_name(attr
, "attr1");
3430 IHTMLDOMAttribute_Release(attr
);
3433 IDispatchEx_Release(dispex
);
3436 static void test_attr_collection(IHTMLElement
*elem
)
3438 static const WCHAR testW
[] = {'t','e','s','t',0};
3441 IDispatch
*disp
, *attr
;
3442 IHTMLDOMAttribute
*dom_attr
;
3443 IHTMLAttributeCollection
*attr_col
;
3444 BSTR name
= SysAllocString(testW
);
3446 LONG i
, len
, checked
;
3449 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3450 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3452 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3453 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3455 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3456 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3457 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3458 IDispatch_Release(attr
);
3459 IHTMLDOMNode_Release(node
);
3461 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3462 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3464 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3465 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3469 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3470 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3471 SysFreeString(name
);
3473 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3474 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3475 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3478 for(i
=0; i
<len
; i
++) {
3481 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3482 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3484 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3485 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3486 IDispatch_Release(attr
);
3488 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3489 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3491 if(!strcmp_wa(name
, "id")) {
3493 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3494 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3495 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3496 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3497 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3498 test_attr_value(dom_attr
, "attr");
3499 } else if(!strcmp_wa(name
, "attr1")) {
3501 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3502 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3503 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3504 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3505 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3506 test_attr_value(dom_attr
, "attr1");
3507 } else if(!strcmp_wa(name
, "attr2")) {
3509 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3510 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3511 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3512 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3513 test_attr_value(dom_attr
, "");
3514 } else if(!strcmp_wa(name
, "attr3")) {
3516 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3517 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3518 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3519 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3520 test_attr_value(dom_attr
, "attr3");
3521 } else if(!strcmp_wa(name
, "test")) {
3523 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3524 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3525 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3526 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3527 test_attr_value(dom_attr
, "1");
3530 IHTMLDOMAttribute_Release(dom_attr
);
3531 SysFreeString(name
);
3534 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3537 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3538 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3540 V_VT(&id
) = VT_BSTR
;
3541 V_BSTR(&id
) = a2bstr("nonexisting");
3542 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3543 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3546 test_attr_collection_disp(disp
);
3548 IDispatch_Release(disp
);
3549 IHTMLAttributeCollection_Release(attr_col
);
3552 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3553 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3555 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3556 BSTR id
= (void*)0xdeadbeef;
3559 hres
= IHTMLElement_get_id(elem
, &id
);
3560 IHTMLElement_Release(elem
);
3561 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3564 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3566 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3571 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3572 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3574 BSTR lang
= (void*)0xdeadbeef;
3577 hres
= IHTMLElement_get_language(elem
, &lang
);
3578 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3581 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3583 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3585 SysFreeString(lang
);
3588 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3589 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3591 BSTR str
= a2bstr(lang
);
3594 hres
= IHTMLElement_put_language(elem
, str
);
3595 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3598 _test_elem_language(line
, elem
, lang
);
3601 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3602 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3604 BSTR lang
= (void*)0xdeadbeef;
3607 hres
= IHTMLElement_get_lang(elem
, &lang
);
3608 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3611 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3613 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3615 SysFreeString(lang
);
3618 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3619 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3621 BSTR str
= a2bstr(lang
);
3624 hres
= IHTMLElement_put_lang(elem
, str
);
3625 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3628 _test_elem_lang(line
, elem
, lang
);
3631 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3632 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3634 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3635 BSTR tmp
= a2bstr(new_id
);
3638 hres
= IHTMLElement_put_id(elem
, tmp
);
3639 IHTMLElement_Release(elem
);
3641 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3643 _test_elem_id(line
, unk
, new_id
);
3646 static void test_contenteditable(IUnknown
*unk
)
3648 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3650 BSTR str
, strDefault
;
3652 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3653 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3655 str
= a2bstr("true");
3656 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3657 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3659 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3660 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3661 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3663 /* Restore origin contentEditable */
3664 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3665 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3666 SysFreeString(strDefault
);
3668 IHTMLElement3_Release(elem3
);
3671 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3672 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3677 hres
= IHTMLInputElement_get_type(input
, &type
);
3678 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3679 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3680 SysFreeString(type
);
3683 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3684 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3686 BSTR name
= (BSTR
)0xdeadbeef;
3689 hres
= IHTMLInputElement_get_name(input
, &name
);
3690 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3692 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3694 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3695 SysFreeString(name
);
3698 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3699 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3701 BSTR tmp
= a2bstr(name
);
3704 hres
= IHTMLInputElement_put_name(input
, tmp
);
3705 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3708 _test_input_name(line
, input
, name
);
3711 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3712 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3714 VARIANT_BOOL disabled
= 100;
3717 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3718 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3719 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3721 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3724 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3725 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3729 hres
= IHTMLInputElement_put_disabled(input
, b
);
3730 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3732 _test_input_get_disabled(line
, input
, b
);
3735 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3736 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3738 VARIANT_BOOL checked
= 100;
3741 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3742 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3743 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3746 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3747 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3751 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3752 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3754 _test_input_get_defaultchecked(line
, input
, b
);
3757 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3758 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3760 VARIANT_BOOL checked
= 100;
3763 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3764 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3765 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3768 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3769 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3773 hres
= IHTMLInputElement_put_checked(input
, b
);
3774 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3776 _test_input_get_checked(line
, input
, b
);
3779 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3780 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3782 LONG maxlength
= 0xdeadbeef;
3785 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3786 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3787 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3790 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3791 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3795 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3796 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3798 _test_input_maxlength(line
, input
, l
);
3801 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3802 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3804 IHTMLInputElement
*input
;
3808 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3809 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3813 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3814 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3816 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3818 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3819 SysFreeString(bstr
);
3820 IHTMLInputElement_Release(input
);
3823 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3824 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3826 IHTMLInputElement
*input
;
3827 IHTMLFormElement
*form
;
3831 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3832 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3833 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3834 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3835 if(FAILED(hres
) || input
== NULL
)
3838 hres
= IHTMLInputElement_get_form(input
, &form
);
3839 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3840 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3841 if(FAILED(hres
) || form
== NULL
){
3842 IHTMLInputElement_Release(input
);
3846 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3847 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3848 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3849 if(FAILED(hres
) || elem
== NULL
){
3850 IHTMLInputElement_Release(input
);
3851 IHTMLFormElement_Release(form
);
3855 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3857 IHTMLInputElement_Release(input
);
3858 IHTMLFormElement_Release(form
);
3859 IHTMLElement_Release(elem
);
3862 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3863 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3865 IHTMLInputElement
*input
;
3869 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3870 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3875 hres
= IHTMLInputElement_put_value(input
, bstr
);
3876 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3877 SysFreeString(bstr
);
3878 IHTMLInputElement_Release(input
);
3880 _test_input_value(line
, unk
, val
);
3883 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3884 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3886 IHTMLInputElement
*input
;
3890 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3891 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3895 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3896 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3898 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3900 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3902 IHTMLInputElement_Release(input
);
3905 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3906 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3908 IHTMLInputElement
*input
;
3912 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3913 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3918 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3919 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3921 IHTMLInputElement_Release(input
);
3923 _test_input_defaultValue(line
, unk
, val
);
3926 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
3927 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
3932 hres
= IHTMLInputElement_get_src(input
, &src
);
3933 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3935 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3937 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
3941 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
3942 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
3948 hres
= IHTMLInputElement_put_src(input
, tmp
);
3950 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3952 _test_input_src(line
, input
, src
);
3955 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
3956 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
3960 hres
= IHTMLInputElement_put_size(input
, size
);
3961 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
3964 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
3965 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
3970 hres
= IHTMLInputElement_get_size(input
, &size
);
3971 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
3972 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
3974 hres
= IHTMLInputElement_get_size(input
, NULL
);
3975 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
3978 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
3979 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
3982 VARIANT_BOOL b
= 100;
3984 hres
= IHTMLInputElement_put_readOnly(input
, v
);
3985 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
3987 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
3988 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
3989 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
3992 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
3993 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
3995 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3996 BSTR
class = (void*)0xdeadbeef;
3999 hres
= IHTMLElement_get_className(elem
, &class);
4000 IHTMLElement_Release(elem
);
4001 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4003 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4005 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4006 SysFreeString(class);
4009 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4010 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4012 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4016 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4017 IHTMLElement2_Release(elem2
);
4018 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4019 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4022 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4023 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4025 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4028 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4029 IHTMLElement2_Release(elem2
);
4030 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4032 _test_elem_tabindex(line
, unk
, index
);
4035 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4036 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4038 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4042 hres
= IHTMLStyleElement_get_media(style
, &media
);
4043 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4045 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4047 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4049 IHTMLStyleElement_Release(style
);
4050 SysFreeString(media
);
4053 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4054 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4056 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4060 str
= a2bstr(media
);
4061 hres
= IHTMLStyleElement_put_media(style
, str
);
4062 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4063 IHTMLStyleElement_Release(style
);
4066 _test_style_media(line
, unk
, media
);
4069 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4070 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4072 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4076 hres
= IHTMLStyleElement_get_type(style
, &type
);
4077 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4079 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4081 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4083 IHTMLStyleElement_Release(style
);
4084 SysFreeString(type
);
4087 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4088 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4090 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4095 hres
= IHTMLStyleElement_put_type(style
, str
);
4096 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4097 IHTMLStyleElement_Release(style
);
4100 _test_style_type(line
, unk
, type
);
4103 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4104 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4106 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4108 IHTMLFiltersCollection
*filters
;
4110 hres
= IHTMLElement_get_filters(elem
, &filters
);
4111 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4112 "get_filters failed: %08x\n", hres
);
4116 IDispatchEx
*dispex
;
4118 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4119 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4120 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4122 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4123 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4124 "Could not get IDispatchEx interface: %08x\n", hres
);
4125 if(SUCCEEDED(hres
)) {
4126 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
4127 IDispatchEx_Release(dispex
);
4130 IHTMLFiltersCollection_Release(filters
);
4133 IHTMLElement_Release(elem
);
4136 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4137 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4139 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4143 tmp
= class ? a2bstr(class) : NULL
;
4144 hres
= IHTMLElement_put_className(elem
, tmp
);
4145 IHTMLElement_Release(elem
);
4146 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4149 _test_elem_class(line
, unk
, class);
4152 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4153 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4155 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4159 hres
= IHTMLElement_get_title(elem
, &title
);
4160 IHTMLElement_Release(elem
);
4161 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4163 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4165 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4167 SysFreeString(title
);
4170 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4171 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4173 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4177 tmp
= a2bstr(title
);
4178 hres
= IHTMLElement_put_title(elem
, tmp
);
4179 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4181 IHTMLElement_Release(elem
);
4185 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4186 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4188 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4192 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4193 IHTMLDOMNode_Release(node
);
4194 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4197 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4198 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4200 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4206 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4207 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4209 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4213 V_VT(&var
) = VT_BSTR
;
4214 V_BSTR(&var
) = a2bstr(val
);
4216 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4217 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4218 IHTMLDOMNode_Release(node
);
4222 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4223 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4225 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4229 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4230 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4231 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4232 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4234 IHTMLElement2_Release(elem
);
4237 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4238 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4240 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4244 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4245 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4246 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4248 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4249 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4250 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4252 IHTMLElement2_Release(elem
);
4255 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4256 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4258 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4259 LONG len
= 0xdeadbeef;
4262 hres
= IHTMLFormElement_get_length(form
, &len
);
4263 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4264 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4266 IHTMLFormElement_Release(form
);
4269 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4270 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4272 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4273 BSTR action
= (void*)0xdeadbeef;
4276 hres
= IHTMLFormElement_get_action(form
, &action
);
4277 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4279 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4281 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4283 SysFreeString(action
);
4284 IHTMLFormElement_Release(form
);
4287 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4288 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4290 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4291 BSTR tmp
= a2bstr(action
);
4294 hres
= IHTMLFormElement_put_action(form
, tmp
);
4295 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4297 IHTMLFormElement_Release(form
);
4299 _test_form_action(line
, unk
, action
);
4302 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4303 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4305 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4306 BSTR method
= (void*)0xdeadbeef;
4309 hres
= IHTMLFormElement_get_method(form
, &method
);
4310 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4312 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4314 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4316 SysFreeString(method
);
4317 IHTMLFormElement_Release(form
);
4320 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4321 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4323 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4324 BSTR tmp
= a2bstr(method
);
4327 hres
= IHTMLFormElement_put_method(form
, tmp
);
4328 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4330 IHTMLFormElement_Release(form
);
4332 if(exp_hres
== S_OK
)
4333 _test_form_method(line
, unk
, method
);
4336 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4337 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4339 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4340 BSTR name
= (void*)0xdeadbeef;
4343 hres
= IHTMLFormElement_get_name(form
, &name
);
4344 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4346 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4348 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4350 SysFreeString(name
);
4351 IHTMLFormElement_Release(form
);
4354 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4355 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4357 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4358 BSTR tmp
= a2bstr(name
);
4361 hres
= IHTMLFormElement_put_name(form
, tmp
);
4362 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4364 IHTMLFormElement_Release(form
);
4366 _test_form_name(line
, unk
, name
);
4369 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4370 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4372 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4373 BSTR encoding
= (void*)0xdeadbeef;
4376 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4377 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4379 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4381 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4383 SysFreeString(encoding
);
4384 IHTMLFormElement_Release(form
);
4387 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4388 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4390 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4391 BSTR tmp
= a2bstr(encoding
);
4394 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4395 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4397 IHTMLFormElement_Release(form
);
4399 if(exp_hres
== S_OK
)
4400 _test_form_encoding(line
, unk
, encoding
);
4403 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4404 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4406 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4411 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4412 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4413 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4414 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4416 IDispatch_Release(disp
);
4417 IHTMLFormElement_Release(form
);
4420 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4421 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4423 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4426 hres
= IHTMLFormElement_reset(form
);
4427 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4429 IHTMLFormElement_Release(form
);
4432 static void test_form_target(IUnknown
*unk
)
4434 IHTMLFormElement
*form
= get_form_iface(unk
);
4437 static const char target
[] = "_blank";
4439 str
= a2bstr(target
);
4440 hres
= IHTMLFormElement_put_target(form
, str
);
4441 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4444 hres
= IHTMLFormElement_get_target(form
, &str
);
4445 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4446 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4449 IHTMLFormElement_Release(form
);
4452 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4454 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4455 IHTMLFormElement
*form
;
4458 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4459 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4461 hres
= IHTMLSelectElement_get_form(select
, &form
);
4462 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4463 ok(form
!= NULL
, "form == NULL\n");
4465 test_form_length((IUnknown
*)form
, 1);
4466 test_form_elements((IUnknown
*)form
);
4467 test_form_name((IUnknown
*)form
, "form_name");
4469 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4471 IHTMLSelectElement_Release(select
);
4472 IHTMLFormElement_Release(form
);
4475 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4477 IHTMLFormElement
*form
;
4480 form
= (IHTMLFormElement
*)0xdeadbeef;
4481 hres
= IHTMLSelectElement_get_form(select
, &form
);
4482 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4483 ok(form
== NULL
, "got %p\n", form
);
4486 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4487 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4489 IHTMLMetaElement
*meta
;
4493 meta
= _get_metaelem_iface(line
, unk
);
4494 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4495 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4496 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4497 SysFreeString(name
);
4498 IHTMLMetaElement_Release(meta
);
4501 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4502 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4504 IHTMLMetaElement
*meta
;
4505 BSTR content
= NULL
;
4508 meta
= _get_metaelem_iface(line
, unk
);
4509 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4510 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4511 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4512 SysFreeString(content
);
4513 IHTMLMetaElement_Release(meta
);
4516 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4517 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4519 IHTMLMetaElement
*meta
;
4523 meta
= _get_metaelem_iface(line
, unk
);
4524 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4525 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4526 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4528 IHTMLMetaElement_Release(meta
);
4531 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4532 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4534 IHTMLMetaElement
*meta
;
4538 meta
= _get_metaelem_iface(line
, unk
);
4539 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4540 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4542 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4544 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4546 IHTMLMetaElement_Release(meta
);
4549 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4550 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4552 BSTR val
= a2bstr(vala
);
4553 IHTMLMetaElement
*meta
;
4556 meta
= _get_metaelem_iface(line
, unk
);
4557 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4558 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4560 IHTMLMetaElement_Release(meta
);
4562 _test_meta_charset(line
, unk
, vala
);
4565 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4566 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4568 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4572 str
= a2bstr(exval
);
4573 hres
= IHTMLLinkElement_put_media(link
, str
);
4574 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4577 hres
= IHTMLLinkElement_get_media(link
, &str
);
4578 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4579 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4581 IHTMLLinkElement_Release(link
);
4584 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4585 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4587 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4588 VARIANT_BOOL b
= 10;
4591 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4592 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4593 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4595 IHTMLLinkElement_Release(link
);
4598 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4599 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4601 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4604 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4605 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4606 IHTMLLinkElement_Release(link
);
4607 _test_link_disabled(line
, elem
, v
);
4610 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4611 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4613 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4617 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4618 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4620 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4622 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4624 IHTMLLinkElement_Release(link
);
4627 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4628 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4630 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4631 BSTR str
= a2bstr(v
);
4634 hres
= IHTMLLinkElement_put_rel(link
, str
);
4635 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4637 IHTMLLinkElement_Release(link
);
4638 _test_link_rel(line
, elem
, v
);
4641 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4642 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4644 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4648 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4649 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4651 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4653 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4655 IHTMLLinkElement_Release(link
);
4658 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4659 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4661 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4662 BSTR str
= a2bstr(v
);
4665 hres
= IHTMLLinkElement_put_rev(link
, str
);
4666 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4668 IHTMLLinkElement_Release(link
);
4669 _test_link_rev(line
, elem
, v
);
4672 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4673 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4675 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4679 hres
= IHTMLLinkElement_get_type(link
, &type
);
4680 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4682 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4684 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4686 IHTMLLinkElement_Release(link
);
4689 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4690 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4695 str
= (void*)0xdeadbeef;
4696 hres
= IHTMLScriptElement_get_text(script
, &str
);
4697 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4698 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4702 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4703 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4705 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4706 BSTR str
= a2bstr(v
);
4709 hres
= IHTMLLinkElement_put_type(link
, str
);
4710 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4712 IHTMLLinkElement_Release(link
);
4713 _test_link_type(line
, elem
, v
);
4716 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4717 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4719 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4723 hres
= IHTMLLinkElement_get_href(link
, &href
);
4724 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4726 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4728 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4730 IHTMLLinkElement_Release(link
);
4733 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4734 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4736 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4737 BSTR str
= a2bstr(v
);
4740 hres
= IHTMLLinkElement_put_href(link
, str
);
4741 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4743 IHTMLLinkElement_Release(link
);
4744 _test_link_href(line
, elem
, v
);
4747 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4748 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4750 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4751 IHTMLDocument2
*doc
;
4756 hres
= IHTMLElement_get_document(elem
, &disp
);
4757 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4758 ok(disp
!= NULL
, "disp == NULL\n");
4760 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4761 IDispatch_Release(disp
);
4762 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4767 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4768 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4770 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4771 BSTR str
= a2bstr(attr_name
);
4772 IHTMLDOMAttribute
*attr
;
4775 attr
= (void*)0xdeadbeef;
4776 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4777 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4779 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4781 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4783 IHTMLElement4_Release(elem
);
4788 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4789 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4793 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4794 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4795 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4798 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4799 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4803 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4804 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4807 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4808 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4810 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4811 BSTR str
= a2bstr(value
);
4814 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4815 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4817 IHTMLDOMAttribute2_Release(attr2
);
4821 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4822 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4824 IHTMLDocument2
*doc
;
4828 hres
= IHTMLWindow2_get_document(window
, &doc
);
4829 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4830 ok(doc
!= NULL
, "disp == NULL\n");
4835 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4836 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4841 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4842 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4843 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4848 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4849 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4851 IHTMLElement
*elem
= NULL
;
4856 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4857 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4858 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4864 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4865 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4867 IHTMLDocument3
*doc3
;
4868 IHTMLDOMNode
*node
= NULL
;
4872 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4873 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4876 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4877 IHTMLDocument3_Release(doc3
);
4879 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4880 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4885 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4886 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4888 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4889 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4890 IHTMLDOMNode
*new_child
= NULL
;
4893 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4894 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4895 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4896 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4898 IHTMLDOMNode_Release(node
);
4899 IHTMLDOMNode_Release(child
);
4904 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4905 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4907 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4908 IHTMLDOMNode
*new_child
= NULL
;
4911 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4912 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4913 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4914 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4916 IHTMLDOMNode_Release(node
);
4921 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4922 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4924 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4925 IHTMLDOMNode
*new_node
= NULL
;
4928 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
4929 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
4930 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
4931 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
4933 IHTMLDOMNode_Release(node
);
4934 IHTMLDOMNode_Release(new_node
);
4937 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
4938 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
4943 hres
= IHTMLDocument2_get_title(doc
, &title
);
4944 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4945 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4946 SysFreeString(title
);
4949 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
4950 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
4955 tmp
= a2bstr(title
);
4956 hres
= IHTMLDocument2_put_title(doc
, tmp
);
4957 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4961 static void test_elem_bounding_client_rect(IUnknown
*unk
)
4963 IHTMLRect
*rect
, *rect2
;
4964 IHTMLElement2
*elem2
;
4968 elem2
= get_elem2_iface(unk
);
4969 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
4970 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4971 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
4972 IHTMLElement2_Release(elem2
);
4973 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4974 ok(rect
!= NULL
, "rect == NULL\n");
4975 ok(rect
!= rect2
, "rect == rect2\n");
4976 IHTMLRect_Release(rect2
);
4978 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
4981 hres
= IHTMLRect_get_top(rect
, &l
);
4982 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4983 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4986 hres
= IHTMLRect_get_left(rect
, &l
);
4987 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4988 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4991 hres
= IHTMLRect_get_bottom(rect
, &l
);
4992 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4993 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4996 hres
= IHTMLRect_get_right(rect
, &l
);
4997 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4998 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5000 IHTMLRect_Release(rect
);
5003 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5004 const elem_type_t
*elem_types
, LONG len
)
5007 VARIANT name
, index
;
5011 V_VT(&index
) = VT_EMPTY
;
5012 V_VT(&name
) = VT_BSTR
;
5013 V_BSTR(&name
) = a2bstr(n
);
5015 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5016 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5018 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5019 IDispatch_Release(disp
);
5021 V_VT(&index
) = VT_I4
;
5023 for(i
=0; i
<len
; i
++) {
5025 disp
= (void*)0xdeadbeef;
5026 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5027 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5028 ok(disp
!= NULL
, "disp == NULL\n");
5029 if(FAILED(hres
) || !disp
)
5032 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5034 IDispatch_Release(disp
);
5038 disp
= (void*)0xdeadbeef;
5039 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5040 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5041 ok(disp
== NULL
, "disp != NULL\n");
5044 disp
= (void*)0xdeadbeef;
5045 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5046 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5047 ok(disp
== NULL
, "disp != NULL\n");
5049 SysFreeString(V_BSTR(&name
));
5052 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5054 IHTMLElementCollection
*col
;
5056 IDispatch
*disp
= (void*)0xdeadbeef;
5057 VARIANT name
, index
;
5060 hres
= IHTMLDocument2_get_all(doc
, &col
);
5061 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5062 ok(col
!= NULL
, "col == NULL\n");
5063 if(FAILED(hres
) || !col
)
5066 V_VT(&index
) = VT_EMPTY
;
5067 V_VT(&name
) = VT_BSTR
;
5068 V_BSTR(&name
) = a2bstr(id
);
5070 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5071 IHTMLElementCollection_Release(col
);
5072 SysFreeString(V_BSTR(&name
));
5073 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5074 if(!expect_success
) {
5075 ok(disp
== NULL
, "disp != NULL\n");
5079 ok(disp
!= NULL
, "disp == NULL\n");
5083 elem
= get_elem_iface((IUnknown
*)disp
);
5084 IDispatch_Release(disp
);
5089 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5091 IHTMLDocument3
*doc3
;
5096 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5097 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5100 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5102 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5104 IHTMLDocument3_Release(doc3
);
5109 static void test_select_elem(IHTMLSelectElement
*select
)
5111 IDispatch
*disp
, *disp2
;
5112 VARIANT name
, index
;
5115 test_select_type(select
, "select-one");
5116 test_select_length(select
, 2);
5117 test_select_selidx(select
, 0);
5118 test_select_put_selidx(select
, 1);
5120 test_select_set_value(select
, "val1");
5121 test_select_value(select
, "val1");
5123 test_select_size(select
, 0);
5124 test_select_set_size(select
, 1, S_OK
);
5125 test_select_size(select
, 1);
5127 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5128 test_select_size(select
, 1);
5129 test_select_set_size(select
, 3, S_OK
);
5130 test_select_size(select
, 3);
5132 test_select_name(select
, NULL
);
5133 test_select_set_name(select
, "select-name");
5134 test_select_name(select
, "select-name");
5135 test_select_form_notfound(select
);
5137 test_select_get_disabled(select
, VARIANT_FALSE
);
5138 test_select_set_disabled(select
, VARIANT_TRUE
);
5139 test_select_set_disabled(select
, VARIANT_FALSE
);
5142 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5143 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5144 ok(disp
!= NULL
, "options == NULL\n");
5145 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5146 IDispatch_Release(disp
);
5148 V_VT(&index
) = VT_EMPTY
;
5149 V_VT(&name
) = VT_I4
;
5151 disp
= (void*)0xdeadbeef;
5152 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5153 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5154 ok(!disp
, "disp = %p\n", disp
);
5157 disp
= (void*)0xdeadbeef;
5158 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5159 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5160 ok(!disp
, "disp = %p\n", disp
);
5163 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5164 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5167 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5168 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5169 ok(disp
!= NULL
, "disp = NULL\n");
5170 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
5172 V_VT(&index
) = VT_I4
;
5175 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5176 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5177 ok(disp2
!= NULL
, "disp = NULL\n");
5178 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5179 IDispatch_Release(disp2
);
5180 IDispatch_Release(disp
);
5182 test_select_multiple(select
, VARIANT_FALSE
);
5183 test_select_set_multiple(select
, VARIANT_TRUE
);
5184 test_select_remove(select
);
5187 static void test_form_item(IHTMLElement
*elem
)
5189 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5190 IDispatch
*disp
, *disp2
;
5191 VARIANT name
, index
;
5194 V_VT(&index
) = VT_EMPTY
;
5195 V_VT(&name
) = VT_I4
;
5197 disp
= (void*)0xdeadbeef;
5198 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5199 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5200 ok(!disp
, "disp = %p\n", disp
);
5203 disp
= (void*)0xdeadbeef;
5204 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5205 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5206 ok(!disp
, "disp = %p\n", disp
);
5209 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5210 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5213 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5214 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5215 ok(disp
!= NULL
, "disp = NULL\n");
5216 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
5218 V_VT(&index
) = VT_I4
;
5221 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5222 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5223 ok(disp2
!= NULL
, "disp = NULL\n");
5224 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5225 IDispatch_Release(disp2
);
5226 IDispatch_Release(disp
);
5229 static void test_create_option_elem(IHTMLDocument2
*doc
)
5231 IHTMLOptionElement
*option
;
5233 option
= create_option_elem(doc
, "test text", "test value");
5235 test_option_put_text(option
, "new text");
5236 test_option_put_value(option
, "new value");
5237 test_option_get_index(option
, 0);
5238 test_option_defaultSelected_property(option
);
5239 test_option_put_selected(option
, VARIANT_TRUE
);
5240 test_option_put_selected(option
, VARIANT_FALSE
);
5242 IHTMLOptionElement_Release(option
);
5245 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5247 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5248 IHTMLFormElement
*form
;
5251 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5252 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5254 hres
= IHTMLOptionElement_get_form(option
, &form
);
5255 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5256 ok(form
!= NULL
, "form == NULL\n");
5258 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5260 IHTMLOptionElement_Release(option
);
5261 IHTMLFormElement_Release(form
);
5264 static void test_create_img_elem(IHTMLDocument2
*doc
)
5266 IHTMLImgElement
*img
;
5268 img
= create_img_elem(doc
, 10, 15);
5271 test_img_put_width(img
, 5);
5272 test_img_put_height(img
, 20);
5274 IHTMLImgElement_Release(img
);
5278 img
= create_img_elem(doc
, -1, -1);
5281 test_img_put_width(img
, 5);
5282 test_img_put_height(img
, 20);
5284 IHTMLImgElement_Release(img
);
5288 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5289 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5291 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5292 IHTMLElement
*ret_elem
= NULL
;
5293 BSTR str
= a2bstr(where
);
5296 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5297 IHTMLElement2_Release(elem2
);
5299 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5300 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5301 IHTMLElement_Release(ret_elem
);
5304 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5306 IHTMLElement
*elem
, *elem2
;
5308 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5309 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5311 elem
= test_create_elem(doc
, "BR");
5312 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5313 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5314 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5315 IHTMLElement_Release(elem
);
5317 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5319 elem
= test_create_elem(doc
, "BR");
5320 insert_adjacent_elem(parent
, "beforeend", elem
);
5322 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5324 elem2
= test_create_elem(doc
, "DIV");
5325 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5326 IHTMLElement_Release(elem2
);
5327 IHTMLElement_Release(elem
);
5329 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5332 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5334 IHTMLBodyElement
*body
;
5335 IHTMLTxtRange
*range
;
5339 elem
= doc_get_body(doc
);
5340 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5341 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5342 IHTMLElement_Release(elem
);
5344 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5345 IHTMLBodyElement_Release(body
);
5346 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5351 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5352 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5357 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5358 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5363 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5364 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5365 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5367 BSTR str
= a2bstr(how
);
5370 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5371 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5375 static void test_txtrange(IHTMLDocument2
*doc
)
5377 IHTMLTxtRange
*body_range
, *range
, *range2
;
5378 IHTMLSelectionObject
*selection
;
5379 IDispatch
*disp_range
;
5383 body_range
= test_create_body_range(doc
);
5385 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, "[object]");
5387 test_range_text(body_range
, "test abc 123\r\nit's text");
5389 range
= range_duplicate(body_range
);
5390 range2
= range_duplicate(body_range
);
5392 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5394 test_range_text(range
, "test abc 123\r\nit's text");
5395 test_range_text(body_range
, "test abc 123\r\nit's text");
5397 test_range_collapse(range
, TRUE
);
5398 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5399 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5400 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5401 IHTMLTxtRange_Release(range2
);
5403 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5404 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5405 test_range_move(range
, characterW
, 2, 2);
5406 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5408 test_range_collapse(range
, FALSE
);
5409 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5411 test_range_collapse(range
, FALSE
);
5412 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5413 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5414 test_range_move(range
, characterW
, 2, 2);
5415 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5416 test_range_moveend(range
, characterW
, -5, -5);
5417 test_range_text(range
, NULL
);
5418 test_range_moveend(range
, characterW
, 3, 3);
5419 test_range_text(range
, "c 1");
5420 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5421 test_range_collapse(range
, TRUE
);
5422 test_range_move(range
, characterW
, 4, 4);
5423 test_range_moveend(range
, characterW
, 1, 1);
5424 test_range_text(range
, " ");
5425 test_range_move(range
, wordW
, 1, 1);
5426 test_range_moveend(range
, characterW
, 2, 2);
5427 test_range_text(range
, "ab");
5429 IHTMLTxtRange_Release(range
);
5431 range
= range_duplicate(body_range
);
5433 test_range_text(range
, "test abc 123\r\nit's text");
5434 test_range_move(range
, characterW
, 3, 3);
5435 test_range_moveend(range
, characterW
, 1, 1);
5436 test_range_text(range
, "t");
5437 test_range_moveend(range
, characterW
, 3, 3);
5438 test_range_text(range
, "t ab");
5439 test_range_moveend(range
, characterW
, -2, -2);
5440 test_range_text(range
, "t ");
5441 test_range_move(range
, characterW
, 6, 6);
5442 test_range_moveend(range
, characterW
, 3, 3);
5443 test_range_text(range
, "123");
5444 test_range_moveend(range
, characterW
, 2, 2);
5445 test_range_text(range
, "123\r\ni");
5447 IHTMLTxtRange_Release(range
);
5449 range
= range_duplicate(body_range
);
5451 test_range_move(range
, wordW
, 1, 1);
5452 test_range_moveend(range
, characterW
, 2, 2);
5453 test_range_text(range
, "ab");
5455 test_range_move(range
, characterW
, -2, -2);
5456 test_range_moveend(range
, characterW
, 2, 2);
5457 test_range_text(range
, "t ");
5459 test_range_move(range
, wordW
, 3, 3);
5460 test_range_move(range
, wordW
, -2, -2);
5461 test_range_moveend(range
, characterW
, 2, 2);
5462 test_range_text(range
, "ab");
5464 test_range_move(range
, characterW
, -6, -5);
5465 test_range_moveend(range
, characterW
, -1, 0);
5466 test_range_moveend(range
, characterW
, -6, 0);
5467 test_range_move(range
, characterW
, 2, 2);
5468 test_range_moveend(range
, characterW
, 2, 2);
5469 test_range_text(range
, "st");
5470 test_range_moveend(range
, characterW
, -6, -4);
5471 test_range_moveend(range
, characterW
, 2, 2);
5473 IHTMLTxtRange_Release(range
);
5475 range
= range_duplicate(body_range
);
5477 test_range_move(range
, wordW
, 2, 2);
5478 test_range_moveend(range
, characterW
, 2, 2);
5479 test_range_text(range
, "12");
5481 test_range_move(range
, characterW
, 15, 14);
5482 test_range_move(range
, characterW
, -2, -2);
5483 test_range_moveend(range
, characterW
, 3, 2);
5484 test_range_text(range
, "t");
5485 test_range_moveend(range
, characterW
, -1, -1);
5486 test_range_text(range
, "t");
5487 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5488 test_range_move(range
, characterW
, -2, -2);
5489 test_range_moveend(range
, characterW
, 2, 2);
5490 test_range_text(range
, "s ");
5491 test_range_move(range
, characterW
, 100, 7);
5492 test_range_move(range
, wordW
, 1, 0);
5493 test_range_move(range
, characterW
, -2, -2);
5494 test_range_moveend(range
, characterW
, 3, 2);
5495 test_range_text(range
, "t");
5497 IHTMLTxtRange_Release(range
);
5499 range
= range_duplicate(body_range
);
5501 test_range_collapse(range
, TRUE
);
5502 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5503 test_range_put_text(range
, "word");
5504 test_range_text(body_range
, "wordabc 123\r\nit's text");
5505 test_range_text(range
, NULL
);
5506 test_range_moveend(range
, characterW
, 3, 3);
5507 test_range_text(range
, "abc");
5508 test_range_movestart(range
, characterW
, -2, -2);
5509 test_range_text(range
, "rdabc");
5510 test_range_movestart(range
, characterW
, 3, 3);
5511 test_range_text(range
, "bc");
5512 test_range_movestart(range
, characterW
, 4, 4);
5513 test_range_text(range
, NULL
);
5514 test_range_movestart(range
, characterW
, -3, -3);
5515 test_range_text(range
, "c 1");
5516 test_range_movestart(range
, characterW
, -7, -6);
5517 test_range_text(range
, "wordabc 1");
5518 test_range_movestart(range
, characterW
, 100, 22);
5519 test_range_text(range
, NULL
);
5521 IHTMLTxtRange_Release(range
);
5523 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5524 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5526 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, "[object]");
5527 test_ifaces((IUnknown
*)selection
, selection_iids
);
5529 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5530 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5531 IHTMLSelectionObject_Release(selection
);
5533 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5534 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5535 IDispatch_Release(disp_range
);
5537 test_range_text(range
, NULL
);
5538 test_range_moveend(range
, characterW
, 3, 3);
5539 test_range_text(range
, "wor");
5540 test_range_parent(range
, ET_BODY
);
5541 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5542 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5543 test_range_move(range
, characterW
, 3, 3);
5544 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5545 test_range_moveend(range
, characterW
, -4, -4);
5546 test_range_put_text(range
, "abc def ");
5547 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5548 test_range_move(range
, wordW
, 1, 1);
5549 test_range_movestart(range
, characterW
, -1, -1);
5550 test_range_text(range
, " ");
5551 test_range_move(range
, wordW
, 1, 1);
5552 test_range_moveend(range
, characterW
, 3, 3);
5553 test_range_text(range
, "def");
5554 test_range_put_text(range
, "xyz");
5555 test_range_moveend(range
, characterW
, 1, 1);
5556 test_range_move(range
, wordW
, 1, 1);
5557 test_range_moveend(range
, characterW
, 2, 2);
5558 test_range_text(range
, "ab");
5560 body
= doc_get_body(doc
);
5562 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5563 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5565 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5566 test_range_parent(range
, ET_BODY
);
5568 test_range_move(range
, wordW
, 1, 1);
5569 test_range_moveend(range
, characterW
, 12, 12);
5570 test_range_text(range
, "xyz abc 123");
5572 test_range_collapse(range
, VARIANT_TRUE
);
5573 test_range_paste_html(range
, "<br>paste<br>");
5574 test_range_text(range
, NULL
);
5576 test_range_moveend(range
, characterW
, 3, 3);
5577 test_range_text(range
, "xyz");
5579 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5580 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5582 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5584 test_range_move(range
, wordW
, 2, 2);
5585 test_range_collapse(range
, VARIANT_TRUE
);
5586 test_range_moveend(range
, characterW
, 5, 5);
5587 test_range_text(range
, "paste");
5589 range2
= range_duplicate(range
);
5591 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5592 test_range_text(range
, "abc \r\npaste");
5594 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5595 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5597 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5598 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5600 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5601 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5602 test_range_text(range
, "abc ");
5604 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5605 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5607 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5608 test_range_text(range
, "abc ");
5610 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5612 IHTMLTxtRange_Release(range
);
5613 IHTMLTxtRange_Release(range2
);
5614 IHTMLTxtRange_Release(body_range
);
5615 IHTMLElement_Release(body
);
5619 static void test_txtrange2(IHTMLDocument2
*doc
)
5621 IHTMLTxtRange
*range
;
5623 range
= test_create_body_range(doc
);
5625 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5626 test_range_move(range
, characterW
, 5, 5);
5627 test_range_moveend(range
, characterW
, 1, 1);
5628 test_range_text(range
, "2");
5629 test_range_move(range
, characterW
, -3, -3);
5630 test_range_moveend(range
, characterW
, 3, 3);
5631 test_range_text(range
, "c\r\n\r\n1");
5632 test_range_collapse(range
, VARIANT_FALSE
);
5633 test_range_moveend(range
, characterW
, 4, 4);
5634 test_range_text(range
, "23");
5635 test_range_moveend(range
, characterW
, 1, 1);
5636 test_range_text(range
, "23\r\n\r\n\r\nd");
5637 test_range_moveend(range
, characterW
, -1, -1);
5638 test_range_text(range
, "23");
5639 test_range_moveend(range
, characterW
, -1, -1);
5640 test_range_text(range
, "23");
5641 test_range_moveend(range
, characterW
, -2, -2);
5642 test_range_text(range
, "2");
5644 IHTMLTxtRange_Release(range
);
5647 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5648 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5650 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5654 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5656 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5658 IHTMLDocument5_Release(doc
);
5661 static void test_location(IHTMLDocument2
*doc
)
5663 IHTMLLocation
*location
, *location2
;
5664 IHTMLWindow2
*window
;
5669 hres
= IHTMLDocument2_get_location(doc
, &location
);
5670 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5672 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5673 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5675 ok(location
== location2
, "location != location2\n");
5676 IHTMLLocation_Release(location2
);
5678 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5679 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5681 hres
= IHTMLWindow2_get_location(window
, &location2
);
5682 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5683 ok(location
== location2
, "location != location2\n");
5684 IHTMLLocation_Release(location2
);
5686 test_ifaces((IUnknown
*)location
, location_iids
);
5687 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5689 hres
= IHTMLLocation_get_pathname(location
, &str
);
5690 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5691 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5694 hres
= IHTMLLocation_get_href(location
, NULL
);
5695 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5697 hres
= IHTMLLocation_get_href(location
, &str
);
5698 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5699 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5702 ref
= IHTMLLocation_Release(location
);
5703 ok(!ref
, "location chould be destroyed here\n");
5706 static void test_plugins_col(IHTMLDocument2
*doc
)
5708 IHTMLPluginsCollection
*col
, *col2
;
5709 IHTMLWindow2
*window
;
5715 window
= get_doc_window(doc
);
5716 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5717 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5718 IHTMLWindow2_Release(window
);
5720 hres
= IOmNavigator_get_plugins(nav
, &col
);
5721 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5723 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5724 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5725 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5726 IHTMLPluginsCollection_Release(col2
);
5728 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5731 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5732 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5733 ok(!len
, "length = %d\n", len
);
5735 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5736 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5738 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5739 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5741 ref
= IHTMLPluginsCollection_Release(col
);
5742 ok(!ref
, "ref=%d\n", ref
);
5744 IOmNavigator_Release(nav
);
5747 static void test_mime_types_col(IOmNavigator
*nav
)
5749 IHTMLMimeTypesCollection
*col
, *col2
;
5754 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5755 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5757 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5758 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5759 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5760 IHTMLMimeTypesCollection_Release(col2
);
5762 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5764 length
= 0xdeadbeef;
5765 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5766 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5767 ok(!length
, "length = %d\n", length
);
5769 ref
= IHTMLMimeTypesCollection_Release(col
);
5770 ok(!ref
, "ref=%d\n", ref
);
5773 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5774 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5776 BSTR str
= (void*)0xdeadbeef;
5777 IHTMLFrameBase
*fbase
;
5780 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5781 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5783 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5784 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5786 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5788 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5791 IHTMLFrameBase_Release(fbase
);
5794 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5795 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5797 IHTMLFrameBase
*fbase
;
5801 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5802 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5804 str
= name
? a2bstr(name
) : NULL
;
5805 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5806 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5809 _test_framebase_name(line
, elem
, name
);
5810 IHTMLFrameBase_Release(fbase
);
5813 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
5814 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
5816 BSTR str
= (void*)0xdeadbeef;
5817 IHTMLFrameBase
*fbase
;
5820 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5821 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5823 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
5824 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
5826 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
5828 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
5831 IHTMLFrameBase_Release(fbase
);
5834 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5835 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5840 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5841 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5842 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5844 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5846 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5850 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5851 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5857 V_BSTR(&v
) = a2bstr(val
);
5858 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5859 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5863 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5864 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5869 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5870 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5871 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5873 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5875 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5879 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5880 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5886 V_BSTR(&v
) = a2bstr(val
);
5887 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5888 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5892 static void test_framebase(IUnknown
*unk
)
5894 IHTMLFrameBase
*fbase
;
5898 /* get/put scrolling */
5899 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5900 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5902 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5903 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5904 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5908 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5909 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5912 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5913 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5914 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5917 str
= a2bstr("junk");
5918 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5919 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5920 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5923 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5924 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5925 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5928 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5929 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5930 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
5933 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
5934 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
5937 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5938 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5939 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
5941 test_framebase_marginheight(fbase
, NULL
);
5942 set_framebase_marginheight(fbase
, "1px");
5943 test_framebase_marginheight(fbase
, "1");
5945 test_framebase_marginwidth(fbase
, NULL
);
5946 set_framebase_marginwidth(fbase
, "2px");
5947 test_framebase_marginwidth(fbase
, "2");
5949 IHTMLFrameBase_Release(fbase
);
5952 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
5953 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
5958 if(pLCIDToLocaleName
) {
5959 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
5960 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
5961 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
5963 win_skip("LCIDToLocaleName not available, unable to test language string\n");
5964 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
5968 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
5969 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
5971 IHTMLElementCollection
*col
;
5975 hres
= IHTMLTable_get_rows(table
, &col
);
5976 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5977 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
5978 if (hres
!= S_OK
|| col
== NULL
)
5980 hres
= IHTMLElementCollection_get_length(col
, &len
);
5981 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5982 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
5984 IHTMLElementCollection_Release(col
);
5987 static void test_navigator(IHTMLDocument2
*doc
)
5989 IHTMLWindow2
*window
;
5990 IOmNavigator
*navigator
, *navigator2
;
5998 static const WCHAR v40
[] = {'4','.','0'};
6000 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6001 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6003 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6004 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6005 ok(navigator
!= NULL
, "navigator == NULL\n");
6006 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
6008 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6009 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6010 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6011 IOmNavigator_Release(navigator2
);
6013 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6014 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6015 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6016 IOmNavigator_Release(navigator2
);
6018 IHTMLWindow2_Release(window
);
6020 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6021 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6022 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6023 SysFreeString(bstr
);
6026 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6027 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6028 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6029 SysFreeString(bstr
);
6032 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6033 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6034 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6035 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6036 SysFreeString(bstr
);
6039 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6040 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6041 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6042 SysFreeString(bstr
);
6045 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6046 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6047 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6048 SysFreeString(bstr
);
6051 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6052 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6053 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6054 SysFreeString(bstr
);
6056 if (pGetUserDefaultUILanguage
)
6059 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6060 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6061 test_language_string(bstr
, pGetUserDefaultUILanguage());
6062 SysFreeString(bstr
);
6065 win_skip("GetUserDefaultUILanguage not available\n");
6068 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6069 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6070 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6071 SysFreeString(bstr
);
6073 hres
= IOmNavigator_toString(navigator
, NULL
);
6074 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6077 hres
= IOmNavigator_toString(navigator
, &bstr
);
6078 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6079 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6080 SysFreeString(bstr
);
6083 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6084 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6085 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6088 hres
= ObtainUserAgentString(0, buf
, &size
);
6089 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6092 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6093 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6094 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6095 SysFreeString(bstr
);
6097 if(!strncmp(buf
, "Mozilla/", 8)) {
6099 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6100 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6101 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6102 SysFreeString(bstr
);
6104 skip("nonstandard user agent\n");
6108 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6109 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6110 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6111 SysFreeString(bstr
);
6113 test_mime_types_col(navigator
);
6115 ref
= IOmNavigator_Release(navigator
);
6116 ok(!ref
, "navigator should be destroyed here\n");
6119 static void test_screen(IHTMLWindow2
*window
)
6121 IHTMLScreen
*screen
, *screen2
;
6122 IDispatchEx
*dispex
;
6129 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6130 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6131 ok(screen
!= NULL
, "screen == NULL\n");
6134 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6135 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6136 ok(screen2
!= NULL
, "screen == NULL\n");
6137 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6138 IHTMLScreen_Release(screen2
);
6140 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6141 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6142 if(SUCCEEDED(hres
)) {
6143 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
6144 IDispatchEx_Release(dispex
);
6147 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6149 exl
= GetDeviceCaps(hdc
, HORZRES
);
6151 hres
= IHTMLScreen_get_width(screen
, &l
);
6152 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6153 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6155 exl
= GetDeviceCaps(hdc
, VERTRES
);
6157 hres
= IHTMLScreen_get_height(screen
, &l
);
6158 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6159 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6161 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6163 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6164 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6165 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6169 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6172 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6173 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6174 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6177 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6178 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6179 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6181 IHTMLScreen_Release(screen
);
6184 static void test_default_selection(IHTMLDocument2
*doc
)
6186 IHTMLSelectionObject
*selection
;
6187 IHTMLTxtRange
*range
;
6192 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6193 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6195 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
6196 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
6197 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
6200 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6201 IHTMLSelectionObject_Release(selection
);
6202 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6204 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6205 IDispatch_Release(disp
);
6206 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6208 test_range_text(range
, NULL
);
6209 IHTMLTxtRange_Release(range
);
6212 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6214 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6215 IHTMLUniqueName
*unique_name
;
6221 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6223 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6224 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6225 ok(SysStringLen(id
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6227 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6228 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6229 ok(SysStringLen(id2
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6231 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6233 id
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6234 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6235 id2
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6236 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6241 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6242 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6244 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6245 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6246 trace("id %s\n", wine_dbgstr_w(id
));
6248 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6249 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6250 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6251 trace("id %s\n", wine_dbgstr_w(id2
));
6253 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6254 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6255 ok(num
, "num = 0\n");
6257 sprintf(buf
, "ms__id%u", num
);
6258 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6259 trace("num %d\n", num
);
6264 IHTMLUniqueName_Release(unique_name
);
6265 IHTMLDocument3_Release(doc3
);
6268 static void test_doc_elem(IHTMLDocument2
*doc
)
6270 IHTMLDocument2
*doc_node
, *owner_doc
;
6272 IHTMLDocument3
*doc3
;
6276 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6277 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6279 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6280 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6281 ok(!strcmp_wa(bstr
, "[object]"),
6282 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6283 SysFreeString(bstr
);
6285 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6286 IHTMLDocument3_Release(doc3
);
6287 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6289 test_node_name((IUnknown
*)elem
, "HTML");
6290 test_elem_tag((IUnknown
*)elem
, "HTML");
6292 doc_node
= get_doc_node(doc
);
6293 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6294 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6295 IHTMLDocument2_Release(owner_doc
);
6297 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6298 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6299 IHTMLDocument2_Release(doc_node
);
6301 test_elem_client_rect((IUnknown
*)elem
);
6302 test_unique_id(doc
, elem
);
6304 IHTMLElement_Release(elem
);
6307 static void test_default_body(IHTMLBodyElement
*body
)
6314 bstr
= (void*)0xdeadbeef;
6315 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6316 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6317 ok(bstr
== NULL
, "bstr != NULL\n");
6319 l
= elem_get_scroll_height((IUnknown
*)body
);
6320 ok(l
!= -1, "scrollHeight == -1\n");
6321 l
= elem_get_scroll_width((IUnknown
*)body
);
6322 ok(l
!= -1, "scrollWidth == -1\n");
6323 l
= elem_get_scroll_top((IUnknown
*)body
);
6324 ok(!l
, "scrollTop = %d\n", l
);
6325 elem_get_scroll_left((IUnknown
*)body
);
6327 test_elem_dir((IUnknown
*)body
, NULL
);
6328 set_elem_dir((IUnknown
*)body
, "ltr");
6330 /* get_text tests */
6331 hres
= IHTMLBodyElement_get_text(body
, &v
);
6332 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6333 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6334 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6336 /* get_text - Invalid Text */
6338 V_BSTR(&v
) = a2bstr("Invalid");
6339 hres
= IHTMLBodyElement_put_text(body
, v
);
6340 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6344 hres
= IHTMLBodyElement_get_text(body
, &v
);
6345 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6346 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6347 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6350 /* get_text - Valid Text */
6352 V_BSTR(&v
) = a2bstr("#FF0000");
6353 hres
= IHTMLBodyElement_put_text(body
, v
);
6354 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6358 hres
= IHTMLBodyElement_get_text(body
, &v
);
6359 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6360 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6361 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6365 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6366 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6371 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6372 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6373 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6377 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6378 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6380 BSTR str
= a2bstr(val
);
6383 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6384 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6387 _test_body_scroll(line
, body
, val
);
6390 static void test_body_funs(IHTMLBodyElement
*body
)
6392 VARIANT vbg
, vDefaultbg
;
6395 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6396 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6397 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6398 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6400 V_VT(&vbg
) = VT_BSTR
;
6401 V_BSTR(&vbg
) = a2bstr("red");
6402 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6403 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6406 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6407 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6408 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6409 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6412 /* Restore Originial */
6413 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6414 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6415 VariantClear(&vDefaultbg
);
6417 test_body_scroll(body
, NULL
);
6418 set_body_scroll(body
, "yes");
6419 set_body_scroll(body
, "no");
6420 set_body_scroll(body
, "auto");
6423 static void test_history(IHTMLWindow2
*window
)
6425 IOmHistory
*history
, *history2
;
6429 hres
= IHTMLWindow2_get_history(window
, &history
);
6430 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6431 ok(history
!= NULL
, "history = NULL\n");
6433 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
6436 hres
= IHTMLWindow2_get_history(window
, &history2
);
6437 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6438 ok(history2
!= NULL
, "history2 = NULL\n");
6439 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6441 IOmHistory_Release(history2
);
6442 IOmHistory_Release(history
);
6445 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6449 IHTMLXMLHttpRequestFactory
*factory
;
6450 IHTMLXMLHttpRequest
*xml
;
6452 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6453 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6454 ok(V_VT(&var
) == VT_DISPATCH
, "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6457 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6458 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6459 ok(factory
!= NULL
, "factory == NULL\n");
6462 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6463 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6464 ok(xml
!= NULL
, "xml == NULL\n");
6465 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, "[object]");
6467 IHTMLXMLHttpRequest_Release(xml
);
6468 IHTMLXMLHttpRequestFactory_Release(factory
);
6472 static void test_window(IHTMLDocument2
*doc
)
6474 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6475 IHTMLWindow5
*window5
;
6476 IHTMLDocument2
*doc2
= NULL
;
6483 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6484 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6485 test_ifaces((IUnknown
*)window
, window_iids
);
6486 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6488 IUnknown_Release(unk
);
6490 win_skip("IID_ITravelLogClient not supported\n");
6492 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
6494 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6495 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6496 ok(doc2
!= NULL
, "doc2 == NULL\n");
6498 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6499 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
6500 test_class_info((IUnknown
*)doc2
);
6502 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6503 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
6504 test_class_info((IUnknown
*)doc
);
6506 unk
= (void*)0xdeadbeef;
6507 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6508 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6509 ok(!unk
, "unk = %p\n", unk
);
6511 IHTMLDocument2_Release(doc2
);
6513 hres
= IHTMLWindow2_get_window(window
, &window2
);
6514 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6515 ok(window2
!= NULL
, "window2 == NULL\n");
6517 hres
= IHTMLWindow2_get_self(window
, &self
);
6518 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6519 ok(window2
!= NULL
, "self == NULL\n");
6521 ok(self
== window2
, "self != window2\n");
6523 IHTMLWindow2_Release(window2
);
6526 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6527 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6528 ok(disp
== (void*)window
, "disp != window\n");
6529 IDispatch_Release(disp
);
6531 hres
= IHTMLWindow2_toString(window
, NULL
);
6532 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6535 hres
= IHTMLWindow2_toString(window
, &str
);
6536 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6537 ok(!strcmp_wa(str
, "[object]") ||
6538 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6541 V_VT(&v
) = VT_ERROR
;
6542 hres
= IHTMLWindow2_get_opener(window
, &v
);
6543 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6544 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6547 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6548 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6549 ok(parent
!= NULL
, "parent == NULL\n");
6550 ok(parent
== self
, "parent != window\n");
6551 IHTMLWindow2_Release(parent
);
6552 IHTMLWindow2_Release(self
);
6554 test_window_name(window
, NULL
);
6555 set_window_name(window
, "test");
6556 test_window_length(window
, 0);
6557 test_screen(window
);
6558 test_window_status(window
);
6559 set_window_status(window
, "Test!");
6560 test_history(window
);
6562 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6563 if(SUCCEEDED(hres
)) {
6564 ok(window5
!= NULL
, "window5 == NULL\n");
6565 test_xmlhttprequest(window5
);
6566 IHTMLWindow5_Release(window5
);
6568 win_skip("IHTMLWindow5 not supported!\n");
6571 IHTMLWindow2_Release(window
);
6574 static void test_dom_implementation(IHTMLDocument2
*doc
)
6576 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6577 IHTMLDOMImplementation
*dom_implementation
;
6583 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6584 IHTMLDocument5_Release(doc5
);
6585 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6586 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6588 str
= a2bstr("test");
6590 V_BSTR(&v
) = a2bstr("1.0");
6592 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6595 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6596 ok(!b
, "hasFeature returned %x\n", b
);
6598 IHTMLDOMImplementation_Release(dom_implementation
);
6601 static void test_xhr(IHTMLDocument2
*doc
)
6603 IHTMLWindow2
*window
;
6604 IDispatchEx
*dispex
;
6609 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6610 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6612 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6613 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6615 str
= a2bstr("XMLHttpRequest");
6616 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6617 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6620 IHTMLWindow2_Release(window
);
6623 static void test_defaults(IHTMLDocument2
*doc
)
6625 IHTMLStyleSheetsCollection
*stylesheetcol
;
6626 IHTMLCurrentStyle
*cstyle
;
6627 IHTMLBodyElement
*body
;
6628 IHTMLElement2
*elem2
;
6636 IHTMLElementCollection
*collection
;
6638 elem
= doc_get_body(doc
);
6640 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6641 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6643 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6644 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6647 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6648 IHTMLElementCollection_Release(collection
);
6651 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6652 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6654 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6655 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6658 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6659 IHTMLElementCollection_Release(collection
);
6662 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6663 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6665 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6666 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6669 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6670 IHTMLElementCollection_Release(collection
);
6673 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6674 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6676 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6677 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6680 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6681 IHTMLElementCollection_Release(collection
);
6684 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6685 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6687 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6688 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6691 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6692 IHTMLElementCollection_Release(collection
);
6697 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6698 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6699 test_default_body(body
);
6700 test_body_funs(body
);
6701 IHTMLBodyElement_Release(body
);
6703 test_elem_istextedit(elem
, VARIANT_TRUE
);
6705 hres
= IHTMLElement_get_style(elem
, &style
);
6706 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6708 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
6709 test_ifaces((IUnknown
*)style
, style_iids
);
6710 IHTMLStyle_Release(style
);
6713 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6714 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6715 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6719 test_compatmode(doc
, "BackCompat");
6721 test_navigator(doc
);
6722 test_plugins_col(doc
);
6724 elem2
= get_elem2_iface((IUnknown
*)elem
);
6725 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6726 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6727 if(SUCCEEDED(hres
)) {
6730 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
6731 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6733 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6735 IUnknown_Release(unk
);
6738 /*IE6 doesn't have interface */
6739 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6742 IHTMLCurrentStyle_Release(cstyle
);
6744 IHTMLElement2_Release(elem2
);
6746 IHTMLElement_Release(elem
);
6748 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6749 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6752 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6753 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6754 ok(l
== 0, "length = %d\n", l
);
6756 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6758 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6759 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6761 str
= a2bstr("xxx");
6763 V_VT(&v
) = VT_EMPTY
;
6764 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6765 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
6766 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
6769 str
= a2bstr("respectvisibilityindesign");
6772 V_BOOL(&v
) = VARIANT_TRUE
;
6773 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6774 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
6777 test_default_selection(doc
);
6778 test_doc_title(doc
, "");
6779 test_dom_implementation(doc
);
6782 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6783 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6785 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6789 str
= (void*)0xdeadbeef;
6790 hres
= IHTMLButtonElement_get_name(button
, &str
);
6791 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6793 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
6795 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6797 IHTMLButtonElement_Release(button
);
6800 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
6801 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6803 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6804 BSTR str
= a2bstr(name
);
6807 hres
= IHTMLButtonElement_put_name(button
, str
);
6808 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6810 IHTMLButtonElement_Release(button
);
6812 _test_button_name(line
, elem
, name
);
6815 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
6816 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
6818 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6819 VARIANT_BOOL disabled
= 100;
6822 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
6823 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
6824 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
6825 IHTMLButtonElement_Release(button
);
6827 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6830 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6831 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6833 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6836 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6837 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6838 IHTMLButtonElement_Release(button
);
6840 _test_button_get_disabled(line
, elem
, b
);
6843 static void test_button_elem(IHTMLElement
*elem
)
6845 test_button_name(elem
, NULL
);
6846 set_button_name(elem
, "button name");
6848 test_elem_istextedit(elem
, VARIANT_TRUE
);
6851 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6852 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6853 IHTMLTableRow
*row
, LONG len
, const char *id
)
6855 IHTMLElementCollection
*col
;
6861 hres
= IHTMLTableRow_get_cells(row
, &col
);
6862 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6863 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6865 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6866 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6867 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6869 V_VT(&var
) = VT_BSTR
;
6870 V_BSTR(&var
) = a2bstr(id
);
6871 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6872 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6873 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6876 IDispatch_Release(disp
);
6877 IHTMLElementCollection_Release(col
);
6880 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6884 IHTMLTableCell
*cell
;
6886 hres
= IHTMLTableRow_deleteCell(row
, 0);
6887 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6888 test_tr_possess(elem
, row
, 1, "td2");
6890 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6891 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6892 ok(disp
!= NULL
, "disp == NULL\n");
6893 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6894 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6895 ok(cell
!= NULL
, "cell == NULL\n");
6896 if (SUCCEEDED(hres
))
6897 IHTMLTableCell_Release(cell
);
6898 test_tr_possess(elem
, row
, 2, "td2");
6899 IDispatch_Release(disp
);
6902 static void test_tr_elem(IHTMLElement
*elem
)
6904 IHTMLElementCollection
*col
;
6909 VARIANT vbg
, vDefaultbg
;
6911 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6913 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6914 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6919 hres
= IHTMLTableRow_get_cells(row
, &col
);
6920 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6921 ok(col
!= NULL
, "get_cells returned NULL\n");
6923 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6924 IHTMLElementCollection_Release(col
);
6926 bstr
= a2bstr("left");
6927 hres
= IHTMLTableRow_put_align(row
, bstr
);
6928 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6929 SysFreeString(bstr
);
6932 hres
= IHTMLTableRow_get_align(row
, &bstr
);
6933 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6934 ok(bstr
!= NULL
, "get_align returned NULL\n");
6935 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6936 SysFreeString(bstr
);
6938 bstr
= a2bstr("top");
6939 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
6940 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
6941 SysFreeString(bstr
);
6944 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
6945 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
6946 ok(bstr
!= NULL
, "get_valign returned NULL\n");
6947 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
6948 SysFreeString(bstr
);
6951 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
6952 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6953 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
6956 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
6957 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
6958 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
6960 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
6961 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6962 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6963 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6965 V_VT(&vbg
) = VT_BSTR
;
6966 V_BSTR(&vbg
) = a2bstr("red");
6967 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6968 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6971 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6972 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6973 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6974 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6978 V_I4(&vbg
) = 0xff0000;
6979 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6980 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6983 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6984 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6985 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6986 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6989 /* Restore Originial */
6990 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
6991 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6992 VariantClear(&vDefaultbg
);
6994 test_tr_modify(elem
, row
);
6996 IHTMLTableRow_Release(row
);
6999 static void test_td_elem(IHTMLElement
*elem
)
7001 IHTMLTableCell
*cell
;
7005 VARIANT vbg
, vDefaultbg
;
7007 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7008 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7013 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7014 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7015 ok(lval
== 1, "Expected 1, got %d\n", lval
);
7017 str
= a2bstr("left");
7018 hres
= IHTMLTableCell_put_align(cell
, str
);
7019 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7023 hres
= IHTMLTableCell_get_align(cell
, &str
);
7024 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7025 ok(str
!= NULL
, "str is NULL\n");
7026 if (str
!= NULL
&& hres
== S_OK
) {
7027 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7031 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7032 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7033 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7034 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7036 V_VT(&vbg
) = VT_BSTR
;
7037 V_BSTR(&vbg
) = a2bstr("red");
7038 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7039 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7042 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7043 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7044 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7045 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7049 V_I4(&vbg
) = 0xff0000;
7050 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7051 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7054 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7055 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7056 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7057 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7060 /* Restore Originial */
7061 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7062 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7063 VariantClear(&vDefaultbg
);
7065 IHTMLTableCell_Release(cell
);
7068 static void test_label_elem(IHTMLElement
*elem
)
7070 IHTMLLabelElement
*label
;
7074 label
= get_label_iface((IUnknown
*)elem
);
7077 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7078 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7079 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7083 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7084 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7087 str
= (void*)0xdeadbeef;
7088 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7089 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7090 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7092 str
= a2bstr("abc");
7093 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7094 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7098 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7099 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7100 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7103 IHTMLLabelElement_Release(label
);
7106 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7107 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7112 V_VT(&v
) = VT_ERROR
;
7113 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7114 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7115 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7117 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7119 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7123 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7124 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7129 V_VT(&v
) = VT_ERROR
;
7130 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7131 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7132 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7134 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7136 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7140 static void test_table_modify(IHTMLTable
*table
)
7147 test_table_length(table
, 2);
7149 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7150 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7151 ok(disp
!= NULL
, "disp == NULL\n");
7152 test_table_length(table
, 3);
7153 if (hres
!= S_OK
|| disp
== NULL
)
7156 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7157 IDispatch_Release(disp
);
7159 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7160 ok(row
!= NULL
, "row == NULL\n");
7163 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7164 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7165 ok(index
== 0, "index = %d, expected 0\n", index
);
7167 IHTMLTableRow_Release(row
);
7169 hres
= IHTMLTable_deleteRow(table
, 0);
7170 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7171 test_table_length(table
, 2);
7174 static void test_table_elem(IHTMLElement
*elem
)
7176 IHTMLElementCollection
*col
;
7178 IHTMLTable3
*table3
;
7183 VARIANT vbg
, vDefaultbg
;
7185 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7186 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7187 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7189 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7190 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7194 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7195 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7200 hres
= IHTMLTable_get_rows(table
, &col
);
7201 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7202 ok(col
!= NULL
, "get_rows returned NULL\n");
7204 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7205 IHTMLElementCollection_Release(col
);
7207 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7209 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7210 test_elem_tag((IUnknown
*)node
, "TABLE");
7211 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7212 IHTMLDOMNode_Release(node
);
7214 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7215 test_elem_tag((IUnknown
*)node
, "TABLE");
7216 test_elem_all((IUnknown
*)node
, NULL
, 0);
7217 IHTMLDOMNode_Release(node
);
7220 hres
= IHTMLTable_get_tBodies(table
, &col
);
7221 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7222 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7224 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7225 IHTMLElementCollection_Release(col
);
7227 test_table_cell_spacing(table
, NULL
);
7231 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7232 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7233 test_table_cell_spacing(table
, "10");
7236 V_BSTR(&v
) = a2bstr("11");
7237 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7238 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7239 test_table_cell_spacing(table
, "11");
7242 test_table_cell_padding(table
, NULL
);
7246 hres
= IHTMLTable_put_cellPadding(table
, v
);
7247 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7248 test_table_cell_padding(table
, "10");
7251 V_BSTR(&v
) = a2bstr("11");
7252 hres
= IHTMLTable_put_cellPadding(table
, v
);
7253 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7254 test_table_cell_padding(table
, "11");
7259 hres
= IHTMLTable_put_cellPadding(table
, v
);
7260 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7261 test_table_cell_padding(table
, "5");
7263 bstr
= a2bstr("left");
7264 hres
= IHTMLTable_put_align(table
, bstr
);
7265 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7266 SysFreeString(bstr
);
7269 hres
= IHTMLTable_get_align(table
, &bstr
);
7270 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7271 ok(bstr
!= NULL
, "get_align returned NULL\n");
7272 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7273 SysFreeString(bstr
);
7275 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7276 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7277 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7278 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7280 V_VT(&vbg
) = VT_BSTR
;
7281 V_BSTR(&vbg
) = a2bstr("red");
7282 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7283 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7286 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7287 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7288 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7289 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7293 V_I4(&vbg
) = 0xff0000;
7294 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7295 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7298 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7299 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7300 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7301 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7304 /* Restore Originial */
7305 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7306 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7307 VariantClear(&vDefaultbg
);
7310 V_BSTR(&v
) = a2bstr("11");
7311 hres
= IHTMLTable_put_width(table
, v
);
7312 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7314 hres
= IHTMLTable_get_width(table
, &v
);
7315 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7316 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7320 V_BSTR(&v
) = a2bstr("11.9");
7321 hres
= IHTMLTable_put_width(table
, v
);
7322 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7324 hres
= IHTMLTable_get_width(table
, &v
);
7325 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7326 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7330 V_BSTR(&v
) = a2bstr("40.2%");
7331 hres
= IHTMLTable_put_width(table
, v
);
7332 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7334 hres
= IHTMLTable_get_width(table
, &v
);
7335 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7336 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7341 hres
= IHTMLTable_put_width(table
, v
);
7342 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7343 hres
= IHTMLTable_get_width(table
, &v
);
7344 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7345 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7350 hres
= IHTMLTable_put_width(table
, v
);
7351 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7352 hres
= IHTMLTable_get_width(table
, &v
);
7353 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7354 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7357 bstr
= a2bstr("box");
7358 hres
= IHTMLTable_put_frame(table
, bstr
);
7359 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7360 SysFreeString(bstr
);
7361 hres
= IHTMLTable_get_frame(table
, &bstr
);
7362 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7363 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7364 SysFreeString(bstr
);
7366 test_table_modify(table
);
7367 bstr
= a2bstr("summary");
7368 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7369 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7370 SysFreeString(bstr
);
7372 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7373 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7374 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7375 SysFreeString(bstr
);
7377 IHTMLTable3_Release(table3
);
7378 IHTMLTable_Release(table
);
7381 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7390 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7391 SafeArrayAccessData(sa
, (void**)&var
);
7392 V_VT(var
) = VT_BSTR
;
7393 V_BSTR(var
) = a2bstr(text
);
7394 SafeArrayUnaccessData(sa
);
7397 hres
= IHTMLDocument2_writeln(doc
, sa
);
7399 hres
= IHTMLDocument2_write(doc
, sa
);
7400 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7402 SafeArrayDestroy(sa
);
7405 static void doc_complex_write(IHTMLDocument2
*doc
)
7407 SAFEARRAYBOUND dim
= {5, 0};
7412 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7413 SafeArrayAccessData(sa
, (void**)&args
);
7415 V_VT(args
) = VT_BSTR
;
7416 V_BSTR(args
) = a2bstr("<body i4val=\"");
7417 V_VT(args
+1) = VT_I4
;
7419 V_VT(args
+2) = VT_BSTR
;
7420 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7421 V_VT(args
+3) = VT_R8
;
7422 V_R8(args
+3) = 3.14;
7423 V_VT(args
+4) = VT_BSTR
;
7424 V_BSTR(args
+4) = a2bstr("\">");
7425 SafeArrayUnaccessData(sa
);
7427 hres
= IHTMLDocument2_write(doc
, sa
);
7428 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7430 SafeArrayDestroy(sa
);
7433 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7435 IHTMLDocument2
*window_doc
, *elem_doc
;
7436 IHTMLFrameElement3
*frame_elem3
;
7437 IHTMLWindow2
*content_window
;
7440 content_window
= get_frame_content_window(frame_elem
);
7441 test_ifaces((IUnknown
*)content_window
, window_iids
);
7442 window_doc
= get_window_doc(content_window
);
7443 IHTMLWindow2_Release(content_window
);
7445 elem_doc
= get_elem_doc(frame_elem
);
7446 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7449 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7450 if(SUCCEEDED(hres
)) {
7451 IDispatch
*disp
= NULL
;
7453 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7454 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7455 ok(disp
!= NULL
, "contentDocument == NULL\n");
7456 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7458 IDispatch_Release(disp
);
7459 IHTMLFrameElement3_Release(frame_elem3
);
7461 win_skip("IHTMLFrameElement3 not supported\n");
7465 IHTMLDocument2_Release(elem_doc
);
7466 IHTMLDocument2_Release(window_doc
);
7469 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7470 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7472 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7476 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7477 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7478 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7480 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7482 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7484 IHTMLIFrameElement2_Release(iframe
);
7487 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7488 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7490 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7495 V_BSTR(&v
) = a2bstr(val
);
7496 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7497 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7499 IHTMLIFrameElement2_Release(iframe
);
7502 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7503 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7505 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7509 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7510 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7511 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7513 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7515 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7517 IHTMLIFrameElement2_Release(iframe
);
7520 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7521 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7523 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7528 V_BSTR(&v
) = a2bstr(val
);
7529 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7530 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7532 IHTMLIFrameElement2_Release(iframe
);
7535 static void test_iframe_elem(IHTMLElement
*elem
)
7537 IHTMLDocument2
*content_doc
, *owner_doc
;
7538 IHTMLIFrameElement3
*iframe3
;
7539 IHTMLElementCollection
*col
;
7540 IHTMLWindow2
*content_window
;
7547 static const elem_type_t all_types
[] = {
7555 test_frame_doc((IUnknown
*)elem
, TRUE
);
7556 test_framebase((IUnknown
*)elem
);
7558 content_window
= get_frame_content_window((IUnknown
*)elem
);
7559 test_ifaces((IUnknown
*)content_window
, window_iids
);
7560 test_window_length(content_window
, 0);
7562 content_doc
= get_window_doc(content_window
);
7563 IHTMLWindow2_Release(content_window
);
7565 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7566 if(SUCCEEDED(hres
)) {
7567 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7568 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7569 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7570 IDispatch_Release(disp
);
7572 IHTMLIFrameElement3_Release(iframe3
);
7574 win_skip("IHTMLIFrameElement3 not supported\n");
7577 test_iframe_height(elem
, NULL
);
7578 set_iframe_height(elem
, "100px");
7579 set_iframe_height(elem
, "50%");
7580 test_iframe_height(elem
, "50%");
7582 test_iframe_width(elem
, NULL
);
7583 set_iframe_width(elem
, "150px");
7584 set_iframe_width(elem
, "70%");
7585 test_iframe_width(elem
, "70%");
7586 test_framebase_src(elem
, "about:blank");
7588 str
= a2bstr("text/html");
7589 V_VT(&errv
) = VT_ERROR
;
7591 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7593 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7594 ok(disp
!= NULL
, "disp == NULL\n");
7595 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7596 IDispatch_Release(disp
);
7598 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7599 doc_complex_write(content_doc
);
7600 doc_write(content_doc
, TRUE
, "<br />");
7601 doc_write(content_doc
, TRUE
, "</html>");
7603 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7604 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7605 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7606 IHTMLElementCollection_Release(col
);
7608 body
= doc_get_body(content_doc
);
7609 test_elem_attr(body
, "i4val", "4");
7610 test_elem_attr(body
, "r8val", "3.14");
7611 IHTMLElement_Release(body
);
7613 hres
= IHTMLDocument2_close(content_doc
);
7614 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7616 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7617 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7619 IHTMLDocument2_Release(content_doc
);
7622 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7623 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7628 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7629 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7630 todo_wine_if(is_todo
) {
7632 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7634 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7640 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
7641 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7643 BSTR str
= a2bstr(csstext
);
7646 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7647 todo_wine_if(is_todo
)
7648 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7652 static void test_stylesheet(IDispatch
*disp
)
7654 IHTMLStyleSheetRulesCollection
*col
= NULL
;
7655 IHTMLStyleSheet
*stylesheet
;
7659 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
7661 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
7662 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
7664 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
7665 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
7666 ok(col
!= NULL
, "col == NULL\n");
7668 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
7669 IHTMLStyleSheetRulesCollection_Release(col
);
7671 href
= (void*)0xdeadbeef;
7672 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
7673 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
7674 ok(href
== NULL
, "got href != NULL\n");
7675 SysFreeString(href
);
7677 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
7678 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
7679 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
7680 set_stylesheet_csstext(stylesheet
, "", FALSE
);
7681 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
7682 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
7683 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
7685 IHTMLStyleSheet_Release(stylesheet
);
7688 static void test_stylesheets(IHTMLDocument2
*doc
)
7690 IHTMLStyleSheetsCollection
*col
= NULL
;
7695 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
7696 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
7697 ok(col
!= NULL
, "col == NULL\n");
7699 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
7701 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
7702 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7703 ok(len
== 1, "len=%d\n", len
);
7709 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7710 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
7711 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
7712 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
7713 test_stylesheet(V_DISPATCH(&res
));
7720 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7721 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7722 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
7725 IHTMLStyleSheetsCollection_Release(col
);
7728 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
7730 IDispatchEx
*dispex
;
7732 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
7740 static const WCHAR w0
[] = {'0',0};
7741 static const WCHAR w100
[] = {'1','0','0',0};
7743 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
7744 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
7746 bstr
= SysAllocString(w0
);
7747 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7748 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7749 SysFreeString(bstr
);
7752 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
7753 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
7754 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
7755 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
7756 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
7757 type
= get_node_type((IUnknown
*)node
);
7758 ok(type
== 3, "type=%d\n", type
);
7759 IHTMLDOMNode_Release(node
);
7762 bstr
= SysAllocString(w100
);
7763 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7764 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
7765 SysFreeString(bstr
);
7767 IDispatchEx_Release(dispex
);
7770 static void test_enum_children(IUnknown
*unk
, unsigned len
)
7772 IEnumVARIANT
*enum_var
;
7777 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
7778 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
7780 for(i
=0; i
<len
; i
++) {
7782 V_VT(&v
) = VT_ERROR
;
7783 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
7784 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
7786 ok(fetched
== 1, "fetched = %d\n", fetched
);
7787 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
7788 IDispatch_Release(V_DISPATCH(&v
));
7791 fetched
= 0xdeadbeef;
7793 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
7794 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
7795 ok(fetched
== 0, "fetched = %d\n", fetched
);
7796 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7798 hres
= IEnumVARIANT_Reset(enum_var
);
7799 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7801 fetched
= 0xdeadbeef;
7803 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
7804 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
7805 ok(fetched
== 0, "fetched = %d\n", fetched
);
7806 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7808 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
7809 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
7811 hres
= IEnumVARIANT_Reset(enum_var
);
7812 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7814 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
7815 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
7817 IEnumVARIANT_Release(enum_var
);
7820 static void test_elems(IHTMLDocument2
*doc
)
7822 IHTMLElementCollection
*col
;
7823 IHTMLDOMChildrenCollection
*child_col
;
7824 IHTMLElement
*elem
, *elem2
, *elem3
;
7825 IHTMLDOMNode
*node
, *node2
;
7826 IHTMLWindow2
*window
;
7830 IHTMLElementCollection
*collection
;
7831 IHTMLDocument3
*doc3
;
7834 static const elem_type_t all_types
[] = {
7867 static const elem_type_t item_types
[] = {
7873 hres
= IHTMLDocument2_get_all(doc
, &col
);
7874 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7875 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7876 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
7878 elem
= get_elem_col_item_idx(col
, 0);
7879 test_elem_source_index(elem
, 0);
7880 IHTMLElement_Release(elem
);
7882 elem
= get_elem_col_item_idx(col
, 3);
7883 test_elem_source_index(elem
, 3);
7884 IHTMLElement_Release(elem
);
7886 IHTMLElementCollection_Release(col
);
7888 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7889 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
7892 static const elem_type_t images_types
[] = {ET_IMG
};
7893 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7895 IHTMLElementCollection_Release(collection
);
7898 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7899 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
7902 static const elem_type_t images_types
[] = {ET_A
};
7903 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7905 IHTMLElementCollection_Release(collection
);
7908 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7909 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7912 static const elem_type_t anchor_types
[] = {ET_A
};
7913 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7915 IHTMLElementCollection_Release(collection
);
7918 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7919 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7921 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7922 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7923 IHTMLElementCollection_Release(collection
);
7926 test_plugins_col(doc
);
7928 elem
= get_doc_elem(doc
);
7929 test_elem_istextedit(elem
, VARIANT_FALSE
);
7930 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
7931 IHTMLElement_Release(elem
);
7933 get_elem_by_id(doc
, "xxx", FALSE
);
7934 elem
= get_doc_elem_by_id(doc
, "xxx");
7935 ok(!elem
, "elem != NULL\n");
7937 elem
= get_doc_elem_by_id(doc
, "s");
7938 ok(elem
!= NULL
, "elem == NULL\n");
7940 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
7941 test_elem_attr(elem
, "xxx", NULL
);
7942 test_elem_attr(elem
, "id", "s");
7943 test_elem_class((IUnknown
*)elem
, NULL
);
7944 test_elem_set_class((IUnknown
*)elem
, "cl");
7945 test_elem_set_class((IUnknown
*)elem
, NULL
);
7946 test_elem_tabindex((IUnknown
*)elem
, 0);
7947 test_elem_set_tabindex((IUnknown
*)elem
, 1);
7948 test_elem_filters((IUnknown
*)elem
);
7949 test_elem_istextedit(elem
, VARIANT_FALSE
);
7951 node
= test_node_get_parent((IUnknown
*)elem
);
7952 ok(node
!= NULL
, "node == NULL\n");
7953 test_node_name((IUnknown
*)node
, "BODY");
7954 node2
= test_node_get_parent((IUnknown
*)node
);
7955 IHTMLDOMNode_Release(node
);
7956 ok(node2
!= NULL
, "node == NULL\n");
7957 test_node_name((IUnknown
*)node2
, "HTML");
7958 node
= test_node_get_parent((IUnknown
*)node2
);
7959 IHTMLDOMNode_Release(node2
);
7960 ok(node
!= NULL
, "node == NULL\n");
7963 test_node_name((IUnknown
*)node
, "#document");
7964 type
= get_node_type((IUnknown
*)node
);
7965 ok(type
== 9, "type=%d, expected 9\n", type
);
7966 node2
= test_node_get_parent((IUnknown
*)node
);
7967 IHTMLDOMNode_Release(node
);
7968 ok(node2
== NULL
, "node != NULL\n");
7971 elem2
= test_elem_get_parent((IUnknown
*)elem
);
7972 ok(elem2
!= NULL
, "elem2 == NULL\n");
7973 test_node_name((IUnknown
*)elem2
, "BODY");
7975 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
7976 ok(elem3
!= NULL
, "elem3 == NULL\n");
7977 test_node_name((IUnknown
*)elem3
, "HTML");
7979 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
7980 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
7981 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
7982 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
7983 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
7984 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
7985 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
7986 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
7987 IHTMLElement_Release(elem2
);
7989 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
7990 ok(elem2
== NULL
, "elem2 != NULL\n");
7991 test_elem_source_index(elem3
, 0);
7992 IHTMLElement_Release(elem3
);
7994 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
7995 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
7996 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
7998 test_elem_innertext(elem
, "opt1opt2");
8000 IHTMLElement_Release(elem
);
8003 elem
= get_elem_by_id(doc
, "s", TRUE
);
8005 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8006 IHTMLDocument2
*doc_node
, *elem_doc
;
8008 test_select_elem(select
);
8010 test_elem_istextedit(elem
, VARIANT_FALSE
);
8011 test_elem_title((IUnknown
*)select
, NULL
);
8012 test_elem_set_title((IUnknown
*)select
, "Title");
8013 test_elem_title((IUnknown
*)select
, "Title");
8014 test_elem_offset((IUnknown
*)select
, "BODY");
8015 test_elem_bounding_client_rect((IUnknown
*)select
);
8017 node
= get_first_child((IUnknown
*)select
);
8018 ok(node
!= NULL
, "node == NULL\n");
8020 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8021 IHTMLDOMNode_Release(node
);
8024 type
= get_node_type((IUnknown
*)select
);
8025 ok(type
== 1, "type=%d\n", type
);
8027 IHTMLSelectElement_Release(select
);
8029 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8031 doc_node
= get_doc_node(doc
);
8032 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8033 IHTMLDocument2_Release(doc_node
);
8034 IHTMLDocument2_Release(elem_doc
);
8036 IHTMLElement_Release(elem
);
8039 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8041 IHTMLScriptElement
*script
;
8044 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8045 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8047 test_elem_language(elem
, NULL
);
8048 test_elem_istextedit(elem
, VARIANT_FALSE
);
8054 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8055 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8056 hres
= IHTMLScriptElement_get_type(script
, &type
);
8057 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8058 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8060 type
= a2bstr("text/javascript");
8061 hres
= IHTMLScriptElement_put_type (script
, type
);
8062 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8063 SysFreeString(type
);
8064 hres
= IHTMLScriptElement_get_type(script
, &type
);
8065 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8066 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8067 SysFreeString(type
);
8069 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8072 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8073 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8075 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8076 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8077 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8079 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8080 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8082 str
= (BSTR
)0xdeadbeef;
8083 hres
= IHTMLScriptElement_get_src(script
, &str
);
8084 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8085 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8088 IHTMLScriptElement_Release(script
);
8090 set_elem_language(elem
, "vbscript");
8091 set_elem_language(elem
, "xxx");
8094 elem
= get_elem_by_id(doc
, "in", TRUE
);
8096 IHTMLInputElement
*input
;
8098 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8099 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8101 test_elem_id((IUnknown
*)elem
, "in");
8102 test_elem_put_id((IUnknown
*)elem
, "newin");
8103 test_input_get_disabled(input
, VARIANT_FALSE
);
8104 test_input_set_disabled(input
, VARIANT_TRUE
);
8105 test_input_set_disabled(input
, VARIANT_FALSE
);
8106 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8107 test_input_get_disabled(input
, VARIANT_TRUE
);
8108 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8109 test_input_get_disabled(input
, VARIANT_FALSE
);
8110 test_elem_client_size((IUnknown
*)elem
);
8111 test_input_type(input
, "text");
8112 test_elem_istextedit(elem
, VARIANT_TRUE
);
8114 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8115 test_node_put_value_str((IUnknown
*)elem
, "test");
8116 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8117 test_input_value((IUnknown
*)elem
, NULL
);
8118 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8119 test_input_put_value((IUnknown
*)elem
, "test");
8120 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8121 test_elem_class((IUnknown
*)elem
, "testclass");
8122 test_elem_tabindex((IUnknown
*)elem
, 2);
8123 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8124 test_elem_title((IUnknown
*)elem
, "test title");
8126 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8127 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8128 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8130 test_input_get_checked(input
, VARIANT_FALSE
);
8131 test_input_set_checked(input
, VARIANT_TRUE
);
8132 test_input_set_checked(input
, VARIANT_FALSE
);
8134 test_input_maxlength(input
, 0x7fffffff);
8135 test_input_set_maxlength(input
, 30);
8137 test_input_name(input
, NULL
);
8138 test_input_set_name(input
, "test");
8140 test_input_src(input
, NULL
);
8141 test_input_set_src(input
, "about:blank");
8143 test_input_set_size(input
, 15, S_OK
);
8144 test_input_get_size(input
, 15);
8145 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8146 test_input_get_size(input
, 15);
8147 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8148 test_input_get_size(input
, 15);
8150 test_input_readOnly(input
, VARIANT_TRUE
);
8151 test_input_readOnly(input
, VARIANT_FALSE
);
8153 test_elem_lang(elem
, NULL
);
8154 set_elem_lang(elem
, "en-us");
8156 IHTMLInputElement_Release(input
);
8157 IHTMLElement_Release(elem
);
8160 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8162 test_img_align((IUnknown
*)elem
, "left");
8163 test_img_name((IUnknown
*)elem
, "WineImg");
8164 test_img_src((IUnknown
*)elem
, "", NULL
);
8165 test_img_set_src((IUnknown
*)elem
, "about:blank");
8166 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8167 test_img_alt((IUnknown
*)elem
, NULL
);
8168 test_img_set_alt((IUnknown
*)elem
, "alt test");
8169 test_img_name((IUnknown
*)elem
, "WineImg");
8170 test_img_complete(elem
, VARIANT_FALSE
);
8171 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8172 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8173 IHTMLElement_Release(elem
);
8176 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8178 test_dynamic_properties(elem
);
8179 test_attr_collection(elem
);
8180 test_contenteditable((IUnknown
*)elem
);
8181 IHTMLElement_Release(elem
);
8184 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8186 test_style_media((IUnknown
*)elem
, NULL
);
8187 test_style_put_media((IUnknown
*)elem
, "screen");
8188 test_style_type((IUnknown
*)elem
, NULL
);
8189 test_style_put_type((IUnknown
*)elem
, "text/css");
8190 IHTMLElement_Release(elem
);
8193 elem
= get_doc_elem_by_id(doc
, "tbl");
8194 ok(elem
!= NULL
, "elem == NULL\n");
8196 test_table_elem(elem
);
8197 IHTMLElement_Release(elem
);
8200 elem
= get_doc_elem_by_id(doc
, "labelid");
8201 ok(elem
!= NULL
, "elem == NULL\n");
8203 test_label_elem(elem
);
8204 IHTMLElement_Release(elem
);
8207 elem
= get_doc_elem_by_id(doc
, "td2");
8208 ok(elem
!= NULL
, "elem == NULL\n");
8211 IHTMLElement_Release(elem
);
8214 elem
= get_doc_elem_by_id(doc
, "row2");
8215 ok(elem
!= NULL
, "elem == NULL\n");
8218 IHTMLElement_Release(elem
);
8221 elem
= get_doc_elem_by_id(doc
, "ifr");
8222 ok(elem
!= NULL
, "elem == NULL\n");
8224 test_iframe_elem(elem
);
8225 IHTMLElement_Release(elem
);
8228 elem
= get_doc_elem_by_id(doc
, "btnid");
8229 ok(elem
!= NULL
, "elem == NULL\n");
8231 test_button_elem(elem
);
8232 test_button_get_disabled(elem
, VARIANT_FALSE
);
8233 test_button_set_disabled(elem
, VARIANT_TRUE
);
8234 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8235 test_button_get_disabled(elem
, VARIANT_FALSE
);
8236 IHTMLElement_Release(elem
);
8239 elem
= get_doc_elem_by_id(doc
, "objid");
8240 ok(elem
!= NULL
, "elem == NULL\n");
8242 test_object_vspace((IUnknown
*)elem
, 100);
8243 test_object_name(elem
, "objname");
8244 set_object_name(elem
, "test");
8245 set_object_name(elem
, NULL
);
8246 IHTMLElement_Release(elem
);
8249 elem
= get_elem_by_id(doc
, "a", TRUE
);
8251 test_anchor_href((IUnknown
*)elem
, "http://test/");
8253 /* Change the href */
8254 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8255 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8256 test_anchor_hostname((IUnknown
*)elem
, "test1");
8258 /* Restore the href */
8259 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8260 test_anchor_href((IUnknown
*)elem
, "http://test/");
8261 test_anchor_hostname((IUnknown
*)elem
, "test");
8262 test_anchor_hash(elem
, NULL
);
8265 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8267 test_anchor_rel((IUnknown
*)elem
, NULL
);
8268 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8269 test_anchor_rel((IUnknown
*)elem
, "Next");
8271 /* Change the target */
8272 test_anchor_put_target((IUnknown
*)elem
, "wine");
8273 test_anchor_get_target((IUnknown
*)elem
, "wine");
8275 /* Restore the target */
8276 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8277 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8279 test_anchor_name((IUnknown
*)elem
, "x");
8280 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8281 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8282 test_anchor_put_name((IUnknown
*)elem
, "x");
8284 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8285 test_anchor_hash(elem
, "#hash");
8286 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8288 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8289 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8290 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8291 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8293 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8294 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8296 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8297 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8299 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8300 as part of the pathname, and cannot be accessed by get_search. */
8301 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8302 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8304 IHTMLElement_Release(elem
);
8307 elem
= get_doc_elem_by_id(doc
, "metaid");
8309 test_meta_name((IUnknown
*)elem
, "meta name");
8310 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8311 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8312 test_meta_charset((IUnknown
*)elem
, NULL
);
8313 set_meta_charset((IUnknown
*)elem
, "utf-8");
8314 IHTMLElement_Release(elem
);
8317 elem
= doc_get_body(doc
);
8319 node
= get_first_child((IUnknown
*)elem
);
8320 ok(node
!= NULL
, "node == NULL\n");
8322 test_ifaces((IUnknown
*)node
, text_iids
);
8323 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8325 node2
= get_first_child((IUnknown
*)node
);
8326 ok(!node2
, "node2 != NULL\n");
8328 type
= get_node_type((IUnknown
*)node
);
8329 ok(type
== 3, "type=%d\n", type
);
8331 test_node_get_value_str((IUnknown
*)node
, "text test");
8332 test_node_put_value_str((IUnknown
*)elem
, "test text");
8333 test_node_get_value_str((IUnknown
*)node
, "text test");
8335 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8336 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8337 ok(!disp
, "disp != NULL\n");
8339 IHTMLDOMNode_Release(node
);
8342 child_col
= get_child_nodes((IUnknown
*)elem
);
8343 ok(child_col
!= NULL
, "child_coll == NULL\n");
8348 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
8350 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
8351 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8352 ok(length
, "length=0\n");
8355 node
= get_child_item(child_col
, 0);
8356 ok(node
!= NULL
, "node == NULL\n");
8360 type
= get_node_type((IUnknown
*)node
);
8361 ok(type
== 3, "type=%d\n", type
);
8362 node2
= node_get_next((IUnknown
*)node
);
8364 prev
= node_get_prev((IUnknown
*)node2
);
8365 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8366 IHTMLDOMNode_Release(prev
);
8368 IHTMLDOMNode_Release(node
);
8371 node
= get_child_item(child_col
, 1);
8372 ok(node
!= NULL
, "node == NULL\n");
8374 type
= get_node_type((IUnknown
*)node
);
8375 ok(type
== 8, "type=%d\n", type
);
8377 test_elem_id((IUnknown
*)node
, NULL
);
8378 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8379 IHTMLDOMNode_Release(node2
);
8380 IHTMLDOMNode_Release(node
);
8383 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8384 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8386 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8387 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8389 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8390 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8392 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8393 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8395 test_child_col_disp(child_col
);
8397 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8398 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8400 test_enum_children(enum_unk
, length
);
8402 IUnknown_Release(enum_unk
);
8404 IHTMLDOMChildrenCollection_Release(child_col
);
8407 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8408 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8409 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8411 IHTMLElement_Release(elem
);
8413 elem
= get_doc_elem_by_id(doc
, "frm");
8414 ok(elem
!= NULL
, "elem == NULL\n");
8416 test_form_length((IUnknown
*)elem
, 0);
8417 test_form_elements((IUnknown
*)elem
);
8418 IHTMLElement_Release(elem
);
8421 test_stylesheets(doc
);
8422 test_create_option_elem(doc
);
8423 test_create_img_elem(doc
);
8425 elem
= get_doc_elem_by_id(doc
, "tbl");
8426 ok(elem
!= NULL
, "elem = NULL\n");
8427 test_elem_set_innertext(elem
, "inner text");
8428 IHTMLElement_Release(elem
);
8430 test_doc_title(doc
, "test");
8431 test_doc_set_title(doc
, "test title");
8432 test_doc_title(doc
, "test title");
8435 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8436 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8439 IDispatchEx
*dispex
;
8440 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8441 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8445 BSTR str
= a2bstr("Testing");
8446 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8447 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8448 ok(pid
!= -1, "pid == -1\n");
8450 IDispatchEx_Release(dispex
);
8453 IDispatch_Release(disp
);
8455 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8457 elem
= get_doc_elem_by_id(doc
, "y");
8458 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8459 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8460 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8461 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8462 node
= node_get_next((IUnknown
*)elem
);
8463 ok(!node
, "node = %p\n", node
);
8465 elem2
= get_doc_elem_by_id(doc
, "x");
8466 test_elem_tag((IUnknown
*)elem2
, "A");
8467 node
= node_get_next((IUnknown
*)elem2
);
8468 IHTMLDOMNode_Release(node
);
8469 IHTMLElement_Release(elem2
);
8470 IHTMLElement_Release(elem
);
8472 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8473 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8475 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8476 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8478 IHTMLDocument3_Release(doc3
);
8480 elem
= get_elem_by_id(doc
, "s", TRUE
);
8482 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8484 test_select_put_length((IUnknown
*)elem
, 3);
8485 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8486 test_select_put_length((IUnknown
*)elem
, 1);
8487 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8488 IHTMLElement_Release(elem
);
8491 window
= get_doc_window(doc
);
8492 test_window_name(window
, NULL
);
8493 set_window_name(window
, "test name");
8494 test_window_length(window
, 1);
8495 IHTMLWindow2_Release(window
);
8498 static void test_attr(IHTMLElement
*elem
)
8500 IHTMLDOMAttribute
*attr
, *attr2
;
8503 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8505 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8507 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8508 test_ifaces((IUnknown
*)attr
, attr_iids
);
8509 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8510 test_attr_specified(attr
, VARIANT_TRUE
);
8512 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8513 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8514 IHTMLDOMAttribute_Release(attr2
);
8516 get_attr_node_value(attr
, &v
, VT_BSTR
);
8517 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8521 V_BSTR(&v
) = a2bstr("divid2");
8522 put_attr_node_value(attr
, v
);
8524 get_attr_node_value(attr
, &v
, VT_BSTR
);
8525 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8528 put_attr_value(attr
, "divid3");
8530 get_attr_node_value(attr
, &v
, VT_BSTR
);
8531 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8534 IHTMLDOMAttribute_Release(attr
);
8536 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8537 get_attr_node_value(attr
, &v
, VT_BSTR
);
8538 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8542 V_BSTR(&v
) = a2bstr("newvalue");
8543 put_attr_node_value(attr
, v
);
8546 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8547 get_attr_node_value(attr
, &v
, VT_BSTR
);
8548 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8551 test_attr_specified(attr
, VARIANT_TRUE
);
8552 IHTMLDOMAttribute_Release(attr
);
8556 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
8557 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
8558 get_attr_node_value(attr
, &v
, VT_I4
);
8559 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
8560 test_attr_specified(attr
, VARIANT_TRUE
);
8564 put_attr_node_value(attr
, v
);
8566 get_attr_node_value(attr
, &v
, VT_I4
);
8567 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
8569 put_attr_value(attr
, "160");
8570 get_attr_node_value(attr
, &v
, VT_BSTR
);
8571 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8574 IHTMLDOMAttribute_Release(attr
);
8576 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
8577 test_attr_specified(attr
, VARIANT_FALSE
);
8578 test_attr_expando(attr
, VARIANT_FALSE
);
8579 IHTMLDOMAttribute_Release(attr
);
8582 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
8586 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8587 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
8588 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8590 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8591 IHTMLElement_Release(elem
);
8594 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8595 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
8596 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8598 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
8599 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
8600 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
8601 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
8602 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8603 IHTMLElement_Release(elem
);
8607 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
8608 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
8610 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
8611 IHTMLElementCollection
*col
;
8612 BSTR str
= a2bstr(name
);
8615 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
8616 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
8617 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
8619 IHTMLDocument3_Release(doc3
);
8624 static void test_elem_names(IHTMLDocument2
*doc
)
8626 IHTMLElementCollection
*col
;
8631 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
8633 body
= doc_get_body(doc
);
8635 test_elem_set_innerhtml((IUnknown
*)body
,
8636 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
8637 col
= doc_get_elems_by_name(doc
, "test");
8638 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
8639 IHTMLElementCollection_Release(col
);
8641 col
= doc_get_elems_by_name(doc
, "yyy");
8642 test_elem_collection((IUnknown
*)col
, NULL
, 0);
8643 IHTMLElementCollection_Release(col
);
8645 /* case insensivity test */
8646 col
= doc_get_elems_by_name(doc
, "Xxx");
8647 hres
= IHTMLElementCollection_get_length(col
, &len
);
8648 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8649 todo_wine
ok(len
== 1, "len = %d\n", len
);
8650 IHTMLElementCollection_Release(col
);
8652 IHTMLElement_Release(body
);
8655 static void test_elems2(IHTMLDocument2
*doc
)
8657 IHTMLElement
*elem
, *elem2
, *div
;
8659 static const elem_type_t outer_types
[] = {
8664 div
= get_doc_elem_by_id(doc
, "divid");
8666 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
8668 test_link_disabled(elem
, VARIANT_FALSE
);
8669 test_link_rel(elem
, "stylesheet");
8670 test_link_rev(elem
, NULL
);
8671 test_link_type(elem
, "text/css");
8672 test_link_href(elem
, "about:blank");
8673 test_link_media(elem
, "all");
8674 link_put_disabled(elem
, VARIANT_TRUE
);
8675 link_put_rel(elem
, "prev");
8676 link_put_rev(elem
, "next");
8677 link_put_type(elem
, "text/plain");
8678 link_put_href(elem
, "about:prev");
8679 IHTMLElement_Release(elem
);
8682 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
8683 elem2
= get_doc_elem_by_id(doc
, "innerid");
8684 ok(elem2
!= NULL
, "elem2 == NULL\n");
8685 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
8686 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
8687 IHTMLElement_Release(elem2
);
8689 elem2
= get_doc_elem_by_id(doc
, "aid");
8690 ok(elem2
!= NULL
, "elem2 == NULL\n");
8691 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
8692 test_elem_all((IUnknown
*)div
, outer_types
, 1);
8693 IHTMLElement_Release(elem2
);
8695 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
8696 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8698 IHTMLFormElement
*form
;
8700 test_textarea_value((IUnknown
*)elem
, NULL
);
8701 test_textarea_put_value((IUnknown
*)elem
, "test");
8702 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
8703 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
8704 test_textarea_put_value((IUnknown
*)elem
, "test");
8705 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8706 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
8707 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8708 test_textarea_type((IUnknown
*)elem
);
8710 form
= get_textarea_form((IUnknown
*)elem
);
8711 ok(!form
, "form = %p\n", form
);
8713 test_elem_istextedit(elem
, VARIANT_TRUE
);
8715 IHTMLElement_Release(elem
);
8718 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
8719 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8721 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
8722 IHTMLElement_Release(elem
);
8725 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
8726 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8728 IHTMLFormElement
*form
;
8730 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
8731 ok(elem2
!= NULL
, "elem2 == NULL\n");
8733 form
= get_textarea_form((IUnknown
*)elem
);
8734 ok(form
!= NULL
, "form = NULL\n");
8735 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
8737 IHTMLFormElement_Release(form
);
8738 IHTMLElement_Release(elem2
);
8739 IHTMLElement_Release(elem
);
8742 test_elem_set_innerhtml((IUnknown
*)div
,
8743 "<input value=\"val\" id =\"inputid\" />");
8744 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8746 test_input_defaultValue((IUnknown
*)elem
, "val");
8747 test_input_put_value((IUnknown
*)elem
, "test");
8748 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
8749 test_input_value((IUnknown
*)elem
, "test");
8750 IHTMLElement_Release(elem
);
8753 test_elem_set_innerhtml((IUnknown
*)div
, "");
8754 test_insert_adjacent_elems(doc
, div
);
8756 test_elem_set_innerhtml((IUnknown
*)div
,
8757 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
8758 elem
= get_elem_by_id(doc
, "form", TRUE
);
8760 test_form_length((IUnknown
*)elem
, 2);
8761 test_form_item(elem
);
8762 test_form_action((IUnknown
*)elem
, NULL
);
8763 test_form_put_action((IUnknown
*)elem
, "about:blank");
8764 test_form_method((IUnknown
*)elem
, "get");
8765 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
8766 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
8767 test_form_method((IUnknown
*)elem
, "post");
8768 test_form_name((IUnknown
*)elem
, NULL
);
8769 test_form_put_name((IUnknown
*)elem
, "Name");
8770 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
8771 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
8772 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
8773 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
8774 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
8775 test_form_elements((IUnknown
*)elem
);
8776 test_form_reset((IUnknown
*)elem
);
8777 test_form_target((IUnknown
*)elem
);
8778 IHTMLElement_Release(elem
);
8780 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8781 test_input_get_form((IUnknown
*)elem
, "form");
8782 IHTMLElement_Release(elem
);
8785 test_elem_set_innerhtml((IUnknown
*)div
,
8786 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select></form>");
8787 elem
= get_elem_by_id(doc
, "sform", TRUE
);
8788 elem2
= get_elem_by_id(doc
, "form", TRUE
);
8790 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8791 IHTMLElement_Release(elem
);
8793 elem
= get_elem_by_id(doc
, "oform", TRUE
);
8795 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8796 IHTMLElement_Release(elem
);
8798 IHTMLElement_Release(elem2
);
8802 test_blocked(doc
, div
);
8803 test_elem_names(doc
);
8805 IHTMLElement_Release(div
);
8808 static void test_create_elems(IHTMLDocument2
*doc
)
8810 IHTMLElement
*elem
, *body
, *elem2
;
8811 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
8812 IHTMLDOMAttribute
*attr
;
8813 IHTMLDocument5
*doc5
;
8820 static const elem_type_t types1
[] = { ET_TESTG
};
8822 elem
= test_create_elem(doc
, "TEST");
8823 test_elem_tag((IUnknown
*)elem
, "TEST");
8824 type
= get_node_type((IUnknown
*)elem
);
8825 ok(type
== 1, "type=%d\n", type
);
8826 test_ifaces((IUnknown
*)elem
, elem_iids
);
8827 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
8828 test_elem_source_index(elem
, -1);
8830 body
= doc_get_body(doc
);
8831 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8833 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
8834 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
8835 elem2
= get_elem_iface((IUnknown
*)node
);
8836 IHTMLElement_Release(elem2
);
8838 hres
= IHTMLElement_get_all(body
, &disp
);
8839 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8840 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
8841 IDispatch_Release(disp
);
8843 test_node_remove_child((IUnknown
*)body
, node
);
8845 hres
= IHTMLElement_get_all(body
, &disp
);
8846 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8847 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
8848 IDispatch_Release(disp
);
8849 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8851 IHTMLElement_Release(elem
);
8852 IHTMLDOMNode_Release(node
);
8854 node
= test_create_text(doc
, "abc");
8855 test_ifaces((IUnknown
*)node
, text_iids
);
8856 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8857 test_text_length((IUnknown
*)node
, 3);
8858 test_text_data((IUnknown
*)node
, "abc");
8859 set_text_data((IUnknown
*)node
, "test");
8860 test_text_data((IUnknown
*)node
, "test");
8861 text_append_data((IUnknown
*)node
, " append");
8862 test_text_data((IUnknown
*)node
, "test append");
8863 text_append_data((IUnknown
*)node
, NULL
);
8864 test_text_data((IUnknown
*)node
, "test append");
8865 set_text_data((IUnknown
*)node
, "test");
8867 V_VT(&var
) = VT_NULL
;
8868 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8869 IHTMLDOMNode_Release(node
);
8871 node
= test_create_text(doc
, "insert ");
8873 V_VT(&var
) = VT_DISPATCH
;
8874 V_DISPATCH(&var
) = (IDispatch
*)node2
;
8875 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8876 IHTMLDOMNode_Release(node
);
8877 IHTMLDOMNode_Release(node2
);
8878 IHTMLDOMNode_Release(node3
);
8880 test_elem_innertext(body
, "insert test");
8881 test_elem_innerhtml((IUnknown
*)body
, "insert test");
8883 node
= test_create_text(doc
, " Test");
8884 V_VT(&var
) = VT_DISPATCH
;
8885 V_DISPATCH(&var
) = NULL
;
8886 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8887 test_elem_innertext(body
, "insert test Test");
8888 IHTMLDOMNode_Release(node
);
8890 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
8892 str
= a2bstr("testing");
8893 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
8895 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
8898 type
= get_node_type((IUnknown
*)comment
);
8899 ok(type
== 8, "type=%d, expected 8\n", type
);
8901 test_node_get_value_str((IUnknown
*)comment
, "testing");
8902 test_elem_title((IUnknown
*)comment
, NULL
);
8903 test_elem_set_title((IUnknown
*)comment
, "comment title");
8904 test_elem_title((IUnknown
*)comment
, "comment title");
8905 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
8906 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
8907 test_comment_attrs((IUnknown
*)comment
);
8909 IHTMLDOMNode_Release(comment
);
8912 str
= a2bstr("Test");
8913 hres
= IHTMLDocument5_createAttribute(doc5
, str
, &attr
);
8914 ok(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
8916 if(SUCCEEDED(hres
)) {
8917 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8918 test_ifaces((IUnknown
*)attr
, attr_iids
);
8919 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8921 test_attr_node_name(attr
, "Test");
8923 IHTMLDOMAttribute_Release(attr
);
8926 IHTMLDocument5_Release(doc5
);
8929 IHTMLElement_Release(body
);
8932 static void test_replacechild_elems(IHTMLDocument2
*doc
)
8935 IHTMLDOMNode
*node
, *node2
, *node3
;
8936 IHTMLDOMNode
*nodeBody
, *nodeNew
;
8940 body
= doc_get_body(doc
);
8942 node
= test_create_text(doc
, "insert");
8944 V_VT(&var
) = VT_NULL
;
8945 V_DISPATCH(&var
) = NULL
;
8946 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8947 IHTMLDOMNode_Release(node
);
8949 test_elem_innertext(body
, "insert");
8951 node3
= test_create_text(doc
, "replaced");
8953 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
8955 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
8956 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
8958 test_elem_innertext(body
, "replaced");
8960 IHTMLDOMNode_Release(node2
);
8961 IHTMLDOMNode_Release(node3
);
8962 IHTMLDOMNode_Release(nodeBody
);
8964 IHTMLElement_Release(body
);
8967 static void test_noscript(IHTMLDocument2
*doc
)
8969 IHTMLElementCollection
*col
;
8973 static const elem_type_t all_types
[] = {
8982 static const elem_type_t body_all_types
[] = {
8987 hres
= IHTMLDocument2_get_all(doc
, &col
);
8988 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8989 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8990 IHTMLElementCollection_Release(col
);
8992 body
= doc_get_body(doc
);
8993 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
8994 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
8995 IHTMLElement_Release(body
);
8998 static void test_doctype(IHTMLDocument2
*doc
)
9000 IHTMLDocument2
*doc_node
;
9001 IHTMLDOMNode
*doctype
;
9004 doc_node
= get_doc_node(doc
);
9005 doctype
= get_first_child((IUnknown
*)doc_node
);
9006 IHTMLDocument2_Release(doc_node
);
9008 type
= get_node_type((IUnknown
*)doctype
);
9009 ok(type
== 8, "type = %d\n", type
);
9011 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9012 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9013 IHTMLDOMNode_Release(doctype
);
9016 static void test_null_write(IHTMLDocument2
*doc
)
9020 doc_write(doc
, FALSE
, NULL
);
9021 doc_write(doc
, TRUE
, NULL
);
9023 hres
= IHTMLDocument2_write(doc
, NULL
);
9025 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9027 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9029 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9032 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9034 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9035 IHTMLStyleElement
*style_elem
;
9036 IHTMLElement
*doc_elem
, *elem
;
9039 static const elem_type_t all_types
[] = {
9047 static const elem_type_t all_types2
[] = {
9056 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
9058 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9059 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9061 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
9063 doc_elem
= get_doc_elem(doc
);
9065 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9066 IHTMLElement_Release(doc_elem
);
9068 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9069 IHTMLElement_Release(elem
);
9070 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9073 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9074 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9075 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9076 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9078 IHTMLStyleSheet_Release(stylesheet2
);
9079 IHTMLStyleSheet_Release(stylesheet
);
9081 IHTMLStyleElement_Release(style_elem
);
9084 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9086 IOleCommandTarget
*cmdtrg
;
9089 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9090 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9092 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9093 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9095 IOleCommandTarget_Release(cmdtrg
);
9098 static void test_indent(IHTMLDocument2
*doc
)
9100 IHTMLElementCollection
*col
;
9101 IHTMLTxtRange
*range
;
9104 static const elem_type_t all_types
[] = {
9113 static const elem_type_t indent_types
[] = {
9124 hres
= IHTMLDocument2_get_all(doc
, &col
);
9125 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9126 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9127 IHTMLElementCollection_Release(col
);
9129 range
= test_create_body_range(doc
);
9130 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9131 IHTMLTxtRange_Release(range
);
9133 hres
= IHTMLDocument2_get_all(doc
, &col
);
9134 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9135 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9136 IHTMLElementCollection_Release(col
);
9139 static void test_cond_comment(IHTMLDocument2
*doc
)
9141 IHTMLElementCollection
*col
;
9144 static const elem_type_t all_types
[] = {
9152 hres
= IHTMLDocument2_get_all(doc
, &col
);
9153 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9154 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9155 IHTMLElementCollection_Release(col
);
9158 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9160 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9161 return E_NOINTERFACE
;
9164 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9169 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9174 static const IUnknownVtbl UnknownVtbl
= {
9175 Unknown_QueryInterface
,
9179 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9181 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9183 IHTMLWindow2
*frame2
, *parent
, *top
;
9184 IHTMLDocument2
*parent_doc
, *top_doc
;
9185 IHTMLWindow4
*frame
;
9186 IHTMLFrameBase
*frame_elem
;
9187 IObjectIdentity
*obj_ident
;
9188 ITravelLogClient
*tlc
;
9191 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9192 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9196 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9197 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9198 IHTMLWindow4_Release(frame
);
9202 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9203 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9204 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9205 IHTMLFrameBase_Release(frame_elem
);
9207 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9208 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9212 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9213 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9215 IHTMLWindow2_Release(frame2
);
9219 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9220 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9221 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9222 if(hres
== E_NOINTERFACE
) {
9223 win_skip("IID_ITravelLogClient not available\n");
9226 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9228 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9229 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9230 ITravelLogClient_Release(tlc
);
9233 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9234 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9235 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9236 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9237 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9238 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9240 IObjectIdentity_Release(obj_ident
);
9242 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9243 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9244 IHTMLWindow2_Release(parent
);
9246 IHTMLWindow2_Release(frame2
);
9250 test_doc_title(parent_doc
, "frameset test");
9251 IHTMLDocument2_Release(parent_doc
);
9254 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9255 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9256 IHTMLWindow2_Release(frame2
);
9260 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9261 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9262 IHTMLWindow2_Release(top
);
9266 test_doc_title(top_doc
, "frameset test");
9267 IHTMLDocument2_Release(top_doc
);
9270 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9272 VARIANT index_var
, result_var
;
9276 /* test result length */
9277 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9278 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9279 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9281 /* test first frame */
9282 V_VT(&index_var
) = VT_I4
;
9283 V_I4(&index_var
) = 0;
9284 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9285 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9286 if(SUCCEEDED(hres
)) {
9287 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9288 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9290 VariantClear(&result_var
);
9292 /* test second frame */
9293 V_I4(&index_var
) = 1;
9294 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9295 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9296 if(SUCCEEDED(hres
)) {
9297 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9298 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9300 VariantClear(&result_var
);
9302 /* fail on next frame */
9303 V_I4(&index_var
) = 3;
9304 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9305 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9306 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9307 VariantClear(&result_var
);
9309 /* string argument (element id lookup) */
9310 V_VT(&index_var
) = VT_BSTR
;
9311 V_BSTR(&index_var
) = a2bstr(frid
);
9312 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9313 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9314 if(SUCCEEDED(hres
)) {
9315 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9316 test_frame(V_DISPATCH(&result_var
), frid
);
9318 VariantClear(&result_var
);
9319 VariantClear(&index_var
);
9321 /* invalid argument */
9322 V_VT(&index_var
) = VT_BOOL
;
9323 V_BOOL(&index_var
) = VARIANT_TRUE
;
9324 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9325 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9326 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9327 VariantClear(&result_var
);
9330 static void test_frameset(IHTMLDocument2
*doc
)
9332 IHTMLWindow2
*window
;
9333 IHTMLFramesCollection2
*frames
;
9337 window
= get_doc_window(doc
);
9339 /* test using IHTMLFramesCollection object */
9341 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9342 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9346 test_frames_collection(frames
, "fr1");
9347 IHTMLFramesCollection2_Release(frames
);
9349 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9350 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9354 test_frames_collection(frames
, "fr1");
9355 IHTMLFramesCollection2_Release(frames
);
9357 /* test using IHTMLWindow2 inheritance */
9358 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9360 /* getElementById with node name attributes */
9361 elem
= get_doc_elem_by_id(doc
, "nm1");
9362 test_elem_id((IUnknown
*)elem
, "fr1");
9364 test_framebase((IUnknown
*)elem
);
9365 test_framebase_name(elem
, "nm1");
9366 test_framebase_put_name(elem
, "frame name");
9367 test_framebase_put_name(elem
, NULL
);
9368 test_framebase_put_name(elem
, "nm1");
9369 test_framebase_src(elem
, "about:blank");
9370 IHTMLElement_Release(elem
);
9372 /* get_name with no name attr */
9373 elem
= get_doc_elem_by_id(doc
, "fr3");
9374 test_framebase_name(elem
, NULL
);
9375 test_framebase_put_name(elem
, "frame name");
9376 test_framebase_put_name(elem
, NULL
);
9377 IHTMLElement_Release(elem
);
9379 IHTMLWindow2_Release(window
);
9382 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9384 IHTMLDocument2
*frag
;
9385 IHTMLDocument3
*doc3
;
9388 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9389 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9391 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9392 IHTMLDocument3_Release(doc3
);
9393 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9394 ok(frag
!= NULL
, "frag == NULL\n");
9399 static void test_docfrag(IHTMLDocument2
*doc
)
9401 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9402 IHTMLElement
*div
, *body
, *br
;
9403 IHTMLElementCollection
*col
;
9404 IHTMLLocation
*location
;
9407 static const elem_type_t all_types
[] = {
9416 frag
= create_docfrag(doc
);
9418 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
9420 body
= (void*)0xdeadbeef;
9421 hres
= IHTMLDocument2_get_body(frag
, &body
);
9422 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
9423 ok(!body
, "body != NULL\n");
9425 location
= (void*)0xdeadbeef;
9426 hres
= IHTMLDocument2_get_location(frag
, &location
);
9427 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
9428 ok(location
== (void*)0xdeadbeef, "location changed\n");
9430 br
= test_create_elem(doc
, "BR");
9431 test_elem_source_index(br
, -1);
9432 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
9433 test_elem_source_index(br
, 0);
9434 IHTMLElement_Release(br
);
9436 test_doc_getelembytag(frag
, "a", ET_A
, 0);
9437 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
9439 div
= get_elem_by_id(doc
, "divid", TRUE
);
9440 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
9441 IHTMLElement_Release(div
);
9443 hres
= IHTMLDocument2_get_all(doc
, &col
);
9444 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9445 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9446 IHTMLElementCollection_Release(col
);
9448 div
= test_create_elem(frag
, "div");
9449 owner_doc
= get_owner_doc((IUnknown
*)div
);
9450 doc_node
= get_doc_node(doc
);
9451 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
9452 IHTMLDocument2_Release(doc_node
);
9453 IHTMLDocument2_Release(owner_doc
);
9454 IHTMLElement_Release(div
);
9456 IHTMLDocument2_Release(frag
);
9459 static void check_quirks_mode(IHTMLDocument2
*doc
)
9461 test_compatmode(doc
, "BackCompat");
9464 static void check_strict_mode(IHTMLDocument2
*doc
)
9466 test_compatmode(doc
, "CSS1Compat");
9469 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
9475 hres
= IHTMLDocument2_get_body(doc
, &elem
);
9476 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
9478 /* body.offsetHeight value depends on window size in quirks mode */
9479 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
9480 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
9481 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
9482 IHTMLElement_Release(elem
);
9485 static IHTMLDocument2
*notif_doc
;
9486 static BOOL doc_complete
;
9488 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
9489 REFIID riid
, void**ppv
)
9491 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
9496 ok(0, "unexpected call\n");
9497 return E_NOINTERFACE
;
9500 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
9505 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
9510 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
9512 if(dispID
== DISPID_READYSTATE
){
9516 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
9517 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
9519 if(!strcmp_wa(state
, "complete"))
9520 doc_complete
= TRUE
;
9522 SysFreeString(state
);
9528 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
9530 ok(0, "unexpected call\n");
9534 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
9535 PropertyNotifySink_QueryInterface
,
9536 PropertyNotifySink_AddRef
,
9537 PropertyNotifySink_Release
,
9538 PropertyNotifySink_OnChanged
,
9539 PropertyNotifySink_OnRequestEdit
9542 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
9544 static HRESULT
cs_qi(REFIID
,void **);
9545 static IOleDocumentView
*view
;
9546 static HWND container_hwnd
;
9548 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
9550 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
9552 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
9553 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
9556 return E_NOINTERFACE
;
9559 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
9564 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
9569 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
9574 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
9579 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
9584 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
9585 LPCBORDERWIDTHS pborderwidths
)
9590 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
9591 LPCBORDERWIDTHS pborderwidths
)
9596 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
9597 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
9602 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9603 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
9608 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9609 HOLEMENU holemenu
, HWND hwndActiveObject
)
9611 ok(0, "unexpected call\n");
9615 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
9617 ok(0, "unexpected call\n");
9621 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
9626 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
9631 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
9633 ok(0, "unexpected call\n");
9637 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
9638 InPlaceFrame_QueryInterface
,
9639 InPlaceFrame_AddRef
,
9640 InPlaceFrame_Release
,
9641 InPlaceFrame_GetWindow
,
9642 InPlaceFrame_ContextSensitiveHelp
,
9643 InPlaceFrame_GetBorder
,
9644 InPlaceFrame_RequestBorderSpace
,
9645 InPlaceFrame_SetBorderSpace
,
9646 InPlaceFrame_SetActiveObject
,
9647 InPlaceFrame_InsertMenus
,
9648 InPlaceFrame_SetMenu
,
9649 InPlaceFrame_RemoveMenus
,
9650 InPlaceFrame_SetStatusText
,
9651 InPlaceFrame_EnableModeless
,
9652 InPlaceFrame_TranslateAccelerator
9655 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
9657 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
9659 return cs_qi(riid
, ppv
);
9662 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
9667 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
9672 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
9674 *phwnd
= container_hwnd
;
9678 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
9680 ok(0, "unexpected call\n");
9684 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
9689 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
9694 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
9699 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
9700 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
9701 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
9703 static const RECT rect
= {0,0,500,500};
9705 *ppFrame
= &InPlaceFrame
;
9707 *lprcPosRect
= rect
;
9708 *lprcClipRect
= rect
;
9710 lpFrameInfo
->fMDIApp
= FALSE
;
9711 lpFrameInfo
->hwndFrame
= container_hwnd
;
9712 lpFrameInfo
->haccel
= NULL
;
9713 lpFrameInfo
->cAccelEntries
= 0;
9718 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
9723 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
9728 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
9733 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
9738 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
9743 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
9748 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
9749 InPlaceSite_QueryInterface
,
9751 InPlaceSite_Release
,
9752 InPlaceSite_GetWindow
,
9753 InPlaceSite_ContextSensitiveHelp
,
9754 InPlaceSite_CanInPlaceActivate
,
9755 InPlaceSite_OnInPlaceActivate
,
9756 InPlaceSite_OnUIActivate
,
9757 InPlaceSite_GetWindowContext
,
9759 InPlaceSite_OnUIDeactivate
,
9760 InPlaceSite_OnInPlaceDeactivate
,
9761 InPlaceSite_DiscardUndoState
,
9762 InPlaceSite_DeactivateAndUndo
,
9763 InPlaceSite_OnPosRectChange
,
9766 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
9768 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
9770 return cs_qi(riid
, ppv
);
9773 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
9778 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
9783 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
9785 ok(0, "unexpected call\n");
9789 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
9792 ok(0, "unexpected call\n");
9796 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
9801 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
9803 ok(0, "unexpected call\n");
9807 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
9809 ok(0, "unexpected call\n");
9813 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
9815 ok(0, "unexpected call\n");
9819 static const IOleClientSiteVtbl ClientSiteVtbl
= {
9820 ClientSite_QueryInterface
,
9823 ClientSite_SaveObject
,
9824 ClientSite_GetMoniker
,
9825 ClientSite_GetContainer
,
9826 ClientSite_ShowObject
,
9827 ClientSite_OnShowWindow
,
9828 ClientSite_RequestNewObjectLayout
9831 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
9833 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
9835 return cs_qi(riid
, ppv
);
9838 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
9843 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
9848 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
9850 RECT rect
= {0,0,500,500};
9851 IOleDocument
*document
;
9854 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
9855 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
9857 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
9858 IOleDocument_Release(document
);
9859 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
9861 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
9862 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
9864 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
9865 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
9867 hres
= IOleDocumentView_SetRect(view
, &rect
);
9868 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
9870 hres
= IOleDocumentView_Show(view
, TRUE
);
9871 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
9876 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
9877 DocumentSite_QueryInterface
,
9878 DocumentSite_AddRef
,
9879 DocumentSite_Release
,
9880 DocumentSite_ActivateMe
9883 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
9885 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
9889 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
9891 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
9892 *ppv
= &DocumentSite
;
9893 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
9894 *ppv
= &InPlaceSite
;
9896 return *ppv
? S_OK
: E_NOINTERFACE
;
9899 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
9905 IOleDocumentView_Show(view
, FALSE
);
9906 IOleDocumentView_CloseView(view
, 0);
9907 IOleDocumentView_SetInPlaceSite(view
, NULL
);
9908 IOleDocumentView_Release(view
);
9912 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
9913 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
9915 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
9916 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
9919 IHlinkTarget
*hlink
;
9921 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
9922 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
9924 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
9925 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
9927 IHlinkTarget_Release(hlink
);
9930 IOleObject_Release(oleobj
);
9933 static IHTMLDocument2
*create_doc_with_string(const char *str
)
9935 IPersistStreamInit
*init
;
9937 IHTMLDocument2
*doc
;
9941 notif_doc
= doc
= create_document();
9945 doc_complete
= FALSE
;
9947 mem
= GlobalAlloc(0, len
);
9948 memcpy(mem
, str
, len
);
9949 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
9951 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
9953 IPersistStreamInit_Load(init
, stream
);
9954 IPersistStreamInit_Release(init
);
9955 IStream_Release(stream
);
9960 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
9962 IConnectionPointContainer
*container
;
9963 IConnectionPoint
*cp
;
9967 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
9968 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
9970 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
9971 IConnectionPointContainer_Release(container
);
9972 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
9974 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
9975 IConnectionPoint_Release(cp
);
9976 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
9979 typedef void (*domtest_t
)(IHTMLDocument2
*);
9981 static void run_domtest(const char *str
, domtest_t test
)
9983 IHTMLDocument2
*doc
;
9987 doc
= create_doc_with_string(str
);
9991 set_client_site(doc
, TRUE
);
9992 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
9994 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
9995 TranslateMessage(&msg
);
9996 DispatchMessageW(&msg
);
10001 set_client_site(doc
, FALSE
);
10002 ref
= IHTMLDocument2_Release(doc
);
10003 ok(!ref
|| broken(ref
== 1), /* Vista */
10004 "ref = %d\n", ref
);
10007 static void test_quirks_mode(void)
10009 run_domtest("<html></html>", check_quirks_mode
);
10010 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10011 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10012 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10017 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10018 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10019 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10021 CoInitialize(NULL
);
10022 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10023 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10025 run_domtest(doc_str1
, test_doc_elem
);
10026 run_domtest(doc_str1
, test_get_set_attr
);
10027 run_domtest(range_test_str
, test_txtrange
);
10028 run_domtest(range_test2_str
, test_txtrange2
);
10029 if (winetest_interactive
|| ! is_ie_hardened()) {
10030 run_domtest(elem_test_str
, test_elems
);
10031 run_domtest(elem_test2_str
, test_elems2
);
10032 run_domtest(noscript_str
, test_noscript
);
10034 skip("IE running in Enhanced Security Configuration\n");
10036 run_domtest(doc_blank
, test_create_elems
);
10037 run_domtest(doc_blank
, test_defaults
);
10038 run_domtest(doc_blank
, test_null_write
);
10039 run_domtest(emptydiv_str
, test_create_stylesheet
);
10040 run_domtest(indent_test_str
, test_indent
);
10041 run_domtest(cond_comment_str
, test_cond_comment
);
10042 run_domtest(frameset_str
, test_frameset
);
10043 run_domtest(emptydiv_str
, test_docfrag
);
10044 run_domtest(doc_blank
, test_replacechild_elems
);
10045 run_domtest(doctype_str
, test_doctype
);
10047 test_quirks_mode();
10049 DestroyWindow(container_hwnd
);