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"
41 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
42 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
44 static BOOL is_ie9plus
;
49 } compat_mode
= COMPAT_NONE
;
51 static const char doc_blank
[] =
54 static const char doc_blank_ie9
[] =
58 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
64 static const char doc_str1
[] = "<html><body>test</body></html>";
65 static const char range_test_str
[] =
66 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
67 static const char range_test2_str
[] =
68 "<html><body>abc<hr />123<br /><hr />def</body></html>";
69 static const char elem_test_str
[] =
70 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
71 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
72 "<link id=\"linkid\"></head>"
73 "<body onload=\"Testing()\">text test<!-- a comment -->"
74 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
75 "<label for=\"in\" id=\"labelid\">Label:</label>"
76 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
77 "<button id=\"btnid\" type=\"submit\"></button>"
78 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
79 "<textarea id=\"X\">text text</textarea>"
80 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
81 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
82 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
83 "<img id=\"imgid\" name=\"WineImg\"/>"
84 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
85 "<form id=\"frm\"></form>"
86 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
88 static const char elem_test2_str
[] =
89 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
90 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
91 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
94 static const char indent_test_str
[] =
95 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
96 static const char cond_comment_str
[] =
97 "<html><head><title>test</title></head><body>"
98 "<!--[if gte IE 4]> <br> <![endif]-->"
100 static const char frameset_str
[] =
101 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
102 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
103 "<frame src=\"about:blank\" id=\"fr3\">"
104 "</frameset></html>";
105 static const char emptydiv_str
[] =
106 "<html><head><title>emptydiv test</title></head>"
107 "<body><div id=\"divid\"></div></body></html>";
108 static const char noscript_str
[] =
109 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
110 "<body><noscript><div>test</div></noscript></body></html>";
111 static const char doctype_str
[] =
113 "<html><head><title>emptydiv test</title></head>"
114 "<body><div id=\"divid\"></div></body></html>";
116 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
117 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
118 static WCHAR wordW
[] = {'w','o','r','d',0};
160 static const IID
* const none_iids
[] = {
165 static const IID
* const doc_node_iids
[] = {
173 &IID_IDocumentSelector
,
175 &IID_IConnectionPointContainer
,
176 &IID_IInternetHostSecurityManager
,
179 &IID_IProvideClassInfo
,
183 static const IID
* const doc_obj_iids
[] = {
189 &IID_IDocumentSelector
,
191 &IID_IConnectionPointContainer
,
195 &IID_IProvideClassInfo
,
196 &IID_ITargetContainer
,
200 #define ELEM_IFACES \
202 &IID_IHTMLDOMNode2, \
204 &IID_IHTMLElement2, \
205 &IID_IHTMLElement3, \
206 &IID_IHTMLElement4, \
207 &IID_IHTMLUniqueName, \
210 static const IID
* const elem_iids
[] = {
212 &IID_IConnectionPointContainer
,
216 static const IID
* const body_iids
[] = {
218 &IID_IHTMLTextContainer
,
219 &IID_IHTMLBodyElement
,
220 &IID_IConnectionPointContainer
,
224 static const IID
* const anchor_iids
[] = {
226 &IID_IHTMLAnchorElement
,
227 &IID_IConnectionPointContainer
,
231 static const IID
* const input_iids
[] = {
233 &IID_IHTMLInputElement
,
234 &IID_IHTMLInputTextElement
,
235 &IID_IConnectionPointContainer
,
239 static const IID
*const button_iids
[] = {
241 &IID_IHTMLButtonElement
,
242 &IID_IConnectionPointContainer
,
246 static const IID
*const area_iids
[] = {
248 &IID_IHTMLAreaElement
,
249 &IID_IConnectionPointContainer
,
253 static const IID
* const label_iids
[] = {
255 &IID_IHTMLLabelElement
,
256 &IID_IConnectionPointContainer
,
260 static const IID
* const select_iids
[] = {
262 &IID_IHTMLSelectElement
,
263 &IID_IConnectionPointContainer
,
267 static const IID
* const textarea_iids
[] = {
269 &IID_IHTMLTextAreaElement
,
270 &IID_IConnectionPointContainer
,
274 static const IID
* const option_iids
[] = {
276 &IID_IHTMLOptionElement
,
277 &IID_IConnectionPointContainer
,
281 static const IID
* const table_iids
[] = {
286 &IID_IConnectionPointContainer
,
290 static const IID
* const script_iids
[] = {
292 &IID_IHTMLScriptElement
,
293 &IID_IConnectionPointContainer
,
297 static const IID
* const text_iids
[] = {
300 &IID_IHTMLDOMTextNode
,
301 &IID_IHTMLDOMTextNode2
,
305 static const IID
* const attr_iids
[] = {
306 &IID_IHTMLDOMAttribute
,
307 &IID_IHTMLDOMAttribute2
,
312 static const IID
* const location_iids
[] = {
318 static const IID
* const window_iids
[] = {
323 &IID_IServiceProvider
,
327 static const IID
* const comment_iids
[] = {
329 &IID_IHTMLCommentElement
,
330 &IID_IConnectionPointContainer
,
334 static const IID
* const img_iids
[] = {
336 &IID_IHTMLImgElement
,
337 &IID_IConnectionPointContainer
,
341 static const IID
* const tr_iids
[] = {
344 &IID_IConnectionPointContainer
,
348 static const IID
* const td_iids
[] = {
351 &IID_IConnectionPointContainer
,
355 static const IID
* const frame_iids
[] = {
358 &IID_IHTMLFrameBase2
,
359 &IID_IConnectionPointContainer
,
363 static const IID
* const html_iids
[] = {
365 &IID_IHTMLHtmlElement
,
366 &IID_IConnectionPointContainer
,
370 static const IID
* const head_iids
[] = {
372 &IID_IHTMLHeadElement
,
373 &IID_IConnectionPointContainer
,
377 static const IID
* const title_iids
[] = {
379 &IID_IHTMLTitleElement
,
380 &IID_IConnectionPointContainer
,
384 static const IID
* const meta_iids
[] = {
386 &IID_IHTMLMetaElement
,
387 &IID_IConnectionPointContainer
,
391 static const IID
* const link_iids
[] = {
393 &IID_IHTMLLinkElement
,
394 &IID_IConnectionPointContainer
,
398 static const IID
* const object_iids
[] = {
400 &IID_IHTMLObjectElement
,
401 &IID_IHTMLObjectElement2
,
402 /* FIXME: No IConnectionPointContainer */
406 static const IID
* const embed_iids
[] = {
408 &IID_IHTMLEmbedElement
,
409 /* FIXME: No IConnectionPointContainer */
413 static const IID
* const iframe_iids
[] = {
416 &IID_IHTMLFrameBase2
,
417 &IID_IHTMLIFrameElement
,
418 &IID_IHTMLIFrameElement2
,
419 &IID_IConnectionPointContainer
,
423 static const IID
* const form_iids
[] = {
425 &IID_IHTMLFormElement
,
426 &IID_IConnectionPointContainer
,
427 &DIID_DispHTMLFormElement
,
431 static const IID
* const styleelem_iids
[] = {
433 &IID_IHTMLStyleElement
,
434 &IID_IConnectionPointContainer
,
438 static const IID
* const generic_iids
[] = {
440 &IID_IHTMLGenericElement
,
441 &IID_IConnectionPointContainer
,
445 static const IID
* const style_iids
[] = {
456 static const IID
* const cstyle_iids
[] = {
460 &IID_IHTMLCurrentStyle
,
461 &IID_IHTMLCurrentStyle2
,
462 &IID_IHTMLCurrentStyle3
,
466 static const IID
* const img_factory_iids
[] = {
470 &IID_IHTMLImageElementFactory
,
474 static const IID
* const selection_iids
[] = {
478 &IID_IHTMLSelectionObject
,
479 &IID_IHTMLSelectionObject2
,
490 static const elem_type_info_t elem_type_infos
[] = {
491 {"", none_iids
, NULL
},
492 {"HTML", html_iids
, &DIID_DispHTMLHtmlElement
, &CLSID_HTMLHtmlElement
},
493 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
, &CLSID_HTMLHeadElement
},
494 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
, &CLSID_HTMLTitleElement
},
495 {"BODY", body_iids
, &DIID_DispHTMLBody
, &CLSID_HTMLBody
},
496 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
, &CLSID_HTMLAnchorElement
},
497 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
},
498 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
, &CLSID_HTMLSelectElement
},
499 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
, &CLSID_HTMLTextAreaElement
},
500 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
},
501 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
, &CLSID_HTMLStyleElement
},
502 {"BLOCKQUOTE",elem_iids
, NULL
},
503 {"P", elem_iids
, NULL
},
504 {"BR", elem_iids
, NULL
},
505 {"TABLE", table_iids
, &DIID_DispHTMLTable
, &CLSID_HTMLTable
},
506 {"TBODY", elem_iids
, NULL
},
507 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
, &CLSID_HTMLScriptElement
},
508 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
, &CLSID_HTMLUnknownElement
},
509 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
},
510 {"!", comment_iids
, &DIID_DispHTMLCommentElement
, &CLSID_HTMLCommentElement
},
511 {"IMG", img_iids
, &DIID_DispHTMLImg
, &CLSID_HTMLImg
},
512 {"TR", tr_iids
, &DIID_DispHTMLTableRow
, &CLSID_HTMLTableRow
},
513 {"TD", td_iids
, &DIID_DispHTMLTableCell
, &CLSID_HTMLTableCell
},
514 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
, &CLSID_HTMLIFrame
},
515 {"FORM", form_iids
, &DIID_DispHTMLFormElement
, &CLSID_HTMLFormElement
},
516 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
, &CLSID_HTMLFrameElement
},
517 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
, &CLSID_HTMLObjectElement
},
518 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
, &CLSID_HTMLEmbed
},
519 {"DIV", elem_iids
, NULL
},
520 {"META", meta_iids
, &DIID_DispHTMLMetaElement
, &CLSID_HTMLMetaElement
},
521 {"NOSCRIPT", elem_iids
, /* &DIID_DispHTMLNoShowElement */},
522 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
, &CLSID_HTMLLinkElement
},
523 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
, &CLSID_HTMLLabelElement
},
524 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
, &CLSID_HTMLButtonElement
},
525 {"AREA", area_iids
, &DIID_DispHTMLAreaElement
, &CLSID_HTMLAreaElement
},
526 {"svg", elem_iids
, NULL
},
527 {"circle", elem_iids
, NULL
}
530 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
533 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
534 return lstrcmpA(stra
, buf
);
537 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
542 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
543 prefix_len
= lstrlenA(prefix
);
548 return !lstrcmpA(buf
, prefix
);
551 static BSTR
a2bstr(const char *str
)
559 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
560 ret
= SysAllocStringLen(NULL
, len
);
561 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
566 static const char *debugstr_variant(const VARIANT
*var
)
568 static char buf
[400];
578 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
581 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
584 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
587 sprintf(buf
, "{vt %d}", V_VT(var
));
594 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
596 IUnknown
*unk1
, *unk2
;
601 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
602 IUnknown_Release(unk1
);
603 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
604 IUnknown_Release(unk2
);
609 static IHTMLDocument2
*create_document(void)
612 IHTMLDocument5
*doc5
;
615 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
616 &IID_IHTMLDocument2
, (void**)&doc
);
617 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
621 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
623 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
624 IHTMLDocument2_Release(doc
);
628 IHTMLDocument5_Release(doc5
);
632 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
633 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
638 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
639 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
643 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
644 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
646 const IID
* const *piid
;
650 for(piid
= iids
; *piid
; piid
++) {
651 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
652 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
654 IUnknown_Release(unk
);
658 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
659 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
664 unk
= (void*)0xdeadbeef;
665 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
666 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
667 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
670 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
671 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
673 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
680 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
681 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
682 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
684 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
685 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
687 if(SUCCEEDED(hres
)) {
690 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
691 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
693 *iid
= type_attr
->guid
;
697 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
698 ITypeInfo_Release(typeinfo
);
701 IDispatchEx_Release(dispex
);
705 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
706 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
708 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
709 DISPPARAMS dp
= {NULL
,NULL
,0,0};
714 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
715 IDispatchEx_Release(dispex
);
716 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
718 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
719 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
723 #define test_class_info(a,b) _test_class_info(__LINE__,a,b)
724 static void _test_class_info(unsigned line
, IUnknown
*unk
, const CLSID
*clsid
)
726 IProvideMultipleClassInfo
*multiple_classinfo
;
727 IProvideClassInfo2
*classinfo
;
733 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
734 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
738 hres
= IProvideClassInfo2_GetClassInfo(classinfo
, &typeinfo
);
739 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
742 IProvideClassInfo2_Release(classinfo
);
746 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
747 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
750 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, clsid
),
751 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
752 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
753 "unexpected typekind %d\n", type_attr
->typekind
);
754 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
757 ITypeInfo_Release(typeinfo
);
758 IProvideClassInfo2_Release(classinfo
);
760 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideMultipleClassInfo
, (void**)&multiple_classinfo
);
761 if(IsEqualGUID(clsid
, &CLSID_HTMLXMLHttpRequest
)) {
762 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
764 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
766 hres
= IProvideMultipleClassInfo_GetMultiTypeInfoCount(multiple_classinfo
, &count
);
767 ok_(__FILE__
,line
)(hres
== S_OK
, "GetMultiTypeInfoCount failed: %08x\n", hres
);
768 ok_(__FILE__
,line
)(count
> 0, "count = %u\n", count
);
770 IProvideMultipleClassInfo_Release(multiple_classinfo
);
774 #define test_disp2(a,b,c,d,e) _test_disp2(__LINE__,a,b,c,d,e)
775 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const CLSID
*clsid
, const char *val
)
781 if(_test_get_dispid(line
, unk
, &iid
) && compat_mode
< COMPAT_IE9
)
782 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(diid2
&& IsEqualGUID(&iid
, diid2
)),
783 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
785 if(!IsEqualGUID(diid
, &DIID_DispHTMLWindow2
) && !IsEqualGUID(diid
, &DIID_DispHTMLLocation
)) {
786 u
= (void*)0xdeadbeef;
787 hres
= IUnknown_QueryInterface(unk
, &IID_IMarshal
, (void**)&u
);
788 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IMarshal iface\n");
789 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
792 u
= (void*)0xdeadbeef;
793 hres
= IUnknown_QueryInterface(unk
, &IID_IManagedObject
, (void**)&u
);
794 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IManagedObject iface\n");
795 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
797 if(val
&& compat_mode
< COMPAT_IE9
) /* FIXME: Enable those tests in IE9+ mode */
798 _test_disp_value(line
, unk
, val
);
801 _test_class_info(line
, unk
, clsid
);
803 u
= (void*)0xdeadbeef;
804 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&u
);
805 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IProvideClassInfo iface\n");
806 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
810 #define test_disp(a,b,c,d) _test_disp(__LINE__,a,b,c,d)
811 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const CLSID
*clsid
, const char *val
)
813 return _test_disp2(line
, unk
, diid
, NULL
, clsid
, val
);
816 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
817 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
819 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
820 DISPPARAMS dp
= {val
, NULL
, 1, 0};
827 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
829 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
831 memset(&ei
, 0, sizeof(ei
));
832 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
833 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
837 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
838 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
843 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
844 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
848 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
849 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
854 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
855 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
859 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
860 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
865 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
866 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
870 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
871 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
876 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
877 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
881 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
882 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
884 IHTMLDocument3
*doc3
;
887 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
888 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
893 #define get_node_iface(u) _get_node_iface(__LINE__,u)
894 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
899 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
900 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
904 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
905 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
910 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
911 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
915 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
916 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
921 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
922 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
926 #define get_img_iface(u) _get_img_iface(__LINE__,u)
927 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
929 IHTMLImgElement
*img
;
932 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
933 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
937 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
938 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
940 IHTMLAnchorElement
*anchor
;
943 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
944 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
948 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
949 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
951 IHTMLTextAreaElement
*textarea
;
954 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
955 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
959 #define get_select_iface(u) _get_select_iface(__LINE__,u)
960 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
962 IHTMLSelectElement
*select
;
965 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
966 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
970 #define get_option_iface(u) _get_option_iface(__LINE__,u)
971 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
973 IHTMLOptionElement
*option
;
976 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
977 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
981 #define get_form_iface(u) _get_form_iface(__LINE__,u)
982 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
984 IHTMLFormElement
*form
;
987 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
988 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
992 #define get_text_iface(u) _get_text_iface(__LINE__,u)
993 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
995 IHTMLDOMTextNode
*text
;
998 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
999 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
1003 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
1004 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
1006 IHTMLDOMTextNode2
*text2
;
1009 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
1010 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
1014 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
1015 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
1017 IHTMLCommentElement
*comment
;
1020 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
1021 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
1025 #define get_object_iface(u) _get_object_iface(__LINE__,u)
1026 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
1028 IHTMLObjectElement
*obj
;
1031 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
1032 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
1036 #define get_style_iface(u) _get_style_iface(__LINE__,u)
1037 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
1039 IHTMLStyleElement
*obj
;
1042 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
1043 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
1047 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
1048 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
1050 IHTMLMetaElement
*ret
;
1053 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
1054 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
1058 #define get_link_iface(u) _get_link_iface(__LINE__,u)
1059 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
1061 IHTMLLinkElement
*ret
;
1064 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
1065 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
1069 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
1070 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
1072 IHTMLIFrameElement2
*ret
;
1075 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1076 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1080 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1081 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1083 IHTMLButtonElement
*ret
;
1086 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1087 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1091 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1092 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1094 IHTMLLabelElement
*ret
;
1097 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1098 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1102 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1103 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1105 IHTMLDOMAttribute2
*ret
;
1108 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1109 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1113 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1114 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1116 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1117 IHTMLElement6
*elem
;
1121 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1122 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1123 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1124 SysFreeString(name
);
1126 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement6
, (void**)&elem
);
1127 if(SUCCEEDED(hres
)) {
1128 hres
= IHTMLElement6_get_nodeName(elem
, &name
);
1129 ok_(__FILE__
, line
) (hres
== S_OK
, "(elem) get_nodeName failed: %08x\n", hres
);
1130 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "(elem) got name: %s, expected %s\n",
1131 wine_dbgstr_w(name
), exname
);
1132 SysFreeString(name
);
1133 IHTMLElement6_Release(elem
);
1136 IHTMLDOMNode_Release(node
);
1139 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1140 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1142 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1143 IDispatch
*disp
= (void*)0xdeadbeef;
1144 IHTMLDocument2
*doc
= NULL
;
1147 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1148 IHTMLDOMNode2_Release(node
);
1149 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1152 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1153 IDispatch_Release(disp
);
1154 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1160 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1161 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1163 IHTMLWindow2
*window
;
1167 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1168 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1169 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1174 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1175 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1177 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1178 IHTMLDOMNode
*ret
= NULL
;
1181 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1182 IHTMLDOMNode_Release(node
);
1183 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1184 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1190 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1191 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1193 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1194 IHTMLElement6
*elem6
;
1198 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1199 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1200 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1203 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement6
, (void**)&elem6
);
1204 if(SUCCEEDED(hres
)) {
1205 hres
= IHTMLElement6_get_tagName(elem6
, &tag
);
1206 ok_(__FILE__
, line
)(hres
== S_OK
, "(elem6) get_tagName failed: %08x\n", hres
);
1207 ok_(__FILE__
, line
)(!strcmp_wa(tag
, extag
), "(elem6) got tag: %s, expected %s\n",
1208 wine_dbgstr_w(tag
), extag
);
1210 IHTMLElement6_Release(elem6
);
1213 IHTMLElement_Release(elem
);
1216 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1217 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1219 const char *expected_value
= "[object]";
1221 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1222 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1224 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
) {
1226 expected_value
= NULL
;
1227 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, elem_type_infos
[type
].clsid
, expected_value
);
1231 #define get_node_type(n) _get_node_type(__LINE__,n)
1232 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1234 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1238 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1239 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1241 IHTMLDOMNode_Release(node
);
1246 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1247 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1249 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1250 IHTMLDOMChildrenCollection
*col
= NULL
;
1254 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1255 IHTMLDOMNode_Release(node
);
1256 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1260 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1261 IDispatch_Release(disp
);
1262 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1267 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1268 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1270 IHTMLDOMNode
*node
= NULL
;
1274 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1275 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1277 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1278 IDispatch_Release(disp
);
1283 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1284 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1290 VariantInit(&value
);
1293 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1298 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1299 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1301 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1304 VariantClear(&value
);
1307 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1308 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1310 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1311 IHTMLElement
*off_parent
;
1315 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1316 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1318 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1321 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1322 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1324 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1325 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1327 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1328 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1330 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1331 IHTMLElement_Release(off_parent
);
1333 IHTMLElement_Release(elem
);
1336 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1337 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1339 LONG l
= 0xdeadbeef;
1342 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1343 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1344 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1347 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1348 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1350 IHTMLWindow2
*window
;
1351 IHTMLDocument2
*ret
;
1354 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1355 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1357 hres
= IHTMLWindow2_get_document(window
, &ret
);
1358 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1359 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1364 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1365 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1370 hres
= IHTMLWindow2_get_name(window
, &name
);
1371 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1373 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1375 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1376 SysFreeString(name
);
1379 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1380 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1386 hres
= IHTMLWindow2_put_name(window
, str
);
1388 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1390 _test_window_name(line
, window
, name
);
1393 #define test_window_status(d) _test_window_status(__LINE__,d)
1394 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1399 status
= (void*)0xdeadbeef;
1400 hres
= IHTMLWindow2_get_status(window
, &status
);
1401 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1402 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1403 SysFreeString(status
);
1406 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1407 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1412 str
= a2bstr(status
);
1413 hres
= IHTMLWindow2_put_status(window
, str
);
1415 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1418 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1419 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1424 hres
= IHTMLWindow2_get_length(window
, &length
);
1425 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1426 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1429 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1430 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1432 IHTMLFrameBase2
*base2
;
1433 IHTMLWindow2
*window
;
1436 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1437 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1440 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1441 IHTMLFrameBase2_Release(base2
);
1442 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1443 ok(window
!= NULL
, "contentWindow = NULL\n");
1448 static void test_get_set_attr(IHTMLDocument2
*doc
)
1451 IHTMLDocument3
*doc3
;
1456 /* grab an element to test with */
1457 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1458 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1460 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1461 IHTMLDocument3_Release(doc3
);
1462 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1464 /* get a non-present attribute */
1465 bstr
= a2bstr("notAnAttribute");
1466 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1467 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1468 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1470 SysFreeString(bstr
);
1472 /* get a present attribute */
1473 bstr
= a2bstr("scrollHeight");
1474 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1475 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1476 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1478 SysFreeString(bstr
);
1480 /* create a new BSTR attribute */
1481 bstr
= a2bstr("newAttribute");
1483 V_VT(&val
) = VT_BSTR
;
1484 V_BSTR(&val
) = a2bstr("the value");
1485 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1486 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1489 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1490 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1491 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1492 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
)));
1495 /* overwrite the attribute with a BOOL */
1496 V_VT(&val
) = VT_BOOL
;
1497 V_BOOL(&val
) = VARIANT_TRUE
;
1498 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1499 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1502 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1503 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1504 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1505 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1508 SysFreeString(bstr
);
1510 /* case-insensitive */
1511 bstr
= a2bstr("newattribute");
1512 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1513 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1514 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1515 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1518 /* overwrite the attribute with null */
1519 V_VT(&val
) = VT_NULL
;
1520 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1521 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1523 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1524 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1525 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1526 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1529 SysFreeString(bstr
);
1530 IHTMLElement_Release(elem
);
1533 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1534 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1537 IHTMLDocument3
*doc3
;
1540 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1541 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1542 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1543 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1544 IHTMLDocument3_Release(doc3
);
1549 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1550 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1552 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1556 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1557 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1558 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1561 _test_disp_value(line
, unk
, exhref
);
1564 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1565 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1567 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1571 str
= a2bstr(exhref
);
1572 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1573 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1576 _test_disp_value(line
, unk
, exhref
);
1579 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1580 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1582 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1586 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1587 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1589 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1591 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1595 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1596 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1598 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1602 str
= a2bstr(exrel
);
1603 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1604 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1608 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1609 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1611 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1615 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1616 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1618 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1620 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1624 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1625 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1627 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1631 str
= target
? a2bstr(target
) : NULL
;
1632 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1633 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1637 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1638 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1640 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1644 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1645 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1647 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1649 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1653 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1654 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1656 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1660 str
= name
? a2bstr(name
) : NULL
;
1661 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1662 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1665 _test_anchor_name(line
, unk
, name
);
1668 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1669 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1671 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1675 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1676 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1678 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1680 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1684 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1685 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1687 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1691 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1692 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1693 if ( ! str
&& allowbroken
)
1694 win_skip("skip ie6 incorrect behavior\n");
1696 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1698 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1702 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1703 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1705 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1709 str
= search
? a2bstr(search
) : NULL
;
1710 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1711 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1715 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1716 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1718 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1722 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1723 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1725 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1727 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1731 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1732 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1737 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1738 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1739 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1740 SysFreeString(bstr
);
1743 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1744 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1749 bstr
= a2bstr(text
);
1750 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1751 SysFreeString(bstr
);
1752 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1754 _test_option_text(line
, option
, text
);
1757 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1758 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1763 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1764 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1765 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1766 SysFreeString(bstr
);
1769 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1770 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1775 bstr
= a2bstr(value
);
1776 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1777 SysFreeString(bstr
);
1778 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1780 _test_option_value(line
, option
, value
);
1783 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1784 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1786 VARIANT_BOOL b
= 0x100;
1789 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1790 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1791 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1794 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1795 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1799 hres
= IHTMLOptionElement_put_selected(option
, b
);
1800 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1801 _test_option_selected(line
, option
, b
);
1804 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1805 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1810 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1811 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1814 hres
= IHTMLOptionElement_get_index(option
, &val
);
1815 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1816 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1817 "value = %d, expected = %d\n", val
, exval
);
1820 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1821 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1825 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1826 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1829 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1830 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1835 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1836 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1839 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1840 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1841 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1844 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1846 test_option_defaultSelected(option
, VARIANT_FALSE
);
1847 test_option_selected(option
, VARIANT_FALSE
);
1849 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1850 test_option_defaultSelected(option
, VARIANT_FALSE
);
1851 test_option_selected(option
, VARIANT_FALSE
);
1853 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1854 test_option_defaultSelected(option
, VARIANT_TRUE
);
1855 test_option_selected(option
, VARIANT_FALSE
);
1857 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1858 test_option_defaultSelected(option
, VARIANT_FALSE
);
1859 test_option_selected(option
, VARIANT_FALSE
);
1861 test_option_put_selected(option
, VARIANT_TRUE
);
1862 test_option_selected(option
, VARIANT_TRUE
);
1863 test_option_defaultSelected(option
, VARIANT_FALSE
);
1865 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1866 test_option_defaultSelected(option
, VARIANT_TRUE
);
1867 test_option_selected(option
, VARIANT_TRUE
);
1869 /* Restore defaultSelected */
1870 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1871 test_option_put_selected(option
, VARIANT_FALSE
);
1874 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1875 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1877 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1878 BSTR value
= (void*)0xdeadbeef;
1881 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1882 IHTMLTextAreaElement_Release(textarea
);
1883 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1885 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1887 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1888 SysFreeString(value
);
1891 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1892 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1894 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1895 BSTR tmp
= a2bstr(value
);
1898 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1899 IHTMLTextAreaElement_Release(textarea
);
1900 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1903 _test_textarea_value(line
, unk
, value
);
1906 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1907 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1909 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1910 BSTR value
= (void*)0xdeadbeef;
1913 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1914 IHTMLTextAreaElement_Release(textarea
);
1915 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1917 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1919 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1920 SysFreeString(value
);
1923 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1924 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1926 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1927 BSTR tmp
= a2bstr(value
);
1930 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1931 IHTMLTextAreaElement_Release(textarea
);
1932 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1935 _test_textarea_defaultvalue(line
, unk
, value
);
1938 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1939 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1941 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1942 VARIANT_BOOL b
= 0x100;
1945 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1946 IHTMLTextAreaElement_Release(textarea
);
1947 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1948 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1951 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1952 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1954 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1957 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1958 IHTMLTextAreaElement_Release(textarea
);
1959 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1961 _test_textarea_readonly(line
, unk
, b
);
1964 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1965 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1967 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1968 BSTR type
= (void*)0xdeadbeef;
1971 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1972 IHTMLTextAreaElement_Release(textarea
);
1973 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1974 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1975 SysFreeString(type
);
1978 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1979 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1981 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1982 IHTMLFormElement
*form
;
1985 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1986 IHTMLTextAreaElement_Release(textarea
);
1987 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1992 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1993 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1995 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1999 hres
= IHTMLCommentElement_get_text(comment
, &text
);
2000 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
2001 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
2003 IHTMLCommentElement_Release(comment
);
2004 SysFreeString(text
);
2007 #define create_attr(a,b) _create_attr(__LINE__,a,b)
2008 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
2010 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
2011 BSTR str
= a2bstr("Test");
2012 IHTMLDOMAttribute
*attr
;
2015 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
2016 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
2018 IHTMLDocument5_Release(doc
);
2023 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
2024 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2026 VARIANT_BOOL specified
;
2029 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
2030 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
2031 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
2034 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
2035 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2037 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2038 VARIANT_BOOL expando
;
2041 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
2042 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
2043 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
2045 IHTMLDOMAttribute2_Release(attr2
);
2048 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
2049 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
2051 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2055 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
2056 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
2058 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
2060 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
2062 IHTMLDOMAttribute2_Release(attr2
);
2066 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
2067 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
2069 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2070 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
2071 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
2072 IHTMLDOMAttribute
*attr
;
2073 BSTR name
= a2bstr("test");
2077 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2078 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2079 ok(attr
== NULL
, "attr != NULL\n");
2083 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2084 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2086 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2087 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2088 ok(attr
!= NULL
, "attr == NULL\n");
2090 test_attr_expando(attr
, VARIANT_TRUE
);
2092 IHTMLDOMAttribute_Release(attr
);
2093 IHTMLCommentElement_Release(comment
);
2094 IHTMLElement_Release(elem
);
2095 IHTMLElement4_Release(elem4
);
2096 SysFreeString(name
);
2099 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2100 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2102 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2107 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2108 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
2109 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
2110 IHTMLObjectElement_Release(object
);
2113 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2114 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
2116 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2120 str
= (void*)0xdeadbeef;
2121 hres
= IHTMLObjectElement_get_name(object
, &str
);
2122 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2124 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2126 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2128 IHTMLObjectElement_Release(object
);
2131 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2132 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2134 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2139 hres
= IHTMLObjectElement_put_name(object
, str
);
2140 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2142 IHTMLObjectElement_Release(object
);
2144 _test_object_name(line
, elem
, name
);
2147 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2148 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2149 const char *txt
, const char *val
)
2151 IHTMLOptionElementFactory
*factory
;
2152 IHTMLOptionElement
*option
;
2153 IHTMLWindow2
*window
;
2154 VARIANT text
, value
, empty
;
2157 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2158 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2160 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2161 IHTMLWindow2_Release(window
);
2162 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2164 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, NULL
, "[object]");
2166 V_VT(&text
) = VT_BSTR
;
2167 V_BSTR(&text
) = a2bstr(txt
);
2168 V_VT(&value
) = VT_BSTR
;
2169 V_BSTR(&value
) = a2bstr(val
);
2170 V_VT(&empty
) = VT_EMPTY
;
2172 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2173 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2175 IHTMLOptionElementFactory_Release(factory
);
2176 VariantClear(&text
);
2177 VariantClear(&value
);
2179 _test_option_text(line
, option
, txt
);
2180 _test_option_value(line
, option
, val
);
2181 _test_option_selected(line
, option
, VARIANT_FALSE
);
2186 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2187 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2192 hres
= IHTMLImgElement_get_width(img
, &found
);
2193 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2194 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2197 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2198 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2202 hres
= IHTMLImgElement_put_width(img
, width
);
2203 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2205 _test_img_width(line
, img
, width
);
2208 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2209 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2214 hres
= IHTMLImgElement_get_height(img
, &found
);
2215 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2216 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2219 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2220 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2224 hres
= IHTMLImgElement_put_height(img
, height
);
2225 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2227 _test_img_height(line
, img
, height
);
2230 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2231 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2232 LONG wdth
, LONG hght
)
2234 IHTMLImageElementFactory
*factory
;
2235 IHTMLImgElement
*img
;
2236 IHTMLWindow2
*window
;
2237 VARIANT width
, height
;
2241 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2242 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2244 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2245 IHTMLWindow2_Release(window
);
2246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2248 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2249 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, NULL
, "[object]");
2252 snprintf(buf
, 16, "%d", wdth
);
2253 V_VT(&width
) = VT_BSTR
;
2254 V_BSTR(&width
) = a2bstr(buf
);
2256 V_VT(&width
) = VT_EMPTY
;
2261 snprintf(buf
, 16, "%d", hght
);
2262 V_VT(&height
) = VT_BSTR
;
2263 V_BSTR(&height
) = a2bstr(buf
);
2265 V_VT(&height
) = VT_EMPTY
;
2269 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2270 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2272 IHTMLImageElementFactory_Release(factory
);
2273 VariantClear(&width
);
2274 VariantClear(&height
);
2276 if(SUCCEEDED(hres
)) {
2277 _test_img_width(line
, img
, wdth
);
2278 _test_img_height(line
, img
, hght
);
2285 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2286 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2288 LONG len
= 0xdeadbeef;
2291 hres
= IHTMLSelectElement_get_length(select
, &len
);
2292 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2293 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2296 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2297 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2299 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2302 hres
= IHTMLSelectElement_put_length(select
, length
);
2303 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2304 _test_select_length(line
, select
, length
);
2305 IHTMLSelectElement_Release(select
);
2308 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2309 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2311 LONG idx
= 0xdeadbeef;
2314 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2316 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2319 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2320 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2324 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2325 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2326 _test_select_selidx(line
, select
, index
);
2329 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2330 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2335 hres
= IHTMLSelectElement_get_value(select
, &val
);
2336 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2338 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2340 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2344 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2345 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2351 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2352 SysFreeString(bstr
);
2353 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2356 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2357 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2362 hres
= IHTMLSelectElement_get_type(select
, &type
);
2363 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2364 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2365 SysFreeString(type
);
2368 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2369 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2371 VARIANT_BOOL b
= 100;
2374 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2375 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2376 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2379 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2380 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2384 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2385 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2387 _test_select_multiple(line
, select
, val
);
2390 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2391 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2396 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2397 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2400 hres
= IHTMLSelectElement_get_size(select
, &val
);
2401 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2402 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2405 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2406 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2410 hres
= IHTMLSelectElement_put_size(select
, val
);
2411 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2414 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2415 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2421 hres
= IHTMLSelectElement_get_name(select
, &text
);
2422 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2424 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2425 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2426 wine_dbgstr_w(text
), extext
);
2427 SysFreeString(text
);
2429 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2432 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2433 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2438 bstr
= a2bstr(text
);
2440 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2441 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2442 SysFreeString(bstr
);
2445 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2446 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2451 hres
= IHTMLTxtRange_get_text(range
, &text
);
2452 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2455 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2456 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2458 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2461 SysFreeString(text
);
2465 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2466 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2470 hres
= IHTMLTxtRange_collapse(range
, b
);
2471 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2472 _test_range_text(line
, range
, NULL
);
2475 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2476 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2477 VARIANT_BOOL exb
, const char *extext
)
2479 VARIANT_BOOL b
= 0xe0e0;
2482 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2483 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2484 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2485 _test_range_text(line
, range
, extext
);
2488 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2489 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2491 LONG c
= 0xdeadbeef;
2494 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2495 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2496 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2497 _test_range_text(line
, range
, NULL
);
2500 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2501 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2502 LPWSTR unit
, LONG cnt
, LONG excnt
)
2504 LONG c
= 0xdeadbeef;
2507 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2508 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2509 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2512 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2513 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2515 LONG c
= 0xdeadbeef;
2518 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2519 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2520 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2523 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2524 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2527 BSTR bstr
= a2bstr(text
);
2529 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2530 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2531 SysFreeString(bstr
);
2532 _test_range_text(line
, range
, NULL
);
2535 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2536 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2542 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2543 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2544 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2547 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2548 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2554 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2555 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2556 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2559 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2560 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2561 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2564 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2565 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2569 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2570 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2572 BSTR str
= a2bstr(html
);
2575 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2576 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2580 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2581 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2586 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2587 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2589 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2591 IHTMLElement_Release(elem
);
2594 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2595 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2597 VARIANT name
, index
;
2602 V_VT(&index
) = VT_EMPTY
;
2603 V_VT(&name
) = VT_I4
;
2605 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2606 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2607 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2609 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2610 IDispatch_Release(disp
);
2614 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2615 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2616 const elem_type_t
*elem_types
, LONG exlen
)
2618 IHTMLElementCollection
*col
;
2619 IEnumVARIANT
*enum_var
;
2624 VARIANT name
, index
, v
, vs
[5];
2625 IDispatch
*disp
, *disp2
;
2628 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2629 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2631 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, NULL
, "[object]");
2633 hres
= IHTMLElementCollection_get_length(col
, &len
);
2634 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2635 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2640 V_VT(&index
) = VT_EMPTY
;
2642 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2643 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2645 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2646 IUnknown_Release(enum_unk
);
2647 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2649 for(i
=0; i
<len
; i
++) {
2650 V_VT(&name
) = VT_I4
;
2652 disp
= (void*)0xdeadbeef;
2653 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2654 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2655 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2656 if(FAILED(hres
) || !disp
)
2659 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2662 V_VT(&name
) = VT_UINT
;
2664 disp2
= (void*)0xdeadbeef;
2665 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2666 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2667 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2669 IDispatch_Release(disp2
);
2673 V_VT(&v
) = VT_ERROR
;
2674 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2675 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2677 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2678 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2679 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2680 IDispatch_Release(V_DISPATCH(&v
));
2682 IDispatch_Release(disp
);
2685 fetched
= 0xdeadbeef;
2687 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2688 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2689 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2690 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2692 hres
= IEnumVARIANT_Reset(enum_var
);
2693 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2695 fetched
= 0xdeadbeef;
2697 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2698 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2699 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2700 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2702 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2703 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2705 memset(vs
, 0, sizeof(vs
));
2707 hres
= IEnumVARIANT_Next(enum_var
, ARRAY_SIZE(vs
), vs
, &fetched
);
2708 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2709 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2711 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2712 IDispatch_Release(V_DISPATCH(vs
));
2715 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2716 IDispatch_Release(V_DISPATCH(vs
+1));
2719 hres
= IEnumVARIANT_Reset(enum_var
);
2720 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2722 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2723 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2725 IEnumVARIANT_Release(enum_var
);
2727 V_VT(&name
) = VT_I4
;
2729 disp
= (void*)0xdeadbeef;
2730 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2731 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2732 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2734 V_VT(&name
) = VT_UI4
;
2736 disp
= (void*)0xdeadbeef;
2737 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2738 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2739 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2741 V_VT(&name
) = VT_INT
;
2743 disp
= (void*)0xdeadbeef;
2744 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2745 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2746 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2748 V_VT(&name
) = VT_UINT
;
2750 disp
= (void*)0xdeadbeef;
2751 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2752 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2753 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2755 V_VT(&name
) = VT_I4
;
2757 disp
= (void*)0xdeadbeef;
2758 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2759 if(compat_mode
< COMPAT_IE9
)
2760 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2762 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2763 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2765 IHTMLElementCollection_Release(col
);
2768 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2769 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2771 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2775 hres
= IHTMLElement_get_all(elem
, &disp
);
2776 IHTMLElement_Release(elem
);
2777 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2779 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2780 IDispatch_Release(disp
);
2783 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2784 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2786 IHTMLElementCollection
*col
;
2789 hres
= IHTMLDocument2_get_all(doc
, &col
);
2790 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2792 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2793 IHTMLElementCollection_Release(col
);
2796 #define test_children_collection_length(a,b) _test_children_collection_length(__LINE__,a,b)
2797 static LONG
_test_children_collection_length(unsigned line
, IHTMLDOMChildrenCollection
*collection
, LONG exlen
)
2802 hres
= IHTMLDOMChildrenCollection_get_length(collection
, &length
);
2803 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2805 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
2810 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2811 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2813 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2814 IHTMLElementCollection
*col
= NULL
;
2815 elem_type_t
*types
= NULL
;
2820 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2821 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2823 IHTMLElement2_Release(elem
);
2824 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2825 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2828 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2829 for(i
=0; i
<exlen
; i
++)
2833 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2835 HeapFree(GetProcessHeap(), 0, types
);
2838 *ret
= get_elem_col_item_idx(col
, 0);
2839 IHTMLElementCollection_Release(col
);
2842 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2843 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2845 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2846 IHTMLElementCollection
*col
= NULL
;
2847 elem_type_t
*types
= NULL
;
2852 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2853 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2855 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2856 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2859 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2860 for(i
=0; i
<exlen
; i
++)
2864 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2866 HeapFree(GetProcessHeap(), 0, types
);
2867 IHTMLElementCollection_Release(col
);
2868 IHTMLDocument3_Release(doc
);
2871 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2872 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2877 hres
= IHTMLElement_get_innerText(elem
, &text
);
2878 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2880 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2881 wine_dbgstr_w(text
), extext
);
2883 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2884 SysFreeString(text
);
2887 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2888 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2890 IHTMLDOMChildrenCollection
*col
;
2895 hres
= IHTMLElement_put_innerText(elem
, str
);
2896 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2899 _test_elem_innertext(line
, elem
, text
);
2902 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2903 ok(col
!= NULL
, "col == NULL\n");
2908 _test_children_collection_length(line
, col
, 1);
2910 node
= _get_child_item(line
, col
, 0);
2911 ok(node
!= NULL
, "node == NULL\n");
2913 type
= _get_node_type(line
, (IUnknown
*)node
);
2914 ok(type
== 3, "type=%d\n", type
);
2915 IHTMLDOMNode_Release(node
);
2918 IHTMLDOMChildrenCollection_Release(col
);
2923 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
2924 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2929 hres
= IHTMLElement_get_outerText(elem
, &text
);
2930 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08x\n", hres
);
2932 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_outerText returned %s expected %s\n",
2933 wine_dbgstr_w(text
), extext
);
2935 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2936 SysFreeString(text
);
2939 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
2940 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2942 BSTR str
= a2bstr(text
);
2945 hres
= IHTMLElement_put_outerText(elem
, str
);
2946 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08x\n", hres
);
2950 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
2951 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
2953 BSTR str
= a2bstr("test");
2956 hres
= IHTMLElement_put_outerText(elem
, str
);
2957 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08x\n", hres
);
2961 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2962 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2964 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2968 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2969 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2971 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2973 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2975 IHTMLElement_Release(elem
);
2976 SysFreeString(html
);
2979 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2980 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2982 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2986 html
= a2bstr(inner_html
);
2987 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2988 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2990 IHTMLElement_Release(elem
);
2991 SysFreeString(html
);
2994 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2995 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2997 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3001 html
= a2bstr(outer_html
);
3002 hres
= IHTMLElement_put_outerHTML(elem
, html
);
3003 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
3005 IHTMLElement_Release(elem
);
3006 SysFreeString(html
);
3009 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
3010 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
3012 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3016 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
3017 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
3018 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
3020 IHTMLElement_Release(elem
);
3021 SysFreeString(html
);
3024 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
3025 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
3031 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
3032 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
3033 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
3036 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
3037 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
3043 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
3044 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
3045 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
3048 #define get_first_child(n) _get_first_child(__LINE__,n)
3049 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
3051 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3052 IHTMLDOMNode
*child
= NULL
;
3055 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
3056 IHTMLDOMNode_Release(node
);
3057 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
3062 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
3063 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3065 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3066 VARIANT_BOOL b
= 0xdead;
3069 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
3070 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
3071 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
3073 IHTMLDOMNode_Release(node
);
3076 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
3077 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
3079 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3080 IHTMLDOMNode
*parent
;
3083 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
3084 IHTMLDOMNode_Release(node
);
3085 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3090 #define node_get_next(u) _node_get_next(__LINE__,u)
3091 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
3093 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3097 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
3098 IHTMLDOMNode_Release(node
);
3099 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
3104 #define node_get_prev(u) _node_get_prev(__LINE__,u)
3105 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
3107 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3111 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3112 IHTMLDOMNode_Release(node
);
3113 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
3118 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3119 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3121 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3122 IHTMLElement
*parent
;
3125 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3126 IHTMLElement_Release(elem
);
3127 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
3132 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3133 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3135 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3136 VARIANT_BOOL disabled
= 100;
3140 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3141 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3142 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3143 IHTMLElement3_Release(elem3
);
3146 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3147 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3149 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3153 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3154 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3156 IHTMLElement3_Release(elem3
);
3157 _test_elem3_get_disabled(line
, unk
, b
);
3160 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3161 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3163 VARIANT_BOOL disabled
= 100;
3166 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3167 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3168 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3170 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3173 static void test_select_remove(IHTMLSelectElement
*select
)
3177 hres
= IHTMLSelectElement_remove(select
, 3);
3178 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3179 test_select_length(select
, 2);
3181 hres
= IHTMLSelectElement_remove(select
, -1);
3182 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3183 test_select_length(select
, 2);
3185 hres
= IHTMLSelectElement_remove(select
, 0);
3186 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3187 test_select_length(select
, 1);
3190 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3191 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3193 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3197 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3198 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3199 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3200 IHTMLDOMTextNode_Release(text
);
3203 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3204 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3206 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3210 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3211 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3212 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3213 IHTMLDOMTextNode_Release(text
);
3217 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3218 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3220 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3221 BSTR str
= a2bstr(data
);
3224 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3225 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3226 IHTMLDOMTextNode_Release(text
);
3230 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3231 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3233 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3234 BSTR str
= a2bstr(data
);
3237 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3238 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3239 IHTMLDOMTextNode2_Release(text
);
3243 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3244 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3248 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3249 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3251 _test_select_get_disabled(line
, select
, b
);
3254 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3255 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3257 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3261 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3262 IHTMLElement2_Release(elem
);
3263 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3265 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3267 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3272 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3273 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3275 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3276 BSTR dir
= a2bstr(dira
);
3279 hres
= IHTMLElement2_put_dir(elem
, dir
);
3280 IHTMLElement2_Release(elem
);
3281 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3284 _test_elem_dir(line
, unk
, dira
);
3287 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3288 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3290 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3291 IHTMLTextContainer
*txtcont
;
3292 LONG l
= -1, l2
= -1;
3295 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3297 IHTMLElement2_Release(elem
);
3299 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3300 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3302 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3303 IHTMLTextContainer_Release(txtcont
);
3304 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3305 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3310 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3311 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3313 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3314 IHTMLTextContainer
*txtcont
;
3315 LONG l
= -1, l2
= -1;
3318 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3320 IHTMLElement2_Release(elem
);
3322 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3323 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3325 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3326 IHTMLTextContainer_Release(txtcont
);
3327 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3328 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3333 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3334 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3336 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3337 IHTMLTextContainer
*txtcont
;
3338 LONG l
= -1, l2
= -1;
3341 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3342 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3343 IHTMLElement2_Release(elem
);
3345 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3346 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3348 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3349 IHTMLTextContainer_Release(txtcont
);
3350 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3351 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3356 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3357 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3359 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3360 IHTMLTextContainer
*txtcont
;
3361 LONG l
= -1, l2
= -1;
3364 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3365 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3367 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3368 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3369 IHTMLElement2_Release(elem
);
3371 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3372 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3374 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3375 IHTMLTextContainer_Release(txtcont
);
3376 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3377 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3380 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3381 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3383 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3387 hres
= IHTMLImgElement_get_src(img
, &src
);
3388 IHTMLImgElement_Release(img
);
3389 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3390 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3391 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3395 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3396 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3398 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3403 hres
= IHTMLImgElement_put_src(img
, tmp
);
3404 IHTMLImgElement_Release(img
);
3406 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3409 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3410 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3412 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3416 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3417 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3419 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3421 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3425 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3426 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3428 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3433 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3434 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3437 _test_img_alt(line
, unk
, alt
);
3440 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3441 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3443 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3447 tmp
= a2bstr(align
);
3448 hres
= IHTMLImgElement_put_align(img
, tmp
);
3449 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3452 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3453 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3454 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3458 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3459 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3461 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3465 hres
= IHTMLImgElement_get_name(img
, &sName
);
3466 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3467 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3468 IHTMLImgElement_Release(img
);
3469 SysFreeString(sName
);
3472 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3473 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3475 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3476 VARIANT_BOOL b
= 100;
3479 hres
= IHTMLImgElement_get_complete(img
, &b
);
3480 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3481 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3482 IHTMLImgElement_Release(img
);
3485 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3486 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3488 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3489 VARIANT_BOOL b
= 100;
3492 hres
= IHTMLImgElement_put_isMap(img
, v
);
3493 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3495 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3496 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3497 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3499 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3500 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3501 IHTMLImgElement_Release(img
);
3504 static void test_dynamic_properties(IHTMLElement
*elem
)
3506 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3507 IDispatchEx
*dispex
;
3508 BSTR name
, attr1
= SysAllocString(attr1W
);
3512 DISPID id
= DISPID_STARTENUM
;
3515 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3516 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3518 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3519 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3520 ok(succ
, "removeAttribute set succ to FALSE\n");
3523 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3524 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3528 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3529 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3531 if(!strcmp_wa(name
, "attr1"))
3532 ok(0, "attr1 should be removed\n");
3533 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3535 SysFreeString(name
);
3537 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3538 IDispatchEx_Release(dispex
);
3540 V_VT(&val
) = VT_BSTR
;
3541 V_BSTR(&val
) = attr1
;
3542 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3543 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3544 SysFreeString(attr1
);
3547 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3548 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3553 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3554 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3555 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3559 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3560 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3562 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3563 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3566 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3567 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3568 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3569 IHTMLDOMAttribute2_Release(attr2
);
3572 static void test_attr_collection_disp(IDispatch
*disp
)
3574 IDispatchEx
*dispex
;
3575 IHTMLDOMAttribute
*attr
;
3576 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3583 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3584 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3587 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3588 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3589 SysFreeString(bstr
);
3592 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3593 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3594 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3595 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3598 bstr
= a2bstr("attr1");
3599 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3600 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3601 SysFreeString(bstr
);
3604 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3605 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3606 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3607 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3608 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3609 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3611 test_attr_node_name(attr
, "attr1");
3613 IHTMLDOMAttribute_Release(attr
);
3616 IDispatchEx_Release(dispex
);
3619 static void test_attr_collection(IHTMLElement
*elem
)
3621 static const WCHAR testW
[] = {'t','e','s','t',0};
3624 IDispatch
*disp
, *attr
;
3625 IHTMLDOMAttribute
*dom_attr
;
3626 IHTMLAttributeCollection
*attr_col
;
3627 BSTR name
= SysAllocString(testW
);
3629 LONG i
, len
, checked
;
3632 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3633 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3635 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3636 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3638 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3639 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3640 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3641 IDispatch_Release(attr
);
3642 IHTMLDOMNode_Release(node
);
3644 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3645 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3647 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3648 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3652 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3653 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3654 SysFreeString(name
);
3656 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3657 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3658 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3661 for(i
=0; i
<len
; i
++) {
3664 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3665 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3667 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3668 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3669 IDispatch_Release(attr
);
3671 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3672 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3674 if(!strcmp_wa(name
, "id")) {
3676 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3677 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3678 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3679 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3680 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3681 test_attr_value(dom_attr
, "attr");
3682 } else if(!strcmp_wa(name
, "attr1")) {
3684 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3685 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3686 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3687 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3688 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3689 test_attr_value(dom_attr
, "attr1");
3690 } else if(!strcmp_wa(name
, "attr2")) {
3692 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3693 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3694 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3695 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3696 test_attr_value(dom_attr
, "");
3697 } else if(!strcmp_wa(name
, "attr3")) {
3699 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3700 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3701 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3702 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3703 test_attr_value(dom_attr
, "attr3");
3704 } else if(!strcmp_wa(name
, "test")) {
3706 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3707 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3708 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3709 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3710 test_attr_value(dom_attr
, "1");
3713 IHTMLDOMAttribute_Release(dom_attr
);
3714 SysFreeString(name
);
3717 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3720 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3721 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3723 V_VT(&id
) = VT_BSTR
;
3724 V_BSTR(&id
) = a2bstr("nonexisting");
3725 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3726 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3729 test_attr_collection_disp(disp
);
3731 IDispatch_Release(disp
);
3732 IHTMLAttributeCollection_Release(attr_col
);
3735 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3736 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3738 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3739 BSTR id
= (void*)0xdeadbeef;
3742 hres
= IHTMLElement_get_id(elem
, &id
);
3743 IHTMLElement_Release(elem
);
3744 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3747 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3749 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3754 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3755 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3757 BSTR lang
= (void*)0xdeadbeef;
3760 hres
= IHTMLElement_get_language(elem
, &lang
);
3761 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3764 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3766 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3768 SysFreeString(lang
);
3771 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3772 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3774 BSTR str
= a2bstr(lang
);
3777 hres
= IHTMLElement_put_language(elem
, str
);
3778 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3781 _test_elem_language(line
, elem
, lang
);
3784 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3785 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3787 BSTR lang
= (void*)0xdeadbeef;
3790 hres
= IHTMLElement_get_lang(elem
, &lang
);
3791 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3794 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3796 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3798 SysFreeString(lang
);
3801 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3802 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3804 BSTR str
= a2bstr(lang
);
3807 hres
= IHTMLElement_put_lang(elem
, str
);
3808 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3811 _test_elem_lang(line
, elem
, lang
);
3814 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3815 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3817 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3818 BSTR tmp
= a2bstr(new_id
);
3821 hres
= IHTMLElement_put_id(elem
, tmp
);
3822 IHTMLElement_Release(elem
);
3824 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3826 _test_elem_id(line
, unk
, new_id
);
3829 static void test_contenteditable(IUnknown
*unk
)
3831 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3833 BSTR str
, strDefault
;
3835 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3836 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3838 str
= a2bstr("true");
3839 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3840 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3842 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3843 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3844 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3847 /* Restore origin contentEditable */
3848 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3849 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3850 SysFreeString(strDefault
);
3852 IHTMLElement3_Release(elem3
);
3855 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3856 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3861 hres
= IHTMLInputElement_get_type(input
, &type
);
3862 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3863 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3864 SysFreeString(type
);
3867 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3868 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3870 BSTR name
= (BSTR
)0xdeadbeef;
3873 hres
= IHTMLInputElement_get_name(input
, &name
);
3874 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3876 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3878 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3879 SysFreeString(name
);
3882 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3883 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3885 BSTR tmp
= a2bstr(name
);
3888 hres
= IHTMLInputElement_put_name(input
, tmp
);
3889 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3892 _test_input_name(line
, input
, name
);
3895 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3896 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3898 VARIANT_BOOL disabled
= 100;
3901 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3902 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3903 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3905 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3908 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3909 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3913 hres
= IHTMLInputElement_put_disabled(input
, b
);
3914 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3916 _test_input_get_disabled(line
, input
, b
);
3919 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3920 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3922 VARIANT_BOOL checked
= 100;
3925 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3926 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3927 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3930 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3931 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3935 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3936 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3938 _test_input_get_defaultchecked(line
, input
, b
);
3941 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3942 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3944 VARIANT_BOOL checked
= 100;
3947 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3948 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3949 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3952 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3953 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3957 hres
= IHTMLInputElement_put_checked(input
, b
);
3958 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3960 _test_input_get_checked(line
, input
, b
);
3963 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3964 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3966 LONG maxlength
= 0xdeadbeef;
3969 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3970 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3971 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3974 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3975 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3979 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3980 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3982 _test_input_maxlength(line
, input
, l
);
3985 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3986 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3988 IHTMLInputElement
*input
;
3992 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3993 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3997 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3998 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
4000 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
4002 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
4003 SysFreeString(bstr
);
4004 IHTMLInputElement_Release(input
);
4007 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
4008 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
4010 IHTMLInputElement
*input
;
4011 IHTMLFormElement
*form
;
4015 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
4016 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4017 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4018 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
4019 if(FAILED(hres
) || input
== NULL
)
4022 hres
= IHTMLInputElement_get_form(input
, &form
);
4023 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
4024 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
4025 if(FAILED(hres
) || form
== NULL
){
4026 IHTMLInputElement_Release(input
);
4030 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
4031 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
4032 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
4033 if(FAILED(hres
) || elem
== NULL
){
4034 IHTMLInputElement_Release(input
);
4035 IHTMLFormElement_Release(form
);
4039 _test_elem_id(line
, (IUnknown
*)elem
, id
);
4041 IHTMLInputElement_Release(input
);
4042 IHTMLFormElement_Release(form
);
4043 IHTMLElement_Release(elem
);
4046 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
4047 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
4049 IHTMLInputElement
*input
;
4053 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4054 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4059 hres
= IHTMLInputElement_put_value(input
, bstr
);
4060 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
4061 SysFreeString(bstr
);
4062 IHTMLInputElement_Release(input
);
4064 _test_input_value(line
, unk
, val
);
4067 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
4068 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
4070 IHTMLInputElement
*input
;
4074 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4075 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4079 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
4080 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4082 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
4084 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
4086 IHTMLInputElement_Release(input
);
4089 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
4090 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
4092 IHTMLInputElement
*input
;
4096 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4097 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4102 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
4103 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4105 IHTMLInputElement_Release(input
);
4107 _test_input_defaultValue(line
, unk
, val
);
4110 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4111 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
4116 hres
= IHTMLInputElement_get_src(input
, &src
);
4117 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
4119 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
4121 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4125 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4126 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
4132 hres
= IHTMLInputElement_put_src(input
, tmp
);
4134 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
4136 _test_input_src(line
, input
, src
);
4139 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4140 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4144 hres
= IHTMLInputElement_put_size(input
, size
);
4145 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
4148 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4149 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4154 hres
= IHTMLInputElement_get_size(input
, &size
);
4155 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
4156 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
4158 hres
= IHTMLInputElement_get_size(input
, NULL
);
4159 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
4162 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4163 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4166 VARIANT_BOOL b
= 100;
4168 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4169 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
4171 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4172 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
4173 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4176 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4177 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
4179 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4180 BSTR
class = (void*)0xdeadbeef;
4183 hres
= IHTMLElement_get_className(elem
, &class);
4184 IHTMLElement_Release(elem
);
4185 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4187 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4189 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4190 SysFreeString(class);
4193 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4194 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4196 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4200 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4201 IHTMLElement2_Release(elem2
);
4202 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4203 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4206 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4207 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4209 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4212 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4213 IHTMLElement2_Release(elem2
);
4214 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4216 _test_elem_tabindex(line
, unk
, index
);
4219 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4220 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4222 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4226 hres
= IHTMLStyleElement_get_media(style
, &media
);
4227 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4229 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4231 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4233 IHTMLStyleElement_Release(style
);
4234 SysFreeString(media
);
4237 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4238 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4240 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4244 str
= a2bstr(media
);
4245 hres
= IHTMLStyleElement_put_media(style
, str
);
4246 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4247 IHTMLStyleElement_Release(style
);
4250 _test_style_media(line
, unk
, media
);
4253 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4254 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4256 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4260 hres
= IHTMLStyleElement_get_type(style
, &type
);
4261 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4263 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4265 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4267 IHTMLStyleElement_Release(style
);
4268 SysFreeString(type
);
4271 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4272 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4274 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4279 hres
= IHTMLStyleElement_put_type(style
, str
);
4280 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4281 IHTMLStyleElement_Release(style
);
4284 _test_style_type(line
, unk
, type
);
4287 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4288 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4290 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4292 IHTMLFiltersCollection
*filters
;
4294 hres
= IHTMLElement_get_filters(elem
, &filters
);
4295 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4296 "get_filters failed: %08x\n", hres
);
4300 IDispatchEx
*dispex
;
4302 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4303 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4304 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4306 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4307 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4308 "Could not get IDispatchEx interface: %08x\n", hres
);
4309 if(SUCCEEDED(hres
)) {
4310 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, NULL
, "[object]");
4311 IDispatchEx_Release(dispex
);
4314 IHTMLFiltersCollection_Release(filters
);
4317 IHTMLElement_Release(elem
);
4320 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4321 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4323 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4327 tmp
= class ? a2bstr(class) : NULL
;
4328 hres
= IHTMLElement_put_className(elem
, tmp
);
4329 IHTMLElement_Release(elem
);
4330 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4333 _test_elem_class(line
, unk
, class);
4336 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4337 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4339 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4343 hres
= IHTMLElement_get_title(elem
, &title
);
4344 IHTMLElement_Release(elem
);
4345 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4347 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4349 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4351 SysFreeString(title
);
4354 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4355 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4357 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4361 tmp
= a2bstr(title
);
4362 hres
= IHTMLElement_put_title(elem
, tmp
);
4363 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4365 IHTMLElement_Release(elem
);
4369 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4370 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4372 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4376 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4377 IHTMLDOMNode_Release(node
);
4378 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4381 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4382 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4384 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4390 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4391 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4393 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4397 V_VT(&var
) = VT_BSTR
;
4398 V_BSTR(&var
) = a2bstr(val
);
4400 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4401 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4402 IHTMLDOMNode_Release(node
);
4406 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4407 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4409 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4413 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4414 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4415 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4416 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4418 IHTMLElement2_Release(elem
);
4421 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4422 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4424 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4428 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4429 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4430 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4432 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4433 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4434 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4436 IHTMLElement2_Release(elem
);
4439 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4440 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4442 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4443 LONG len
= 0xdeadbeef;
4446 hres
= IHTMLFormElement_get_length(form
, &len
);
4447 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4448 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4450 IHTMLFormElement_Release(form
);
4453 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4454 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4456 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4457 BSTR action
= (void*)0xdeadbeef;
4460 hres
= IHTMLFormElement_get_action(form
, &action
);
4461 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4463 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4465 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4467 SysFreeString(action
);
4468 IHTMLFormElement_Release(form
);
4471 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4472 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4474 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4475 BSTR tmp
= a2bstr(action
);
4478 hres
= IHTMLFormElement_put_action(form
, tmp
);
4479 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4481 IHTMLFormElement_Release(form
);
4483 _test_form_action(line
, unk
, action
);
4486 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4487 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4489 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4490 BSTR method
= (void*)0xdeadbeef;
4493 hres
= IHTMLFormElement_get_method(form
, &method
);
4494 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4496 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4498 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4500 SysFreeString(method
);
4501 IHTMLFormElement_Release(form
);
4504 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4505 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4507 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4508 BSTR tmp
= a2bstr(method
);
4511 hres
= IHTMLFormElement_put_method(form
, tmp
);
4512 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4514 IHTMLFormElement_Release(form
);
4516 if(exp_hres
== S_OK
)
4517 _test_form_method(line
, unk
, method
);
4520 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4521 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4523 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4524 BSTR name
= (void*)0xdeadbeef;
4527 hres
= IHTMLFormElement_get_name(form
, &name
);
4528 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4530 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4532 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4534 SysFreeString(name
);
4535 IHTMLFormElement_Release(form
);
4538 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4539 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4541 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4542 BSTR tmp
= a2bstr(name
);
4545 hres
= IHTMLFormElement_put_name(form
, tmp
);
4546 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4548 IHTMLFormElement_Release(form
);
4550 _test_form_name(line
, unk
, name
);
4553 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4554 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4556 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4557 BSTR encoding
= (void*)0xdeadbeef;
4560 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4561 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4563 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4565 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4567 SysFreeString(encoding
);
4568 IHTMLFormElement_Release(form
);
4571 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4572 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4574 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4575 BSTR tmp
= a2bstr(encoding
);
4578 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4579 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4581 IHTMLFormElement_Release(form
);
4583 if(exp_hres
== S_OK
)
4584 _test_form_encoding(line
, unk
, encoding
);
4587 #define test_form_elements(a,b,c) _test_form_elements(__LINE__,a,b,c)
4588 static void _test_form_elements(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
,
4589 LONG elem_types_cnt
)
4591 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4596 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4597 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4598 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4599 if(compat_mode
< COMPAT_IE9
)
4600 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4602 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, elem_types_cnt
);
4604 IDispatch_Release(disp
);
4605 IHTMLFormElement_Release(form
);
4608 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4609 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4611 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4614 hres
= IHTMLFormElement_reset(form
);
4615 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4617 IHTMLFormElement_Release(form
);
4620 static void test_form_target(IUnknown
*unk
)
4622 IHTMLFormElement
*form
= get_form_iface(unk
);
4625 static const char target
[] = "_blank";
4627 str
= a2bstr(target
);
4628 hres
= IHTMLFormElement_put_target(form
, str
);
4629 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4632 hres
= IHTMLFormElement_get_target(form
, &str
);
4633 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4634 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4637 IHTMLFormElement_Release(form
);
4640 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4642 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4643 IHTMLFormElement
*form
;
4646 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4647 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4649 hres
= IHTMLSelectElement_get_form(select
, &form
);
4650 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4651 ok(form
!= NULL
, "form == NULL\n");
4653 test_form_length((IUnknown
*)form
, 2);
4654 test_form_elements((IUnknown
*)form
, NULL
, 0);
4655 test_form_name((IUnknown
*)form
, "form_name");
4657 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4659 IHTMLSelectElement_Release(select
);
4660 IHTMLFormElement_Release(form
);
4663 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4665 IHTMLFormElement
*form
;
4668 form
= (IHTMLFormElement
*)0xdeadbeef;
4669 hres
= IHTMLSelectElement_get_form(select
, &form
);
4670 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4671 ok(form
== NULL
, "got %p\n", form
);
4674 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4675 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4677 IHTMLMetaElement
*meta
;
4681 meta
= _get_metaelem_iface(line
, unk
);
4682 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4683 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4684 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4685 SysFreeString(name
);
4686 IHTMLMetaElement_Release(meta
);
4689 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4690 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4692 IHTMLMetaElement
*meta
;
4693 BSTR content
= NULL
;
4696 meta
= _get_metaelem_iface(line
, unk
);
4697 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4698 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4699 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4700 SysFreeString(content
);
4701 IHTMLMetaElement_Release(meta
);
4704 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4705 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4707 IHTMLMetaElement
*meta
;
4711 meta
= _get_metaelem_iface(line
, unk
);
4712 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4713 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4714 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4716 IHTMLMetaElement_Release(meta
);
4719 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4720 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4722 IHTMLMetaElement
*meta
;
4726 meta
= _get_metaelem_iface(line
, unk
);
4727 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4728 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4730 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4732 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4734 IHTMLMetaElement_Release(meta
);
4737 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4738 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4740 BSTR val
= a2bstr(vala
);
4741 IHTMLMetaElement
*meta
;
4744 meta
= _get_metaelem_iface(line
, unk
);
4745 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4746 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4748 IHTMLMetaElement_Release(meta
);
4750 _test_meta_charset(line
, unk
, vala
);
4753 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4754 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4756 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4760 str
= a2bstr(exval
);
4761 hres
= IHTMLLinkElement_put_media(link
, str
);
4762 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4765 hres
= IHTMLLinkElement_get_media(link
, &str
);
4766 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4767 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4769 IHTMLLinkElement_Release(link
);
4772 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4773 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4775 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4776 VARIANT_BOOL b
= 10;
4779 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4780 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4781 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4783 IHTMLLinkElement_Release(link
);
4786 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4787 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4789 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4792 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4793 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4794 IHTMLLinkElement_Release(link
);
4795 _test_link_disabled(line
, elem
, v
);
4798 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4799 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4801 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4805 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4806 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4808 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4810 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4813 IHTMLLinkElement_Release(link
);
4816 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4817 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4819 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4820 BSTR str
= a2bstr(v
);
4823 hres
= IHTMLLinkElement_put_rel(link
, str
);
4824 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4826 IHTMLLinkElement_Release(link
);
4827 _test_link_rel(line
, elem
, v
);
4830 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4831 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4833 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4837 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4838 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4840 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4842 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4845 IHTMLLinkElement_Release(link
);
4848 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4849 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4851 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4852 BSTR str
= a2bstr(v
);
4855 hres
= IHTMLLinkElement_put_rev(link
, str
);
4856 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4858 IHTMLLinkElement_Release(link
);
4859 _test_link_rev(line
, elem
, v
);
4862 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4863 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4865 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4869 hres
= IHTMLLinkElement_get_type(link
, &type
);
4870 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4872 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4874 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4875 SysFreeString(type
);
4877 IHTMLLinkElement_Release(link
);
4880 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4881 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4886 str
= (void*)0xdeadbeef;
4887 hres
= IHTMLScriptElement_get_text(script
, &str
);
4888 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4889 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4893 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4894 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4896 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4897 BSTR str
= a2bstr(v
);
4900 hres
= IHTMLLinkElement_put_type(link
, str
);
4901 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4903 IHTMLLinkElement_Release(link
);
4904 _test_link_type(line
, elem
, v
);
4907 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4908 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4910 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4914 hres
= IHTMLLinkElement_get_href(link
, &href
);
4915 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4917 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4919 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4920 SysFreeString(href
);
4922 IHTMLLinkElement_Release(link
);
4925 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4926 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4928 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4929 BSTR str
= a2bstr(v
);
4932 hres
= IHTMLLinkElement_put_href(link
, str
);
4933 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4935 IHTMLLinkElement_Release(link
);
4936 _test_link_href(line
, elem
, v
);
4939 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4940 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4942 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4943 IHTMLDocument2
*doc
;
4948 hres
= IHTMLElement_get_document(elem
, &disp
);
4949 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4950 ok(disp
!= NULL
, "disp == NULL\n");
4952 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4953 IDispatch_Release(disp
);
4954 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4959 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4960 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4962 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4963 BSTR str
= a2bstr(attr_name
);
4964 IHTMLDOMAttribute
*attr
;
4967 attr
= (void*)0xdeadbeef;
4968 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4969 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4971 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4973 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4975 IHTMLElement4_Release(elem
);
4980 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4981 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4986 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4987 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4988 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4991 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4992 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4996 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4997 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
5000 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
5001 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
5003 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
5004 BSTR str
= a2bstr(value
);
5007 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
5008 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
5010 IHTMLDOMAttribute2_Release(attr2
);
5014 #define get_window_doc(e) _get_window_doc(__LINE__,e)
5015 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
5017 IHTMLDocument2
*doc
;
5021 hres
= IHTMLWindow2_get_document(window
, &doc
);
5022 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5023 ok(doc
!= NULL
, "disp == NULL\n");
5028 #define doc_get_body(d) _doc_get_body(__LINE__,d)
5029 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
5034 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5035 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5036 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
5041 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
5042 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
5044 IHTMLElement
*elem
= NULL
;
5049 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
5050 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5051 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
5057 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
5058 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
5060 IHTMLDocument3
*doc3
;
5061 IHTMLDOMNode
*node
= NULL
;
5065 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5066 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
5069 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
5070 IHTMLDocument3_Release(doc3
);
5072 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5073 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
5078 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
5079 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5081 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5082 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
5083 IHTMLDOMNode
*new_child
= NULL
;
5086 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
5087 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
5088 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5089 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5091 IHTMLDOMNode_Release(node
);
5092 IHTMLDOMNode_Release(child
);
5097 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
5098 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
5100 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5101 IHTMLDOMNode
*new_child
= NULL
;
5104 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
5105 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
5106 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5107 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5109 IHTMLDOMNode_Release(node
);
5114 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
5115 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
5117 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5118 IHTMLDOMNode
*new_node
= NULL
;
5121 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5122 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
5123 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5124 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5126 IHTMLDOMNode_Release(node
);
5127 IHTMLDOMNode_Release(new_node
);
5130 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5131 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
5136 hres
= IHTMLDocument2_get_title(doc
, &title
);
5137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5138 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5139 SysFreeString(title
);
5142 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5143 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
5148 tmp
= a2bstr(title
);
5149 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5150 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5154 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5156 IHTMLRect
*rect
, *rect2
;
5157 IHTMLElement2
*elem2
;
5161 elem2
= get_elem2_iface(unk
);
5162 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5163 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5164 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5165 IHTMLElement2_Release(elem2
);
5166 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5167 ok(rect
!= NULL
, "rect == NULL\n");
5168 ok(rect
!= rect2
, "rect == rect2\n");
5169 IHTMLRect_Release(rect2
);
5171 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, NULL
, "[object]");
5174 hres
= IHTMLRect_get_top(rect
, &l
);
5175 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
5176 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5179 hres
= IHTMLRect_get_left(rect
, &l
);
5180 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
5181 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5184 hres
= IHTMLRect_get_bottom(rect
, &l
);
5185 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
5186 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5189 hres
= IHTMLRect_get_right(rect
, &l
);
5190 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
5191 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5193 IHTMLRect_Release(rect
);
5196 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5197 const elem_type_t
*elem_types
, LONG len
)
5200 VARIANT name
, index
;
5204 V_VT(&index
) = VT_EMPTY
;
5205 V_VT(&name
) = VT_BSTR
;
5206 V_BSTR(&name
) = a2bstr(n
);
5208 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5209 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5211 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5212 IDispatch_Release(disp
);
5214 V_VT(&index
) = VT_I4
;
5216 for(i
=0; i
<len
; i
++) {
5218 disp
= (void*)0xdeadbeef;
5219 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5220 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5221 ok(disp
!= NULL
, "disp == NULL\n");
5222 if(FAILED(hres
) || !disp
)
5225 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5227 IDispatch_Release(disp
);
5231 disp
= (void*)0xdeadbeef;
5232 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5233 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5234 ok(disp
== NULL
, "disp != NULL\n");
5237 disp
= (void*)0xdeadbeef;
5238 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5239 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5240 ok(disp
== NULL
, "disp != NULL\n");
5242 SysFreeString(V_BSTR(&name
));
5245 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5247 IHTMLElementCollection
*col
;
5249 IDispatch
*disp
= (void*)0xdeadbeef;
5250 VARIANT name
, index
;
5253 hres
= IHTMLDocument2_get_all(doc
, &col
);
5254 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5255 ok(col
!= NULL
, "col == NULL\n");
5256 if(FAILED(hres
) || !col
)
5259 V_VT(&index
) = VT_EMPTY
;
5260 V_VT(&name
) = VT_BSTR
;
5261 V_BSTR(&name
) = a2bstr(id
);
5263 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5264 IHTMLElementCollection_Release(col
);
5265 SysFreeString(V_BSTR(&name
));
5266 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5267 if(!expect_success
) {
5268 ok(disp
== NULL
, "disp != NULL\n");
5272 ok(disp
!= NULL
, "disp == NULL\n");
5276 elem
= get_elem_iface((IUnknown
*)disp
);
5277 IDispatch_Release(disp
);
5282 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5284 IHTMLDocument3
*doc3
;
5289 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5290 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5293 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5295 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5297 IHTMLDocument3_Release(doc3
);
5302 static void test_select_elem(IHTMLSelectElement
*select
)
5304 IDispatch
*disp
, *disp2
;
5305 VARIANT name
, index
;
5308 test_select_type(select
, "select-one");
5309 test_select_length(select
, 2);
5310 test_select_selidx(select
, 0);
5311 test_select_put_selidx(select
, 1);
5313 test_select_set_value(select
, "val1");
5314 test_select_value(select
, "val1");
5316 test_select_size(select
, 0);
5317 test_select_set_size(select
, 1, S_OK
);
5318 test_select_size(select
, 1);
5320 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5321 test_select_size(select
, 1);
5322 test_select_set_size(select
, 3, S_OK
);
5323 test_select_size(select
, 3);
5325 test_select_name(select
, NULL
);
5326 test_select_set_name(select
, "select-name");
5327 test_select_name(select
, "select-name");
5328 test_select_form_notfound(select
);
5330 test_select_get_disabled(select
, VARIANT_FALSE
);
5331 test_select_set_disabled(select
, VARIANT_TRUE
);
5332 test_select_set_disabled(select
, VARIANT_FALSE
);
5335 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5336 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5337 ok(disp
!= NULL
, "options == NULL\n");
5338 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5339 IDispatch_Release(disp
);
5341 V_VT(&index
) = VT_EMPTY
;
5342 V_VT(&name
) = VT_I4
;
5344 disp
= (void*)0xdeadbeef;
5345 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5346 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5347 ok(!disp
, "disp = %p\n", disp
);
5350 disp
= (void*)0xdeadbeef;
5351 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5352 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5353 ok(!disp
, "disp = %p\n", disp
);
5356 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5357 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5360 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5361 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5362 ok(disp
!= NULL
, "disp = NULL\n");
5363 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5365 V_VT(&index
) = VT_I4
;
5368 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5369 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5370 ok(disp2
!= NULL
, "disp = NULL\n");
5371 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5372 IDispatch_Release(disp2
);
5373 IDispatch_Release(disp
);
5375 test_select_multiple(select
, VARIANT_FALSE
);
5376 test_select_set_multiple(select
, VARIANT_TRUE
);
5377 test_select_remove(select
);
5380 static void test_form_item(IHTMLElement
*elem
)
5382 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5383 IDispatch
*disp
, *disp2
;
5384 VARIANT name
, index
;
5387 V_VT(&index
) = VT_EMPTY
;
5388 V_VT(&name
) = VT_I4
;
5390 disp
= (void*)0xdeadbeef;
5391 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5392 if(compat_mode
< COMPAT_IE9
)
5393 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5395 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5396 ok(!disp
, "disp = %p\n", disp
);
5399 disp
= (void*)0xdeadbeef;
5400 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5401 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5402 ok(!disp
, "disp = %p\n", disp
);
5405 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5406 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5409 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5410 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5411 ok(disp
!= NULL
, "disp = NULL\n");
5412 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5414 V_VT(&index
) = VT_I4
;
5417 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5418 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5419 ok(disp2
!= NULL
, "disp = NULL\n");
5420 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5421 IDispatch_Release(disp2
);
5422 IDispatch_Release(disp
);
5425 static void test_create_option_elem(IHTMLDocument2
*doc
)
5427 IHTMLOptionElement
*option
;
5429 option
= create_option_elem(doc
, "test text", "test value");
5431 test_option_put_text(option
, "new text");
5432 test_option_put_value(option
, "new value");
5433 test_option_get_index(option
, 0);
5434 test_option_defaultSelected_property(option
);
5435 test_option_put_selected(option
, VARIANT_TRUE
);
5436 test_option_put_selected(option
, VARIANT_FALSE
);
5438 IHTMLOptionElement_Release(option
);
5441 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5443 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5444 IHTMLFormElement
*form
;
5447 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5448 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5450 hres
= IHTMLOptionElement_get_form(option
, &form
);
5451 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5452 ok(form
!= NULL
, "form == NULL\n");
5454 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5456 IHTMLOptionElement_Release(option
);
5457 IHTMLFormElement_Release(form
);
5460 static void test_create_img_elem(IHTMLDocument2
*doc
)
5462 IHTMLImgElement
*img
;
5464 img
= create_img_elem(doc
, 10, 15);
5467 test_img_put_width(img
, 5);
5468 test_img_put_height(img
, 20);
5470 IHTMLImgElement_Release(img
);
5474 img
= create_img_elem(doc
, -1, -1);
5477 test_img_put_width(img
, 5);
5478 test_img_put_height(img
, 20);
5480 IHTMLImgElement_Release(img
);
5484 #define test_doc_selection_type(a,b) _test_doc_selection_type(__LINE__,a,b)
5485 static void _test_doc_selection_type(unsigned line
, IHTMLDocument2
*doc
, const char *type
)
5487 IHTMLSelectionObject2
*selection2
;
5488 IHTMLSelectionObject
*selection
;
5492 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5493 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5495 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5496 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5497 ok_(__FILE__
,line
)(!strcmp_wa(str
, type
), "type = %s, expected %s\n", wine_dbgstr_w(str
), type
);
5500 hres
= IHTMLSelectionObject_QueryInterface(selection
, &IID_IHTMLSelectionObject2
, (void**)&selection2
);
5501 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLSelectionObject2 iface: %08x\n", hres
);
5503 IHTMLSelectionObject_Release(selection
);
5505 hres
= IHTMLSelectionObject2_get_typeDetail(selection2
, &str
);
5506 ok_(__FILE__
,line
)(hres
== S_OK
, "get_typeDetail failed: %08x\n", hres
);
5507 ok_(__FILE__
,line
)(!strcmp_wa(str
, "undefined"), "typeDetail = %s\n", wine_dbgstr_w(str
));
5510 IHTMLSelectionObject2_Release(selection2
);
5513 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5514 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5516 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5517 IHTMLElement
*ret_elem
= NULL
;
5518 BSTR str
= a2bstr(where
);
5521 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5522 IHTMLElement2_Release(elem2
);
5524 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5525 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5526 IHTMLElement_Release(ret_elem
);
5529 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5531 IHTMLElement
*elem
, *elem2
;
5533 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5534 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5536 elem
= test_create_elem(doc
, "BR");
5537 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5538 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5539 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5540 IHTMLElement_Release(elem
);
5542 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5544 elem
= test_create_elem(doc
, "BR");
5545 insert_adjacent_elem(parent
, "beforeend", elem
);
5547 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5549 elem2
= test_create_elem(doc
, "DIV");
5550 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5551 IHTMLElement_Release(elem2
);
5552 IHTMLElement_Release(elem
);
5554 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5557 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5559 IHTMLBodyElement
*body
;
5560 IHTMLTxtRange
*range
;
5564 elem
= doc_get_body(doc
);
5565 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5566 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5567 IHTMLElement_Release(elem
);
5569 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5570 IHTMLBodyElement_Release(body
);
5571 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5576 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5577 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5582 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5583 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5588 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5589 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5590 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5592 BSTR str
= a2bstr(how
);
5595 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5596 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5600 static void test_txtrange(IHTMLDocument2
*doc
)
5602 IHTMLTxtRange
*body_range
, *range
, *range2
;
5603 IHTMLSelectionObject
*selection
;
5604 IDispatch
*disp_range
;
5608 body_range
= test_create_body_range(doc
);
5610 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, NULL
, "[object]");
5612 test_range_text(body_range
, "test abc 123\r\nit's text");
5614 range
= range_duplicate(body_range
);
5615 range2
= range_duplicate(body_range
);
5617 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5619 test_range_text(range
, "test abc 123\r\nit's text");
5620 test_range_text(body_range
, "test abc 123\r\nit's text");
5622 test_range_collapse(range
, TRUE
);
5623 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5624 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5625 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5626 IHTMLTxtRange_Release(range2
);
5628 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5629 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5630 test_range_move(range
, characterW
, 2, 2);
5631 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5633 test_range_collapse(range
, FALSE
);
5634 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5636 test_range_collapse(range
, FALSE
);
5637 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5638 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5639 test_range_move(range
, characterW
, 2, 2);
5640 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5641 test_range_moveend(range
, characterW
, -5, -5);
5642 test_range_text(range
, NULL
);
5643 test_range_moveend(range
, characterW
, 3, 3);
5644 test_range_text(range
, "c 1");
5645 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5646 test_range_collapse(range
, TRUE
);
5647 test_range_move(range
, characterW
, 4, 4);
5648 test_range_moveend(range
, characterW
, 1, 1);
5649 test_range_text(range
, " ");
5650 test_range_move(range
, wordW
, 1, 1);
5651 test_range_moveend(range
, characterW
, 2, 2);
5652 test_range_text(range
, "ab");
5654 IHTMLTxtRange_Release(range
);
5656 range
= range_duplicate(body_range
);
5658 test_range_text(range
, "test abc 123\r\nit's text");
5659 test_range_move(range
, characterW
, 3, 3);
5660 test_range_moveend(range
, characterW
, 1, 1);
5661 test_range_text(range
, "t");
5662 test_range_moveend(range
, characterW
, 3, 3);
5663 test_range_text(range
, "t ab");
5664 test_range_moveend(range
, characterW
, -2, -2);
5665 test_range_text(range
, "t ");
5666 test_range_move(range
, characterW
, 6, 6);
5667 test_range_moveend(range
, characterW
, 3, 3);
5668 test_range_text(range
, "123");
5669 test_range_moveend(range
, characterW
, 2, 2);
5670 test_range_text(range
, "123\r\ni");
5672 IHTMLTxtRange_Release(range
);
5674 range
= range_duplicate(body_range
);
5676 test_range_move(range
, wordW
, 1, 1);
5677 test_range_moveend(range
, characterW
, 2, 2);
5678 test_range_text(range
, "ab");
5680 test_range_move(range
, characterW
, -2, -2);
5681 test_range_moveend(range
, characterW
, 2, 2);
5682 test_range_text(range
, "t ");
5684 test_range_move(range
, wordW
, 3, 3);
5685 test_range_move(range
, wordW
, -2, -2);
5686 test_range_moveend(range
, characterW
, 2, 2);
5687 test_range_text(range
, "ab");
5689 test_range_move(range
, characterW
, -6, -5);
5690 test_range_moveend(range
, characterW
, -1, 0);
5691 test_range_moveend(range
, characterW
, -6, 0);
5692 test_range_move(range
, characterW
, 2, 2);
5693 test_range_moveend(range
, characterW
, 2, 2);
5694 test_range_text(range
, "st");
5695 test_range_moveend(range
, characterW
, -6, -4);
5696 test_range_moveend(range
, characterW
, 2, 2);
5698 IHTMLTxtRange_Release(range
);
5700 range
= range_duplicate(body_range
);
5702 test_range_move(range
, wordW
, 2, 2);
5703 test_range_moveend(range
, characterW
, 2, 2);
5704 test_range_text(range
, "12");
5706 test_range_move(range
, characterW
, 15, 14);
5707 test_range_move(range
, characterW
, -2, -2);
5708 test_range_moveend(range
, characterW
, 3, 2);
5709 test_range_text(range
, "t");
5710 test_range_moveend(range
, characterW
, -1, -1);
5711 test_range_text(range
, "t");
5712 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5713 test_range_move(range
, characterW
, -2, -2);
5714 test_range_moveend(range
, characterW
, 2, 2);
5715 test_range_text(range
, "s ");
5716 test_range_move(range
, characterW
, 100, 7);
5717 test_range_move(range
, wordW
, 1, 0);
5718 test_range_move(range
, characterW
, -2, -2);
5719 test_range_moveend(range
, characterW
, 3, 2);
5720 test_range_text(range
, "t");
5722 IHTMLTxtRange_Release(range
);
5724 range
= range_duplicate(body_range
);
5726 test_range_collapse(range
, TRUE
);
5727 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5728 test_range_put_text(range
, "word");
5729 test_range_text(body_range
, "wordabc 123\r\nit's text");
5730 test_range_text(range
, NULL
);
5731 test_range_moveend(range
, characterW
, 3, 3);
5732 test_range_text(range
, "abc");
5733 test_range_movestart(range
, characterW
, -2, -2);
5734 test_range_text(range
, "rdabc");
5735 test_range_movestart(range
, characterW
, 3, 3);
5736 test_range_text(range
, "bc");
5737 test_range_movestart(range
, characterW
, 4, 4);
5738 test_range_text(range
, NULL
);
5739 test_range_movestart(range
, characterW
, -3, -3);
5740 test_range_text(range
, "c 1");
5741 test_range_movestart(range
, characterW
, -7, -6);
5742 test_range_text(range
, "wordabc 1");
5743 test_range_movestart(range
, characterW
, 100, 22);
5744 test_range_text(range
, NULL
);
5746 IHTMLTxtRange_Release(range
);
5748 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5749 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5751 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, NULL
, "[object]");
5752 test_ifaces((IUnknown
*)selection
, selection_iids
);
5754 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5755 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5756 IHTMLSelectionObject_Release(selection
);
5758 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5759 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5760 IDispatch_Release(disp_range
);
5762 test_range_text(range
, NULL
);
5763 test_range_moveend(range
, characterW
, 3, 3);
5764 test_range_text(range
, "wor");
5765 test_range_parent(range
, ET_BODY
);
5766 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5767 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5768 test_range_move(range
, characterW
, 3, 3);
5769 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5770 test_range_moveend(range
, characterW
, -4, -4);
5771 test_range_put_text(range
, "abc def ");
5772 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5773 test_range_move(range
, wordW
, 1, 1);
5774 test_range_movestart(range
, characterW
, -1, -1);
5775 test_range_text(range
, " ");
5776 test_range_move(range
, wordW
, 1, 1);
5777 test_range_moveend(range
, characterW
, 3, 3);
5778 test_range_text(range
, "def");
5779 test_range_put_text(range
, "xyz");
5780 test_range_moveend(range
, characterW
, 1, 1);
5781 test_range_move(range
, wordW
, 1, 1);
5782 test_range_moveend(range
, characterW
, 2, 2);
5783 test_range_text(range
, "ab");
5785 body
= doc_get_body(doc
);
5787 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5788 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5790 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5791 test_range_parent(range
, ET_BODY
);
5793 test_range_move(range
, wordW
, 1, 1);
5794 test_range_moveend(range
, characterW
, 12, 12);
5795 test_range_text(range
, "xyz abc 123");
5797 test_range_collapse(range
, VARIANT_TRUE
);
5798 test_range_paste_html(range
, "<br>paste<br>");
5799 test_range_text(range
, NULL
);
5801 test_range_moveend(range
, characterW
, 3, 3);
5802 test_range_text(range
, "xyz");
5804 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5805 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5807 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5809 test_range_move(range
, wordW
, 2, 2);
5810 test_range_collapse(range
, VARIANT_TRUE
);
5811 test_range_moveend(range
, characterW
, 5, 5);
5812 test_range_text(range
, "paste");
5814 range2
= range_duplicate(range
);
5816 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5817 test_range_text(range
, "abc \r\npaste");
5819 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5820 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5822 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5823 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5825 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5826 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5827 test_range_text(range
, "abc ");
5829 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5830 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5832 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5833 test_range_text(range
, "abc ");
5835 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5837 hres
= IHTMLTxtRange_select(range
);
5838 ok(hres
== S_OK
, "select failed: %08x\n", hres
);
5840 test_doc_selection_type(doc
, "Text");
5842 IHTMLTxtRange_Release(range
);
5843 IHTMLTxtRange_Release(range2
);
5844 IHTMLTxtRange_Release(body_range
);
5845 IHTMLElement_Release(body
);
5849 static void test_txtrange2(IHTMLDocument2
*doc
)
5851 IHTMLTxtRange
*range
;
5853 range
= test_create_body_range(doc
);
5855 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5856 test_range_move(range
, characterW
, 5, 5);
5857 test_range_moveend(range
, characterW
, 1, 1);
5858 test_range_text(range
, "2");
5859 test_range_move(range
, characterW
, -3, -3);
5860 test_range_moveend(range
, characterW
, 3, 3);
5861 test_range_text(range
, "c\r\n\r\n1");
5862 test_range_collapse(range
, VARIANT_FALSE
);
5863 test_range_moveend(range
, characterW
, 4, 4);
5864 test_range_text(range
, "23");
5865 test_range_moveend(range
, characterW
, 1, 1);
5866 test_range_text(range
, "23\r\n\r\n\r\nd");
5867 test_range_moveend(range
, characterW
, -1, -1);
5868 test_range_text(range
, "23");
5869 test_range_moveend(range
, characterW
, -1, -1);
5870 test_range_text(range
, "23");
5871 test_range_moveend(range
, characterW
, -2, -2);
5872 test_range_text(range
, "2");
5874 IHTMLTxtRange_Release(range
);
5877 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5878 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5880 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5884 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5885 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5886 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5889 IHTMLDocument5_Release(doc
);
5892 static void test_location(IHTMLDocument2
*doc
)
5894 IHTMLLocation
*location
, *location2
;
5895 IHTMLWindow2
*window
;
5900 hres
= IHTMLDocument2_get_location(doc
, &location
);
5901 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5903 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5904 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5906 ok(location
== location2
, "location != location2\n");
5907 IHTMLLocation_Release(location2
);
5909 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5910 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5912 hres
= IHTMLWindow2_get_location(window
, &location2
);
5913 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5914 ok(location
== location2
, "location != location2\n");
5915 IHTMLLocation_Release(location2
);
5917 test_ifaces((IUnknown
*)location
, location_iids
);
5918 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, NULL
, "about:blank");
5920 hres
= IHTMLLocation_get_pathname(location
, &str
);
5921 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5922 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5925 hres
= IHTMLLocation_get_href(location
, NULL
);
5926 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5928 hres
= IHTMLLocation_get_href(location
, &str
);
5929 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5930 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5933 ref
= IHTMLLocation_Release(location
);
5934 ok(!ref
, "location should be destroyed here\n");
5937 static void test_plugins_col(IHTMLDocument2
*doc
)
5939 IHTMLPluginsCollection
*col
, *col2
;
5940 IHTMLWindow2
*window
;
5946 window
= get_doc_window(doc
);
5947 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5948 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5949 IHTMLWindow2_Release(window
);
5951 hres
= IOmNavigator_get_plugins(nav
, &col
);
5952 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5954 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5955 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5956 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5957 IHTMLPluginsCollection_Release(col2
);
5959 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, NULL
, "[object]");
5962 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5963 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5964 ok(!len
, "length = %d\n", len
);
5966 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5967 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5969 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5970 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5972 ref
= IHTMLPluginsCollection_Release(col
);
5973 ok(!ref
, "ref=%d\n", ref
);
5975 IOmNavigator_Release(nav
);
5978 static void test_mime_types_col(IOmNavigator
*nav
)
5980 IHTMLMimeTypesCollection
*col
, *col2
;
5985 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5986 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5988 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5989 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5990 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5991 IHTMLMimeTypesCollection_Release(col2
);
5993 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, NULL
, "[object]");
5995 length
= 0xdeadbeef;
5996 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5997 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5998 ok(!length
, "length = %d\n", length
);
6000 ref
= IHTMLMimeTypesCollection_Release(col
);
6001 ok(!ref
, "ref=%d\n", ref
);
6004 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
6005 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6007 BSTR str
= (void*)0xdeadbeef;
6008 IHTMLFrameBase
*fbase
;
6011 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6012 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6014 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6015 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
6017 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
6019 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6022 IHTMLFrameBase_Release(fbase
);
6025 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
6026 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6028 IHTMLFrameBase
*fbase
;
6032 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6033 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6035 str
= name
? a2bstr(name
) : NULL
;
6036 hres
= IHTMLFrameBase_put_name(fbase
, str
);
6037 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
6040 _test_framebase_name(line
, elem
, name
);
6041 IHTMLFrameBase_Release(fbase
);
6044 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
6045 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
6047 BSTR str
= (void*)0xdeadbeef;
6048 IHTMLFrameBase
*fbase
;
6051 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6052 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6054 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
6055 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
6057 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
6059 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
6062 IHTMLFrameBase_Release(fbase
);
6065 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
6066 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6071 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
6072 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
6073 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
6075 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6077 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6081 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
6082 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6088 V_BSTR(&v
) = a2bstr(val
);
6089 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
6090 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
6094 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
6095 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6100 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
6101 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
6102 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
6104 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6106 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6110 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
6111 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6117 V_BSTR(&v
) = a2bstr(val
);
6118 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
6119 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
6123 static void test_framebase(IUnknown
*unk
)
6125 IHTMLFrameBase
*fbase
;
6129 /* get/put scrolling */
6130 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6131 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6133 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6134 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6135 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6139 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6140 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6143 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6144 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6145 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6148 str
= a2bstr("junk");
6149 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6150 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6151 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6154 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6155 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6156 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6159 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6160 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6161 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6164 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6165 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
6168 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6169 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6170 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6173 test_framebase_marginheight(fbase
, NULL
);
6174 set_framebase_marginheight(fbase
, "1px");
6175 test_framebase_marginheight(fbase
, "1");
6177 test_framebase_marginwidth(fbase
, NULL
);
6178 set_framebase_marginwidth(fbase
, "2px");
6179 test_framebase_marginwidth(fbase
, "2");
6181 IHTMLFrameBase_Release(fbase
);
6184 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6185 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6190 if(pLCIDToLocaleName
) {
6191 res
= pLCIDToLocaleName(lcid
, buf
, ARRAY_SIZE(buf
), 0);
6192 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
6193 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6195 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6196 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6200 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6201 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6203 IHTMLElementCollection
*col
;
6207 hres
= IHTMLTable_get_rows(table
, &col
);
6208 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6209 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6210 if (hres
!= S_OK
|| col
== NULL
)
6212 hres
= IHTMLElementCollection_get_length(col
, &len
);
6213 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6214 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
6216 IHTMLElementCollection_Release(col
);
6219 static void test_navigator(IHTMLDocument2
*doc
)
6221 IHTMLWindow2
*window
;
6222 IOmNavigator
*navigator
, *navigator2
;
6230 static const WCHAR v40
[] = {'4','.','0'};
6232 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6233 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6235 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6236 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6237 ok(navigator
!= NULL
, "navigator == NULL\n");
6238 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, NULL
, "[object]");
6240 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6241 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6242 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6243 IOmNavigator_Release(navigator2
);
6245 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6246 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6247 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6248 IOmNavigator_Release(navigator2
);
6250 IHTMLWindow2_Release(window
);
6252 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6253 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6254 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6255 SysFreeString(bstr
);
6258 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6259 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6260 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6261 SysFreeString(bstr
);
6264 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6265 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6266 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6267 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6268 SysFreeString(bstr
);
6271 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6272 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6273 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6274 SysFreeString(bstr
);
6277 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6278 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6279 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6280 SysFreeString(bstr
);
6283 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6284 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6285 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6286 SysFreeString(bstr
);
6288 if (pGetUserDefaultUILanguage
)
6291 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6292 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6293 test_language_string(bstr
, pGetUserDefaultUILanguage());
6294 SysFreeString(bstr
);
6297 win_skip("GetUserDefaultUILanguage not available\n");
6300 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6301 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6302 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6303 SysFreeString(bstr
);
6305 hres
= IOmNavigator_toString(navigator
, NULL
);
6306 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6309 hres
= IOmNavigator_toString(navigator
, &bstr
);
6310 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6311 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6312 SysFreeString(bstr
);
6315 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6316 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6317 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6320 hres
= ObtainUserAgentString(0, buf
, &size
);
6321 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6324 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6325 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6326 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6327 SysFreeString(bstr
);
6329 if(!strncmp(buf
, "Mozilla/", 8)) {
6331 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6332 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6333 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6334 SysFreeString(bstr
);
6336 skip("nonstandard user agent\n");
6340 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6341 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6342 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6343 SysFreeString(bstr
);
6345 test_mime_types_col(navigator
);
6347 ref
= IOmNavigator_Release(navigator
);
6348 ok(!ref
, "navigator should be destroyed here\n");
6351 static void test_screen(IHTMLWindow2
*window
)
6353 IHTMLScreen
*screen
, *screen2
;
6354 IDispatchEx
*dispex
;
6361 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6362 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6363 ok(screen
!= NULL
, "screen == NULL\n");
6366 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6367 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6368 ok(screen2
!= NULL
, "screen == NULL\n");
6369 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6370 IHTMLScreen_Release(screen2
);
6372 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6373 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6374 if(SUCCEEDED(hres
)) {
6375 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, NULL
, "[object]");
6376 IDispatchEx_Release(dispex
);
6379 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6381 exl
= GetDeviceCaps(hdc
, HORZRES
);
6383 hres
= IHTMLScreen_get_width(screen
, &l
);
6384 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6385 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6387 exl
= GetDeviceCaps(hdc
, VERTRES
);
6389 hres
= IHTMLScreen_get_height(screen
, &l
);
6390 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6391 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6393 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6395 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6396 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6397 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6401 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6404 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6405 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6406 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6409 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6410 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6411 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6413 IHTMLScreen_Release(screen
);
6416 static void test_default_selection(IHTMLDocument2
*doc
)
6418 IHTMLSelectionObject
*selection
;
6419 IHTMLTxtRange
*range
;
6423 test_doc_selection_type(doc
, "None");
6425 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6426 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6428 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6429 IHTMLSelectionObject_Release(selection
);
6430 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6432 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6433 IDispatch_Release(disp
);
6434 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6436 test_range_text(range
, NULL
);
6437 IHTMLTxtRange_Release(range
);
6440 static void test_doc_dir(IHTMLDocument2
*doc2
)
6442 IHTMLDocument3
*doc
= get_doc3_iface(doc2
);
6446 dir
= (BSTR
)0xdeadbeef;
6447 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6448 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6449 ok(!dir
, "dir = %s\n", wine_dbgstr_w(dir
));
6451 dir
= a2bstr("rtl");
6452 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6453 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6457 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6458 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6459 ok(!strcmp_wa(dir
, "rtl"), "dir = %s\n", wine_dbgstr_w(dir
));
6462 dir
= a2bstr("ltr");
6463 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6464 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6468 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6469 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6470 ok(!strcmp_wa(dir
, "ltr"), "dir = %s\n", wine_dbgstr_w(dir
));
6473 IHTMLDocument3_Release(doc
);
6476 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6478 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6479 IHTMLUniqueName
*unique_name
;
6485 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6487 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6488 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6489 ok(SysStringLen(id
) >= ARRAY_SIZE(prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6491 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6492 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6493 ok(SysStringLen(id2
) >= ARRAY_SIZE(prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6495 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6497 id
[ARRAY_SIZE(prefixW
)-1] = 0;
6498 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6499 id2
[ARRAY_SIZE(prefixW
)-1] = 0;
6500 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6505 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6506 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6508 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6509 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6511 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6512 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6513 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6515 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6516 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6517 ok(num
, "num = 0\n");
6519 sprintf(buf
, "ms__id%u", num
);
6520 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6525 IHTMLUniqueName_Release(unique_name
);
6526 IHTMLDocument3_Release(doc3
);
6529 static void test_doc_elem(IHTMLDocument2
*doc
)
6531 IHTMLDocument2
*doc_node
, *owner_doc
;
6533 IHTMLDocument3
*doc3
;
6537 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6538 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6540 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6541 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6542 ok(!strcmp_wa(bstr
, "[object]"),
6543 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6544 SysFreeString(bstr
);
6546 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6547 IHTMLDocument3_Release(doc3
);
6548 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6550 test_node_name((IUnknown
*)elem
, "HTML");
6551 test_elem_tag((IUnknown
*)elem
, "HTML");
6552 test_elem_set_outertext_fail(elem
);
6554 doc_node
= get_doc_node(doc
);
6555 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6556 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6557 IHTMLDocument2_Release(owner_doc
);
6559 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6560 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6561 IHTMLDocument2_Release(doc_node
);
6563 test_elem_client_rect((IUnknown
*)elem
);
6564 test_unique_id(doc
, elem
);
6567 IHTMLElement_Release(elem
);
6570 static void test_default_body(IHTMLBodyElement
*body
)
6577 bstr
= (void*)0xdeadbeef;
6578 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6579 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6580 ok(bstr
== NULL
, "bstr != NULL\n");
6582 l
= elem_get_scroll_height((IUnknown
*)body
);
6583 ok(l
!= -1, "scrollHeight == -1\n");
6584 l
= elem_get_scroll_width((IUnknown
*)body
);
6585 ok(l
!= -1, "scrollWidth == -1\n");
6586 l
= elem_get_scroll_top((IUnknown
*)body
);
6587 ok(!l
, "scrollTop = %d\n", l
);
6588 elem_get_scroll_left((IUnknown
*)body
);
6590 test_elem_dir((IUnknown
*)body
, NULL
);
6591 set_elem_dir((IUnknown
*)body
, "ltr");
6593 /* get_text tests */
6594 hres
= IHTMLBodyElement_get_text(body
, &v
);
6595 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6596 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6597 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6599 /* get_text - Invalid Text */
6601 V_BSTR(&v
) = a2bstr("Invalid");
6602 hres
= IHTMLBodyElement_put_text(body
, v
);
6603 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6607 hres
= IHTMLBodyElement_get_text(body
, &v
);
6608 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6609 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6610 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6613 /* get_text - Valid Text */
6615 V_BSTR(&v
) = a2bstr("#FF0000");
6616 hres
= IHTMLBodyElement_put_text(body
, v
);
6617 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6621 hres
= IHTMLBodyElement_get_text(body
, &v
);
6622 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6623 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6624 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6628 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6629 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6634 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6635 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6636 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6640 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6641 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6643 BSTR str
= a2bstr(val
);
6646 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6647 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6650 _test_body_scroll(line
, body
, val
);
6653 static void test_body_funs(IHTMLBodyElement
*body
)
6655 VARIANT vbg
, vDefaultbg
;
6658 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6659 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6660 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6661 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6663 V_VT(&vbg
) = VT_BSTR
;
6664 V_BSTR(&vbg
) = a2bstr("red");
6665 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6666 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6669 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6670 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6671 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6672 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6675 /* Restore Original */
6676 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6677 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6678 VariantClear(&vDefaultbg
);
6680 test_body_scroll(body
, NULL
);
6681 set_body_scroll(body
, "yes");
6682 set_body_scroll(body
, "no");
6683 set_body_scroll(body
, "auto");
6686 static void test_history(IHTMLWindow2
*window
)
6688 IOmHistory
*history
, *history2
;
6692 hres
= IHTMLWindow2_get_history(window
, &history
);
6693 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6694 ok(history
!= NULL
, "history = NULL\n");
6696 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, NULL
, "[object]");
6699 hres
= IHTMLWindow2_get_history(window
, &history2
);
6700 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6701 ok(history2
!= NULL
, "history2 = NULL\n");
6702 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6704 IOmHistory_Release(history2
);
6705 IOmHistory_Release(history
);
6708 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6712 IHTMLXMLHttpRequestFactory
*factory
;
6713 IHTMLXMLHttpRequest
*xml
;
6715 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6716 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6717 ok(V_VT(&var
) == VT_DISPATCH
|| broken(V_VT(&var
) == VT_EMPTY
), "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6719 if (V_VT(&var
) == VT_EMPTY
) {
6720 win_skip("Native XMLHTTP support is missing or disabled.\n");
6725 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6726 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6727 ok(factory
!= NULL
, "factory == NULL\n");
6730 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6731 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6732 ok(xml
!= NULL
, "xml == NULL\n");
6734 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, &CLSID_HTMLXMLHttpRequest
, "[object]");
6736 IHTMLXMLHttpRequest_Release(xml
);
6737 IHTMLXMLHttpRequestFactory_Release(factory
);
6741 static void test_window(IHTMLDocument2
*doc
)
6743 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6744 IHTMLWindow5
*window5
;
6745 IHTMLWindow7
*window7
;
6746 IHTMLDocument2
*doc2
= NULL
;
6753 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6754 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6755 test_ifaces((IUnknown
*)window
, window_iids
);
6756 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6758 IUnknown_Release(unk
);
6760 win_skip("IID_ITravelLogClient not supported\n");
6762 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, &CLSID_HTMLWindow2
, "[object]");
6764 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6765 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6766 ok(doc2
!= NULL
, "doc2 == NULL\n");
6769 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6770 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6773 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6774 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6776 unk
= (void*)0xdeadbeef;
6777 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6778 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6779 ok(!unk
, "unk = %p\n", unk
);
6781 IHTMLDocument2_Release(doc2
);
6783 hres
= IHTMLWindow2_get_window(window
, &window2
);
6784 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6785 ok(window2
!= NULL
, "window2 == NULL\n");
6787 hres
= IHTMLWindow2_get_self(window
, &self
);
6788 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6789 ok(window2
!= NULL
, "self == NULL\n");
6791 ok(self
== window2
, "self != window2\n");
6793 IHTMLWindow2_Release(window2
);
6796 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6797 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6798 ok(disp
== (void*)window
, "disp != window\n");
6799 IDispatch_Release(disp
);
6801 hres
= IHTMLWindow2_toString(window
, NULL
);
6802 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6805 hres
= IHTMLWindow2_toString(window
, &str
);
6806 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6807 ok(!strcmp_wa(str
, "[object]") ||
6808 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6811 V_VT(&v
) = VT_ERROR
;
6812 hres
= IHTMLWindow2_get_opener(window
, &v
);
6813 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6814 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6817 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6818 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6819 ok(parent
!= NULL
, "parent == NULL\n");
6820 ok(parent
== self
, "parent != window\n");
6821 IHTMLWindow2_Release(parent
);
6822 IHTMLWindow2_Release(self
);
6824 test_window_name(window
, NULL
);
6825 set_window_name(window
, "test");
6826 test_window_length(window
, 0);
6827 test_screen(window
);
6828 test_window_status(window
);
6829 set_window_status(window
, "Test!");
6830 test_history(window
);
6832 hres
= IHTMLWindow2_moveBy(window
, 0, 0);
6833 ok(hres
== S_FALSE
, "moveBy failed: %08x\n", hres
);
6835 hres
= IHTMLWindow2_resizeBy(window
, 0, 0);
6836 ok(hres
== S_FALSE
, "resizeBy failed: %08x\n", hres
);
6838 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6839 if(SUCCEEDED(hres
)) {
6840 ok(window5
!= NULL
, "window5 == NULL\n");
6841 test_xmlhttprequest(window5
);
6842 IHTMLWindow5_Release(window5
);
6844 win_skip("IHTMLWindow5 not supported!\n");
6847 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow7
, (void**)&window7
);
6848 if(SUCCEEDED(hres
)) {
6849 IHTMLPerformance
*performance
;
6851 ok(window7
!= NULL
, "window7 == NULL\n");
6853 hres
= IHTMLWindow7_get_performance(window7
, &v
);
6854 ok(hres
== S_OK
, "get_performance failed: %08x\n", hres
);
6855 if(SUCCEEDED(hres
)) {
6856 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(performance) = %u\n", V_VT(&v
));
6858 hres
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IHTMLPerformance
,
6859 (void**)&performance
);
6860 ok(hres
== S_OK
, "Could not get IHTMLPerformance iface: %08x\n", hres
);
6862 IHTMLPerformance_Release(performance
);
6866 hres
= IHTMLWindow7_put_performance(window7
, v
);
6867 ok(hres
== S_OK
, "put_performance failed: %08x\n", hres
);
6869 V_VT(&v
) = VT_ERROR
;
6870 hres
= IHTMLWindow7_get_performance(window7
, &v
);
6871 ok(hres
== S_OK
, "get_performance failed: %08x\n", hres
);
6872 ok(V_VT(&v
) == VT_I2
, "V_VT(performance) = %u\n", V_VT(&v
));
6873 ok(V_I2(&v
) == 2, "V_I2(performance) = %d\n", V_I2(&v
));
6875 IHTMLWindow7_Release(window7
);
6878 win_skip("IHTMLWindow7 not supported\n");
6881 IHTMLWindow2_Release(window
);
6884 static void test_dom_implementation(IHTMLDocument2
*doc
)
6886 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6887 IHTMLDOMImplementation
*dom_implementation
;
6893 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6894 IHTMLDocument5_Release(doc5
);
6895 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6896 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6898 str
= a2bstr("test");
6900 V_BSTR(&v
) = a2bstr("1.0");
6902 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6905 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6906 ok(!b
, "hasFeature returned %x\n", b
);
6908 IHTMLDOMImplementation_Release(dom_implementation
);
6911 static void test_xhr(IHTMLDocument2
*doc
)
6913 IHTMLWindow2
*window
;
6914 IDispatchEx
*dispex
;
6919 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6920 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6922 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6923 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6925 str
= a2bstr("XMLHttpRequest");
6926 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6927 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6930 IHTMLWindow2_Release(window
);
6933 static void test_defaults(IHTMLDocument2
*doc
)
6935 IHTMLStyleSheetsCollection
*stylesheetcol
;
6936 IHTMLCurrentStyle
*cstyle
;
6937 IHTMLBodyElement
*body
;
6938 IHTMLElement2
*elem2
;
6946 IHTMLElementCollection
*collection
;
6948 elem
= doc_get_body(doc
);
6950 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6951 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6953 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6954 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6957 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6958 IHTMLElementCollection_Release(collection
);
6961 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6962 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6964 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6965 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6968 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6969 IHTMLElementCollection_Release(collection
);
6972 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6973 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6975 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6976 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6979 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6980 IHTMLElementCollection_Release(collection
);
6983 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6984 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6986 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6987 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6990 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6991 IHTMLElementCollection_Release(collection
);
6994 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6995 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6997 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6998 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7001 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7002 IHTMLElementCollection_Release(collection
);
7007 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
7008 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
7009 test_default_body(body
);
7010 test_body_funs(body
);
7011 IHTMLBodyElement_Release(body
);
7013 test_elem_set_outertext_fail(elem
);
7015 test_elem_istextedit(elem
, VARIANT_TRUE
);
7017 hres
= IHTMLElement_get_style(elem
, &style
);
7018 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
7020 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, NULL
, "[object]");
7021 test_ifaces((IUnknown
*)style
, style_iids
);
7022 IHTMLStyle_Release(style
);
7025 hres
= IHTMLDocument2_get_charset(doc
, &str
);
7026 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
7027 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
7031 test_compatmode(doc
, "BackCompat");
7033 test_navigator(doc
);
7034 test_plugins_col(doc
);
7036 elem2
= get_elem2_iface((IUnknown
*)elem
);
7037 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
7038 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
7039 if(SUCCEEDED(hres
)) {
7042 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, NULL
, "[object]");
7043 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
7045 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
7047 IUnknown_Release(unk
);
7050 /*IE6 doesn't have interface */
7051 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
7054 IHTMLCurrentStyle_Release(cstyle
);
7056 IHTMLElement2_Release(elem2
);
7058 IHTMLElement_Release(elem
);
7060 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
7061 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
7064 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
7065 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7066 ok(l
== 0, "length = %d\n", l
);
7068 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
7070 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
7071 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
7073 str
= a2bstr("xxx");
7075 V_VT(&v
) = VT_EMPTY
;
7076 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7077 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
7078 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
7081 str
= a2bstr("respectvisibilityindesign");
7084 V_BOOL(&v
) = VARIANT_TRUE
;
7085 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7086 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
7089 test_default_selection(doc
);
7090 test_doc_title(doc
, "");
7091 test_dom_implementation(doc
);
7094 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
7095 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
7097 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7101 str
= (void*)0xdeadbeef;
7102 hres
= IHTMLButtonElement_get_name(button
, &str
);
7103 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7105 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
7107 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
7109 IHTMLButtonElement_Release(button
);
7112 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
7113 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
7115 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7116 BSTR str
= a2bstr(name
);
7119 hres
= IHTMLButtonElement_put_name(button
, str
);
7120 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7122 IHTMLButtonElement_Release(button
);
7124 _test_button_name(line
, elem
, name
);
7127 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
7128 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
7130 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7131 VARIANT_BOOL disabled
= 100;
7134 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
7135 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
7136 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
7137 IHTMLButtonElement_Release(button
);
7139 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
7142 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
7143 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
7145 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7148 hres
= IHTMLButtonElement_put_disabled(button
, b
);
7149 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
7150 IHTMLButtonElement_Release(button
);
7152 _test_button_get_disabled(line
, elem
, b
);
7155 #define test_button_type(a,b) _test_button_type(__LINE__,a,b)
7156 static void _test_button_type(unsigned line
, IHTMLElement
*elem
, const char *extype
)
7158 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7162 hres
= IHTMLButtonElement_get_type(button
, &str
);
7163 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7164 ok_(__FILE__
,line
)(!strcmp_wa(str
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(str
), extype
);
7167 IHTMLButtonElement_Release(button
);
7170 #define test_button_value(a,b) _test_button_value(__LINE__,a,b)
7171 static void _test_button_value(unsigned line
, IHTMLElement
*elem
, const char *exvalue
)
7173 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7177 hres
= IHTMLButtonElement_get_value(button
, &str
);
7178 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
7180 ok_(__FILE__
,line
)(!strcmp_wa(str
, exvalue
), "value = %s, expected %s\n", wine_dbgstr_w(str
), exvalue
);
7182 ok_(__FILE__
,line
)(!str
, "value = %s, expected NULL\n", wine_dbgstr_w(str
));
7185 IHTMLButtonElement_Release(button
);
7188 #define set_button_value(a,b) _set_button_value(__LINE__,a,b)
7189 static void _set_button_value(unsigned line
, IHTMLElement
*elem
, const char *value
)
7191 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7192 BSTR str
= a2bstr(value
);
7195 hres
= IHTMLButtonElement_put_value(button
, str
);
7196 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
7197 IHTMLButtonElement_Release(button
);
7200 _test_button_value(line
, elem
, value
);
7203 #define get_button_form(a) _get_button_form(__LINE__,a)
7204 static IHTMLFormElement
*_get_button_form(unsigned line
, IHTMLElement
*elem
)
7206 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7207 IHTMLFormElement
*form
;
7210 hres
= IHTMLButtonElement_get_form(button
, &form
);
7211 ok_(__FILE__
,line
)(hres
== S_OK
, "get_form failed: %08x\n", hres
);
7212 IHTMLButtonElement_Release(button
);
7217 static void test_button_elem(IHTMLElement
*elem
)
7219 IHTMLFormElement
*form
;
7221 test_button_name(elem
, NULL
);
7222 set_button_name(elem
, "button name");
7223 test_button_type(elem
, "submit");
7224 test_button_value(elem
, NULL
);
7225 set_button_value(elem
, "val");
7227 form
= get_button_form(elem
);
7228 ok(!form
, "form != NULL\n");
7230 test_elem_istextedit(elem
, VARIANT_TRUE
);
7233 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
7234 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
7235 IHTMLTableRow
*row
, LONG len
, const char *id
)
7237 IHTMLElementCollection
*col
;
7243 hres
= IHTMLTableRow_get_cells(row
, &col
);
7244 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7245 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
7247 hres
= IHTMLElementCollection_get_length(col
, &lval
);
7248 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
7249 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
7251 V_VT(&var
) = VT_BSTR
;
7252 V_BSTR(&var
) = a2bstr(id
);
7253 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
7254 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
7255 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
7258 IDispatch_Release(disp
);
7259 IHTMLElementCollection_Release(col
);
7262 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
7266 IHTMLTableCell
*cell
;
7268 hres
= IHTMLTableRow_deleteCell(row
, 0);
7269 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
7270 test_tr_possess(elem
, row
, 1, "td2");
7272 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
7273 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
7274 ok(disp
!= NULL
, "disp == NULL\n");
7275 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
7276 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
7277 ok(cell
!= NULL
, "cell == NULL\n");
7278 if (SUCCEEDED(hres
))
7279 IHTMLTableCell_Release(cell
);
7280 test_tr_possess(elem
, row
, 2, "td2");
7281 IDispatch_Release(disp
);
7284 static void test_tr_elem(IHTMLElement
*elem
)
7286 IHTMLElementCollection
*col
;
7291 VARIANT vbg
, vDefaultbg
;
7293 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
7295 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
7296 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7301 hres
= IHTMLTableRow_get_cells(row
, &col
);
7302 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7303 ok(col
!= NULL
, "get_cells returned NULL\n");
7305 test_elem_collection((IUnknown
*)col
, cell_types
, ARRAY_SIZE(cell_types
));
7306 IHTMLElementCollection_Release(col
);
7308 bstr
= a2bstr("left");
7309 hres
= IHTMLTableRow_put_align(row
, bstr
);
7310 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7311 SysFreeString(bstr
);
7314 hres
= IHTMLTableRow_get_align(row
, &bstr
);
7315 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7316 ok(bstr
!= NULL
, "get_align returned NULL\n");
7317 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7318 SysFreeString(bstr
);
7320 bstr
= a2bstr("top");
7321 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
7322 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
7323 SysFreeString(bstr
);
7326 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
7327 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
7328 ok(bstr
!= NULL
, "get_valign returned NULL\n");
7329 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
7330 SysFreeString(bstr
);
7333 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
7334 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7335 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
7338 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
7339 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
7340 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
7342 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
7343 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7344 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7345 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7347 V_VT(&vbg
) = VT_BSTR
;
7348 V_BSTR(&vbg
) = a2bstr("red");
7349 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7350 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7353 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7354 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7355 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7356 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7360 V_I4(&vbg
) = 0xff0000;
7361 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7362 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7365 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7366 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7367 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7368 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7371 /* Restore Original */
7372 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
7373 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7374 VariantClear(&vDefaultbg
);
7376 test_tr_modify(elem
, row
);
7378 IHTMLTableRow_Release(row
);
7381 static void test_td_elem(IHTMLDocument2
*doc
, IHTMLElement
*div
)
7383 IHTMLTableCell
*cell
;
7388 VARIANT vbg
, vDefaultbg
;
7390 test_elem_set_innerhtml((IUnknown
*)div
,
7391 "<table id=\"tbl\"><tbody>"
7393 " <tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td><td></td></tr>"
7395 "</tbody></table>");
7397 elem
= get_doc_elem_by_id(doc
, "td1");
7398 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7399 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7400 IHTMLElement_Release(elem
);
7403 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7404 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7405 ok(!lval
, "Expected 0, got %d\n", lval
);
7407 str
= a2bstr("left");
7408 hres
= IHTMLTableCell_put_align(cell
, str
);
7409 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7413 hres
= IHTMLTableCell_get_align(cell
, &str
);
7414 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7415 ok(str
!= NULL
, "str is NULL\n");
7416 if (str
!= NULL
&& hres
== S_OK
) {
7417 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7421 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7422 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7423 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7424 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7426 V_VT(&vbg
) = VT_BSTR
;
7427 V_BSTR(&vbg
) = a2bstr("red");
7428 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7429 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7432 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7433 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7434 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7435 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7439 V_I4(&vbg
) = 0xff0000;
7440 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7441 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7444 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7445 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7446 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7447 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7450 /* Restore Original */
7451 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7452 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7453 VariantClear(&vDefaultbg
);
7455 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7456 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7457 ok(lval
== 1, "rowSpan = %d\n", lval
);
7459 hres
= IHTMLTableCell_put_rowSpan(cell
, -1);
7460 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7462 hres
= IHTMLTableCell_put_rowSpan(cell
, 0);
7463 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7465 hres
= IHTMLTableCell_put_rowSpan(cell
, 2);
7466 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7468 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7469 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7470 ok(lval
== 2, "rowSpan = %d\n", lval
);
7472 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7473 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7474 ok(lval
== 1, "rowSpan = %d\n", lval
);
7476 hres
= IHTMLTableCell_put_colSpan(cell
, -1);
7477 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7479 hres
= IHTMLTableCell_put_colSpan(cell
, 0);
7480 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7482 hres
= IHTMLTableCell_put_colSpan(cell
, 2);
7483 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7485 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7486 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7487 ok(lval
== 2, "rowSpan = %d\n", lval
);
7489 IHTMLTableCell_Release(cell
);
7492 static void test_label_elem(IHTMLElement
*elem
)
7494 IHTMLLabelElement
*label
;
7498 label
= get_label_iface((IUnknown
*)elem
);
7501 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7502 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7503 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7507 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7508 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7511 str
= (void*)0xdeadbeef;
7512 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7513 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7514 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7517 str
= a2bstr("abc");
7518 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7519 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7523 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7524 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7525 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7528 IHTMLLabelElement_Release(label
);
7531 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7532 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7537 V_VT(&v
) = VT_ERROR
;
7538 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7539 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7540 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7542 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7544 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7548 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7549 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7554 V_VT(&v
) = VT_ERROR
;
7555 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7556 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7557 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7559 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7561 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7565 static void test_table_modify(IHTMLTable
*table
)
7572 test_table_length(table
, 2);
7574 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7575 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7576 ok(disp
!= NULL
, "disp == NULL\n");
7577 test_table_length(table
, 3);
7578 if (hres
!= S_OK
|| disp
== NULL
)
7581 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7582 IDispatch_Release(disp
);
7584 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7585 ok(row
!= NULL
, "row == NULL\n");
7588 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7589 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7590 ok(index
== 0, "index = %d, expected 0\n", index
);
7592 IHTMLTableRow_Release(row
);
7594 hres
= IHTMLTable_deleteRow(table
, 0);
7595 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7596 test_table_length(table
, 2);
7599 static void test_table_elem(IHTMLElement
*elem
)
7601 IHTMLElementCollection
*col
;
7603 IHTMLTable3
*table3
;
7608 VARIANT vbg
, vDefaultbg
;
7610 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7611 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7612 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7614 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7615 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7619 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7620 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7625 hres
= IHTMLTable_get_rows(table
, &col
);
7626 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7627 ok(col
!= NULL
, "get_rows returned NULL\n");
7629 test_elem_collection((IUnknown
*)col
, row_types
, ARRAY_SIZE(row_types
));
7630 IHTMLElementCollection_Release(col
);
7632 test_elem_all((IUnknown
*)table
, all_types
, ARRAY_SIZE(all_types
));
7634 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7635 test_elem_tag((IUnknown
*)node
, "TABLE");
7636 test_elem_all((IUnknown
*)node
, all_types
, ARRAY_SIZE(all_types
));
7637 IHTMLDOMNode_Release(node
);
7639 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7640 test_elem_tag((IUnknown
*)node
, "TABLE");
7641 test_elem_all((IUnknown
*)node
, NULL
, 0);
7642 IHTMLDOMNode_Release(node
);
7645 hres
= IHTMLTable_get_tBodies(table
, &col
);
7646 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7647 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7649 test_elem_collection((IUnknown
*)col
, tbodies_types
, ARRAY_SIZE(tbodies_types
));
7650 IHTMLElementCollection_Release(col
);
7652 test_table_cell_spacing(table
, NULL
);
7656 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7657 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7658 test_table_cell_spacing(table
, "10");
7661 V_BSTR(&v
) = a2bstr("11");
7662 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7663 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7664 test_table_cell_spacing(table
, "11");
7667 test_table_cell_padding(table
, NULL
);
7671 hres
= IHTMLTable_put_cellPadding(table
, v
);
7672 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7673 test_table_cell_padding(table
, "10");
7676 V_BSTR(&v
) = a2bstr("11");
7677 hres
= IHTMLTable_put_cellPadding(table
, v
);
7678 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7679 test_table_cell_padding(table
, "11");
7684 hres
= IHTMLTable_put_cellPadding(table
, v
);
7685 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7686 test_table_cell_padding(table
, "5");
7688 bstr
= a2bstr("left");
7689 hres
= IHTMLTable_put_align(table
, bstr
);
7690 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7691 SysFreeString(bstr
);
7694 hres
= IHTMLTable_get_align(table
, &bstr
);
7695 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7696 ok(bstr
!= NULL
, "get_align returned NULL\n");
7697 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7698 SysFreeString(bstr
);
7700 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7701 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7702 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7703 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7705 V_VT(&vbg
) = VT_BSTR
;
7706 V_BSTR(&vbg
) = a2bstr("red");
7707 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7708 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7711 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7712 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7713 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7714 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7718 V_I4(&vbg
) = 0xff0000;
7719 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7720 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7723 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7724 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7725 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7726 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7729 /* Restore Original */
7730 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7731 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7732 VariantClear(&vDefaultbg
);
7735 V_BSTR(&v
) = a2bstr("11");
7736 hres
= IHTMLTable_put_width(table
, v
);
7737 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7739 hres
= IHTMLTable_get_width(table
, &v
);
7740 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7741 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7745 V_BSTR(&v
) = a2bstr("11.9");
7746 hres
= IHTMLTable_put_width(table
, v
);
7747 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7749 hres
= IHTMLTable_get_width(table
, &v
);
7750 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7751 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7755 V_BSTR(&v
) = a2bstr("40.2%");
7756 hres
= IHTMLTable_put_width(table
, v
);
7757 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7759 hres
= IHTMLTable_get_width(table
, &v
);
7760 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7761 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7766 hres
= IHTMLTable_put_width(table
, v
);
7767 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7768 hres
= IHTMLTable_get_width(table
, &v
);
7769 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7770 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7775 hres
= IHTMLTable_put_width(table
, v
);
7776 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7777 hres
= IHTMLTable_get_width(table
, &v
);
7778 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7779 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7782 bstr
= a2bstr("box");
7783 hres
= IHTMLTable_put_frame(table
, bstr
);
7784 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7785 SysFreeString(bstr
);
7786 hres
= IHTMLTable_get_frame(table
, &bstr
);
7787 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7788 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7789 SysFreeString(bstr
);
7791 test_table_modify(table
);
7792 bstr
= a2bstr("summary");
7793 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7794 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7795 SysFreeString(bstr
);
7797 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7798 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7799 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7800 SysFreeString(bstr
);
7802 IHTMLTable3_Release(table3
);
7803 IHTMLTable_Release(table
);
7806 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7815 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7816 hres
= SafeArrayAccessData(sa
, (void**)&var
);
7817 ok(hres
== S_OK
, "Failed to access array data: %08x\n", hres
);
7818 V_VT(var
) = VT_BSTR
;
7819 V_BSTR(var
) = a2bstr(text
);
7820 SafeArrayUnaccessData(sa
);
7823 hres
= IHTMLDocument2_writeln(doc
, sa
);
7825 hres
= IHTMLDocument2_write(doc
, sa
);
7826 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7828 SafeArrayDestroy(sa
);
7831 static void doc_complex_write(IHTMLDocument2
*doc
)
7833 SAFEARRAYBOUND dim
= {5, 0};
7838 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7839 hres
= SafeArrayAccessData(sa
, (void**)&args
);
7840 ok(hres
== S_OK
, "Failed to access array data: %08x\n", hres
);
7842 V_VT(args
) = VT_BSTR
;
7843 V_BSTR(args
) = a2bstr("<body i4val=\"");
7844 V_VT(args
+1) = VT_I4
;
7846 V_VT(args
+2) = VT_BSTR
;
7847 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7848 V_VT(args
+3) = VT_R8
;
7849 V_R8(args
+3) = 3.14;
7850 V_VT(args
+4) = VT_BSTR
;
7851 V_BSTR(args
+4) = a2bstr("\">");
7852 SafeArrayUnaccessData(sa
);
7854 hres
= IHTMLDocument2_write(doc
, sa
);
7855 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7857 SafeArrayDestroy(sa
);
7860 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7862 IHTMLDocument2
*window_doc
, *elem_doc
;
7863 IHTMLFrameElement3
*frame_elem3
;
7864 IHTMLWindow2
*content_window
;
7867 content_window
= get_frame_content_window(frame_elem
);
7868 test_ifaces((IUnknown
*)content_window
, window_iids
);
7869 window_doc
= get_window_doc(content_window
);
7870 IHTMLWindow2_Release(content_window
);
7872 elem_doc
= get_elem_doc(frame_elem
);
7873 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7876 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7877 if(SUCCEEDED(hres
)) {
7878 IDispatch
*disp
= NULL
;
7880 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7881 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7882 ok(disp
!= NULL
, "contentDocument == NULL\n");
7883 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7885 IDispatch_Release(disp
);
7886 IHTMLFrameElement3_Release(frame_elem3
);
7888 win_skip("IHTMLFrameElement3 not supported\n");
7892 IHTMLDocument2_Release(elem_doc
);
7893 IHTMLDocument2_Release(window_doc
);
7896 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7897 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7899 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7903 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7904 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7905 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7907 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7909 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7911 IHTMLIFrameElement2_Release(iframe
);
7914 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7915 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7917 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7922 V_BSTR(&v
) = a2bstr(val
);
7923 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7924 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7926 IHTMLIFrameElement2_Release(iframe
);
7929 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7930 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7932 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7936 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7937 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7938 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7940 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7942 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7944 IHTMLIFrameElement2_Release(iframe
);
7947 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7948 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7950 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7955 V_BSTR(&v
) = a2bstr(val
);
7956 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7957 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7959 IHTMLIFrameElement2_Release(iframe
);
7962 static void test_iframe_elem(IHTMLElement
*elem
)
7964 IHTMLDocument2
*content_doc
, *owner_doc
;
7965 IHTMLIFrameElement3
*iframe3
;
7966 IHTMLElementCollection
*col
;
7967 IHTMLWindow2
*content_window
;
7974 static const elem_type_t all_types
[] = {
7982 test_frame_doc((IUnknown
*)elem
, TRUE
);
7983 test_framebase((IUnknown
*)elem
);
7985 content_window
= get_frame_content_window((IUnknown
*)elem
);
7986 test_ifaces((IUnknown
*)content_window
, window_iids
);
7987 test_window_length(content_window
, 0);
7989 content_doc
= get_window_doc(content_window
);
7990 IHTMLWindow2_Release(content_window
);
7992 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7993 if(SUCCEEDED(hres
)) {
7994 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7995 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7996 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7997 IDispatch_Release(disp
);
7999 IHTMLIFrameElement3_Release(iframe3
);
8001 win_skip("IHTMLIFrameElement3 not supported\n");
8004 test_iframe_height(elem
, NULL
);
8005 set_iframe_height(elem
, "100px");
8006 set_iframe_height(elem
, "50%");
8007 test_iframe_height(elem
, "50%");
8009 test_iframe_width(elem
, NULL
);
8010 set_iframe_width(elem
, "150px");
8011 set_iframe_width(elem
, "70%");
8012 test_iframe_width(elem
, "70%");
8013 test_framebase_src(elem
, "about:blank");
8015 str
= a2bstr("text/html");
8016 V_VT(&errv
) = VT_ERROR
;
8018 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
8020 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
8021 ok(disp
!= NULL
, "disp == NULL\n");
8022 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
8023 IDispatch_Release(disp
);
8025 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
8026 doc_complex_write(content_doc
);
8027 doc_write(content_doc
, TRUE
, "<br />");
8028 doc_write(content_doc
, TRUE
, "</html>");
8030 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
8031 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8032 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
8033 IHTMLElementCollection_Release(col
);
8035 body
= doc_get_body(content_doc
);
8036 test_elem_attr(body
, "i4val", "4");
8037 test_elem_attr(body
, "r8val", "3.14");
8038 IHTMLElement_Release(body
);
8040 hres
= IHTMLDocument2_close(content_doc
);
8041 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
8043 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
8044 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
8046 IHTMLDocument2_Release(content_doc
);
8049 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
8050 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
8055 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
8056 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
8057 todo_wine_if(is_todo
) {
8059 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
8061 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
8067 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
8068 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
8070 BSTR str
= a2bstr(csstext
);
8073 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
8074 todo_wine_if(is_todo
)
8075 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
8079 static void test_stylesheet(IDispatch
*disp
)
8081 IHTMLStyleSheetRulesCollection
*col
= NULL
;
8082 IHTMLStyleSheet
*stylesheet
;
8086 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, "[object]");
8088 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
8089 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
8091 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
8092 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
8093 ok(col
!= NULL
, "col == NULL\n");
8095 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, NULL
, "[object]");
8096 IHTMLStyleSheetRulesCollection_Release(col
);
8098 href
= (void*)0xdeadbeef;
8099 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
8100 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
8101 ok(href
== NULL
, "got href != NULL\n");
8102 SysFreeString(href
);
8104 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
8105 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
8106 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
8107 set_stylesheet_csstext(stylesheet
, "", FALSE
);
8108 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
8109 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
8110 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
8112 IHTMLStyleSheet_Release(stylesheet
);
8115 static void test_stylesheets(IHTMLDocument2
*doc
)
8117 IHTMLStyleSheetsCollection
*col
= NULL
;
8122 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
8123 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
8124 ok(col
!= NULL
, "col == NULL\n");
8126 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, NULL
, "[object]");
8128 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
8129 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8130 ok(len
== 1, "len=%d\n", len
);
8136 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8137 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
8138 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8139 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8140 test_stylesheet(V_DISPATCH(&res
));
8147 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8148 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8149 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
8152 IHTMLStyleSheetsCollection_Release(col
);
8155 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
8157 IDispatchEx
*dispex
;
8159 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
8167 static const WCHAR w0
[] = {'0',0};
8168 static const WCHAR w100
[] = {'1','0','0',0};
8170 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
8171 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
8173 bstr
= SysAllocString(w0
);
8174 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8175 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8176 SysFreeString(bstr
);
8179 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
8180 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
8181 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
8182 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
8183 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
8184 type
= get_node_type((IUnknown
*)node
);
8185 ok(type
== 3, "type=%d\n", type
);
8186 IHTMLDOMNode_Release(node
);
8189 bstr
= SysAllocString(w100
);
8190 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8191 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
8192 SysFreeString(bstr
);
8194 IDispatchEx_Release(dispex
);
8197 static void test_enum_children(IUnknown
*unk
, unsigned len
)
8199 IEnumVARIANT
*enum_var
;
8204 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
8205 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
8207 for(i
=0; i
<len
; i
++) {
8209 V_VT(&v
) = VT_ERROR
;
8210 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
8211 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
8213 ok(fetched
== 1, "fetched = %d\n", fetched
);
8214 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
8215 IDispatch_Release(V_DISPATCH(&v
));
8218 fetched
= 0xdeadbeef;
8220 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
8221 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
8222 ok(fetched
== 0, "fetched = %d\n", fetched
);
8223 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8225 hres
= IEnumVARIANT_Reset(enum_var
);
8226 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8228 fetched
= 0xdeadbeef;
8230 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
8231 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
8232 ok(fetched
== 0, "fetched = %d\n", fetched
);
8233 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8235 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
8236 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
8238 hres
= IEnumVARIANT_Reset(enum_var
);
8239 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8241 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
8242 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
8244 IEnumVARIANT_Release(enum_var
);
8247 static void test_selectors(IHTMLDocument2
*doc
, IHTMLElement
*div
)
8249 IHTMLDOMChildrenCollection
*collection
;
8250 IDocumentSelector
*doc_selector
;
8251 IElementSelector
*elem_selector
;
8255 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8257 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentSelector
, (void**)&doc_selector
);
8258 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDocumentSelector iface: %08x\n", hres
);
8260 win_skip("IDocumentSelector tests skipped.\n");
8265 str
= a2bstr("nomatch");
8266 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8267 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8268 ok(collection
!= NULL
, "collection == NULL\n");
8269 test_children_collection_length(collection
, 0);
8270 IHTMLDOMChildrenCollection_Release(collection
);
8274 str
= a2bstr(".cl1");
8275 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8276 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8277 ok(collection
!= NULL
, "collection == NULL\n");
8278 test_children_collection_length(collection
, 2);
8279 IHTMLDOMChildrenCollection_Release(collection
);
8282 IDocumentSelector_Release(doc_selector
);
8284 hres
= IHTMLElement_QueryInterface(div
, &IID_IElementSelector
, (void**)&elem_selector
);
8285 ok(hres
== S_OK
, "Could not get IElementSelector iface: %08x\n", hres
);
8288 str
= a2bstr("nomatch");
8289 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8290 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8291 ok(collection
!= NULL
, "collection == NULL\n");
8292 test_children_collection_length(collection
, 0);
8293 IHTMLDOMChildrenCollection_Release(collection
);
8297 str
= a2bstr(".cl1");
8298 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8299 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8300 ok(collection
!= NULL
, "collection == NULL\n");
8301 test_children_collection_length(collection
, 2);
8302 IHTMLDOMChildrenCollection_Release(collection
);
8305 IElementSelector_Release(elem_selector
);
8308 static void test_elemsbyclass(IHTMLElement
*div
)
8310 IHTMLElementCollection
*collection
;
8311 IHTMLElement6
*elem
;
8315 static const elem_type_t types
[] = {ET_DIV
, ET_FORM
};
8317 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8319 hres
= IHTMLElement_QueryInterface(div
, &IID_IHTMLElement6
, (void**)&elem
);
8320 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IHTMLElement6 iface: %08x\n", hres
);
8322 win_skip("IHTMLElement6 tests skipped.\n");
8327 str
= a2bstr("nomatch");
8328 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8329 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8330 ok(collection
!= NULL
, "collection == NULL\n");
8331 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
8332 IHTMLElementCollection_Release(collection
);
8336 str
= a2bstr("cl1");
8337 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8338 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8339 ok(collection
!= NULL
, "collection == NULL\n");
8340 test_elem_collection((IUnknown
*)collection
, types
, ARRAY_SIZE(types
));
8341 IHTMLElementCollection_Release(collection
);
8344 IHTMLElement6_Release(elem
);
8347 static void test_elems(IHTMLDocument2
*doc
)
8349 IHTMLElementCollection
*col
;
8350 IHTMLDOMChildrenCollection
*child_col
;
8351 IHTMLElement
*elem
, *elem2
, *elem3
;
8352 IHTMLDOMNode
*node
, *node2
;
8353 IHTMLWindow2
*window
;
8357 IHTMLElementCollection
*collection
;
8358 IHTMLDocument3
*doc3
;
8361 static const elem_type_t all_types
[] = {
8394 static const elem_type_t item_types
[] = {
8400 hres
= IHTMLDocument2_get_all(doc
, &col
);
8401 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8402 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
8403 test_elem_col_item(col
, "x", item_types
, ARRAY_SIZE(item_types
));
8405 elem
= get_elem_col_item_idx(col
, 0);
8406 test_elem_source_index(elem
, 0);
8407 IHTMLElement_Release(elem
);
8409 elem
= get_elem_col_item_idx(col
, 3);
8410 test_elem_source_index(elem
, 3);
8411 IHTMLElement_Release(elem
);
8413 IHTMLElementCollection_Release(col
);
8415 hres
= IHTMLDocument2_get_images(doc
, &collection
);
8416 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
8419 static const elem_type_t images_types
[] = {ET_IMG
};
8420 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8422 IHTMLElementCollection_Release(collection
);
8425 hres
= IHTMLDocument2_get_links(doc
, &collection
);
8426 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
8429 static const elem_type_t images_types
[] = {ET_A
};
8430 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8432 IHTMLElementCollection_Release(collection
);
8435 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
8436 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
8439 static const elem_type_t anchor_types
[] = {ET_A
};
8440 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
8442 IHTMLElementCollection_Release(collection
);
8445 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
8446 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
8448 static const elem_type_t script_types
[] = {ET_SCRIPT
};
8449 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
8450 IHTMLElementCollection_Release(collection
);
8453 test_plugins_col(doc
);
8455 elem
= get_doc_elem(doc
);
8456 test_elem_istextedit(elem
, VARIANT_FALSE
);
8457 test_elem_all((IUnknown
*)elem
, all_types
+1, ARRAY_SIZE(all_types
)-1);
8458 IHTMLElement_Release(elem
);
8460 get_elem_by_id(doc
, "xxx", FALSE
);
8461 elem
= get_doc_elem_by_id(doc
, "xxx");
8462 ok(!elem
, "elem != NULL\n");
8464 elem
= get_doc_elem_by_id(doc
, "s");
8465 ok(elem
!= NULL
, "elem == NULL\n");
8467 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
8468 test_elem_attr(elem
, "xxx", NULL
);
8469 test_elem_attr(elem
, "id", "s");
8470 test_elem_class((IUnknown
*)elem
, NULL
);
8471 test_elem_set_class((IUnknown
*)elem
, "cl");
8472 test_elem_set_class((IUnknown
*)elem
, NULL
);
8473 test_elem_tabindex((IUnknown
*)elem
, 0);
8474 test_elem_set_tabindex((IUnknown
*)elem
, 1);
8475 test_elem_filters((IUnknown
*)elem
);
8476 test_elem_istextedit(elem
, VARIANT_FALSE
);
8478 node
= test_node_get_parent((IUnknown
*)elem
);
8479 ok(node
!= NULL
, "node == NULL\n");
8480 test_node_name((IUnknown
*)node
, "BODY");
8481 node2
= test_node_get_parent((IUnknown
*)node
);
8482 IHTMLDOMNode_Release(node
);
8483 ok(node2
!= NULL
, "node == NULL\n");
8484 test_node_name((IUnknown
*)node2
, "HTML");
8485 node
= test_node_get_parent((IUnknown
*)node2
);
8486 IHTMLDOMNode_Release(node2
);
8487 ok(node
!= NULL
, "node == NULL\n");
8490 test_node_name((IUnknown
*)node
, "#document");
8491 type
= get_node_type((IUnknown
*)node
);
8492 ok(type
== 9, "type=%d, expected 9\n", type
);
8493 node2
= test_node_get_parent((IUnknown
*)node
);
8494 IHTMLDOMNode_Release(node
);
8495 ok(node2
== NULL
, "node != NULL\n");
8498 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8499 ok(elem2
!= NULL
, "elem2 == NULL\n");
8500 test_node_name((IUnknown
*)elem2
, "BODY");
8502 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
8503 ok(elem3
!= NULL
, "elem3 == NULL\n");
8504 test_node_name((IUnknown
*)elem3
, "HTML");
8506 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
8507 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
8508 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
8509 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
8510 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
8511 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
8512 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
8513 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
8514 IHTMLElement_Release(elem2
);
8516 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
8517 ok(elem2
== NULL
, "elem2 != NULL\n");
8518 test_elem_source_index(elem3
, 0);
8519 IHTMLElement_Release(elem3
);
8521 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
8522 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
8523 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
8525 test_elem_innertext(elem
, "opt1opt2");
8527 IHTMLElement_Release(elem
);
8530 elem
= get_elem_by_id(doc
, "s", TRUE
);
8532 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8533 IHTMLDocument2
*doc_node
, *elem_doc
;
8535 test_select_elem(select
);
8537 test_elem_istextedit(elem
, VARIANT_FALSE
);
8538 test_elem_title((IUnknown
*)select
, NULL
);
8539 test_elem_set_title((IUnknown
*)select
, "Title");
8540 test_elem_title((IUnknown
*)select
, "Title");
8541 test_elem_offset((IUnknown
*)select
, "BODY");
8542 test_elem_bounding_client_rect((IUnknown
*)select
);
8544 node
= get_first_child((IUnknown
*)select
);
8545 ok(node
!= NULL
, "node == NULL\n");
8547 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8548 IHTMLDOMNode_Release(node
);
8551 type
= get_node_type((IUnknown
*)select
);
8552 ok(type
== 1, "type=%d\n", type
);
8554 IHTMLSelectElement_Release(select
);
8556 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8558 doc_node
= get_doc_node(doc
);
8559 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8560 IHTMLDocument2_Release(doc_node
);
8561 IHTMLDocument2_Release(elem_doc
);
8563 IHTMLElement_Release(elem
);
8566 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8568 IHTMLScriptElement
*script
;
8571 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8572 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8574 test_elem_language(elem
, NULL
);
8575 test_elem_istextedit(elem
, VARIANT_FALSE
);
8581 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8582 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8583 hres
= IHTMLScriptElement_get_type(script
, &type
);
8584 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8585 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8587 type
= a2bstr("text/javascript");
8588 hres
= IHTMLScriptElement_put_type (script
, type
);
8589 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8590 SysFreeString(type
);
8591 hres
= IHTMLScriptElement_get_type(script
, &type
);
8592 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8593 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8594 SysFreeString(type
);
8596 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8599 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8600 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8602 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8603 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8604 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8606 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8607 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8609 str
= (BSTR
)0xdeadbeef;
8610 hres
= IHTMLScriptElement_get_src(script
, &str
);
8611 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8612 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8615 IHTMLScriptElement_Release(script
);
8617 set_elem_language(elem
, "vbscript");
8618 set_elem_language(elem
, "xxx");
8621 elem
= get_elem_by_id(doc
, "in", TRUE
);
8623 IHTMLInputElement
*input
;
8625 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8626 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8628 test_elem_id((IUnknown
*)elem
, "in");
8629 test_elem_put_id((IUnknown
*)elem
, "newin");
8630 test_input_get_disabled(input
, VARIANT_FALSE
);
8631 test_input_set_disabled(input
, VARIANT_TRUE
);
8632 test_input_set_disabled(input
, VARIANT_FALSE
);
8633 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8634 test_input_get_disabled(input
, VARIANT_TRUE
);
8635 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8636 test_input_get_disabled(input
, VARIANT_FALSE
);
8637 test_elem_client_size((IUnknown
*)elem
);
8638 test_input_type(input
, "text");
8639 test_elem_istextedit(elem
, VARIANT_TRUE
);
8641 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8642 test_node_put_value_str((IUnknown
*)elem
, "test");
8643 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8644 test_input_value((IUnknown
*)elem
, NULL
);
8645 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8646 test_input_put_value((IUnknown
*)elem
, "test");
8647 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8648 test_elem_class((IUnknown
*)elem
, "testclass");
8649 test_elem_tabindex((IUnknown
*)elem
, 2);
8650 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8651 test_elem_title((IUnknown
*)elem
, "test title");
8653 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8654 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8655 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8657 test_input_get_checked(input
, VARIANT_FALSE
);
8658 test_input_set_checked(input
, VARIANT_TRUE
);
8659 test_input_set_checked(input
, VARIANT_FALSE
);
8661 test_input_maxlength(input
, 0x7fffffff);
8662 test_input_set_maxlength(input
, 30);
8664 test_input_name(input
, NULL
);
8665 test_input_set_name(input
, "test");
8667 test_input_src(input
, NULL
);
8668 test_input_set_src(input
, "about:blank");
8670 test_input_set_size(input
, 15, S_OK
);
8671 test_input_get_size(input
, 15);
8672 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8673 test_input_get_size(input
, 15);
8674 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8675 test_input_get_size(input
, 15);
8677 test_input_readOnly(input
, VARIANT_TRUE
);
8678 test_input_readOnly(input
, VARIANT_FALSE
);
8680 test_elem_lang(elem
, NULL
);
8681 set_elem_lang(elem
, "en-us");
8683 IHTMLInputElement_Release(input
);
8684 IHTMLElement_Release(elem
);
8687 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8689 test_img_align((IUnknown
*)elem
, "left");
8690 test_img_name((IUnknown
*)elem
, "WineImg");
8691 test_img_src((IUnknown
*)elem
, "", NULL
);
8692 test_img_set_src((IUnknown
*)elem
, "about:blank");
8693 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8694 test_img_alt((IUnknown
*)elem
, NULL
);
8695 test_img_set_alt((IUnknown
*)elem
, "alt test");
8696 test_img_name((IUnknown
*)elem
, "WineImg");
8697 test_img_complete(elem
, VARIANT_FALSE
);
8698 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8699 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8700 IHTMLElement_Release(elem
);
8703 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8705 test_dynamic_properties(elem
);
8706 test_attr_collection(elem
);
8707 test_contenteditable((IUnknown
*)elem
);
8708 IHTMLElement_Release(elem
);
8711 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8713 test_style_media((IUnknown
*)elem
, NULL
);
8714 test_style_put_media((IUnknown
*)elem
, "screen");
8715 test_style_type((IUnknown
*)elem
, NULL
);
8716 test_style_put_type((IUnknown
*)elem
, "text/css");
8717 IHTMLElement_Release(elem
);
8720 elem
= get_doc_elem_by_id(doc
, "tbl");
8721 ok(elem
!= NULL
, "elem == NULL\n");
8723 test_table_elem(elem
);
8724 IHTMLElement_Release(elem
);
8727 elem
= get_doc_elem_by_id(doc
, "labelid");
8728 ok(elem
!= NULL
, "elem == NULL\n");
8730 test_label_elem(elem
);
8731 IHTMLElement_Release(elem
);
8734 elem
= get_doc_elem_by_id(doc
, "row2");
8735 ok(elem
!= NULL
, "elem == NULL\n");
8738 IHTMLElement_Release(elem
);
8741 elem
= get_doc_elem_by_id(doc
, "ifr");
8742 ok(elem
!= NULL
, "elem == NULL\n");
8744 test_iframe_elem(elem
);
8745 IHTMLElement_Release(elem
);
8748 elem
= get_doc_elem_by_id(doc
, "btnid");
8749 ok(elem
!= NULL
, "elem == NULL\n");
8751 test_button_elem(elem
);
8752 test_button_get_disabled(elem
, VARIANT_FALSE
);
8753 test_button_set_disabled(elem
, VARIANT_TRUE
);
8754 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8755 test_button_get_disabled(elem
, VARIANT_FALSE
);
8756 IHTMLElement_Release(elem
);
8759 elem
= get_doc_elem_by_id(doc
, "objid");
8760 ok(elem
!= NULL
, "elem == NULL\n");
8762 test_object_vspace((IUnknown
*)elem
, 100);
8763 test_object_name(elem
, "objname");
8764 set_object_name(elem
, "test");
8765 set_object_name(elem
, NULL
);
8766 IHTMLElement_Release(elem
);
8769 elem
= get_elem_by_id(doc
, "a", TRUE
);
8771 test_anchor_href((IUnknown
*)elem
, "http://test/");
8773 /* Change the href */
8774 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8775 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8776 test_anchor_hostname((IUnknown
*)elem
, "test1");
8778 /* Restore the href */
8779 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8780 test_anchor_href((IUnknown
*)elem
, "http://test/");
8781 test_anchor_hostname((IUnknown
*)elem
, "test");
8782 test_anchor_hash(elem
, NULL
);
8785 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8787 test_anchor_rel((IUnknown
*)elem
, NULL
);
8788 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8789 test_anchor_rel((IUnknown
*)elem
, "Next");
8791 /* Change the target */
8792 test_anchor_put_target((IUnknown
*)elem
, "wine");
8793 test_anchor_get_target((IUnknown
*)elem
, "wine");
8795 /* Restore the target */
8796 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8797 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8799 test_anchor_name((IUnknown
*)elem
, "x");
8800 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8801 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8802 test_anchor_put_name((IUnknown
*)elem
, "x");
8804 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8805 test_anchor_hash(elem
, "#hash");
8806 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8808 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8809 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8810 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8811 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8813 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8814 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8816 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8817 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8819 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8820 as part of the pathname, and cannot be accessed by get_search. */
8821 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8822 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8824 IHTMLElement_Release(elem
);
8827 elem
= get_doc_elem_by_id(doc
, "metaid");
8829 test_meta_name((IUnknown
*)elem
, "meta name");
8830 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8831 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8832 test_meta_charset((IUnknown
*)elem
, NULL
);
8833 set_meta_charset((IUnknown
*)elem
, "utf-8");
8834 IHTMLElement_Release(elem
);
8837 elem
= doc_get_body(doc
);
8839 node
= get_first_child((IUnknown
*)elem
);
8840 ok(node
!= NULL
, "node == NULL\n");
8842 test_ifaces((IUnknown
*)node
, text_iids
);
8843 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
8845 node2
= get_first_child((IUnknown
*)node
);
8846 ok(!node2
, "node2 != NULL\n");
8848 type
= get_node_type((IUnknown
*)node
);
8849 ok(type
== 3, "type=%d\n", type
);
8851 test_node_get_value_str((IUnknown
*)node
, "text test");
8852 test_node_put_value_str((IUnknown
*)elem
, "test text");
8853 test_node_get_value_str((IUnknown
*)node
, "text test");
8855 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8856 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8857 ok(!disp
, "disp != NULL\n");
8859 IHTMLDOMNode_Release(node
);
8862 child_col
= get_child_nodes((IUnknown
*)elem
);
8863 ok(child_col
!= NULL
, "child_coll == NULL\n");
8868 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, NULL
, "[object]");
8869 length
= test_children_collection_length(child_col
, -1);
8872 node
= get_child_item(child_col
, 0);
8873 ok(node
!= NULL
, "node == NULL\n");
8877 type
= get_node_type((IUnknown
*)node
);
8878 ok(type
== 3, "type=%d\n", type
);
8879 node2
= node_get_next((IUnknown
*)node
);
8881 prev
= node_get_prev((IUnknown
*)node2
);
8882 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8883 IHTMLDOMNode_Release(prev
);
8885 IHTMLDOMNode_Release(node
);
8888 node
= get_child_item(child_col
, 1);
8889 ok(node
!= NULL
, "node == NULL\n");
8891 type
= get_node_type((IUnknown
*)node
);
8892 ok(type
== 8, "type=%d\n", type
);
8894 test_elem_id((IUnknown
*)node
, NULL
);
8895 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8896 IHTMLDOMNode_Release(node2
);
8897 IHTMLDOMNode_Release(node
);
8900 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8901 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8903 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8904 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8906 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8907 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8909 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8910 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8912 test_child_col_disp(child_col
);
8914 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8915 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8917 test_enum_children(enum_unk
, length
);
8919 IUnknown_Release(enum_unk
);
8921 IHTMLDOMChildrenCollection_Release(child_col
);
8924 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8925 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8926 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8928 IHTMLElement_Release(elem
);
8930 elem
= get_doc_elem_by_id(doc
, "frm");
8931 ok(elem
!= NULL
, "elem == NULL\n");
8933 test_form_length((IUnknown
*)elem
, 0);
8934 test_form_elements((IUnknown
*)elem
, NULL
, 0);
8935 IHTMLElement_Release(elem
);
8938 test_stylesheets(doc
);
8939 test_create_option_elem(doc
);
8940 test_create_img_elem(doc
);
8942 elem
= get_doc_elem_by_id(doc
, "tbl");
8943 ok(elem
!= NULL
, "elem = NULL\n");
8944 test_elem_set_innertext(elem
, "inner text");
8945 IHTMLElement_Release(elem
);
8947 test_doc_title(doc
, "test");
8948 test_doc_set_title(doc
, "test title");
8949 test_doc_title(doc
, "test title");
8952 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8953 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8956 IDispatchEx
*dispex
;
8957 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8958 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8962 BSTR str
= a2bstr("Testing");
8963 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8964 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8965 ok(pid
!= -1, "pid == -1\n");
8967 IDispatchEx_Release(dispex
);
8970 IDispatch_Release(disp
);
8972 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8974 elem
= get_doc_elem_by_id(doc
, "y");
8975 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8976 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8977 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8978 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8979 node
= node_get_next((IUnknown
*)elem
);
8980 ok(!node
, "node = %p\n", node
);
8982 elem2
= get_doc_elem_by_id(doc
, "x");
8983 test_elem_tag((IUnknown
*)elem2
, "A");
8984 node
= node_get_next((IUnknown
*)elem2
);
8985 IHTMLDOMNode_Release(node
);
8986 IHTMLElement_Release(elem2
);
8987 IHTMLElement_Release(elem
);
8989 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8990 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8992 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8993 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8995 IHTMLDocument3_Release(doc3
);
8997 elem
= get_elem_by_id(doc
, "s", TRUE
);
8999 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
9001 test_select_put_length((IUnknown
*)elem
, 3);
9002 test_elem_all((IUnknown
*)elem
, select_types
, ARRAY_SIZE(select_types
));
9003 test_select_put_length((IUnknown
*)elem
, 1);
9004 test_elem_all((IUnknown
*)elem
, select_types
, 1);
9005 IHTMLElement_Release(elem
);
9008 window
= get_doc_window(doc
);
9009 test_window_name(window
, NULL
);
9010 set_window_name(window
, "test name");
9011 test_window_length(window
, 1);
9012 IHTMLWindow2_Release(window
);
9015 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
9017 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
9018 IHTMLElement4
*elem4
;
9022 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
9024 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9026 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
9027 test_ifaces((IUnknown
*)attr
, attr_iids
);
9028 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9029 test_attr_specified(attr
, VARIANT_TRUE
);
9030 test_attr_parent(attr
);
9032 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9033 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
9034 IHTMLDOMAttribute_Release(attr2
);
9036 get_attr_node_value(attr
, &v
, VT_BSTR
);
9037 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9041 V_BSTR(&v
) = a2bstr("divid2");
9042 put_attr_node_value(attr
, v
);
9045 get_attr_node_value(attr
, &v
, VT_BSTR
);
9046 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9049 put_attr_value(attr
, "divid3");
9051 get_attr_node_value(attr
, &v
, VT_BSTR
);
9052 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9055 IHTMLDOMAttribute_Release(attr
);
9057 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
9058 get_attr_node_value(attr
, &v
, VT_BSTR
);
9059 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9063 V_BSTR(&v
) = a2bstr("newvalue");
9064 put_attr_node_value(attr
, v
);
9067 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
9068 get_attr_node_value(attr
, &v
, VT_BSTR
);
9069 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9072 test_attr_specified(attr
, VARIANT_TRUE
);
9073 IHTMLDOMAttribute_Release(attr
);
9077 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
9078 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
9079 get_attr_node_value(attr
, &v
, VT_I4
);
9080 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
9081 test_attr_specified(attr
, VARIANT_TRUE
);
9085 put_attr_node_value(attr
, v
);
9087 get_attr_node_value(attr
, &v
, VT_I4
);
9088 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
9090 put_attr_value(attr
, "160");
9091 get_attr_node_value(attr
, &v
, VT_BSTR
);
9092 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9095 IHTMLDOMAttribute_Release(attr
);
9097 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
9098 test_attr_specified(attr
, VARIANT_FALSE
);
9099 test_attr_expando(attr
, VARIANT_FALSE
);
9100 IHTMLDOMAttribute_Release(attr
);
9102 /* Test created, detached attribute. */
9103 attr
= create_attr((IUnknown
*)doc
, "Test");
9105 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
9106 test_ifaces((IUnknown
*)attr
, attr_iids
);
9107 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9109 test_attr_node_name(attr
, "Test");
9110 test_attr_expando(attr
, VARIANT_FALSE
);
9112 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9116 put_attr_node_value(attr
, v
);
9118 get_attr_node_value(attr
, &v
, VT_I4
);
9119 ok(V_I4(&v
) == 1, "nodeValue = %d\n", V_I4(&v
));
9120 test_attr_value(attr
, "1");
9122 V_VT(&v
) = VT_EMPTY
;
9123 put_attr_node_value(attr
, v
);
9124 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9127 V_BSTR(&v
) = a2bstr("testing");
9128 put_attr_node_value(attr
, v
);
9129 SysFreeString(V_BSTR(&v
));
9130 test_attr_value(attr
, "testing");
9132 elem4
= get_elem4_iface((IUnknown
*)elem
);
9134 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
9135 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9136 ok(!attr2
, "attr2 != NULL\n");
9138 test_elem_attr(elem
, "Test", "testing");
9139 put_attr_value(attr
, "new value");
9140 test_elem_attr(elem
, "Test", "new value");
9142 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9143 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9144 IHTMLDOMAttribute_Release(attr2
);
9146 attr3
= create_attr((IUnknown
*)doc
, "Test");
9147 put_attr_value(attr3
, "replace test");
9149 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9150 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9151 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9152 IHTMLDOMAttribute_Release(attr2
);
9154 test_elem_attr(elem
, "Test", "replace test");
9155 test_attr_value(attr
, "new value");
9156 test_attr_value(attr3
, "replace test");
9158 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9159 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
9160 IHTMLDOMAttribute_Release(attr2
);
9162 put_attr_value(attr
, "new value2");
9163 test_elem_attr(elem
, "Test", "replace test");
9164 test_attr_value(attr
, "new value2");
9165 test_attr_value(attr3
, "replace test");
9167 put_attr_value(attr3
, "new replace value");
9168 test_elem_attr(elem
, "Test", "new replace value");
9169 test_attr_value(attr
, "new value2");
9170 test_attr_value(attr3
, "new replace value");
9172 /* Attached attributes cause errors. */
9173 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9174 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9175 IHTMLDOMAttribute_Release(attr3
);
9177 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9178 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
9179 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9180 IHTMLDOMAttribute_Release(attr2
);
9182 IHTMLElement4_Release(elem4
);
9183 IHTMLDOMAttribute_Release(attr
);
9186 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
9190 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9191 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
9192 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9194 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9195 IHTMLElement_Release(elem
);
9198 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9199 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
9200 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9202 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
9203 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
9204 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
9205 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
9206 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9207 IHTMLElement_Release(elem
);
9211 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
9212 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
9214 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
9215 IHTMLElementCollection
*col
;
9216 BSTR str
= a2bstr(name
);
9219 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
9220 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
9221 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
9223 IHTMLDocument3_Release(doc3
);
9228 static void test_elem_names(IHTMLDocument2
*doc
)
9230 IHTMLElementCollection
*col
;
9235 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
9237 body
= doc_get_body(doc
);
9239 test_elem_set_innerhtml((IUnknown
*)body
,
9240 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
9241 col
= doc_get_elems_by_name(doc
, "test");
9242 test_elem_collection((IUnknown
*)col
, test1_types
, ARRAY_SIZE(test1_types
));
9243 IHTMLElementCollection_Release(col
);
9245 col
= doc_get_elems_by_name(doc
, "yyy");
9246 test_elem_collection((IUnknown
*)col
, NULL
, 0);
9247 IHTMLElementCollection_Release(col
);
9249 /* case insensivity test */
9250 col
= doc_get_elems_by_name(doc
, "Xxx");
9251 hres
= IHTMLElementCollection_get_length(col
, &len
);
9252 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
9253 todo_wine
ok(len
== 1, "len = %d\n", len
);
9254 IHTMLElementCollection_Release(col
);
9256 IHTMLElement_Release(body
);
9259 static void test_elems2(IHTMLDocument2
*doc
)
9261 IHTMLElement
*elem
, *elem2
, *div
;
9263 static const elem_type_t outer_types
[] = {
9268 div
= get_doc_elem_by_id(doc
, "divid");
9270 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
9272 test_link_disabled(elem
, VARIANT_FALSE
);
9273 test_link_rel(elem
, "stylesheet");
9274 test_link_rev(elem
, NULL
);
9275 test_link_type(elem
, "text/css");
9276 test_link_href(elem
, "about:blank");
9277 test_link_media(elem
, "all");
9278 link_put_disabled(elem
, VARIANT_TRUE
);
9279 link_put_rel(elem
, "prev");
9280 link_put_rev(elem
, "next");
9281 link_put_type(elem
, "text/plain");
9282 link_put_href(elem
, "about:prev");
9283 IHTMLElement_Release(elem
);
9286 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
9287 elem2
= get_doc_elem_by_id(doc
, "innerid");
9288 ok(elem2
!= NULL
, "elem2 == NULL\n");
9289 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
9290 test_elem_all((IUnknown
*)div
, outer_types
, ARRAY_SIZE(outer_types
));
9291 IHTMLElement_Release(elem2
);
9293 elem2
= get_doc_elem_by_id(doc
, "aid");
9294 ok(elem2
!= NULL
, "elem2 == NULL\n");
9295 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
9296 test_elem_all((IUnknown
*)div
, outer_types
, 1);
9297 IHTMLElement_Release(elem2
);
9299 test_elem_set_innerhtml((IUnknown
*)div
,
9300 "<input value=\"val\" id =\"inputid\" />");
9301 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9303 test_input_defaultValue((IUnknown
*)elem
, "val");
9304 test_input_put_value((IUnknown
*)elem
, "test");
9305 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
9306 test_input_value((IUnknown
*)elem
, "test");
9307 IHTMLElement_Release(elem
);
9310 test_elem_set_innerhtml((IUnknown
*)div
, "");
9311 test_insert_adjacent_elems(doc
, div
);
9313 test_elem_set_innerhtml((IUnknown
*)div
,
9314 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select><button id=\"btnid\"></button></form>");
9315 elem
= get_elem_by_id(doc
, "sform", TRUE
);
9316 elem2
= get_elem_by_id(doc
, "form", TRUE
);
9318 IHTMLFormElement
*form
;
9320 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9321 IHTMLElement_Release(elem
);
9323 elem
= get_elem_by_id(doc
, "oform", TRUE
);
9325 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9326 IHTMLElement_Release(elem
);
9329 elem
= get_elem_by_id(doc
, "btnid", TRUE
);
9331 form
= get_button_form(elem
);
9332 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9333 IHTMLFormElement_Release(form
);
9335 IHTMLElement_Release(elem
);
9336 IHTMLElement_Release(elem2
);
9339 test_selectors(doc
, div
);
9340 test_elemsbyclass(div
);
9342 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"elemid\">test</div>");
9343 elem
= get_elem_by_id(doc
, "elemid", TRUE
);
9345 test_elem_outertext(elem
, "test");
9346 test_elem_set_outertext(elem
, "outer text");
9347 test_elem_outertext(elem
, NULL
);
9348 test_elem_all((IUnknown
*)div
, NULL
, 0);
9349 elem2
= test_elem_get_parent((IUnknown
*)elem
);
9350 ok(!elem2
, "parent != NULL\n");
9351 IHTMLElement_Release(elem
);
9354 test_elem_set_innerhtml((IUnknown
*)div
, "<map><area id=\"areaid\"></area></map>");
9355 elem
= get_elem_by_id(doc
, "areaid", TRUE
);
9357 test_elem_type((IUnknown
*)elem
, ET_AREA
);
9358 IHTMLElement_Release(elem
);
9361 test_td_elem(doc
, div
);
9362 test_attr(doc
, div
);
9363 test_blocked(doc
, div
);
9364 test_elem_names(doc
);
9366 IHTMLElement_Release(div
);
9369 static void test_textarea_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
9371 IHTMLElement
*form_elem
, *elem
;
9372 IHTMLFormElement
*form
;
9374 test_elem_set_innerhtml((IUnknown
*)parent
,
9375 "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
9376 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9377 test_elem_type((IUnknown
*)elem
, ET_TEXTAREA
);
9379 form_elem
= get_elem_by_id(doc
, "fid", TRUE
);
9380 ok(form_elem
!= NULL
, "form_elem == NULL\n");
9382 form
= get_textarea_form((IUnknown
*)elem
);
9383 ok(form
!= NULL
, "form = NULL\n");
9384 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)form_elem
), "form != form_elem\n");
9386 IHTMLFormElement_Release(form
);
9387 IHTMLElement_Release(form_elem
);
9388 IHTMLElement_Release(elem
);
9390 test_elem_set_innerhtml((IUnknown
*)parent
, "<textarea id=\"ta\"></textarea>");
9391 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9393 test_textarea_value((IUnknown
*)elem
, NULL
);
9394 test_textarea_put_value((IUnknown
*)elem
, "test");
9395 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
9396 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
9397 test_textarea_put_value((IUnknown
*)elem
, "test");
9398 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9399 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
9400 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9401 test_textarea_type((IUnknown
*)elem
);
9403 form
= get_textarea_form((IUnknown
*)elem
);
9404 ok(!form
, "form = %p\n", form
);
9406 test_elem_istextedit(elem
, VARIANT_TRUE
);
9408 IHTMLElement_Release(elem
);
9410 test_elem_set_innerhtml((IUnknown
*)parent
, "<textarea id=\"ta\">default text</textarea>");
9411 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9412 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
9413 IHTMLElement_Release(elem
);
9416 static void test_form_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
9418 IHTMLElement
*elem
, *input_elem
;
9420 static const elem_type_t elems_textarea_input
[] = { ET_TEXTAREA
, ET_INPUT
};
9422 test_elem_set_innerhtml((IUnknown
*)parent
,
9423 "<form id=\"form\">"
9424 "<textarea></textarea>"
9425 "<div><input type=\"text\" id=\"inputid\" /></div>"
9427 elem
= get_elem_by_id(doc
, "form", TRUE
);
9428 test_elem_type((IUnknown
*)elem
, ET_FORM
);
9430 test_form_length((IUnknown
*)elem
, 2);
9431 test_form_item(elem
);
9432 test_form_action((IUnknown
*)elem
, NULL
);
9433 test_form_put_action((IUnknown
*)elem
, "about:blank");
9434 test_form_method((IUnknown
*)elem
, "get");
9435 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
9436 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
9437 test_form_method((IUnknown
*)elem
, "post");
9438 test_form_name((IUnknown
*)elem
, NULL
);
9439 test_form_put_name((IUnknown
*)elem
, "Name");
9440 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
9441 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
9442 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
9443 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
9444 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
9445 test_form_elements((IUnknown
*)elem
, elems_textarea_input
, ARRAY_SIZE(elems_textarea_input
));
9446 test_form_reset((IUnknown
*)elem
);
9447 test_form_target((IUnknown
*)elem
);
9449 input_elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9450 test_input_get_form((IUnknown
*)input_elem
, "form");
9451 IHTMLElement_Release(input_elem
);
9453 IHTMLElement_Release(elem
);
9456 static void test_svg_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
9458 IHTMLDOMNode
*svg_node
, *circle_node
;
9460 test_elem_set_innerhtml((IUnknown
*)parent
,
9461 "<svg width=\"100\" height=\"100\" id=\"svgid\">"
9462 "<circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"black\" />"
9464 svg_node
= get_first_child((IUnknown
*)parent
);
9465 if(compat_mode
< COMPAT_IE9
) {
9467 ok(!svg_node
, "svg_node != NULL\n");
9469 IHTMLDOMNode_Release(svg_node
);
9472 ok(svg_node
!= NULL
, "svg_node = NULL\n");
9473 test_elem_type((IUnknown
*)svg_node
, ET_SVG
);
9475 circle_node
= get_first_child((IUnknown
*)svg_node
);
9476 ok(circle_node
!= NULL
, "circle_node = NULL\n");
9479 test_elem_type((IUnknown
*)circle_node
, ET_CIRCLE
);
9481 IHTMLDOMNode_Release(circle_node
);
9482 IHTMLDOMNode_Release(svg_node
);
9485 static void test_dom_elements(IHTMLDocument2
*doc
)
9487 IHTMLElement
*body
, *div
;
9489 body
= doc_get_body(doc
);
9490 test_elem_set_innerhtml((IUnknown
*)body
, "<div id=\"parentdiv\"></div>");
9491 div
= get_doc_elem_by_id(doc
, "parentdiv");
9493 test_textarea_element(doc
, div
);
9494 test_form_element(doc
, div
);
9495 test_svg_element(doc
, div
);
9497 IHTMLElement_Release(body
);
9498 IHTMLElement_Release(div
);
9501 static void test_create_elems(IHTMLDocument2
*doc
)
9503 IHTMLElement
*elem
, *body
, *elem2
;
9504 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
9505 IHTMLDocument5
*doc5
;
9512 static const elem_type_t types1
[] = { ET_TESTG
};
9514 elem
= test_create_elem(doc
, "TEST");
9515 test_elem_tag((IUnknown
*)elem
, "TEST");
9516 type
= get_node_type((IUnknown
*)elem
);
9517 ok(type
== 1, "type=%d\n", type
);
9518 test_ifaces((IUnknown
*)elem
, elem_iids
);
9519 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
, "[object]");
9520 test_elem_source_index(elem
, -1);
9522 body
= doc_get_body(doc
);
9523 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9525 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
9526 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
9527 elem2
= get_elem_iface((IUnknown
*)node
);
9528 IHTMLElement_Release(elem2
);
9530 hres
= IHTMLElement_get_all(body
, &disp
);
9531 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9532 test_elem_collection((IUnknown
*)disp
, types1
, ARRAY_SIZE(types1
));
9533 IDispatch_Release(disp
);
9535 test_node_remove_child((IUnknown
*)body
, node
);
9537 hres
= IHTMLElement_get_all(body
, &disp
);
9538 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9539 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
9540 IDispatch_Release(disp
);
9541 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9543 IHTMLElement_Release(elem
);
9544 IHTMLDOMNode_Release(node
);
9546 node
= test_create_text(doc
, "abc");
9547 test_ifaces((IUnknown
*)node
, text_iids
);
9548 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
9549 test_text_length((IUnknown
*)node
, 3);
9550 test_text_data((IUnknown
*)node
, "abc");
9551 set_text_data((IUnknown
*)node
, "test");
9552 test_text_data((IUnknown
*)node
, "test");
9553 text_append_data((IUnknown
*)node
, " append");
9554 test_text_data((IUnknown
*)node
, "test append");
9555 text_append_data((IUnknown
*)node
, NULL
);
9556 test_text_data((IUnknown
*)node
, "test append");
9557 set_text_data((IUnknown
*)node
, "test");
9559 V_VT(&var
) = VT_NULL
;
9560 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9561 IHTMLDOMNode_Release(node
);
9563 node
= test_create_text(doc
, "insert ");
9565 V_VT(&var
) = VT_DISPATCH
;
9566 V_DISPATCH(&var
) = (IDispatch
*)node2
;
9567 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9568 IHTMLDOMNode_Release(node
);
9569 IHTMLDOMNode_Release(node2
);
9570 IHTMLDOMNode_Release(node3
);
9572 test_elem_innertext(body
, "insert test");
9573 test_elem_innerhtml((IUnknown
*)body
, "insert test");
9575 node
= test_create_text(doc
, " Test");
9576 V_VT(&var
) = VT_DISPATCH
;
9577 V_DISPATCH(&var
) = NULL
;
9578 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9579 test_elem_innertext(body
, "insert test Test");
9580 IHTMLDOMNode_Release(node
);
9582 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
9584 str
= a2bstr("testing");
9585 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
9587 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
9590 type
= get_node_type((IUnknown
*)comment
);
9591 ok(type
== 8, "type=%d, expected 8\n", type
);
9593 test_node_get_value_str((IUnknown
*)comment
, "testing");
9594 test_elem_title((IUnknown
*)comment
, NULL
);
9595 test_elem_set_title((IUnknown
*)comment
, "comment title");
9596 test_elem_title((IUnknown
*)comment
, "comment title");
9597 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
9598 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
9599 test_comment_attrs((IUnknown
*)comment
);
9601 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
9602 test_comment_text((IUnknown
*)node2
, "<!--testing-->");
9603 IHTMLDOMNode_Release(node2
);
9605 test_elem_getelembytag((IUnknown
*)comment
, ET_COMMENT
, 0, NULL
);
9607 IHTMLDOMNode_Release(comment
);
9610 IHTMLDocument5_Release(doc5
);
9613 IHTMLElement_Release(body
);
9616 static void test_replacechild_elems(IHTMLDocument2
*doc
)
9619 IHTMLDOMNode
*node
, *node2
, *node3
;
9620 IHTMLDOMNode
*nodeBody
, *nodeNew
;
9624 body
= doc_get_body(doc
);
9626 node
= test_create_text(doc
, "insert");
9628 V_VT(&var
) = VT_NULL
;
9629 V_DISPATCH(&var
) = NULL
;
9630 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9631 IHTMLDOMNode_Release(node
);
9633 test_elem_innertext(body
, "insert");
9635 node3
= test_create_text(doc
, "replaced");
9637 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
9639 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
9640 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
9642 test_elem_innertext(body
, "replaced");
9644 IHTMLDOMNode_Release(node2
);
9645 IHTMLDOMNode_Release(node3
);
9646 IHTMLDOMNode_Release(nodeBody
);
9648 IHTMLElement_Release(body
);
9651 static void test_noscript(IHTMLDocument2
*doc
)
9653 IHTMLElementCollection
*col
;
9657 static const elem_type_t all_types
[] = {
9666 static const elem_type_t body_all_types
[] = {
9671 hres
= IHTMLDocument2_get_all(doc
, &col
);
9672 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9673 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
9674 IHTMLElementCollection_Release(col
);
9676 body
= doc_get_body(doc
);
9677 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
9678 test_elem_all((IUnknown
*)body
, body_all_types
, ARRAY_SIZE(body_all_types
));
9679 IHTMLElement_Release(body
);
9682 static void test_doctype(IHTMLDocument2
*doc
)
9684 IHTMLDocument2
*doc_node
;
9685 IHTMLDOMNode
*doctype
;
9688 doc_node
= get_doc_node(doc
);
9689 doctype
= get_first_child((IUnknown
*)doc_node
);
9690 IHTMLDocument2_Release(doc_node
);
9692 type
= get_node_type((IUnknown
*)doctype
);
9693 ok(type
== 8, "type = %d\n", type
);
9695 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9696 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9697 IHTMLDOMNode_Release(doctype
);
9700 static void test_null_write(IHTMLDocument2
*doc
)
9704 doc_write(doc
, FALSE
, NULL
);
9705 doc_write(doc
, TRUE
, NULL
);
9707 hres
= IHTMLDocument2_write(doc
, NULL
);
9709 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9711 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9713 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9716 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9718 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9719 IHTMLStyleElement
*style_elem
;
9720 IHTMLElement
*doc_elem
, *elem
;
9723 static const elem_type_t all_types
[] = {
9731 static const elem_type_t all_types2
[] = {
9740 test_doc_all(doc
, all_types
, ARRAY_SIZE(all_types
));
9742 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9743 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9745 test_doc_all(doc
, all_types2
, ARRAY_SIZE(all_types2
));
9747 doc_elem
= get_doc_elem(doc
);
9749 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9750 IHTMLElement_Release(doc_elem
);
9752 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9753 IHTMLElement_Release(elem
);
9754 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9757 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9758 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9759 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9760 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9762 IHTMLStyleSheet_Release(stylesheet2
);
9763 IHTMLStyleSheet_Release(stylesheet
);
9765 IHTMLStyleElement_Release(style_elem
);
9768 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9770 IOleCommandTarget
*cmdtrg
;
9773 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9774 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9776 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9777 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9779 IOleCommandTarget_Release(cmdtrg
);
9782 static void test_indent(IHTMLDocument2
*doc
)
9784 IHTMLElementCollection
*col
;
9785 IHTMLTxtRange
*range
;
9788 static const elem_type_t all_types
[] = {
9797 static const elem_type_t indent_types
[] = {
9808 hres
= IHTMLDocument2_get_all(doc
, &col
);
9809 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9810 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
9811 IHTMLElementCollection_Release(col
);
9813 range
= test_create_body_range(doc
);
9814 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9815 IHTMLTxtRange_Release(range
);
9817 hres
= IHTMLDocument2_get_all(doc
, &col
);
9818 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9819 test_elem_collection((IUnknown
*)col
, indent_types
, ARRAY_SIZE(indent_types
));
9820 IHTMLElementCollection_Release(col
);
9823 static void test_cond_comment(IHTMLDocument2
*doc
)
9825 IHTMLElementCollection
*col
;
9828 static const elem_type_t all_types
[] = {
9836 hres
= IHTMLDocument2_get_all(doc
, &col
);
9837 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9838 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
9839 IHTMLElementCollection_Release(col
);
9842 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9844 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9845 return E_NOINTERFACE
;
9848 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9853 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9858 static const IUnknownVtbl UnknownVtbl
= {
9859 Unknown_QueryInterface
,
9863 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9865 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9867 IHTMLWindow2
*frame2
, *parent
, *top
;
9868 IHTMLDocument2
*parent_doc
, *top_doc
;
9869 IHTMLWindow4
*frame
;
9870 IHTMLFrameBase
*frame_elem
;
9871 IObjectIdentity
*obj_ident
;
9872 ITravelLogClient
*tlc
;
9875 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9876 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9880 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9881 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9882 IHTMLWindow4_Release(frame
);
9886 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9887 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9888 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9889 IHTMLFrameBase_Release(frame_elem
);
9891 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9892 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9896 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9897 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9899 IHTMLWindow2_Release(frame2
);
9903 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9904 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9905 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9906 if(hres
== E_NOINTERFACE
) {
9907 win_skip("IID_ITravelLogClient not available\n");
9910 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9912 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9913 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9914 ITravelLogClient_Release(tlc
);
9917 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9918 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9919 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9920 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9921 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9922 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9924 IObjectIdentity_Release(obj_ident
);
9926 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9927 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9928 IHTMLWindow2_Release(parent
);
9930 IHTMLWindow2_Release(frame2
);
9934 test_doc_title(parent_doc
, "frameset test");
9935 IHTMLDocument2_Release(parent_doc
);
9938 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9939 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9940 IHTMLWindow2_Release(frame2
);
9944 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9945 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9946 IHTMLWindow2_Release(top
);
9950 test_doc_title(top_doc
, "frameset test");
9951 IHTMLDocument2_Release(top_doc
);
9954 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9956 VARIANT index_var
, result_var
;
9960 /* test result length */
9961 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9962 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9963 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9965 /* test first frame */
9966 V_VT(&index_var
) = VT_I4
;
9967 V_I4(&index_var
) = 0;
9968 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9969 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9970 if(SUCCEEDED(hres
)) {
9971 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9972 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9974 VariantClear(&result_var
);
9976 /* test second frame */
9977 V_I4(&index_var
) = 1;
9978 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9979 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9980 if(SUCCEEDED(hres
)) {
9981 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9982 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9984 VariantClear(&result_var
);
9986 /* fail on next frame */
9987 V_I4(&index_var
) = 3;
9988 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9989 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9990 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9991 VariantClear(&result_var
);
9993 /* string argument (element id lookup) */
9994 V_VT(&index_var
) = VT_BSTR
;
9995 V_BSTR(&index_var
) = a2bstr(frid
);
9996 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9997 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9998 if(SUCCEEDED(hres
)) {
9999 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
10000 test_frame(V_DISPATCH(&result_var
), frid
);
10002 VariantClear(&result_var
);
10003 VariantClear(&index_var
);
10005 /* invalid argument */
10006 V_VT(&index_var
) = VT_BOOL
;
10007 V_BOOL(&index_var
) = VARIANT_TRUE
;
10008 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10009 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
10010 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
10011 VariantClear(&result_var
);
10014 static void test_frameset(IHTMLDocument2
*doc
)
10016 IHTMLWindow2
*window
;
10017 IHTMLFramesCollection2
*frames
;
10018 IHTMLDocument6
*doc6
;
10019 IHTMLElement
*elem
;
10022 window
= get_doc_window(doc
);
10024 /* test using IHTMLFramesCollection object */
10026 hres
= IHTMLWindow2_get_frames(window
, &frames
);
10027 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
10031 test_frames_collection(frames
, "fr1");
10032 IHTMLFramesCollection2_Release(frames
);
10034 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
10035 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
10039 test_frames_collection(frames
, "fr1");
10040 IHTMLFramesCollection2_Release(frames
);
10042 /* test using IHTMLWindow2 inheritance */
10043 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
10045 /* getElementById with node name attributes */
10046 elem
= get_doc_elem_by_id(doc
, "nm1");
10047 test_elem_id((IUnknown
*)elem
, "fr1");
10049 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
10050 if(SUCCEEDED(hres
)) {
10051 IHTMLElement2
*elem2
;
10054 str
= a2bstr("nm1");
10055 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
10056 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
10057 ok(!elem2
, "elem = %p\n", elem2
);
10058 SysFreeString(str
);
10060 str
= a2bstr("fr1");
10061 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
10062 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
10063 ok(elem2
!= NULL
, "elem2 is NULL\n");
10064 test_elem_id((IUnknown
*)elem2
, "fr1");
10065 SysFreeString(str
);
10067 IHTMLDocument6_Release(doc6
);
10069 win_skip("IHTMLDocument6 not supported\n");
10072 test_framebase((IUnknown
*)elem
);
10073 test_framebase_name(elem
, "nm1");
10074 test_framebase_put_name(elem
, "frame name");
10075 test_framebase_put_name(elem
, NULL
);
10076 test_framebase_put_name(elem
, "nm1");
10077 test_framebase_src(elem
, "about:blank");
10078 IHTMLElement_Release(elem
);
10080 /* get_name with no name attr */
10081 elem
= get_doc_elem_by_id(doc
, "fr3");
10082 test_framebase_name(elem
, NULL
);
10083 test_framebase_put_name(elem
, "frame name");
10084 test_framebase_put_name(elem
, NULL
);
10085 IHTMLElement_Release(elem
);
10087 IHTMLWindow2_Release(window
);
10090 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
10092 IHTMLDocument2
*frag
;
10093 IHTMLDocument3
*doc3
;
10096 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
10097 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
10099 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
10100 IHTMLDocument3_Release(doc3
);
10101 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
10102 ok(frag
!= NULL
, "frag == NULL\n");
10107 static void test_docfrag(IHTMLDocument2
*doc
)
10109 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
10110 IHTMLElement
*div
, *body
, *br
;
10111 IHTMLElementCollection
*col
;
10112 IHTMLLocation
*location
;
10115 static const elem_type_t all_types
[] = {
10124 frag
= create_docfrag(doc
);
10126 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
10128 body
= (void*)0xdeadbeef;
10129 hres
= IHTMLDocument2_get_body(frag
, &body
);
10130 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
10131 ok(!body
, "body != NULL\n");
10133 location
= (void*)0xdeadbeef;
10134 hres
= IHTMLDocument2_get_location(frag
, &location
);
10135 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
10136 ok(location
== (void*)0xdeadbeef, "location changed\n");
10138 br
= test_create_elem(doc
, "BR");
10139 test_elem_source_index(br
, -1);
10140 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
10141 test_elem_source_index(br
, 0);
10142 IHTMLElement_Release(br
);
10144 test_doc_getelembytag(frag
, "a", ET_A
, 0);
10145 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
10147 div
= get_elem_by_id(doc
, "divid", TRUE
);
10148 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
10149 IHTMLElement_Release(div
);
10151 hres
= IHTMLDocument2_get_all(doc
, &col
);
10152 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
10153 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
10154 IHTMLElementCollection_Release(col
);
10156 div
= test_create_elem(frag
, "div");
10157 owner_doc
= get_owner_doc((IUnknown
*)div
);
10158 doc_node
= get_doc_node(doc
);
10159 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
10160 IHTMLDocument2_Release(doc_node
);
10161 IHTMLDocument2_Release(owner_doc
);
10162 IHTMLElement_Release(div
);
10164 IHTMLDocument2_Release(frag
);
10167 static void check_quirks_mode(IHTMLDocument2
*doc
)
10169 test_compatmode(doc
, "BackCompat");
10172 static void check_strict_mode(IHTMLDocument2
*doc
)
10174 test_compatmode(doc
, "CSS1Compat");
10177 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
10179 IHTMLElement
*elem
;
10183 hres
= IHTMLDocument2_get_body(doc
, &elem
);
10184 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
10186 /* body.offsetHeight value depends on window size in quirks mode */
10187 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
10188 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
10189 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
10190 IHTMLElement_Release(elem
);
10193 static IHTMLDocument2
*notif_doc
;
10194 static BOOL doc_complete
;
10196 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
10197 REFIID riid
, void**ppv
)
10199 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
10204 ok(0, "unexpected call\n");
10205 return E_NOINTERFACE
;
10208 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
10213 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
10218 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
10220 if(dispID
== DISPID_READYSTATE
){
10224 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
10225 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
10227 if(!strcmp_wa(state
, "complete"))
10228 doc_complete
= TRUE
;
10230 SysFreeString(state
);
10236 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
10238 ok(0, "unexpected call\n");
10242 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
10243 PropertyNotifySink_QueryInterface
,
10244 PropertyNotifySink_AddRef
,
10245 PropertyNotifySink_Release
,
10246 PropertyNotifySink_OnChanged
,
10247 PropertyNotifySink_OnRequestEdit
10250 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
10252 static HRESULT
cs_qi(REFIID
,void **);
10253 static IOleDocumentView
*view
;
10254 static HWND container_hwnd
;
10256 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
10258 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
10260 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
10261 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
10264 return E_NOINTERFACE
;
10267 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
10272 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
10277 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
10282 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
10287 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
10292 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
10293 LPCBORDERWIDTHS pborderwidths
)
10298 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
10299 LPCBORDERWIDTHS pborderwidths
)
10304 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
10305 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
10310 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10311 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
10316 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10317 HOLEMENU holemenu
, HWND hwndActiveObject
)
10319 ok(0, "unexpected call\n");
10323 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
10325 ok(0, "unexpected call\n");
10329 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
10334 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
10339 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
10341 ok(0, "unexpected call\n");
10345 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
10346 InPlaceFrame_QueryInterface
,
10347 InPlaceFrame_AddRef
,
10348 InPlaceFrame_Release
,
10349 InPlaceFrame_GetWindow
,
10350 InPlaceFrame_ContextSensitiveHelp
,
10351 InPlaceFrame_GetBorder
,
10352 InPlaceFrame_RequestBorderSpace
,
10353 InPlaceFrame_SetBorderSpace
,
10354 InPlaceFrame_SetActiveObject
,
10355 InPlaceFrame_InsertMenus
,
10356 InPlaceFrame_SetMenu
,
10357 InPlaceFrame_RemoveMenus
,
10358 InPlaceFrame_SetStatusText
,
10359 InPlaceFrame_EnableModeless
,
10360 InPlaceFrame_TranslateAccelerator
10363 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
10365 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
10367 return cs_qi(riid
, ppv
);
10370 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
10375 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
10380 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
10382 *phwnd
= container_hwnd
;
10386 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
10388 ok(0, "unexpected call\n");
10392 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
10397 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
10402 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
10407 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
10408 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
10409 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
10411 static const RECT rect
= {0,0,500,500};
10413 *ppFrame
= &InPlaceFrame
;
10415 *lprcPosRect
= rect
;
10416 *lprcClipRect
= rect
;
10418 lpFrameInfo
->fMDIApp
= FALSE
;
10419 lpFrameInfo
->hwndFrame
= container_hwnd
;
10420 lpFrameInfo
->haccel
= NULL
;
10421 lpFrameInfo
->cAccelEntries
= 0;
10426 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
10431 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
10436 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
10441 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
10446 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
10451 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
10456 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
10457 InPlaceSite_QueryInterface
,
10458 InPlaceSite_AddRef
,
10459 InPlaceSite_Release
,
10460 InPlaceSite_GetWindow
,
10461 InPlaceSite_ContextSensitiveHelp
,
10462 InPlaceSite_CanInPlaceActivate
,
10463 InPlaceSite_OnInPlaceActivate
,
10464 InPlaceSite_OnUIActivate
,
10465 InPlaceSite_GetWindowContext
,
10466 InPlaceSite_Scroll
,
10467 InPlaceSite_OnUIDeactivate
,
10468 InPlaceSite_OnInPlaceDeactivate
,
10469 InPlaceSite_DiscardUndoState
,
10470 InPlaceSite_DeactivateAndUndo
,
10471 InPlaceSite_OnPosRectChange
,
10474 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
10476 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
10478 return cs_qi(riid
, ppv
);
10481 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
10486 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
10491 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
10493 ok(0, "unexpected call\n");
10497 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
10500 ok(0, "unexpected call\n");
10504 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
10509 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
10511 ok(0, "unexpected call\n");
10515 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
10517 ok(0, "unexpected call\n");
10521 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
10523 ok(0, "unexpected call\n");
10527 static const IOleClientSiteVtbl ClientSiteVtbl
= {
10528 ClientSite_QueryInterface
,
10530 ClientSite_Release
,
10531 ClientSite_SaveObject
,
10532 ClientSite_GetMoniker
,
10533 ClientSite_GetContainer
,
10534 ClientSite_ShowObject
,
10535 ClientSite_OnShowWindow
,
10536 ClientSite_RequestNewObjectLayout
10539 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
10541 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
10543 return cs_qi(riid
, ppv
);
10546 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
10551 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
10556 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
10558 RECT rect
= {0,0,500,500};
10559 IOleDocument
*document
;
10562 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
10563 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
10565 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
10566 IOleDocument_Release(document
);
10567 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
10569 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
10570 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
10572 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
10573 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
10575 hres
= IOleDocumentView_SetRect(view
, &rect
);
10576 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
10578 hres
= IOleDocumentView_Show(view
, TRUE
);
10579 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
10584 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
10585 DocumentSite_QueryInterface
,
10586 DocumentSite_AddRef
,
10587 DocumentSite_Release
,
10588 DocumentSite_ActivateMe
10591 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
10593 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
10597 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
10598 *ppv
= &ClientSite
;
10599 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
10600 *ppv
= &DocumentSite
;
10601 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
10602 *ppv
= &InPlaceSite
;
10604 return *ppv
? S_OK
: E_NOINTERFACE
;
10607 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
10609 IOleObject
*oleobj
;
10613 IOleDocumentView_Show(view
, FALSE
);
10614 IOleDocumentView_CloseView(view
, 0);
10615 IOleDocumentView_SetInPlaceSite(view
, NULL
);
10616 IOleDocumentView_Release(view
);
10620 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
10621 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
10623 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
10624 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
10627 IHlinkTarget
*hlink
;
10629 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
10630 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
10632 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
10633 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
10635 IHlinkTarget_Release(hlink
);
10638 IOleObject_Release(oleobj
);
10641 static IHTMLDocument2
*create_doc_with_string(const char *str
)
10643 IPersistStreamInit
*init
;
10645 IHTMLDocument2
*doc
;
10650 notif_doc
= doc
= create_document();
10654 doc_complete
= FALSE
;
10656 mem
= GlobalAlloc(0, len
);
10657 memcpy(mem
, str
, len
);
10658 hr
= CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
10659 ok(hr
== S_OK
, "Failed to create a stream, hr %#x.\n", hr
);
10661 hr
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
10662 ok(hr
== S_OK
, "Failed to get IPersistStreamInit, hr %#x.\n", hr
);
10664 IPersistStreamInit_Load(init
, stream
);
10665 IPersistStreamInit_Release(init
);
10666 IStream_Release(stream
);
10671 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
10673 IConnectionPointContainer
*container
;
10674 IConnectionPoint
*cp
;
10678 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
10679 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
10681 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
10682 IConnectionPointContainer_Release(container
);
10683 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
10685 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
10686 IConnectionPoint_Release(cp
);
10687 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
10690 typedef void (*domtest_t
)(IHTMLDocument2
*);
10692 static void run_domtest(const char *str
, domtest_t test
)
10694 IHTMLDocument2
*doc
;
10698 doc
= create_doc_with_string(str
);
10702 set_client_site(doc
, TRUE
);
10703 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
10705 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
10706 TranslateMessage(&msg
);
10707 DispatchMessageW(&msg
);
10712 set_client_site(doc
, FALSE
);
10713 ref
= IHTMLDocument2_Release(doc
);
10714 ok(!ref
|| broken(ref
== 1), /* Vista */
10715 "ref = %d\n", ref
);
10718 static float expected_document_mode
;
10720 static void test_document_mode(IHTMLDocument2
*doc2
)
10722 IEventTarget
*event_target
;
10723 IHTMLDocument2
*doc_node
;
10724 IHTMLDocument6
*doc
;
10725 IHTMLElement
*body
;
10729 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument6
, (void**)&doc
);
10730 if(hres
== E_NOINTERFACE
) {
10731 win_skip("IHTMLDocument6 not supported\n");
10734 ok(hres
== S_OK
, "Could not get IHTMLDocument6 interface: %08x\n", hres
);
10736 V_VT(&v
) = VT_EMPTY
;
10737 hres
= IHTMLDocument6_get_documentMode(doc
, &v
);
10738 ok(hres
== S_OK
, "get_documentMode failed: %08x\n", hres
);
10739 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
10740 ok(V_R4(&v
) == expected_document_mode
, "documentMode = %f\n", V_R4(&v
));
10741 IHTMLDocument6_Release(doc
);
10743 doc_node
= get_doc_node(doc2
);
10745 hres
= IHTMLDocument2_QueryInterface(doc_node
, &IID_IEventTarget
, (void**)&event_target
);
10746 if(expected_document_mode
>= 9) {
10747 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10748 IEventTarget_Release(event_target
);
10750 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10753 IHTMLDocument2_Release(doc_node
);
10756 body
= doc_get_body(doc2
);
10758 hres
= IHTMLElement_QueryInterface(body
, &IID_IEventTarget
, (void**)&event_target
);
10759 if(expected_document_mode
>= 9) {
10760 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10761 IEventTarget_Release(event_target
);
10763 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10766 IHTMLElement_Release(body
);
10769 static void test_quirks_mode(void)
10771 run_domtest("<html></html>", check_quirks_mode
);
10772 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10773 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10774 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10776 expected_document_mode
= 5;
10777 run_domtest("<html><body></body></html>", test_document_mode
);
10782 expected_document_mode
= 9;
10783 run_domtest("<!DOCTYPE html>\n"
10786 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10790 "</html>", test_document_mode
);
10792 expected_document_mode
= 8;
10793 run_domtest("<!DOCTYPE html>\n"
10796 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
10797 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10801 "</html>", test_document_mode
);
10804 static void check_ie(void)
10806 IHTMLDocument2
*doc
;
10807 IHTMLDocument7
*doc7
;
10810 doc
= create_document();
10814 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
10815 if(SUCCEEDED(hres
)) {
10817 IHTMLDocument7_Release(doc7
);
10820 trace("is_ie9plus %x\n", is_ie9plus
);
10822 IHTMLDocument2_Release(doc
);
10827 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10828 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10829 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10831 CoInitialize(NULL
);
10832 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10833 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10837 run_domtest(doc_str1
, test_doc_elem
);
10838 run_domtest(doc_str1
, test_get_set_attr
);
10839 run_domtest(range_test_str
, test_txtrange
);
10840 run_domtest(range_test2_str
, test_txtrange2
);
10841 if (winetest_interactive
|| ! is_ie_hardened()) {
10842 run_domtest(elem_test_str
, test_elems
);
10843 run_domtest(elem_test2_str
, test_elems2
);
10844 run_domtest(doc_blank
, test_dom_elements
);
10846 compat_mode
= COMPAT_IE9
;
10847 run_domtest(doc_blank_ie9
, test_dom_elements
);
10848 compat_mode
= COMPAT_NONE
;
10850 run_domtest(noscript_str
, test_noscript
);
10852 skip("IE running in Enhanced Security Configuration\n");
10854 run_domtest(doc_blank
, test_create_elems
);
10855 run_domtest(doc_blank
, test_defaults
);
10856 run_domtest(doc_blank
, test_null_write
);
10857 run_domtest(emptydiv_str
, test_create_stylesheet
);
10858 run_domtest(indent_test_str
, test_indent
);
10859 run_domtest(cond_comment_str
, test_cond_comment
);
10860 run_domtest(frameset_str
, test_frameset
);
10861 run_domtest(emptydiv_str
, test_docfrag
);
10862 run_domtest(doc_blank
, test_replacechild_elems
);
10863 run_domtest(doctype_str
, test_doctype
);
10865 test_quirks_mode();
10867 DestroyWindow(container_hwnd
);