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
;
46 static const char doc_blank
[] = "<html></html>";
47 static const char doc_str1
[] = "<html><body>test</body></html>";
48 static const char range_test_str
[] =
49 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
50 static const char range_test2_str
[] =
51 "<html><body>abc<hr />123<br /><hr />def</body></html>";
52 static const char elem_test_str
[] =
53 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
54 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
55 "<link id=\"linkid\"></head>"
56 "<body onload=\"Testing()\">text test<!-- a comment -->"
57 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
58 "<label for=\"in\" id=\"labelid\">Label:</label>"
59 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
60 "<button id=\"btnid\" type=\"submit\"></button>"
61 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
62 "<textarea id=\"X\">text text</textarea>"
63 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
64 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
65 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
66 "<img id=\"imgid\" name=\"WineImg\"/>"
67 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
68 "<form id=\"frm\"></form>"
69 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
71 static const char elem_test2_str
[] =
72 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
73 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
74 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
77 static const char indent_test_str
[] =
78 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
79 static const char cond_comment_str
[] =
80 "<html><head><title>test</title></head><body>"
81 "<!--[if gte IE 4]> <br> <![endif]-->"
83 static const char frameset_str
[] =
84 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
85 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
86 "<frame src=\"about:blank\" id=\"fr3\">"
88 static const char emptydiv_str
[] =
89 "<html><head><title>emptydiv test</title></head>"
90 "<body><div id=\"divid\"></div></body></html>";
91 static const char noscript_str
[] =
92 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
93 "<body><noscript><div>test</div></noscript></body></html>";
94 static const char doctype_str
[] =
96 "<html><head><title>emptydiv test</title></head>"
97 "<body><div id=\"divid\"></div></body></html>";
99 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
100 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
101 static WCHAR wordW
[] = {'w','o','r','d',0};
141 static const IID
* const none_iids
[] = {
146 static const IID
* const doc_node_iids
[] = {
154 &IID_IDocumentSelector
,
156 &IID_IConnectionPointContainer
,
157 &IID_IInternetHostSecurityManager
,
160 &IID_IProvideClassInfo
,
164 static const IID
* const doc_obj_iids
[] = {
170 &IID_IDocumentSelector
,
172 &IID_IConnectionPointContainer
,
176 &IID_IProvideClassInfo
,
177 &IID_ITargetContainer
,
181 #define ELEM_IFACES \
183 &IID_IHTMLDOMNode2, \
185 &IID_IHTMLElement2, \
186 &IID_IHTMLElement3, \
187 &IID_IHTMLElement4, \
188 &IID_IHTMLUniqueName, \
191 static const IID
* const elem_iids
[] = {
193 &IID_IConnectionPointContainer
,
197 static const IID
* const body_iids
[] = {
199 &IID_IHTMLTextContainer
,
200 &IID_IHTMLBodyElement
,
201 &IID_IConnectionPointContainer
,
205 static const IID
* const anchor_iids
[] = {
207 &IID_IHTMLAnchorElement
,
208 &IID_IConnectionPointContainer
,
212 static const IID
* const input_iids
[] = {
214 &IID_IHTMLInputElement
,
215 &IID_IHTMLInputTextElement
,
216 &IID_IConnectionPointContainer
,
220 static const IID
*const button_iids
[] = {
222 &IID_IHTMLButtonElement
,
223 &IID_IConnectionPointContainer
,
227 static const IID
*const area_iids
[] = {
229 &IID_IHTMLAreaElement
,
230 &IID_IConnectionPointContainer
,
234 static const IID
* const label_iids
[] = {
236 &IID_IHTMLLabelElement
,
237 &IID_IConnectionPointContainer
,
241 static const IID
* const select_iids
[] = {
243 &IID_IHTMLSelectElement
,
244 &IID_IConnectionPointContainer
,
248 static const IID
* const textarea_iids
[] = {
250 &IID_IHTMLTextAreaElement
,
251 &IID_IConnectionPointContainer
,
255 static const IID
* const option_iids
[] = {
257 &IID_IHTMLOptionElement
,
258 &IID_IConnectionPointContainer
,
262 static const IID
* const table_iids
[] = {
267 &IID_IConnectionPointContainer
,
271 static const IID
* const script_iids
[] = {
273 &IID_IHTMLScriptElement
,
274 &IID_IConnectionPointContainer
,
278 static const IID
* const text_iids
[] = {
281 &IID_IHTMLDOMTextNode
,
282 &IID_IHTMLDOMTextNode2
,
286 static const IID
* const attr_iids
[] = {
287 &IID_IHTMLDOMAttribute
,
288 &IID_IHTMLDOMAttribute2
,
293 static const IID
* const location_iids
[] = {
299 static const IID
* const window_iids
[] = {
304 &IID_IServiceProvider
,
308 static const IID
* const comment_iids
[] = {
310 &IID_IHTMLCommentElement
,
311 &IID_IConnectionPointContainer
,
315 static const IID
* const img_iids
[] = {
317 &IID_IHTMLImgElement
,
318 &IID_IConnectionPointContainer
,
322 static const IID
* const tr_iids
[] = {
325 &IID_IConnectionPointContainer
,
329 static const IID
* const td_iids
[] = {
332 &IID_IConnectionPointContainer
,
336 static const IID
* const frame_iids
[] = {
339 &IID_IHTMLFrameBase2
,
340 &IID_IConnectionPointContainer
,
344 static const IID
* const html_iids
[] = {
346 &IID_IHTMLHtmlElement
,
347 &IID_IConnectionPointContainer
,
351 static const IID
* const head_iids
[] = {
353 &IID_IHTMLHeadElement
,
354 &IID_IConnectionPointContainer
,
358 static const IID
* const title_iids
[] = {
360 &IID_IHTMLTitleElement
,
361 &IID_IConnectionPointContainer
,
365 static const IID
* const meta_iids
[] = {
367 &IID_IHTMLMetaElement
,
368 &IID_IConnectionPointContainer
,
372 static const IID
* const link_iids
[] = {
374 &IID_IHTMLLinkElement
,
375 &IID_IConnectionPointContainer
,
379 static const IID
* const object_iids
[] = {
381 &IID_IHTMLObjectElement
,
382 &IID_IHTMLObjectElement2
,
383 /* FIXME: No IConnectionPointContainer */
387 static const IID
* const embed_iids
[] = {
389 &IID_IHTMLEmbedElement
,
390 /* FIXME: No IConnectionPointContainer */
394 static const IID
* const iframe_iids
[] = {
397 &IID_IHTMLFrameBase2
,
398 &IID_IHTMLIFrameElement
,
399 &IID_IHTMLIFrameElement2
,
400 &IID_IConnectionPointContainer
,
404 static const IID
* const form_iids
[] = {
406 &IID_IHTMLFormElement
,
407 &IID_IConnectionPointContainer
,
408 &DIID_DispHTMLFormElement
,
412 static const IID
* const styleelem_iids
[] = {
414 &IID_IHTMLStyleElement
,
415 &IID_IConnectionPointContainer
,
419 static const IID
* const generic_iids
[] = {
421 &IID_IHTMLGenericElement
,
422 &IID_IConnectionPointContainer
,
426 static const IID
* const style_iids
[] = {
437 static const IID
* const cstyle_iids
[] = {
441 &IID_IHTMLCurrentStyle
,
442 &IID_IHTMLCurrentStyle2
,
443 &IID_IHTMLCurrentStyle3
,
447 static const IID
* const img_factory_iids
[] = {
451 &IID_IHTMLImageElementFactory
,
455 static const IID
* const selection_iids
[] = {
459 &IID_IHTMLSelectionObject
,
460 &IID_IHTMLSelectionObject2
,
471 static const elem_type_info_t elem_type_infos
[] = {
472 {"", none_iids
, NULL
},
473 {"HTML", html_iids
, &DIID_DispHTMLHtmlElement
, &CLSID_HTMLHtmlElement
},
474 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
, &CLSID_HTMLHeadElement
},
475 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
, &CLSID_HTMLTitleElement
},
476 {"BODY", body_iids
, &DIID_DispHTMLBody
, &CLSID_HTMLBody
},
477 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
, &CLSID_HTMLAnchorElement
},
478 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
},
479 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
, &CLSID_HTMLSelectElement
},
480 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
, &CLSID_HTMLTextAreaElement
},
481 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
},
482 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
, &CLSID_HTMLStyleElement
},
483 {"BLOCKQUOTE",elem_iids
, NULL
},
484 {"P", elem_iids
, NULL
},
485 {"BR", elem_iids
, NULL
},
486 {"TABLE", table_iids
, &DIID_DispHTMLTable
, &CLSID_HTMLTable
},
487 {"TBODY", elem_iids
, NULL
},
488 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
, &CLSID_HTMLScriptElement
},
489 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
, &CLSID_HTMLUnknownElement
},
490 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
},
491 {"!", comment_iids
, &DIID_DispHTMLCommentElement
, &CLSID_HTMLCommentElement
},
492 {"IMG", img_iids
, &DIID_DispHTMLImg
, &CLSID_HTMLImg
},
493 {"TR", tr_iids
, &DIID_DispHTMLTableRow
, &CLSID_HTMLTableRow
},
494 {"TD", td_iids
, &DIID_DispHTMLTableCell
, &CLSID_HTMLTableCell
},
495 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
, &CLSID_HTMLIFrame
},
496 {"FORM", form_iids
, &DIID_DispHTMLFormElement
, &CLSID_HTMLFormElement
},
497 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
, &CLSID_HTMLFrameElement
},
498 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
, &CLSID_HTMLObjectElement
},
499 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
, &CLSID_HTMLEmbed
},
500 {"DIV", elem_iids
, NULL
},
501 {"META", meta_iids
, &DIID_DispHTMLMetaElement
, &CLSID_HTMLMetaElement
},
502 {"NOSCRIPT", elem_iids
, /* &DIID_DispHTMLNoShowElement */},
503 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
, &CLSID_HTMLLinkElement
},
504 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
, &CLSID_HTMLLabelElement
},
505 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
, &CLSID_HTMLButtonElement
},
506 {"AREA", area_iids
, &DIID_DispHTMLAreaElement
, &CLSID_HTMLAreaElement
}
509 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
512 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
513 return lstrcmpA(stra
, buf
);
516 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
521 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
522 prefix_len
= lstrlenA(prefix
);
527 return !lstrcmpA(buf
, prefix
);
530 static BSTR
a2bstr(const char *str
)
538 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
539 ret
= SysAllocStringLen(NULL
, len
);
540 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
545 static const char *debugstr_variant(const VARIANT
*var
)
547 static char buf
[400];
557 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
560 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
563 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
566 sprintf(buf
, "{vt %d}", V_VT(var
));
573 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
575 IUnknown
*unk1
, *unk2
;
580 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
581 IUnknown_Release(unk1
);
582 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
583 IUnknown_Release(unk2
);
588 static IHTMLDocument2
*create_document(void)
591 IHTMLDocument5
*doc5
;
594 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
595 &IID_IHTMLDocument2
, (void**)&doc
);
596 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
600 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
602 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
603 IHTMLDocument2_Release(doc
);
607 IHTMLDocument5_Release(doc5
);
611 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
612 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
617 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
618 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
622 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
623 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
625 const IID
* const *piid
;
629 for(piid
= iids
; *piid
; piid
++) {
630 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
631 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
633 IUnknown_Release(unk
);
637 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
638 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
643 unk
= (void*)0xdeadbeef;
644 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
645 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
646 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
649 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
650 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
652 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
659 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
660 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
661 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
663 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
664 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
666 if(SUCCEEDED(hres
)) {
669 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
670 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
672 *iid
= type_attr
->guid
;
676 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
677 ITypeInfo_Release(typeinfo
);
680 IDispatchEx_Release(dispex
);
684 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
685 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
687 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
688 DISPPARAMS dp
= {NULL
,NULL
,0,0};
693 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
694 IDispatchEx_Release(dispex
);
695 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
697 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
698 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
702 #define test_class_info(a,b) _test_class_info(__LINE__,a,b)
703 static void _test_class_info(unsigned line
, IUnknown
*unk
, const CLSID
*clsid
)
705 IProvideMultipleClassInfo
*multiple_classinfo
;
706 IProvideClassInfo2
*classinfo
;
712 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
713 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
717 hres
= IProvideClassInfo2_GetClassInfo(classinfo
, &typeinfo
);
718 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
721 IProvideClassInfo2_Release(classinfo
);
725 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
726 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
729 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, clsid
),
730 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
731 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
732 "unexpected typekind %d\n", type_attr
->typekind
);
733 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
736 ITypeInfo_Release(typeinfo
);
737 IProvideClassInfo2_Release(classinfo
);
739 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideMultipleClassInfo
, (void**)&multiple_classinfo
);
740 if(IsEqualGUID(clsid
, &CLSID_HTMLXMLHttpRequest
)) {
741 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
743 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
745 hres
= IProvideMultipleClassInfo_GetMultiTypeInfoCount(multiple_classinfo
, &count
);
746 ok_(__FILE__
,line
)(hres
== S_OK
, "GetMultiTypeInfoCount failed: %08x\n", hres
);
747 ok_(__FILE__
,line
)(count
> 0, "count = %u\n", count
);
749 IProvideMultipleClassInfo_Release(multiple_classinfo
);
753 #define test_disp2(a,b,c,d,e) _test_disp2(__LINE__,a,b,c,d,e)
754 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const CLSID
*clsid
, const char *val
)
760 if(_test_get_dispid(line
, unk
, &iid
))
761 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(diid2
&& IsEqualGUID(&iid
, diid2
)),
762 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
764 if(!IsEqualGUID(diid
, &DIID_DispHTMLWindow2
) && !IsEqualGUID(diid
, &DIID_DispHTMLLocation
)) {
765 u
= (void*)0xdeadbeef;
766 hres
= IUnknown_QueryInterface(unk
, &IID_IMarshal
, (void**)&u
);
767 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IMarshal iface\n");
768 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
771 u
= (void*)0xdeadbeef;
772 hres
= IUnknown_QueryInterface(unk
, &IID_IManagedObject
, (void**)&u
);
773 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IManagedObject iface\n");
774 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
777 _test_disp_value(line
, unk
, val
);
780 _test_class_info(line
, unk
, clsid
);
782 u
= (void*)0xdeadbeef;
783 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&u
);
784 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IProvideClassInfo iface\n");
785 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
789 #define test_disp(a,b,c,d) _test_disp(__LINE__,a,b,c,d)
790 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const CLSID
*clsid
, const char *val
)
792 return _test_disp2(line
, unk
, diid
, NULL
, clsid
, val
);
795 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
796 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
798 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
799 DISPPARAMS dp
= {val
, NULL
, 1, 0};
806 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
808 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
810 memset(&ei
, 0, sizeof(ei
));
811 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
812 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
816 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
817 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
822 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
823 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
827 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
828 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
833 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
834 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
838 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
839 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
844 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
845 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
849 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
850 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
855 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
856 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
860 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
861 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
863 IHTMLDocument3
*doc3
;
866 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
867 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
872 #define get_node_iface(u) _get_node_iface(__LINE__,u)
873 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
878 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
879 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
883 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
884 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
889 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
890 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
894 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
895 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
900 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
901 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
905 #define get_img_iface(u) _get_img_iface(__LINE__,u)
906 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
908 IHTMLImgElement
*img
;
911 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
916 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
917 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
919 IHTMLAnchorElement
*anchor
;
922 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
927 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
928 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
930 IHTMLTextAreaElement
*textarea
;
933 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
934 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
938 #define get_select_iface(u) _get_select_iface(__LINE__,u)
939 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
941 IHTMLSelectElement
*select
;
944 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
945 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
949 #define get_option_iface(u) _get_option_iface(__LINE__,u)
950 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
952 IHTMLOptionElement
*option
;
955 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
956 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
960 #define get_form_iface(u) _get_form_iface(__LINE__,u)
961 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
963 IHTMLFormElement
*form
;
966 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
967 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
971 #define get_text_iface(u) _get_text_iface(__LINE__,u)
972 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
974 IHTMLDOMTextNode
*text
;
977 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
978 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
982 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
983 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
985 IHTMLDOMTextNode2
*text2
;
988 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
989 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
993 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
994 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
996 IHTMLCommentElement
*comment
;
999 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
1000 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
1004 #define get_object_iface(u) _get_object_iface(__LINE__,u)
1005 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
1007 IHTMLObjectElement
*obj
;
1010 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
1011 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
1015 #define get_style_iface(u) _get_style_iface(__LINE__,u)
1016 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
1018 IHTMLStyleElement
*obj
;
1021 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
1022 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
1026 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
1027 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
1029 IHTMLMetaElement
*ret
;
1032 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
1033 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
1037 #define get_link_iface(u) _get_link_iface(__LINE__,u)
1038 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
1040 IHTMLLinkElement
*ret
;
1043 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
1044 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
1048 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
1049 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
1051 IHTMLIFrameElement2
*ret
;
1054 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1055 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1059 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1060 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1062 IHTMLButtonElement
*ret
;
1065 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1066 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1070 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1071 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1073 IHTMLLabelElement
*ret
;
1076 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1077 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1081 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1082 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1084 IHTMLDOMAttribute2
*ret
;
1087 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1088 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1092 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1093 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1095 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1096 IHTMLElement6
*elem
;
1100 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1101 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1102 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1103 SysFreeString(name
);
1105 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement6
, (void**)&elem
);
1106 if(SUCCEEDED(hres
)) {
1107 hres
= IHTMLElement6_get_nodeName(elem
, &name
);
1108 ok_(__FILE__
, line
) (hres
== S_OK
, "(elem) get_nodeName failed: %08x\n", hres
);
1109 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "(elem) got name: %s, expected %s\n",
1110 wine_dbgstr_w(name
), exname
);
1111 SysFreeString(name
);
1112 IHTMLElement6_Release(elem
);
1115 IHTMLDOMNode_Release(node
);
1118 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1119 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1121 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1122 IDispatch
*disp
= (void*)0xdeadbeef;
1123 IHTMLDocument2
*doc
= NULL
;
1126 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1127 IHTMLDOMNode2_Release(node
);
1128 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1131 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1132 IDispatch_Release(disp
);
1133 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1139 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1140 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1142 IHTMLWindow2
*window
;
1146 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1147 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1148 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1153 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1154 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1156 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1157 IHTMLDOMNode
*ret
= NULL
;
1160 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1161 IHTMLDOMNode_Release(node
);
1162 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1163 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1169 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1170 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1172 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1173 IHTMLElement6
*elem6
;
1177 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1178 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1179 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1182 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement6
, (void**)&elem6
);
1183 if(SUCCEEDED(hres
)) {
1184 hres
= IHTMLElement6_get_tagName(elem6
, &tag
);
1185 ok_(__FILE__
, line
)(hres
== S_OK
, "(elem6) get_tagName failed: %08x\n", hres
);
1186 ok_(__FILE__
, line
)(!strcmp_wa(tag
, extag
), "(elem6) got tag: %s, expected %s\n",
1187 wine_dbgstr_w(tag
), extag
);
1189 IHTMLElement6_Release(elem6
);
1192 IHTMLElement_Release(elem
);
1195 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1196 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1198 const char *expected_value
= "[object]";
1200 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1201 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1203 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
) {
1205 expected_value
= NULL
;
1206 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, elem_type_infos
[type
].clsid
, expected_value
);
1210 #define get_node_type(n) _get_node_type(__LINE__,n)
1211 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1213 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1217 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1218 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1220 IHTMLDOMNode_Release(node
);
1225 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1226 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1228 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1229 IHTMLDOMChildrenCollection
*col
= NULL
;
1233 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1234 IHTMLDOMNode_Release(node
);
1235 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1239 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1240 IDispatch_Release(disp
);
1241 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1246 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1247 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1249 IHTMLDOMNode
*node
= NULL
;
1253 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1254 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1256 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1257 IDispatch_Release(disp
);
1262 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1263 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1269 VariantInit(&value
);
1272 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1274 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1277 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1278 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1280 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1283 VariantClear(&value
);
1286 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1287 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1289 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1290 IHTMLElement
*off_parent
;
1294 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1295 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1297 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1298 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1300 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1301 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1303 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1304 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1306 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1307 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1309 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1310 IHTMLElement_Release(off_parent
);
1312 IHTMLElement_Release(elem
);
1315 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1316 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1318 LONG l
= 0xdeadbeef;
1321 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1322 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1323 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1326 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1327 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1329 IHTMLWindow2
*window
;
1330 IHTMLDocument2
*ret
;
1333 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1334 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1336 hres
= IHTMLWindow2_get_document(window
, &ret
);
1337 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1338 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1343 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1344 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1349 hres
= IHTMLWindow2_get_name(window
, &name
);
1350 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1352 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1354 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1355 SysFreeString(name
);
1358 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1359 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1365 hres
= IHTMLWindow2_put_name(window
, str
);
1367 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1369 _test_window_name(line
, window
, name
);
1372 #define test_window_status(d) _test_window_status(__LINE__,d)
1373 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1378 status
= (void*)0xdeadbeef;
1379 hres
= IHTMLWindow2_get_status(window
, &status
);
1380 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1381 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1382 SysFreeString(status
);
1385 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1386 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1391 str
= a2bstr(status
);
1392 hres
= IHTMLWindow2_put_status(window
, str
);
1394 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1397 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1398 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1403 hres
= IHTMLWindow2_get_length(window
, &length
);
1404 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1405 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1408 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1409 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1411 IHTMLFrameBase2
*base2
;
1412 IHTMLWindow2
*window
;
1415 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1416 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1419 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1420 IHTMLFrameBase2_Release(base2
);
1421 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1422 ok(window
!= NULL
, "contentWindow = NULL\n");
1427 static void test_get_set_attr(IHTMLDocument2
*doc
)
1430 IHTMLDocument3
*doc3
;
1435 /* grab an element to test with */
1436 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1437 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1439 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1440 IHTMLDocument3_Release(doc3
);
1441 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1443 /* get a non-present attribute */
1444 bstr
= a2bstr("notAnAttribute");
1445 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1446 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1447 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1449 SysFreeString(bstr
);
1451 /* get a present attribute */
1452 bstr
= a2bstr("scrollHeight");
1453 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1454 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1455 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1457 SysFreeString(bstr
);
1459 /* create a new BSTR attribute */
1460 bstr
= a2bstr("newAttribute");
1462 V_VT(&val
) = VT_BSTR
;
1463 V_BSTR(&val
) = a2bstr("the value");
1464 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1465 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1468 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1469 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1470 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1471 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
)));
1474 /* overwrite the attribute with a BOOL */
1475 V_VT(&val
) = VT_BOOL
;
1476 V_BOOL(&val
) = VARIANT_TRUE
;
1477 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1478 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1481 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1482 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1483 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1484 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1487 SysFreeString(bstr
);
1489 /* case-insensitive */
1490 bstr
= a2bstr("newattribute");
1491 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1492 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1493 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1494 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1497 /* overwrite the attribute with null */
1498 V_VT(&val
) = VT_NULL
;
1499 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1500 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1502 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1503 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1504 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1505 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1508 SysFreeString(bstr
);
1509 IHTMLElement_Release(elem
);
1512 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1513 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1516 IHTMLDocument3
*doc3
;
1519 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1520 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1521 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1522 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1523 IHTMLDocument3_Release(doc3
);
1528 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1529 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1531 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1535 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1536 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1537 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1540 _test_disp_value(line
, unk
, exhref
);
1543 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1544 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1546 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1550 str
= a2bstr(exhref
);
1551 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1552 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1555 _test_disp_value(line
, unk
, exhref
);
1558 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1559 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1561 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1565 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1566 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1568 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1570 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1574 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1575 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1577 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1581 str
= a2bstr(exrel
);
1582 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1583 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1587 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1588 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1590 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1594 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1595 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1597 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1599 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1603 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1604 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1606 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1610 str
= target
? a2bstr(target
) : NULL
;
1611 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1612 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1616 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1617 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1619 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1623 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1624 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1626 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1628 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1632 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1633 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1635 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1639 str
= name
? a2bstr(name
) : NULL
;
1640 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1641 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1644 _test_anchor_name(line
, unk
, name
);
1647 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1648 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1650 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1654 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1657 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1659 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1663 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1664 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1666 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1670 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1671 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1672 if ( ! str
&& allowbroken
)
1673 win_skip("skip ie6 incorrect behavior\n");
1675 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1677 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1681 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1682 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1684 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1688 str
= search
? a2bstr(search
) : NULL
;
1689 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1690 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1694 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1695 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1697 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1701 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1702 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1704 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1706 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1710 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1711 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1716 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1717 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1718 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1719 SysFreeString(bstr
);
1722 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1723 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1728 bstr
= a2bstr(text
);
1729 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1730 SysFreeString(bstr
);
1731 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1733 _test_option_text(line
, option
, text
);
1736 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1737 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1742 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1743 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1744 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1745 SysFreeString(bstr
);
1748 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1749 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1754 bstr
= a2bstr(value
);
1755 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1756 SysFreeString(bstr
);
1757 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1759 _test_option_value(line
, option
, value
);
1762 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1763 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1765 VARIANT_BOOL b
= 0x100;
1768 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1769 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1770 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1773 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1774 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1778 hres
= IHTMLOptionElement_put_selected(option
, b
);
1779 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1780 _test_option_selected(line
, option
, b
);
1783 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1784 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1789 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1790 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1793 hres
= IHTMLOptionElement_get_index(option
, &val
);
1794 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1795 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1796 "value = %d, expected = %d\n", val
, exval
);
1799 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1800 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1804 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1805 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1808 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1809 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1814 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1815 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1818 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1819 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1820 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1823 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1825 test_option_defaultSelected(option
, VARIANT_FALSE
);
1826 test_option_selected(option
, VARIANT_FALSE
);
1828 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1829 test_option_defaultSelected(option
, VARIANT_FALSE
);
1830 test_option_selected(option
, VARIANT_FALSE
);
1832 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1833 test_option_defaultSelected(option
, VARIANT_TRUE
);
1834 test_option_selected(option
, VARIANT_FALSE
);
1836 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1837 test_option_defaultSelected(option
, VARIANT_FALSE
);
1838 test_option_selected(option
, VARIANT_FALSE
);
1840 test_option_put_selected(option
, VARIANT_TRUE
);
1841 test_option_selected(option
, VARIANT_TRUE
);
1842 test_option_defaultSelected(option
, VARIANT_FALSE
);
1844 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1845 test_option_defaultSelected(option
, VARIANT_TRUE
);
1846 test_option_selected(option
, VARIANT_TRUE
);
1848 /* Restore defaultSelected */
1849 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1850 test_option_put_selected(option
, VARIANT_FALSE
);
1853 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1854 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1856 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1857 BSTR value
= (void*)0xdeadbeef;
1860 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1861 IHTMLTextAreaElement_Release(textarea
);
1862 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1864 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1866 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1867 SysFreeString(value
);
1870 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1871 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1873 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1874 BSTR tmp
= a2bstr(value
);
1877 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1878 IHTMLTextAreaElement_Release(textarea
);
1879 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1882 _test_textarea_value(line
, unk
, value
);
1885 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1886 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1888 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1889 BSTR value
= (void*)0xdeadbeef;
1892 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1893 IHTMLTextAreaElement_Release(textarea
);
1894 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1896 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1898 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1899 SysFreeString(value
);
1902 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1903 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1905 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1906 BSTR tmp
= a2bstr(value
);
1909 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1910 IHTMLTextAreaElement_Release(textarea
);
1911 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1914 _test_textarea_defaultvalue(line
, unk
, value
);
1917 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1918 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1920 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1921 VARIANT_BOOL b
= 0x100;
1924 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1925 IHTMLTextAreaElement_Release(textarea
);
1926 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1927 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1930 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1931 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1933 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1936 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1937 IHTMLTextAreaElement_Release(textarea
);
1938 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1940 _test_textarea_readonly(line
, unk
, b
);
1943 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1944 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1946 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1947 BSTR type
= (void*)0xdeadbeef;
1950 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1951 IHTMLTextAreaElement_Release(textarea
);
1952 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1953 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1954 SysFreeString(type
);
1957 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1958 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1960 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1961 IHTMLFormElement
*form
;
1964 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1965 IHTMLTextAreaElement_Release(textarea
);
1966 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1971 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1972 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1974 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1978 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1979 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1980 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1982 IHTMLCommentElement_Release(comment
);
1983 SysFreeString(text
);
1986 #define create_attr(a,b) _create_attr(__LINE__,a,b)
1987 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
1989 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
1990 BSTR str
= a2bstr("Test");
1991 IHTMLDOMAttribute
*attr
;
1994 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
1995 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
1997 IHTMLDocument5_Release(doc
);
2002 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
2003 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2005 VARIANT_BOOL specified
;
2008 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
2009 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
2010 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
2013 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
2014 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2016 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2017 VARIANT_BOOL expando
;
2020 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
2021 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
2022 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
2024 IHTMLDOMAttribute2_Release(attr2
);
2027 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
2028 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
2030 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2034 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
2035 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
2037 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
2039 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
2041 IHTMLDOMAttribute2_Release(attr2
);
2045 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
2046 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
2048 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2049 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
2050 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
2051 IHTMLDOMAttribute
*attr
;
2052 BSTR name
= a2bstr("test");
2056 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2057 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2058 ok(attr
== NULL
, "attr != NULL\n");
2062 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2063 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2065 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2066 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2067 ok(attr
!= NULL
, "attr == NULL\n");
2069 test_attr_expando(attr
, VARIANT_TRUE
);
2071 IHTMLDOMAttribute_Release(attr
);
2072 IHTMLCommentElement_Release(comment
);
2073 IHTMLElement_Release(elem
);
2074 IHTMLElement4_Release(elem4
);
2075 SysFreeString(name
);
2078 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2079 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2081 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2086 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2087 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
2088 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
2089 IHTMLObjectElement_Release(object
);
2092 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2093 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
2095 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2099 str
= (void*)0xdeadbeef;
2100 hres
= IHTMLObjectElement_get_name(object
, &str
);
2101 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2103 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2105 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2107 IHTMLObjectElement_Release(object
);
2110 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2111 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2113 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2118 hres
= IHTMLObjectElement_put_name(object
, str
);
2119 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2121 IHTMLObjectElement_Release(object
);
2123 _test_object_name(line
, elem
, name
);
2126 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2127 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2128 const char *txt
, const char *val
)
2130 IHTMLOptionElementFactory
*factory
;
2131 IHTMLOptionElement
*option
;
2132 IHTMLWindow2
*window
;
2133 VARIANT text
, value
, empty
;
2136 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2139 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2140 IHTMLWindow2_Release(window
);
2141 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2143 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, NULL
, "[object]");
2145 V_VT(&text
) = VT_BSTR
;
2146 V_BSTR(&text
) = a2bstr(txt
);
2147 V_VT(&value
) = VT_BSTR
;
2148 V_BSTR(&value
) = a2bstr(val
);
2149 V_VT(&empty
) = VT_EMPTY
;
2151 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2152 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2154 IHTMLOptionElementFactory_Release(factory
);
2155 VariantClear(&text
);
2156 VariantClear(&value
);
2158 _test_option_text(line
, option
, txt
);
2159 _test_option_value(line
, option
, val
);
2160 _test_option_selected(line
, option
, VARIANT_FALSE
);
2165 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2166 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2171 hres
= IHTMLImgElement_get_width(img
, &found
);
2172 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2173 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2176 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2177 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2181 hres
= IHTMLImgElement_put_width(img
, width
);
2182 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2184 _test_img_width(line
, img
, width
);
2187 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2188 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2193 hres
= IHTMLImgElement_get_height(img
, &found
);
2194 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2195 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2198 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2199 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2203 hres
= IHTMLImgElement_put_height(img
, height
);
2204 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2206 _test_img_height(line
, img
, height
);
2209 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2210 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2211 LONG wdth
, LONG hght
)
2213 IHTMLImageElementFactory
*factory
;
2214 IHTMLImgElement
*img
;
2215 IHTMLWindow2
*window
;
2216 VARIANT width
, height
;
2220 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2221 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2223 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2224 IHTMLWindow2_Release(window
);
2225 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2227 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2228 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, NULL
, "[object]");
2231 snprintf(buf
, 16, "%d", wdth
);
2232 V_VT(&width
) = VT_BSTR
;
2233 V_BSTR(&width
) = a2bstr(buf
);
2235 V_VT(&width
) = VT_EMPTY
;
2240 snprintf(buf
, 16, "%d", hght
);
2241 V_VT(&height
) = VT_BSTR
;
2242 V_BSTR(&height
) = a2bstr(buf
);
2244 V_VT(&height
) = VT_EMPTY
;
2248 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2249 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2251 IHTMLImageElementFactory_Release(factory
);
2252 VariantClear(&width
);
2253 VariantClear(&height
);
2255 if(SUCCEEDED(hres
)) {
2256 _test_img_width(line
, img
, wdth
);
2257 _test_img_height(line
, img
, hght
);
2264 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2265 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2267 LONG len
= 0xdeadbeef;
2270 hres
= IHTMLSelectElement_get_length(select
, &len
);
2271 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2272 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2275 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2276 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2278 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2281 hres
= IHTMLSelectElement_put_length(select
, length
);
2282 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2283 _test_select_length(line
, select
, length
);
2284 IHTMLSelectElement_Release(select
);
2287 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2288 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2290 LONG idx
= 0xdeadbeef;
2293 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2294 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2295 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2298 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2299 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2303 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2304 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2305 _test_select_selidx(line
, select
, index
);
2308 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2309 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2314 hres
= IHTMLSelectElement_get_value(select
, &val
);
2315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2317 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2319 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2323 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2324 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2330 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2331 SysFreeString(bstr
);
2332 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2335 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2336 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2341 hres
= IHTMLSelectElement_get_type(select
, &type
);
2342 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2343 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2344 SysFreeString(type
);
2347 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2348 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2350 VARIANT_BOOL b
= 100;
2353 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2354 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2355 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2358 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2359 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2363 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2364 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2366 _test_select_multiple(line
, select
, val
);
2369 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2370 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2375 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2376 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2379 hres
= IHTMLSelectElement_get_size(select
, &val
);
2380 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2381 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2384 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2385 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2389 hres
= IHTMLSelectElement_put_size(select
, val
);
2390 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2393 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2394 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2400 hres
= IHTMLSelectElement_get_name(select
, &text
);
2401 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2403 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2404 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2405 wine_dbgstr_w(text
), extext
);
2406 SysFreeString(text
);
2408 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2411 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2412 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2417 bstr
= a2bstr(text
);
2419 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2420 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2421 SysFreeString(bstr
);
2424 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2425 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2430 hres
= IHTMLTxtRange_get_text(range
, &text
);
2431 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2434 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2435 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2437 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2440 SysFreeString(text
);
2444 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2445 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2449 hres
= IHTMLTxtRange_collapse(range
, b
);
2450 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2451 _test_range_text(line
, range
, NULL
);
2454 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2455 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2456 VARIANT_BOOL exb
, const char *extext
)
2458 VARIANT_BOOL b
= 0xe0e0;
2461 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2462 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2463 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2464 _test_range_text(line
, range
, extext
);
2467 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2468 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2470 LONG c
= 0xdeadbeef;
2473 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2474 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2475 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2476 _test_range_text(line
, range
, NULL
);
2479 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2480 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2481 LPWSTR unit
, LONG cnt
, LONG excnt
)
2483 LONG c
= 0xdeadbeef;
2486 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2487 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2488 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2491 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2492 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2494 LONG c
= 0xdeadbeef;
2497 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2498 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2499 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2502 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2503 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2506 BSTR bstr
= a2bstr(text
);
2508 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2509 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2510 SysFreeString(bstr
);
2511 _test_range_text(line
, range
, NULL
);
2514 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2515 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2521 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2522 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2523 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2526 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2527 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2533 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2534 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2535 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2538 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2539 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2540 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2543 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2544 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2548 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2549 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2551 BSTR str
= a2bstr(html
);
2554 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2555 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2559 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2560 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2565 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2566 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2568 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2570 IHTMLElement_Release(elem
);
2573 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2574 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2576 VARIANT name
, index
;
2581 V_VT(&index
) = VT_EMPTY
;
2582 V_VT(&name
) = VT_I4
;
2584 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2585 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2586 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2588 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2589 IDispatch_Release(disp
);
2593 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2594 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2595 const elem_type_t
*elem_types
, LONG exlen
)
2597 IHTMLElementCollection
*col
;
2598 IEnumVARIANT
*enum_var
;
2603 VARIANT name
, index
, v
, vs
[5];
2604 IDispatch
*disp
, *disp2
;
2607 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2608 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2610 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, NULL
, "[object]");
2612 hres
= IHTMLElementCollection_get_length(col
, &len
);
2613 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2614 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2619 V_VT(&index
) = VT_EMPTY
;
2621 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2622 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2624 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2625 IUnknown_Release(enum_unk
);
2626 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2628 for(i
=0; i
<len
; i
++) {
2629 V_VT(&name
) = VT_I4
;
2631 disp
= (void*)0xdeadbeef;
2632 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2633 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2634 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2635 if(FAILED(hres
) || !disp
)
2638 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2641 V_VT(&name
) = VT_UINT
;
2643 disp2
= (void*)0xdeadbeef;
2644 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2645 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2646 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2648 IDispatch_Release(disp2
);
2652 V_VT(&v
) = VT_ERROR
;
2653 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2654 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2656 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2657 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2658 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2659 IDispatch_Release(V_DISPATCH(&v
));
2661 IDispatch_Release(disp
);
2664 fetched
= 0xdeadbeef;
2666 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2667 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2668 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2669 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2671 hres
= IEnumVARIANT_Reset(enum_var
);
2672 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2674 fetched
= 0xdeadbeef;
2676 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2677 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2678 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2679 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2681 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2682 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2684 memset(vs
, 0, sizeof(vs
));
2686 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2687 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2688 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2690 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2691 IDispatch_Release(V_DISPATCH(vs
));
2694 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2695 IDispatch_Release(V_DISPATCH(vs
+1));
2698 hres
= IEnumVARIANT_Reset(enum_var
);
2699 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2701 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2702 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2704 IEnumVARIANT_Release(enum_var
);
2706 V_VT(&name
) = VT_I4
;
2708 disp
= (void*)0xdeadbeef;
2709 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2710 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2711 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2713 V_VT(&name
) = VT_UI4
;
2715 disp
= (void*)0xdeadbeef;
2716 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2717 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2718 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2720 V_VT(&name
) = VT_INT
;
2722 disp
= (void*)0xdeadbeef;
2723 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2724 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2725 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2727 V_VT(&name
) = VT_UINT
;
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_I4
;
2736 disp
= (void*)0xdeadbeef;
2737 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2738 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2739 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2741 IHTMLElementCollection_Release(col
);
2744 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2745 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2747 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2751 hres
= IHTMLElement_get_all(elem
, &disp
);
2752 IHTMLElement_Release(elem
);
2753 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2755 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2756 IDispatch_Release(disp
);
2759 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2760 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2762 IHTMLElementCollection
*col
;
2765 hres
= IHTMLDocument2_get_all(doc
, &col
);
2766 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2768 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2769 IHTMLElementCollection_Release(col
);
2772 #define test_children_collection_length(a,b) _test_children_collection_length(__LINE__,a,b)
2773 static LONG
_test_children_collection_length(unsigned line
, IHTMLDOMChildrenCollection
*collection
, LONG exlen
)
2778 hres
= IHTMLDOMChildrenCollection_get_length(collection
, &length
);
2779 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2781 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
2786 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2787 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2789 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2790 IHTMLElementCollection
*col
= NULL
;
2791 elem_type_t
*types
= NULL
;
2796 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2797 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2799 IHTMLElement2_Release(elem
);
2800 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2801 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2804 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2805 for(i
=0; i
<exlen
; i
++)
2809 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2811 HeapFree(GetProcessHeap(), 0, types
);
2814 *ret
= get_elem_col_item_idx(col
, 0);
2815 IHTMLElementCollection_Release(col
);
2818 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2819 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2821 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2822 IHTMLElementCollection
*col
= NULL
;
2823 elem_type_t
*types
= NULL
;
2828 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2829 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2831 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2832 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2835 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2836 for(i
=0; i
<exlen
; i
++)
2840 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2842 HeapFree(GetProcessHeap(), 0, types
);
2843 IHTMLElementCollection_Release(col
);
2844 IHTMLDocument3_Release(doc
);
2847 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2848 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2853 hres
= IHTMLElement_get_innerText(elem
, &text
);
2854 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2856 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2857 wine_dbgstr_w(text
), extext
);
2859 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2860 SysFreeString(text
);
2863 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2864 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2866 IHTMLDOMChildrenCollection
*col
;
2871 hres
= IHTMLElement_put_innerText(elem
, str
);
2872 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2875 _test_elem_innertext(line
, elem
, text
);
2878 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2879 ok(col
!= NULL
, "col == NULL\n");
2884 _test_children_collection_length(line
, col
, 1);
2886 node
= _get_child_item(line
, col
, 0);
2887 ok(node
!= NULL
, "node == NULL\n");
2889 type
= _get_node_type(line
, (IUnknown
*)node
);
2890 ok(type
== 3, "type=%d\n", type
);
2891 IHTMLDOMNode_Release(node
);
2894 IHTMLDOMChildrenCollection_Release(col
);
2899 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
2900 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2905 hres
= IHTMLElement_get_outerText(elem
, &text
);
2906 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08x\n", hres
);
2908 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_outerText returned %s expected %s\n",
2909 wine_dbgstr_w(text
), extext
);
2911 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2912 SysFreeString(text
);
2915 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
2916 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2918 BSTR str
= a2bstr(text
);
2921 hres
= IHTMLElement_put_outerText(elem
, str
);
2922 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08x\n", hres
);
2926 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
2927 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
2929 BSTR str
= a2bstr("test");
2932 hres
= IHTMLElement_put_outerText(elem
, str
);
2933 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08x\n", hres
);
2937 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2938 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2940 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2944 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2945 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2947 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2949 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2951 IHTMLElement_Release(elem
);
2952 SysFreeString(html
);
2955 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2956 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2958 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2962 html
= a2bstr(inner_html
);
2963 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2964 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2966 IHTMLElement_Release(elem
);
2967 SysFreeString(html
);
2970 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2971 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2973 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2977 html
= a2bstr(outer_html
);
2978 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2979 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2981 IHTMLElement_Release(elem
);
2982 SysFreeString(html
);
2985 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2986 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2988 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2992 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2993 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2994 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2996 IHTMLElement_Release(elem
);
2997 SysFreeString(html
);
3000 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
3001 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
3007 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
3008 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
3009 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
3012 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
3013 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
3019 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
3020 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
3021 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
3024 #define get_first_child(n) _get_first_child(__LINE__,n)
3025 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
3027 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3028 IHTMLDOMNode
*child
= NULL
;
3031 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
3032 IHTMLDOMNode_Release(node
);
3033 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
3038 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
3039 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3041 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3042 VARIANT_BOOL b
= 0xdead;
3045 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
3046 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
3047 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
3049 IHTMLDOMNode_Release(node
);
3052 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
3053 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
3055 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3056 IHTMLDOMNode
*parent
;
3059 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
3060 IHTMLDOMNode_Release(node
);
3061 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3066 #define node_get_next(u) _node_get_next(__LINE__,u)
3067 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
3069 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3073 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
3074 IHTMLDOMNode_Release(node
);
3075 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
3080 #define node_get_prev(u) _node_get_prev(__LINE__,u)
3081 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
3083 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3087 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3088 IHTMLDOMNode_Release(node
);
3089 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
3094 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3095 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3097 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3098 IHTMLElement
*parent
;
3101 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3102 IHTMLElement_Release(elem
);
3103 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
3108 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3109 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3111 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3112 VARIANT_BOOL disabled
= 100;
3116 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3117 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3118 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3119 IHTMLElement3_Release(elem3
);
3122 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3123 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3125 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3129 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3130 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3132 IHTMLElement3_Release(elem3
);
3133 _test_elem3_get_disabled(line
, unk
, b
);
3136 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3137 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3139 VARIANT_BOOL disabled
= 100;
3142 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3143 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3144 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3146 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3149 static void test_select_remove(IHTMLSelectElement
*select
)
3153 hres
= IHTMLSelectElement_remove(select
, 3);
3154 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3155 test_select_length(select
, 2);
3157 hres
= IHTMLSelectElement_remove(select
, -1);
3158 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3159 test_select_length(select
, 2);
3161 hres
= IHTMLSelectElement_remove(select
, 0);
3162 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3163 test_select_length(select
, 1);
3166 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3167 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3169 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3173 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3174 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3175 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3176 IHTMLDOMTextNode_Release(text
);
3179 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3180 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3182 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3186 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3187 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3188 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3189 IHTMLDOMTextNode_Release(text
);
3193 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3194 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3196 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3197 BSTR str
= a2bstr(data
);
3200 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3201 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3202 IHTMLDOMTextNode_Release(text
);
3206 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3207 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3209 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3210 BSTR str
= a2bstr(data
);
3213 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3214 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3215 IHTMLDOMTextNode2_Release(text
);
3219 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3220 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3224 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3225 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3227 _test_select_get_disabled(line
, select
, b
);
3230 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3231 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3233 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3237 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3238 IHTMLElement2_Release(elem
);
3239 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3241 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3243 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3248 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3249 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3251 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3252 BSTR dir
= a2bstr(dira
);
3255 hres
= IHTMLElement2_put_dir(elem
, dir
);
3256 IHTMLElement2_Release(elem
);
3257 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3260 _test_elem_dir(line
, unk
, dira
);
3263 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3264 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3266 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3267 IHTMLTextContainer
*txtcont
;
3268 LONG l
= -1, l2
= -1;
3271 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3272 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3273 IHTMLElement2_Release(elem
);
3275 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3276 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3278 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3279 IHTMLTextContainer_Release(txtcont
);
3280 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3281 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3286 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3287 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3289 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3290 IHTMLTextContainer
*txtcont
;
3291 LONG l
= -1, l2
= -1;
3294 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3295 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3296 IHTMLElement2_Release(elem
);
3298 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3299 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3301 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3302 IHTMLTextContainer_Release(txtcont
);
3303 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3304 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3309 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3310 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3312 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3313 IHTMLTextContainer
*txtcont
;
3314 LONG l
= -1, l2
= -1;
3317 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3318 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3319 IHTMLElement2_Release(elem
);
3321 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3322 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3324 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3325 IHTMLTextContainer_Release(txtcont
);
3326 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3327 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3332 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3333 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3335 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3336 IHTMLTextContainer
*txtcont
;
3337 LONG l
= -1, l2
= -1;
3340 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3341 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3343 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3344 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3345 IHTMLElement2_Release(elem
);
3347 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3348 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3350 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3351 IHTMLTextContainer_Release(txtcont
);
3352 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3353 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3356 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3357 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3359 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3363 hres
= IHTMLImgElement_get_src(img
, &src
);
3364 IHTMLImgElement_Release(img
);
3365 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3366 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3367 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3371 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3372 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3374 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3379 hres
= IHTMLImgElement_put_src(img
, tmp
);
3380 IHTMLImgElement_Release(img
);
3382 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3385 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3386 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3388 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3392 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3393 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3395 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3397 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3401 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3402 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3404 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3409 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3410 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3413 _test_img_alt(line
, unk
, alt
);
3416 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3417 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3419 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3423 tmp
= a2bstr(align
);
3424 hres
= IHTMLImgElement_put_align(img
, tmp
);
3425 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3428 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3429 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3430 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3434 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3435 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3437 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3441 hres
= IHTMLImgElement_get_name(img
, &sName
);
3442 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3443 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3444 IHTMLImgElement_Release(img
);
3445 SysFreeString(sName
);
3448 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3449 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3451 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3452 VARIANT_BOOL b
= 100;
3455 hres
= IHTMLImgElement_get_complete(img
, &b
);
3456 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3457 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3458 IHTMLImgElement_Release(img
);
3461 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3462 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3464 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3465 VARIANT_BOOL b
= 100;
3468 hres
= IHTMLImgElement_put_isMap(img
, v
);
3469 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3471 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3472 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3473 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3475 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3476 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3477 IHTMLImgElement_Release(img
);
3480 static void test_dynamic_properties(IHTMLElement
*elem
)
3482 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3483 IDispatchEx
*dispex
;
3484 BSTR name
, attr1
= SysAllocString(attr1W
);
3488 DISPID id
= DISPID_STARTENUM
;
3491 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3492 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3494 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3495 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3496 ok(succ
, "removeAttribute set succ to FALSE\n");
3499 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3500 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3504 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3505 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3507 if(!strcmp_wa(name
, "attr1"))
3508 ok(0, "attr1 should be removed\n");
3509 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3511 SysFreeString(name
);
3513 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3514 IDispatchEx_Release(dispex
);
3516 V_VT(&val
) = VT_BSTR
;
3517 V_BSTR(&val
) = attr1
;
3518 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3519 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3520 SysFreeString(attr1
);
3523 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3524 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3529 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3530 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3531 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3535 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3536 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3538 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3539 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3542 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3543 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3544 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3545 IHTMLDOMAttribute2_Release(attr2
);
3548 static void test_attr_collection_disp(IDispatch
*disp
)
3550 IDispatchEx
*dispex
;
3551 IHTMLDOMAttribute
*attr
;
3552 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3559 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3560 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3563 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3564 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3565 SysFreeString(bstr
);
3568 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3569 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3570 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3571 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3574 bstr
= a2bstr("attr1");
3575 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3576 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3577 SysFreeString(bstr
);
3580 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3581 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3582 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3583 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3584 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3585 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3587 test_attr_node_name(attr
, "attr1");
3589 IHTMLDOMAttribute_Release(attr
);
3592 IDispatchEx_Release(dispex
);
3595 static void test_attr_collection(IHTMLElement
*elem
)
3597 static const WCHAR testW
[] = {'t','e','s','t',0};
3600 IDispatch
*disp
, *attr
;
3601 IHTMLDOMAttribute
*dom_attr
;
3602 IHTMLAttributeCollection
*attr_col
;
3603 BSTR name
= SysAllocString(testW
);
3605 LONG i
, len
, checked
;
3608 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3609 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3611 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3612 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3614 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3615 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3616 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3617 IDispatch_Release(attr
);
3618 IHTMLDOMNode_Release(node
);
3620 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3621 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3623 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3624 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3628 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3629 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3630 SysFreeString(name
);
3632 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3633 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3634 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3637 for(i
=0; i
<len
; i
++) {
3640 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3641 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3643 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3644 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3645 IDispatch_Release(attr
);
3647 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3648 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3650 if(!strcmp_wa(name
, "id")) {
3652 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3653 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3654 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3655 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3656 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3657 test_attr_value(dom_attr
, "attr");
3658 } else if(!strcmp_wa(name
, "attr1")) {
3660 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3661 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3662 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3663 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3664 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3665 test_attr_value(dom_attr
, "attr1");
3666 } else if(!strcmp_wa(name
, "attr2")) {
3668 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3669 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3670 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3671 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3672 test_attr_value(dom_attr
, "");
3673 } else if(!strcmp_wa(name
, "attr3")) {
3675 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3676 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3677 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3678 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3679 test_attr_value(dom_attr
, "attr3");
3680 } else if(!strcmp_wa(name
, "test")) {
3682 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3683 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3684 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3685 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3686 test_attr_value(dom_attr
, "1");
3689 IHTMLDOMAttribute_Release(dom_attr
);
3690 SysFreeString(name
);
3693 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3696 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3697 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3699 V_VT(&id
) = VT_BSTR
;
3700 V_BSTR(&id
) = a2bstr("nonexisting");
3701 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3702 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3705 test_attr_collection_disp(disp
);
3707 IDispatch_Release(disp
);
3708 IHTMLAttributeCollection_Release(attr_col
);
3711 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3712 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3714 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3715 BSTR id
= (void*)0xdeadbeef;
3718 hres
= IHTMLElement_get_id(elem
, &id
);
3719 IHTMLElement_Release(elem
);
3720 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3723 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3725 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3730 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3731 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3733 BSTR lang
= (void*)0xdeadbeef;
3736 hres
= IHTMLElement_get_language(elem
, &lang
);
3737 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3740 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3742 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3744 SysFreeString(lang
);
3747 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3748 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3750 BSTR str
= a2bstr(lang
);
3753 hres
= IHTMLElement_put_language(elem
, str
);
3754 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3757 _test_elem_language(line
, elem
, lang
);
3760 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3761 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3763 BSTR lang
= (void*)0xdeadbeef;
3766 hres
= IHTMLElement_get_lang(elem
, &lang
);
3767 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3770 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3772 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3774 SysFreeString(lang
);
3777 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3778 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3780 BSTR str
= a2bstr(lang
);
3783 hres
= IHTMLElement_put_lang(elem
, str
);
3784 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3787 _test_elem_lang(line
, elem
, lang
);
3790 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3791 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3793 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3794 BSTR tmp
= a2bstr(new_id
);
3797 hres
= IHTMLElement_put_id(elem
, tmp
);
3798 IHTMLElement_Release(elem
);
3800 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3802 _test_elem_id(line
, unk
, new_id
);
3805 static void test_contenteditable(IUnknown
*unk
)
3807 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3809 BSTR str
, strDefault
;
3811 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3812 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3814 str
= a2bstr("true");
3815 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3816 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3818 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3819 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3820 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3823 /* Restore origin contentEditable */
3824 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3825 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3826 SysFreeString(strDefault
);
3828 IHTMLElement3_Release(elem3
);
3831 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3832 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3837 hres
= IHTMLInputElement_get_type(input
, &type
);
3838 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3839 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3840 SysFreeString(type
);
3843 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3844 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3846 BSTR name
= (BSTR
)0xdeadbeef;
3849 hres
= IHTMLInputElement_get_name(input
, &name
);
3850 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3852 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3854 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3855 SysFreeString(name
);
3858 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3859 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3861 BSTR tmp
= a2bstr(name
);
3864 hres
= IHTMLInputElement_put_name(input
, tmp
);
3865 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3868 _test_input_name(line
, input
, name
);
3871 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3872 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3874 VARIANT_BOOL disabled
= 100;
3877 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3878 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3879 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3881 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3884 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3885 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3889 hres
= IHTMLInputElement_put_disabled(input
, b
);
3890 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3892 _test_input_get_disabled(line
, input
, b
);
3895 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3896 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3898 VARIANT_BOOL checked
= 100;
3901 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3902 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3903 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3906 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3907 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3911 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3912 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3914 _test_input_get_defaultchecked(line
, input
, b
);
3917 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3918 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3920 VARIANT_BOOL checked
= 100;
3923 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3924 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3925 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3928 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3929 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3933 hres
= IHTMLInputElement_put_checked(input
, b
);
3934 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3936 _test_input_get_checked(line
, input
, b
);
3939 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3940 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3942 LONG maxlength
= 0xdeadbeef;
3945 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3946 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3947 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3950 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3951 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3955 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3956 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3958 _test_input_maxlength(line
, input
, l
);
3961 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3962 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3964 IHTMLInputElement
*input
;
3968 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3969 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3973 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3974 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3976 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3978 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3979 SysFreeString(bstr
);
3980 IHTMLInputElement_Release(input
);
3983 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3984 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3986 IHTMLInputElement
*input
;
3987 IHTMLFormElement
*form
;
3991 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3992 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3993 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3994 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3995 if(FAILED(hres
) || input
== NULL
)
3998 hres
= IHTMLInputElement_get_form(input
, &form
);
3999 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
4000 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
4001 if(FAILED(hres
) || form
== NULL
){
4002 IHTMLInputElement_Release(input
);
4006 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
4007 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
4008 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
4009 if(FAILED(hres
) || elem
== NULL
){
4010 IHTMLInputElement_Release(input
);
4011 IHTMLFormElement_Release(form
);
4015 _test_elem_id(line
, (IUnknown
*)elem
, id
);
4017 IHTMLInputElement_Release(input
);
4018 IHTMLFormElement_Release(form
);
4019 IHTMLElement_Release(elem
);
4022 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
4023 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
4025 IHTMLInputElement
*input
;
4029 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4030 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4035 hres
= IHTMLInputElement_put_value(input
, bstr
);
4036 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
4037 SysFreeString(bstr
);
4038 IHTMLInputElement_Release(input
);
4040 _test_input_value(line
, unk
, val
);
4043 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
4044 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
4046 IHTMLInputElement
*input
;
4050 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4051 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4055 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
4056 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4058 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
4060 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
4062 IHTMLInputElement_Release(input
);
4065 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
4066 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
4068 IHTMLInputElement
*input
;
4072 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4073 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4078 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
4079 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4081 IHTMLInputElement_Release(input
);
4083 _test_input_defaultValue(line
, unk
, val
);
4086 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4087 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
4092 hres
= IHTMLInputElement_get_src(input
, &src
);
4093 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
4095 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
4097 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4101 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4102 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
4108 hres
= IHTMLInputElement_put_src(input
, tmp
);
4110 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
4112 _test_input_src(line
, input
, src
);
4115 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4116 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4120 hres
= IHTMLInputElement_put_size(input
, size
);
4121 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
4124 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4125 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4130 hres
= IHTMLInputElement_get_size(input
, &size
);
4131 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
4132 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
4134 hres
= IHTMLInputElement_get_size(input
, NULL
);
4135 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
4138 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4139 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4142 VARIANT_BOOL b
= 100;
4144 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4145 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
4147 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4148 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
4149 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4152 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4153 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
4155 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4156 BSTR
class = (void*)0xdeadbeef;
4159 hres
= IHTMLElement_get_className(elem
, &class);
4160 IHTMLElement_Release(elem
);
4161 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4163 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4165 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4166 SysFreeString(class);
4169 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4170 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4172 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4176 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4177 IHTMLElement2_Release(elem2
);
4178 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4179 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4182 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4183 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4185 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4188 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4189 IHTMLElement2_Release(elem2
);
4190 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4192 _test_elem_tabindex(line
, unk
, index
);
4195 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4196 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4198 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4202 hres
= IHTMLStyleElement_get_media(style
, &media
);
4203 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4205 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4207 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4209 IHTMLStyleElement_Release(style
);
4210 SysFreeString(media
);
4213 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4214 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4216 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4220 str
= a2bstr(media
);
4221 hres
= IHTMLStyleElement_put_media(style
, str
);
4222 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4223 IHTMLStyleElement_Release(style
);
4226 _test_style_media(line
, unk
, media
);
4229 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4230 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4232 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4236 hres
= IHTMLStyleElement_get_type(style
, &type
);
4237 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4239 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4241 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4243 IHTMLStyleElement_Release(style
);
4244 SysFreeString(type
);
4247 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4248 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4250 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4255 hres
= IHTMLStyleElement_put_type(style
, str
);
4256 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4257 IHTMLStyleElement_Release(style
);
4260 _test_style_type(line
, unk
, type
);
4263 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4264 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4266 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4268 IHTMLFiltersCollection
*filters
;
4270 hres
= IHTMLElement_get_filters(elem
, &filters
);
4271 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4272 "get_filters failed: %08x\n", hres
);
4276 IDispatchEx
*dispex
;
4278 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4279 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4280 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4282 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4283 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4284 "Could not get IDispatchEx interface: %08x\n", hres
);
4285 if(SUCCEEDED(hres
)) {
4286 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, NULL
, "[object]");
4287 IDispatchEx_Release(dispex
);
4290 IHTMLFiltersCollection_Release(filters
);
4293 IHTMLElement_Release(elem
);
4296 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4297 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4299 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4303 tmp
= class ? a2bstr(class) : NULL
;
4304 hres
= IHTMLElement_put_className(elem
, tmp
);
4305 IHTMLElement_Release(elem
);
4306 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4309 _test_elem_class(line
, unk
, class);
4312 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4313 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4315 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4319 hres
= IHTMLElement_get_title(elem
, &title
);
4320 IHTMLElement_Release(elem
);
4321 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4323 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4325 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4327 SysFreeString(title
);
4330 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4331 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4333 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4337 tmp
= a2bstr(title
);
4338 hres
= IHTMLElement_put_title(elem
, tmp
);
4339 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4341 IHTMLElement_Release(elem
);
4345 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4346 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4348 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4352 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4353 IHTMLDOMNode_Release(node
);
4354 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4357 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4358 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4360 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4366 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4367 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4369 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4373 V_VT(&var
) = VT_BSTR
;
4374 V_BSTR(&var
) = a2bstr(val
);
4376 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4377 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4378 IHTMLDOMNode_Release(node
);
4382 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4383 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4385 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4389 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4390 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4391 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4392 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4394 IHTMLElement2_Release(elem
);
4397 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4398 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4400 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4404 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4405 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4406 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4408 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4409 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4410 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4412 IHTMLElement2_Release(elem
);
4415 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4416 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4418 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4419 LONG len
= 0xdeadbeef;
4422 hres
= IHTMLFormElement_get_length(form
, &len
);
4423 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4424 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4426 IHTMLFormElement_Release(form
);
4429 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4430 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4432 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4433 BSTR action
= (void*)0xdeadbeef;
4436 hres
= IHTMLFormElement_get_action(form
, &action
);
4437 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4439 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4441 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4443 SysFreeString(action
);
4444 IHTMLFormElement_Release(form
);
4447 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4448 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4450 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4451 BSTR tmp
= a2bstr(action
);
4454 hres
= IHTMLFormElement_put_action(form
, tmp
);
4455 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4457 IHTMLFormElement_Release(form
);
4459 _test_form_action(line
, unk
, action
);
4462 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4463 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4465 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4466 BSTR method
= (void*)0xdeadbeef;
4469 hres
= IHTMLFormElement_get_method(form
, &method
);
4470 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4472 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4474 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4476 SysFreeString(method
);
4477 IHTMLFormElement_Release(form
);
4480 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4481 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4483 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4484 BSTR tmp
= a2bstr(method
);
4487 hres
= IHTMLFormElement_put_method(form
, tmp
);
4488 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4490 IHTMLFormElement_Release(form
);
4492 if(exp_hres
== S_OK
)
4493 _test_form_method(line
, unk
, method
);
4496 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4497 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4499 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4500 BSTR name
= (void*)0xdeadbeef;
4503 hres
= IHTMLFormElement_get_name(form
, &name
);
4504 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4506 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4508 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4510 SysFreeString(name
);
4511 IHTMLFormElement_Release(form
);
4514 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4515 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4517 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4518 BSTR tmp
= a2bstr(name
);
4521 hres
= IHTMLFormElement_put_name(form
, tmp
);
4522 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4524 IHTMLFormElement_Release(form
);
4526 _test_form_name(line
, unk
, name
);
4529 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4530 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4532 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4533 BSTR encoding
= (void*)0xdeadbeef;
4536 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4537 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4539 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4541 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4543 SysFreeString(encoding
);
4544 IHTMLFormElement_Release(form
);
4547 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4548 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4550 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4551 BSTR tmp
= a2bstr(encoding
);
4554 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4555 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4557 IHTMLFormElement_Release(form
);
4559 if(exp_hres
== S_OK
)
4560 _test_form_encoding(line
, unk
, encoding
);
4563 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4564 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4566 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4571 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4572 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4573 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4574 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4576 IDispatch_Release(disp
);
4577 IHTMLFormElement_Release(form
);
4580 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4581 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4583 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4586 hres
= IHTMLFormElement_reset(form
);
4587 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4589 IHTMLFormElement_Release(form
);
4592 static void test_form_target(IUnknown
*unk
)
4594 IHTMLFormElement
*form
= get_form_iface(unk
);
4597 static const char target
[] = "_blank";
4599 str
= a2bstr(target
);
4600 hres
= IHTMLFormElement_put_target(form
, str
);
4601 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4604 hres
= IHTMLFormElement_get_target(form
, &str
);
4605 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4606 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4609 IHTMLFormElement_Release(form
);
4612 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4614 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4615 IHTMLFormElement
*form
;
4618 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4619 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4621 hres
= IHTMLSelectElement_get_form(select
, &form
);
4622 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4623 ok(form
!= NULL
, "form == NULL\n");
4625 test_form_length((IUnknown
*)form
, 2);
4626 test_form_elements((IUnknown
*)form
);
4627 test_form_name((IUnknown
*)form
, "form_name");
4629 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4631 IHTMLSelectElement_Release(select
);
4632 IHTMLFormElement_Release(form
);
4635 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4637 IHTMLFormElement
*form
;
4640 form
= (IHTMLFormElement
*)0xdeadbeef;
4641 hres
= IHTMLSelectElement_get_form(select
, &form
);
4642 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4643 ok(form
== NULL
, "got %p\n", form
);
4646 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4647 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4649 IHTMLMetaElement
*meta
;
4653 meta
= _get_metaelem_iface(line
, unk
);
4654 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4656 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4657 SysFreeString(name
);
4658 IHTMLMetaElement_Release(meta
);
4661 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4662 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4664 IHTMLMetaElement
*meta
;
4665 BSTR content
= NULL
;
4668 meta
= _get_metaelem_iface(line
, unk
);
4669 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4670 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4671 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4672 SysFreeString(content
);
4673 IHTMLMetaElement_Release(meta
);
4676 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4677 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4679 IHTMLMetaElement
*meta
;
4683 meta
= _get_metaelem_iface(line
, unk
);
4684 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4685 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4686 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4688 IHTMLMetaElement_Release(meta
);
4691 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4692 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4694 IHTMLMetaElement
*meta
;
4698 meta
= _get_metaelem_iface(line
, unk
);
4699 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4700 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4702 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4704 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4706 IHTMLMetaElement_Release(meta
);
4709 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4710 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4712 BSTR val
= a2bstr(vala
);
4713 IHTMLMetaElement
*meta
;
4716 meta
= _get_metaelem_iface(line
, unk
);
4717 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4718 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4720 IHTMLMetaElement_Release(meta
);
4722 _test_meta_charset(line
, unk
, vala
);
4725 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4726 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4728 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4732 str
= a2bstr(exval
);
4733 hres
= IHTMLLinkElement_put_media(link
, str
);
4734 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4737 hres
= IHTMLLinkElement_get_media(link
, &str
);
4738 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4739 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4741 IHTMLLinkElement_Release(link
);
4744 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4745 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4747 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4748 VARIANT_BOOL b
= 10;
4751 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4752 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4753 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4755 IHTMLLinkElement_Release(link
);
4758 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4759 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4761 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4764 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4765 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4766 IHTMLLinkElement_Release(link
);
4767 _test_link_disabled(line
, elem
, v
);
4770 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4771 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4773 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4777 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4778 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4780 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4782 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4785 IHTMLLinkElement_Release(link
);
4788 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4789 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4791 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4792 BSTR str
= a2bstr(v
);
4795 hres
= IHTMLLinkElement_put_rel(link
, str
);
4796 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4798 IHTMLLinkElement_Release(link
);
4799 _test_link_rel(line
, elem
, v
);
4802 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4803 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4805 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4809 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4810 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4812 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4814 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4817 IHTMLLinkElement_Release(link
);
4820 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4821 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4823 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4824 BSTR str
= a2bstr(v
);
4827 hres
= IHTMLLinkElement_put_rev(link
, str
);
4828 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4830 IHTMLLinkElement_Release(link
);
4831 _test_link_rev(line
, elem
, v
);
4834 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4835 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4837 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4841 hres
= IHTMLLinkElement_get_type(link
, &type
);
4842 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4844 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4846 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4847 SysFreeString(type
);
4849 IHTMLLinkElement_Release(link
);
4852 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4853 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4858 str
= (void*)0xdeadbeef;
4859 hres
= IHTMLScriptElement_get_text(script
, &str
);
4860 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4861 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4865 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4866 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4868 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4869 BSTR str
= a2bstr(v
);
4872 hres
= IHTMLLinkElement_put_type(link
, str
);
4873 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4875 IHTMLLinkElement_Release(link
);
4876 _test_link_type(line
, elem
, v
);
4879 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4880 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4882 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4886 hres
= IHTMLLinkElement_get_href(link
, &href
);
4887 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4889 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4891 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4892 SysFreeString(href
);
4894 IHTMLLinkElement_Release(link
);
4897 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4898 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4900 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4901 BSTR str
= a2bstr(v
);
4904 hres
= IHTMLLinkElement_put_href(link
, str
);
4905 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4907 IHTMLLinkElement_Release(link
);
4908 _test_link_href(line
, elem
, v
);
4911 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4912 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4914 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4915 IHTMLDocument2
*doc
;
4920 hres
= IHTMLElement_get_document(elem
, &disp
);
4921 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4922 ok(disp
!= NULL
, "disp == NULL\n");
4924 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4925 IDispatch_Release(disp
);
4926 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4931 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4932 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4934 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4935 BSTR str
= a2bstr(attr_name
);
4936 IHTMLDOMAttribute
*attr
;
4939 attr
= (void*)0xdeadbeef;
4940 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4941 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4943 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4945 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4947 IHTMLElement4_Release(elem
);
4952 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4953 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4958 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4959 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4960 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4963 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4964 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4968 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4969 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4972 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4973 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4975 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4976 BSTR str
= a2bstr(value
);
4979 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4980 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4982 IHTMLDOMAttribute2_Release(attr2
);
4986 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4987 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4989 IHTMLDocument2
*doc
;
4993 hres
= IHTMLWindow2_get_document(window
, &doc
);
4994 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4995 ok(doc
!= NULL
, "disp == NULL\n");
5000 #define doc_get_body(d) _doc_get_body(__LINE__,d)
5001 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
5006 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5007 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5008 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
5013 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
5014 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
5016 IHTMLElement
*elem
= NULL
;
5021 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
5022 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5023 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
5029 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
5030 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
5032 IHTMLDocument3
*doc3
;
5033 IHTMLDOMNode
*node
= NULL
;
5037 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5038 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
5041 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
5042 IHTMLDocument3_Release(doc3
);
5044 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5045 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
5050 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
5051 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5053 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5054 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
5055 IHTMLDOMNode
*new_child
= NULL
;
5058 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
5059 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
5060 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5061 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5063 IHTMLDOMNode_Release(node
);
5064 IHTMLDOMNode_Release(child
);
5069 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
5070 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
5072 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5073 IHTMLDOMNode
*new_child
= NULL
;
5076 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
5077 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
5078 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5079 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5081 IHTMLDOMNode_Release(node
);
5086 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
5087 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
5089 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5090 IHTMLDOMNode
*new_node
= NULL
;
5093 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5094 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
5095 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5096 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5098 IHTMLDOMNode_Release(node
);
5099 IHTMLDOMNode_Release(new_node
);
5102 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5103 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
5108 hres
= IHTMLDocument2_get_title(doc
, &title
);
5109 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5110 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5111 SysFreeString(title
);
5114 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5115 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
5120 tmp
= a2bstr(title
);
5121 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5122 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5126 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5128 IHTMLRect
*rect
, *rect2
;
5129 IHTMLElement2
*elem2
;
5133 elem2
= get_elem2_iface(unk
);
5134 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5135 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5136 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5137 IHTMLElement2_Release(elem2
);
5138 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5139 ok(rect
!= NULL
, "rect == NULL\n");
5140 ok(rect
!= rect2
, "rect == rect2\n");
5141 IHTMLRect_Release(rect2
);
5143 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, NULL
, "[object]");
5146 hres
= IHTMLRect_get_top(rect
, &l
);
5147 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
5148 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5151 hres
= IHTMLRect_get_left(rect
, &l
);
5152 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
5153 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5156 hres
= IHTMLRect_get_bottom(rect
, &l
);
5157 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
5158 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5161 hres
= IHTMLRect_get_right(rect
, &l
);
5162 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
5163 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5165 IHTMLRect_Release(rect
);
5168 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5169 const elem_type_t
*elem_types
, LONG len
)
5172 VARIANT name
, index
;
5176 V_VT(&index
) = VT_EMPTY
;
5177 V_VT(&name
) = VT_BSTR
;
5178 V_BSTR(&name
) = a2bstr(n
);
5180 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5181 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5183 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5184 IDispatch_Release(disp
);
5186 V_VT(&index
) = VT_I4
;
5188 for(i
=0; i
<len
; i
++) {
5190 disp
= (void*)0xdeadbeef;
5191 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5192 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5193 ok(disp
!= NULL
, "disp == NULL\n");
5194 if(FAILED(hres
) || !disp
)
5197 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5199 IDispatch_Release(disp
);
5203 disp
= (void*)0xdeadbeef;
5204 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5205 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5206 ok(disp
== NULL
, "disp != NULL\n");
5209 disp
= (void*)0xdeadbeef;
5210 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5211 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5212 ok(disp
== NULL
, "disp != NULL\n");
5214 SysFreeString(V_BSTR(&name
));
5217 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5219 IHTMLElementCollection
*col
;
5221 IDispatch
*disp
= (void*)0xdeadbeef;
5222 VARIANT name
, index
;
5225 hres
= IHTMLDocument2_get_all(doc
, &col
);
5226 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5227 ok(col
!= NULL
, "col == NULL\n");
5228 if(FAILED(hres
) || !col
)
5231 V_VT(&index
) = VT_EMPTY
;
5232 V_VT(&name
) = VT_BSTR
;
5233 V_BSTR(&name
) = a2bstr(id
);
5235 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5236 IHTMLElementCollection_Release(col
);
5237 SysFreeString(V_BSTR(&name
));
5238 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5239 if(!expect_success
) {
5240 ok(disp
== NULL
, "disp != NULL\n");
5244 ok(disp
!= NULL
, "disp == NULL\n");
5248 elem
= get_elem_iface((IUnknown
*)disp
);
5249 IDispatch_Release(disp
);
5254 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5256 IHTMLDocument3
*doc3
;
5261 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5262 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5265 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5267 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5269 IHTMLDocument3_Release(doc3
);
5274 static void test_select_elem(IHTMLSelectElement
*select
)
5276 IDispatch
*disp
, *disp2
;
5277 VARIANT name
, index
;
5280 test_select_type(select
, "select-one");
5281 test_select_length(select
, 2);
5282 test_select_selidx(select
, 0);
5283 test_select_put_selidx(select
, 1);
5285 test_select_set_value(select
, "val1");
5286 test_select_value(select
, "val1");
5288 test_select_size(select
, 0);
5289 test_select_set_size(select
, 1, S_OK
);
5290 test_select_size(select
, 1);
5292 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5293 test_select_size(select
, 1);
5294 test_select_set_size(select
, 3, S_OK
);
5295 test_select_size(select
, 3);
5297 test_select_name(select
, NULL
);
5298 test_select_set_name(select
, "select-name");
5299 test_select_name(select
, "select-name");
5300 test_select_form_notfound(select
);
5302 test_select_get_disabled(select
, VARIANT_FALSE
);
5303 test_select_set_disabled(select
, VARIANT_TRUE
);
5304 test_select_set_disabled(select
, VARIANT_FALSE
);
5307 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5308 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5309 ok(disp
!= NULL
, "options == NULL\n");
5310 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5311 IDispatch_Release(disp
);
5313 V_VT(&index
) = VT_EMPTY
;
5314 V_VT(&name
) = VT_I4
;
5316 disp
= (void*)0xdeadbeef;
5317 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5318 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5319 ok(!disp
, "disp = %p\n", disp
);
5322 disp
= (void*)0xdeadbeef;
5323 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5324 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5325 ok(!disp
, "disp = %p\n", disp
);
5328 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5329 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5332 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5333 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5334 ok(disp
!= NULL
, "disp = NULL\n");
5335 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5337 V_VT(&index
) = VT_I4
;
5340 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5341 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5342 ok(disp2
!= NULL
, "disp = NULL\n");
5343 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5344 IDispatch_Release(disp2
);
5345 IDispatch_Release(disp
);
5347 test_select_multiple(select
, VARIANT_FALSE
);
5348 test_select_set_multiple(select
, VARIANT_TRUE
);
5349 test_select_remove(select
);
5352 static void test_form_item(IHTMLElement
*elem
)
5354 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5355 IDispatch
*disp
, *disp2
;
5356 VARIANT name
, index
;
5359 V_VT(&index
) = VT_EMPTY
;
5360 V_VT(&name
) = VT_I4
;
5362 disp
= (void*)0xdeadbeef;
5363 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5364 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5365 ok(!disp
, "disp = %p\n", disp
);
5368 disp
= (void*)0xdeadbeef;
5369 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5370 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5371 ok(!disp
, "disp = %p\n", disp
);
5374 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5375 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5378 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5379 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5380 ok(disp
!= NULL
, "disp = NULL\n");
5381 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5383 V_VT(&index
) = VT_I4
;
5386 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5387 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5388 ok(disp2
!= NULL
, "disp = NULL\n");
5389 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5390 IDispatch_Release(disp2
);
5391 IDispatch_Release(disp
);
5394 static void test_create_option_elem(IHTMLDocument2
*doc
)
5396 IHTMLOptionElement
*option
;
5398 option
= create_option_elem(doc
, "test text", "test value");
5400 test_option_put_text(option
, "new text");
5401 test_option_put_value(option
, "new value");
5402 test_option_get_index(option
, 0);
5403 test_option_defaultSelected_property(option
);
5404 test_option_put_selected(option
, VARIANT_TRUE
);
5405 test_option_put_selected(option
, VARIANT_FALSE
);
5407 IHTMLOptionElement_Release(option
);
5410 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5412 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5413 IHTMLFormElement
*form
;
5416 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5417 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5419 hres
= IHTMLOptionElement_get_form(option
, &form
);
5420 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5421 ok(form
!= NULL
, "form == NULL\n");
5423 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5425 IHTMLOptionElement_Release(option
);
5426 IHTMLFormElement_Release(form
);
5429 static void test_create_img_elem(IHTMLDocument2
*doc
)
5431 IHTMLImgElement
*img
;
5433 img
= create_img_elem(doc
, 10, 15);
5436 test_img_put_width(img
, 5);
5437 test_img_put_height(img
, 20);
5439 IHTMLImgElement_Release(img
);
5443 img
= create_img_elem(doc
, -1, -1);
5446 test_img_put_width(img
, 5);
5447 test_img_put_height(img
, 20);
5449 IHTMLImgElement_Release(img
);
5453 #define test_doc_selection_type(a,b) _test_doc_selection_type(__LINE__,a,b)
5454 static void _test_doc_selection_type(unsigned line
, IHTMLDocument2
*doc
, const char *type
)
5456 IHTMLSelectionObject2
*selection2
;
5457 IHTMLSelectionObject
*selection
;
5461 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5462 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5464 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5465 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5466 ok_(__FILE__
,line
)(!strcmp_wa(str
, type
), "type = %s, expected %s\n", wine_dbgstr_w(str
), type
);
5469 hres
= IHTMLSelectionObject_QueryInterface(selection
, &IID_IHTMLSelectionObject2
, (void**)&selection2
);
5470 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLSelectionObject2 iface: %08x\n", hres
);
5472 IHTMLSelectionObject_Release(selection
);
5474 hres
= IHTMLSelectionObject2_get_typeDetail(selection2
, &str
);
5475 ok_(__FILE__
,line
)(hres
== S_OK
, "get_typeDetail failed: %08x\n", hres
);
5476 ok_(__FILE__
,line
)(!strcmp_wa(str
, "undefined"), "typeDetail = %s\n", wine_dbgstr_w(str
));
5479 IHTMLSelectionObject2_Release(selection2
);
5482 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5483 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5485 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5486 IHTMLElement
*ret_elem
= NULL
;
5487 BSTR str
= a2bstr(where
);
5490 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5491 IHTMLElement2_Release(elem2
);
5493 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5494 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5495 IHTMLElement_Release(ret_elem
);
5498 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5500 IHTMLElement
*elem
, *elem2
;
5502 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5503 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5505 elem
= test_create_elem(doc
, "BR");
5506 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5507 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5508 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5509 IHTMLElement_Release(elem
);
5511 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5513 elem
= test_create_elem(doc
, "BR");
5514 insert_adjacent_elem(parent
, "beforeend", elem
);
5516 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5518 elem2
= test_create_elem(doc
, "DIV");
5519 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5520 IHTMLElement_Release(elem2
);
5521 IHTMLElement_Release(elem
);
5523 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5526 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5528 IHTMLBodyElement
*body
;
5529 IHTMLTxtRange
*range
;
5533 elem
= doc_get_body(doc
);
5534 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5535 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5536 IHTMLElement_Release(elem
);
5538 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5539 IHTMLBodyElement_Release(body
);
5540 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5545 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5546 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5551 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5552 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5557 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5558 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5559 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5561 BSTR str
= a2bstr(how
);
5564 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5565 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5569 static void test_txtrange(IHTMLDocument2
*doc
)
5571 IHTMLTxtRange
*body_range
, *range
, *range2
;
5572 IHTMLSelectionObject
*selection
;
5573 IDispatch
*disp_range
;
5577 body_range
= test_create_body_range(doc
);
5579 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, NULL
, "[object]");
5581 test_range_text(body_range
, "test abc 123\r\nit's text");
5583 range
= range_duplicate(body_range
);
5584 range2
= range_duplicate(body_range
);
5586 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5588 test_range_text(range
, "test abc 123\r\nit's text");
5589 test_range_text(body_range
, "test abc 123\r\nit's text");
5591 test_range_collapse(range
, TRUE
);
5592 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5593 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5594 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5595 IHTMLTxtRange_Release(range2
);
5597 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5598 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5599 test_range_move(range
, characterW
, 2, 2);
5600 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5602 test_range_collapse(range
, FALSE
);
5603 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5605 test_range_collapse(range
, FALSE
);
5606 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5607 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5608 test_range_move(range
, characterW
, 2, 2);
5609 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5610 test_range_moveend(range
, characterW
, -5, -5);
5611 test_range_text(range
, NULL
);
5612 test_range_moveend(range
, characterW
, 3, 3);
5613 test_range_text(range
, "c 1");
5614 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5615 test_range_collapse(range
, TRUE
);
5616 test_range_move(range
, characterW
, 4, 4);
5617 test_range_moveend(range
, characterW
, 1, 1);
5618 test_range_text(range
, " ");
5619 test_range_move(range
, wordW
, 1, 1);
5620 test_range_moveend(range
, characterW
, 2, 2);
5621 test_range_text(range
, "ab");
5623 IHTMLTxtRange_Release(range
);
5625 range
= range_duplicate(body_range
);
5627 test_range_text(range
, "test abc 123\r\nit's text");
5628 test_range_move(range
, characterW
, 3, 3);
5629 test_range_moveend(range
, characterW
, 1, 1);
5630 test_range_text(range
, "t");
5631 test_range_moveend(range
, characterW
, 3, 3);
5632 test_range_text(range
, "t ab");
5633 test_range_moveend(range
, characterW
, -2, -2);
5634 test_range_text(range
, "t ");
5635 test_range_move(range
, characterW
, 6, 6);
5636 test_range_moveend(range
, characterW
, 3, 3);
5637 test_range_text(range
, "123");
5638 test_range_moveend(range
, characterW
, 2, 2);
5639 test_range_text(range
, "123\r\ni");
5641 IHTMLTxtRange_Release(range
);
5643 range
= range_duplicate(body_range
);
5645 test_range_move(range
, wordW
, 1, 1);
5646 test_range_moveend(range
, characterW
, 2, 2);
5647 test_range_text(range
, "ab");
5649 test_range_move(range
, characterW
, -2, -2);
5650 test_range_moveend(range
, characterW
, 2, 2);
5651 test_range_text(range
, "t ");
5653 test_range_move(range
, wordW
, 3, 3);
5654 test_range_move(range
, wordW
, -2, -2);
5655 test_range_moveend(range
, characterW
, 2, 2);
5656 test_range_text(range
, "ab");
5658 test_range_move(range
, characterW
, -6, -5);
5659 test_range_moveend(range
, characterW
, -1, 0);
5660 test_range_moveend(range
, characterW
, -6, 0);
5661 test_range_move(range
, characterW
, 2, 2);
5662 test_range_moveend(range
, characterW
, 2, 2);
5663 test_range_text(range
, "st");
5664 test_range_moveend(range
, characterW
, -6, -4);
5665 test_range_moveend(range
, characterW
, 2, 2);
5667 IHTMLTxtRange_Release(range
);
5669 range
= range_duplicate(body_range
);
5671 test_range_move(range
, wordW
, 2, 2);
5672 test_range_moveend(range
, characterW
, 2, 2);
5673 test_range_text(range
, "12");
5675 test_range_move(range
, characterW
, 15, 14);
5676 test_range_move(range
, characterW
, -2, -2);
5677 test_range_moveend(range
, characterW
, 3, 2);
5678 test_range_text(range
, "t");
5679 test_range_moveend(range
, characterW
, -1, -1);
5680 test_range_text(range
, "t");
5681 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5682 test_range_move(range
, characterW
, -2, -2);
5683 test_range_moveend(range
, characterW
, 2, 2);
5684 test_range_text(range
, "s ");
5685 test_range_move(range
, characterW
, 100, 7);
5686 test_range_move(range
, wordW
, 1, 0);
5687 test_range_move(range
, characterW
, -2, -2);
5688 test_range_moveend(range
, characterW
, 3, 2);
5689 test_range_text(range
, "t");
5691 IHTMLTxtRange_Release(range
);
5693 range
= range_duplicate(body_range
);
5695 test_range_collapse(range
, TRUE
);
5696 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5697 test_range_put_text(range
, "word");
5698 test_range_text(body_range
, "wordabc 123\r\nit's text");
5699 test_range_text(range
, NULL
);
5700 test_range_moveend(range
, characterW
, 3, 3);
5701 test_range_text(range
, "abc");
5702 test_range_movestart(range
, characterW
, -2, -2);
5703 test_range_text(range
, "rdabc");
5704 test_range_movestart(range
, characterW
, 3, 3);
5705 test_range_text(range
, "bc");
5706 test_range_movestart(range
, characterW
, 4, 4);
5707 test_range_text(range
, NULL
);
5708 test_range_movestart(range
, characterW
, -3, -3);
5709 test_range_text(range
, "c 1");
5710 test_range_movestart(range
, characterW
, -7, -6);
5711 test_range_text(range
, "wordabc 1");
5712 test_range_movestart(range
, characterW
, 100, 22);
5713 test_range_text(range
, NULL
);
5715 IHTMLTxtRange_Release(range
);
5717 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5718 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5720 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, NULL
, "[object]");
5721 test_ifaces((IUnknown
*)selection
, selection_iids
);
5723 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5724 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5725 IHTMLSelectionObject_Release(selection
);
5727 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5728 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5729 IDispatch_Release(disp_range
);
5731 test_range_text(range
, NULL
);
5732 test_range_moveend(range
, characterW
, 3, 3);
5733 test_range_text(range
, "wor");
5734 test_range_parent(range
, ET_BODY
);
5735 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5736 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5737 test_range_move(range
, characterW
, 3, 3);
5738 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5739 test_range_moveend(range
, characterW
, -4, -4);
5740 test_range_put_text(range
, "abc def ");
5741 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5742 test_range_move(range
, wordW
, 1, 1);
5743 test_range_movestart(range
, characterW
, -1, -1);
5744 test_range_text(range
, " ");
5745 test_range_move(range
, wordW
, 1, 1);
5746 test_range_moveend(range
, characterW
, 3, 3);
5747 test_range_text(range
, "def");
5748 test_range_put_text(range
, "xyz");
5749 test_range_moveend(range
, characterW
, 1, 1);
5750 test_range_move(range
, wordW
, 1, 1);
5751 test_range_moveend(range
, characterW
, 2, 2);
5752 test_range_text(range
, "ab");
5754 body
= doc_get_body(doc
);
5756 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5757 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5759 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5760 test_range_parent(range
, ET_BODY
);
5762 test_range_move(range
, wordW
, 1, 1);
5763 test_range_moveend(range
, characterW
, 12, 12);
5764 test_range_text(range
, "xyz abc 123");
5766 test_range_collapse(range
, VARIANT_TRUE
);
5767 test_range_paste_html(range
, "<br>paste<br>");
5768 test_range_text(range
, NULL
);
5770 test_range_moveend(range
, characterW
, 3, 3);
5771 test_range_text(range
, "xyz");
5773 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5774 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5776 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5778 test_range_move(range
, wordW
, 2, 2);
5779 test_range_collapse(range
, VARIANT_TRUE
);
5780 test_range_moveend(range
, characterW
, 5, 5);
5781 test_range_text(range
, "paste");
5783 range2
= range_duplicate(range
);
5785 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5786 test_range_text(range
, "abc \r\npaste");
5788 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5789 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5791 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5792 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5794 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5795 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5796 test_range_text(range
, "abc ");
5798 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5799 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5801 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5802 test_range_text(range
, "abc ");
5804 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5806 hres
= IHTMLTxtRange_select(range
);
5807 ok(hres
== S_OK
, "select failed: %08x\n", hres
);
5809 test_doc_selection_type(doc
, "Text");
5811 IHTMLTxtRange_Release(range
);
5812 IHTMLTxtRange_Release(range2
);
5813 IHTMLTxtRange_Release(body_range
);
5814 IHTMLElement_Release(body
);
5818 static void test_txtrange2(IHTMLDocument2
*doc
)
5820 IHTMLTxtRange
*range
;
5822 range
= test_create_body_range(doc
);
5824 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5825 test_range_move(range
, characterW
, 5, 5);
5826 test_range_moveend(range
, characterW
, 1, 1);
5827 test_range_text(range
, "2");
5828 test_range_move(range
, characterW
, -3, -3);
5829 test_range_moveend(range
, characterW
, 3, 3);
5830 test_range_text(range
, "c\r\n\r\n1");
5831 test_range_collapse(range
, VARIANT_FALSE
);
5832 test_range_moveend(range
, characterW
, 4, 4);
5833 test_range_text(range
, "23");
5834 test_range_moveend(range
, characterW
, 1, 1);
5835 test_range_text(range
, "23\r\n\r\n\r\nd");
5836 test_range_moveend(range
, characterW
, -1, -1);
5837 test_range_text(range
, "23");
5838 test_range_moveend(range
, characterW
, -1, -1);
5839 test_range_text(range
, "23");
5840 test_range_moveend(range
, characterW
, -2, -2);
5841 test_range_text(range
, "2");
5843 IHTMLTxtRange_Release(range
);
5846 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5847 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5849 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5853 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5854 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5855 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5858 IHTMLDocument5_Release(doc
);
5861 static void test_location(IHTMLDocument2
*doc
)
5863 IHTMLLocation
*location
, *location2
;
5864 IHTMLWindow2
*window
;
5869 hres
= IHTMLDocument2_get_location(doc
, &location
);
5870 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5872 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5873 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5875 ok(location
== location2
, "location != location2\n");
5876 IHTMLLocation_Release(location2
);
5878 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5879 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5881 hres
= IHTMLWindow2_get_location(window
, &location2
);
5882 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5883 ok(location
== location2
, "location != location2\n");
5884 IHTMLLocation_Release(location2
);
5886 test_ifaces((IUnknown
*)location
, location_iids
);
5887 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, NULL
, "about:blank");
5889 hres
= IHTMLLocation_get_pathname(location
, &str
);
5890 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5891 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5894 hres
= IHTMLLocation_get_href(location
, NULL
);
5895 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5897 hres
= IHTMLLocation_get_href(location
, &str
);
5898 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5899 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5902 ref
= IHTMLLocation_Release(location
);
5903 ok(!ref
, "location should be destroyed here\n");
5906 static void test_plugins_col(IHTMLDocument2
*doc
)
5908 IHTMLPluginsCollection
*col
, *col2
;
5909 IHTMLWindow2
*window
;
5915 window
= get_doc_window(doc
);
5916 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5917 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5918 IHTMLWindow2_Release(window
);
5920 hres
= IOmNavigator_get_plugins(nav
, &col
);
5921 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5923 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5924 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5925 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5926 IHTMLPluginsCollection_Release(col2
);
5928 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, NULL
, "[object]");
5931 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5932 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5933 ok(!len
, "length = %d\n", len
);
5935 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5936 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5938 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5939 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5941 ref
= IHTMLPluginsCollection_Release(col
);
5942 ok(!ref
, "ref=%d\n", ref
);
5944 IOmNavigator_Release(nav
);
5947 static void test_mime_types_col(IOmNavigator
*nav
)
5949 IHTMLMimeTypesCollection
*col
, *col2
;
5954 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5955 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5957 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5958 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5959 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5960 IHTMLMimeTypesCollection_Release(col2
);
5962 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, NULL
, "[object]");
5964 length
= 0xdeadbeef;
5965 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5966 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5967 ok(!length
, "length = %d\n", length
);
5969 ref
= IHTMLMimeTypesCollection_Release(col
);
5970 ok(!ref
, "ref=%d\n", ref
);
5973 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5974 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5976 BSTR str
= (void*)0xdeadbeef;
5977 IHTMLFrameBase
*fbase
;
5980 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5981 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5983 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5984 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5986 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5988 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5991 IHTMLFrameBase_Release(fbase
);
5994 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5995 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5997 IHTMLFrameBase
*fbase
;
6001 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6002 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6004 str
= name
? a2bstr(name
) : NULL
;
6005 hres
= IHTMLFrameBase_put_name(fbase
, str
);
6006 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
6009 _test_framebase_name(line
, elem
, name
);
6010 IHTMLFrameBase_Release(fbase
);
6013 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
6014 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
6016 BSTR str
= (void*)0xdeadbeef;
6017 IHTMLFrameBase
*fbase
;
6020 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6021 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6023 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
6024 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
6026 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
6028 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
6031 IHTMLFrameBase_Release(fbase
);
6034 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
6035 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6040 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
6041 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
6042 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
6044 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6046 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6050 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
6051 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6057 V_BSTR(&v
) = a2bstr(val
);
6058 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
6059 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
6063 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
6064 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6069 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
6070 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
6071 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
6073 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6075 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6079 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
6080 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6086 V_BSTR(&v
) = a2bstr(val
);
6087 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
6088 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
6092 static void test_framebase(IUnknown
*unk
)
6094 IHTMLFrameBase
*fbase
;
6098 /* get/put scrolling */
6099 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6100 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6102 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6103 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6104 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6108 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6109 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6112 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6113 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6114 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6117 str
= a2bstr("junk");
6118 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6119 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6120 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6123 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6124 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6125 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6128 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6129 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6130 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6133 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6134 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
6137 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6138 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6139 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6142 test_framebase_marginheight(fbase
, NULL
);
6143 set_framebase_marginheight(fbase
, "1px");
6144 test_framebase_marginheight(fbase
, "1");
6146 test_framebase_marginwidth(fbase
, NULL
);
6147 set_framebase_marginwidth(fbase
, "2px");
6148 test_framebase_marginwidth(fbase
, "2");
6150 IHTMLFrameBase_Release(fbase
);
6153 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6154 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6159 if(pLCIDToLocaleName
) {
6160 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
6161 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
6162 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6164 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6165 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6169 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6170 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6172 IHTMLElementCollection
*col
;
6176 hres
= IHTMLTable_get_rows(table
, &col
);
6177 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6178 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6179 if (hres
!= S_OK
|| col
== NULL
)
6181 hres
= IHTMLElementCollection_get_length(col
, &len
);
6182 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6183 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
6185 IHTMLElementCollection_Release(col
);
6188 static void test_navigator(IHTMLDocument2
*doc
)
6190 IHTMLWindow2
*window
;
6191 IOmNavigator
*navigator
, *navigator2
;
6199 static const WCHAR v40
[] = {'4','.','0'};
6201 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6202 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6204 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6205 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6206 ok(navigator
!= NULL
, "navigator == NULL\n");
6207 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, NULL
, "[object]");
6209 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6210 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6211 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6212 IOmNavigator_Release(navigator2
);
6214 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6215 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6216 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6217 IOmNavigator_Release(navigator2
);
6219 IHTMLWindow2_Release(window
);
6221 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6222 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6223 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6224 SysFreeString(bstr
);
6227 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6228 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6229 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6230 SysFreeString(bstr
);
6233 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6234 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6235 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6236 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6237 SysFreeString(bstr
);
6240 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6241 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6242 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6243 SysFreeString(bstr
);
6246 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6247 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6248 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6249 SysFreeString(bstr
);
6252 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6253 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6254 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6255 SysFreeString(bstr
);
6257 if (pGetUserDefaultUILanguage
)
6260 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6261 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6262 test_language_string(bstr
, pGetUserDefaultUILanguage());
6263 SysFreeString(bstr
);
6266 win_skip("GetUserDefaultUILanguage not available\n");
6269 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6270 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6271 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6272 SysFreeString(bstr
);
6274 hres
= IOmNavigator_toString(navigator
, NULL
);
6275 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6278 hres
= IOmNavigator_toString(navigator
, &bstr
);
6279 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6280 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6281 SysFreeString(bstr
);
6284 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6285 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6286 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6289 hres
= ObtainUserAgentString(0, buf
, &size
);
6290 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6293 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6294 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6295 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6296 SysFreeString(bstr
);
6298 if(!strncmp(buf
, "Mozilla/", 8)) {
6300 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6301 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6302 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6303 SysFreeString(bstr
);
6305 skip("nonstandard user agent\n");
6309 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6310 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6311 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6312 SysFreeString(bstr
);
6314 test_mime_types_col(navigator
);
6316 ref
= IOmNavigator_Release(navigator
);
6317 ok(!ref
, "navigator should be destroyed here\n");
6320 static void test_screen(IHTMLWindow2
*window
)
6322 IHTMLScreen
*screen
, *screen2
;
6323 IDispatchEx
*dispex
;
6330 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6331 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6332 ok(screen
!= NULL
, "screen == NULL\n");
6335 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6336 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6337 ok(screen2
!= NULL
, "screen == NULL\n");
6338 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6339 IHTMLScreen_Release(screen2
);
6341 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6342 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6343 if(SUCCEEDED(hres
)) {
6344 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, NULL
, "[object]");
6345 IDispatchEx_Release(dispex
);
6348 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6350 exl
= GetDeviceCaps(hdc
, HORZRES
);
6352 hres
= IHTMLScreen_get_width(screen
, &l
);
6353 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6354 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6356 exl
= GetDeviceCaps(hdc
, VERTRES
);
6358 hres
= IHTMLScreen_get_height(screen
, &l
);
6359 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6360 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6362 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6364 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6365 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6366 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6370 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6373 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6374 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6375 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6378 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6379 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6380 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6382 IHTMLScreen_Release(screen
);
6385 static void test_default_selection(IHTMLDocument2
*doc
)
6387 IHTMLSelectionObject
*selection
;
6388 IHTMLTxtRange
*range
;
6392 test_doc_selection_type(doc
, "None");
6394 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6395 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6397 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6398 IHTMLSelectionObject_Release(selection
);
6399 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6401 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6402 IDispatch_Release(disp
);
6403 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6405 test_range_text(range
, NULL
);
6406 IHTMLTxtRange_Release(range
);
6409 static void test_doc_dir(IHTMLDocument2
*doc2
)
6411 IHTMLDocument3
*doc
= get_doc3_iface(doc2
);
6415 dir
= (BSTR
)0xdeadbeef;
6416 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6417 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6418 ok(!dir
, "dir = %s\n", wine_dbgstr_w(dir
));
6420 dir
= a2bstr("rtl");
6421 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6422 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6426 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6427 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6428 ok(!strcmp_wa(dir
, "rtl"), "dir = %s\n", wine_dbgstr_w(dir
));
6431 dir
= a2bstr("ltr");
6432 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6433 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6437 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6438 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6439 ok(!strcmp_wa(dir
, "ltr"), "dir = %s\n", wine_dbgstr_w(dir
));
6442 IHTMLDocument3_Release(doc
);
6445 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6447 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6448 IHTMLUniqueName
*unique_name
;
6454 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6456 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6457 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6458 ok(SysStringLen(id
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6460 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6461 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6462 ok(SysStringLen(id2
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6464 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6466 id
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6467 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6468 id2
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6469 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6474 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6475 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6477 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6478 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6480 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6481 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6482 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6484 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6485 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6486 ok(num
, "num = 0\n");
6488 sprintf(buf
, "ms__id%u", num
);
6489 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6494 IHTMLUniqueName_Release(unique_name
);
6495 IHTMLDocument3_Release(doc3
);
6498 static void test_doc_elem(IHTMLDocument2
*doc
)
6500 IHTMLDocument2
*doc_node
, *owner_doc
;
6502 IHTMLDocument3
*doc3
;
6506 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6507 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6509 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6510 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6511 ok(!strcmp_wa(bstr
, "[object]"),
6512 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6513 SysFreeString(bstr
);
6515 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6516 IHTMLDocument3_Release(doc3
);
6517 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6519 test_node_name((IUnknown
*)elem
, "HTML");
6520 test_elem_tag((IUnknown
*)elem
, "HTML");
6521 test_elem_set_outertext_fail(elem
);
6523 doc_node
= get_doc_node(doc
);
6524 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6525 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6526 IHTMLDocument2_Release(owner_doc
);
6528 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6529 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6530 IHTMLDocument2_Release(doc_node
);
6532 test_elem_client_rect((IUnknown
*)elem
);
6533 test_unique_id(doc
, elem
);
6536 IHTMLElement_Release(elem
);
6539 static void test_default_body(IHTMLBodyElement
*body
)
6546 bstr
= (void*)0xdeadbeef;
6547 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6548 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6549 ok(bstr
== NULL
, "bstr != NULL\n");
6551 l
= elem_get_scroll_height((IUnknown
*)body
);
6552 ok(l
!= -1, "scrollHeight == -1\n");
6553 l
= elem_get_scroll_width((IUnknown
*)body
);
6554 ok(l
!= -1, "scrollWidth == -1\n");
6555 l
= elem_get_scroll_top((IUnknown
*)body
);
6556 ok(!l
, "scrollTop = %d\n", l
);
6557 elem_get_scroll_left((IUnknown
*)body
);
6559 test_elem_dir((IUnknown
*)body
, NULL
);
6560 set_elem_dir((IUnknown
*)body
, "ltr");
6562 /* get_text tests */
6563 hres
= IHTMLBodyElement_get_text(body
, &v
);
6564 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6565 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6566 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6568 /* get_text - Invalid Text */
6570 V_BSTR(&v
) = a2bstr("Invalid");
6571 hres
= IHTMLBodyElement_put_text(body
, v
);
6572 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6576 hres
= IHTMLBodyElement_get_text(body
, &v
);
6577 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6578 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6579 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6582 /* get_text - Valid Text */
6584 V_BSTR(&v
) = a2bstr("#FF0000");
6585 hres
= IHTMLBodyElement_put_text(body
, v
);
6586 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6590 hres
= IHTMLBodyElement_get_text(body
, &v
);
6591 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6592 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6593 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6597 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6598 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6603 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6604 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6605 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6609 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6610 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6612 BSTR str
= a2bstr(val
);
6615 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6616 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6619 _test_body_scroll(line
, body
, val
);
6622 static void test_body_funs(IHTMLBodyElement
*body
)
6624 VARIANT vbg
, vDefaultbg
;
6627 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6628 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6629 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6630 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6632 V_VT(&vbg
) = VT_BSTR
;
6633 V_BSTR(&vbg
) = a2bstr("red");
6634 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6635 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6638 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6639 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6640 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6641 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6644 /* Restore Original */
6645 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6646 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6647 VariantClear(&vDefaultbg
);
6649 test_body_scroll(body
, NULL
);
6650 set_body_scroll(body
, "yes");
6651 set_body_scroll(body
, "no");
6652 set_body_scroll(body
, "auto");
6655 static void test_history(IHTMLWindow2
*window
)
6657 IOmHistory
*history
, *history2
;
6661 hres
= IHTMLWindow2_get_history(window
, &history
);
6662 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6663 ok(history
!= NULL
, "history = NULL\n");
6665 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, NULL
, "[object]");
6668 hres
= IHTMLWindow2_get_history(window
, &history2
);
6669 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6670 ok(history2
!= NULL
, "history2 = NULL\n");
6671 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6673 IOmHistory_Release(history2
);
6674 IOmHistory_Release(history
);
6677 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6681 IHTMLXMLHttpRequestFactory
*factory
;
6682 IHTMLXMLHttpRequest
*xml
;
6684 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6685 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6686 ok(V_VT(&var
) == VT_DISPATCH
|| broken(V_VT(&var
) == VT_EMPTY
), "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6688 if (V_VT(&var
) == VT_EMPTY
) {
6689 win_skip("Native XMLHTTP support is missing or disabled.\n");
6694 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6695 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6696 ok(factory
!= NULL
, "factory == NULL\n");
6699 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6700 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6701 ok(xml
!= NULL
, "xml == NULL\n");
6703 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, &CLSID_HTMLXMLHttpRequest
, "[object]");
6705 IHTMLXMLHttpRequest_Release(xml
);
6706 IHTMLXMLHttpRequestFactory_Release(factory
);
6710 static void test_window(IHTMLDocument2
*doc
)
6712 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6713 IHTMLWindow5
*window5
;
6714 IHTMLDocument2
*doc2
= NULL
;
6721 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6722 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6723 test_ifaces((IUnknown
*)window
, window_iids
);
6724 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6726 IUnknown_Release(unk
);
6728 win_skip("IID_ITravelLogClient not supported\n");
6730 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, &CLSID_HTMLWindow2
, "[object]");
6732 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6733 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6734 ok(doc2
!= NULL
, "doc2 == NULL\n");
6737 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6738 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6741 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6742 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6744 unk
= (void*)0xdeadbeef;
6745 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6746 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6747 ok(!unk
, "unk = %p\n", unk
);
6749 IHTMLDocument2_Release(doc2
);
6751 hres
= IHTMLWindow2_get_window(window
, &window2
);
6752 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6753 ok(window2
!= NULL
, "window2 == NULL\n");
6755 hres
= IHTMLWindow2_get_self(window
, &self
);
6756 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6757 ok(window2
!= NULL
, "self == NULL\n");
6759 ok(self
== window2
, "self != window2\n");
6761 IHTMLWindow2_Release(window2
);
6764 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6765 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6766 ok(disp
== (void*)window
, "disp != window\n");
6767 IDispatch_Release(disp
);
6769 hres
= IHTMLWindow2_toString(window
, NULL
);
6770 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6773 hres
= IHTMLWindow2_toString(window
, &str
);
6774 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6775 ok(!strcmp_wa(str
, "[object]") ||
6776 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6779 V_VT(&v
) = VT_ERROR
;
6780 hres
= IHTMLWindow2_get_opener(window
, &v
);
6781 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6782 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6785 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6786 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6787 ok(parent
!= NULL
, "parent == NULL\n");
6788 ok(parent
== self
, "parent != window\n");
6789 IHTMLWindow2_Release(parent
);
6790 IHTMLWindow2_Release(self
);
6792 test_window_name(window
, NULL
);
6793 set_window_name(window
, "test");
6794 test_window_length(window
, 0);
6795 test_screen(window
);
6796 test_window_status(window
);
6797 set_window_status(window
, "Test!");
6798 test_history(window
);
6800 hres
= IHTMLWindow2_moveBy(window
, 0, 0);
6801 ok(hres
== S_FALSE
, "moveBy failed: %08x\n", hres
);
6803 hres
= IHTMLWindow2_resizeBy(window
, 0, 0);
6804 ok(hres
== S_FALSE
, "resizeBy failed: %08x\n", hres
);
6806 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6807 if(SUCCEEDED(hres
)) {
6808 ok(window5
!= NULL
, "window5 == NULL\n");
6809 test_xmlhttprequest(window5
);
6810 IHTMLWindow5_Release(window5
);
6812 win_skip("IHTMLWindow5 not supported!\n");
6815 IHTMLWindow2_Release(window
);
6818 static void test_dom_implementation(IHTMLDocument2
*doc
)
6820 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6821 IHTMLDOMImplementation
*dom_implementation
;
6827 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6828 IHTMLDocument5_Release(doc5
);
6829 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6830 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6832 str
= a2bstr("test");
6834 V_BSTR(&v
) = a2bstr("1.0");
6836 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6839 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6840 ok(!b
, "hasFeature returned %x\n", b
);
6842 IHTMLDOMImplementation_Release(dom_implementation
);
6845 static void test_xhr(IHTMLDocument2
*doc
)
6847 IHTMLWindow2
*window
;
6848 IDispatchEx
*dispex
;
6853 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6854 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6856 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6857 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6859 str
= a2bstr("XMLHttpRequest");
6860 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6861 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6864 IHTMLWindow2_Release(window
);
6867 static void test_defaults(IHTMLDocument2
*doc
)
6869 IHTMLStyleSheetsCollection
*stylesheetcol
;
6870 IHTMLCurrentStyle
*cstyle
;
6871 IHTMLBodyElement
*body
;
6872 IHTMLElement2
*elem2
;
6880 IHTMLElementCollection
*collection
;
6882 elem
= doc_get_body(doc
);
6884 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6885 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6887 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6888 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6891 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6892 IHTMLElementCollection_Release(collection
);
6895 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6896 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6898 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6899 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6902 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6903 IHTMLElementCollection_Release(collection
);
6906 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6907 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6909 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6910 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6913 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6914 IHTMLElementCollection_Release(collection
);
6917 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6918 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6920 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6921 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6924 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6925 IHTMLElementCollection_Release(collection
);
6928 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6929 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6931 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6932 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6935 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6936 IHTMLElementCollection_Release(collection
);
6941 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6942 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6943 test_default_body(body
);
6944 test_body_funs(body
);
6945 IHTMLBodyElement_Release(body
);
6947 test_elem_set_outertext_fail(elem
);
6949 test_elem_istextedit(elem
, VARIANT_TRUE
);
6951 hres
= IHTMLElement_get_style(elem
, &style
);
6952 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6954 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, NULL
, "[object]");
6955 test_ifaces((IUnknown
*)style
, style_iids
);
6956 IHTMLStyle_Release(style
);
6959 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6960 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6961 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6965 test_compatmode(doc
, "BackCompat");
6967 test_navigator(doc
);
6968 test_plugins_col(doc
);
6970 elem2
= get_elem2_iface((IUnknown
*)elem
);
6971 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6972 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6973 if(SUCCEEDED(hres
)) {
6976 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, NULL
, "[object]");
6977 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6979 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6981 IUnknown_Release(unk
);
6984 /*IE6 doesn't have interface */
6985 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6988 IHTMLCurrentStyle_Release(cstyle
);
6990 IHTMLElement2_Release(elem2
);
6992 IHTMLElement_Release(elem
);
6994 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6995 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6998 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6999 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7000 ok(l
== 0, "length = %d\n", l
);
7002 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
7004 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
7005 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
7007 str
= a2bstr("xxx");
7009 V_VT(&v
) = VT_EMPTY
;
7010 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7011 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
7012 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
7015 str
= a2bstr("respectvisibilityindesign");
7018 V_BOOL(&v
) = VARIANT_TRUE
;
7019 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7020 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
7023 test_default_selection(doc
);
7024 test_doc_title(doc
, "");
7025 test_dom_implementation(doc
);
7028 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
7029 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
7031 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7035 str
= (void*)0xdeadbeef;
7036 hres
= IHTMLButtonElement_get_name(button
, &str
);
7037 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7039 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
7041 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
7043 IHTMLButtonElement_Release(button
);
7046 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
7047 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
7049 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7050 BSTR str
= a2bstr(name
);
7053 hres
= IHTMLButtonElement_put_name(button
, str
);
7054 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7056 IHTMLButtonElement_Release(button
);
7058 _test_button_name(line
, elem
, name
);
7061 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
7062 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
7064 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7065 VARIANT_BOOL disabled
= 100;
7068 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
7069 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
7070 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
7071 IHTMLButtonElement_Release(button
);
7073 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
7076 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
7077 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
7079 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7082 hres
= IHTMLButtonElement_put_disabled(button
, b
);
7083 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
7084 IHTMLButtonElement_Release(button
);
7086 _test_button_get_disabled(line
, elem
, b
);
7089 #define test_button_type(a,b) _test_button_type(__LINE__,a,b)
7090 static void _test_button_type(unsigned line
, IHTMLElement
*elem
, const char *extype
)
7092 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7096 hres
= IHTMLButtonElement_get_type(button
, &str
);
7097 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7098 ok_(__FILE__
,line
)(!strcmp_wa(str
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(str
), extype
);
7101 IHTMLButtonElement_Release(button
);
7104 #define test_button_value(a,b) _test_button_value(__LINE__,a,b)
7105 static void _test_button_value(unsigned line
, IHTMLElement
*elem
, const char *exvalue
)
7107 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7111 hres
= IHTMLButtonElement_get_value(button
, &str
);
7112 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
7114 ok_(__FILE__
,line
)(!strcmp_wa(str
, exvalue
), "value = %s, expected %s\n", wine_dbgstr_w(str
), exvalue
);
7116 ok_(__FILE__
,line
)(!str
, "value = %s, expected NULL\n", wine_dbgstr_w(str
));
7119 IHTMLButtonElement_Release(button
);
7122 #define set_button_value(a,b) _set_button_value(__LINE__,a,b)
7123 static void _set_button_value(unsigned line
, IHTMLElement
*elem
, const char *value
)
7125 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7126 BSTR str
= a2bstr(value
);
7129 hres
= IHTMLButtonElement_put_value(button
, str
);
7130 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
7131 IHTMLButtonElement_Release(button
);
7134 _test_button_value(line
, elem
, value
);
7137 #define get_button_form(a) _get_button_form(__LINE__,a)
7138 static IHTMLFormElement
*_get_button_form(unsigned line
, IHTMLElement
*elem
)
7140 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7141 IHTMLFormElement
*form
;
7144 hres
= IHTMLButtonElement_get_form(button
, &form
);
7145 ok_(__FILE__
,line
)(hres
== S_OK
, "get_form failed: %08x\n", hres
);
7146 IHTMLButtonElement_Release(button
);
7151 static void test_button_elem(IHTMLElement
*elem
)
7153 IHTMLFormElement
*form
;
7155 test_button_name(elem
, NULL
);
7156 set_button_name(elem
, "button name");
7157 test_button_type(elem
, "submit");
7158 test_button_value(elem
, NULL
);
7159 set_button_value(elem
, "val");
7161 form
= get_button_form(elem
);
7162 ok(!form
, "form != NULL\n");
7164 test_elem_istextedit(elem
, VARIANT_TRUE
);
7167 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
7168 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
7169 IHTMLTableRow
*row
, LONG len
, const char *id
)
7171 IHTMLElementCollection
*col
;
7177 hres
= IHTMLTableRow_get_cells(row
, &col
);
7178 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7179 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
7181 hres
= IHTMLElementCollection_get_length(col
, &lval
);
7182 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
7183 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
7185 V_VT(&var
) = VT_BSTR
;
7186 V_BSTR(&var
) = a2bstr(id
);
7187 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
7188 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
7189 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
7192 IDispatch_Release(disp
);
7193 IHTMLElementCollection_Release(col
);
7196 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
7200 IHTMLTableCell
*cell
;
7202 hres
= IHTMLTableRow_deleteCell(row
, 0);
7203 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
7204 test_tr_possess(elem
, row
, 1, "td2");
7206 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
7207 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
7208 ok(disp
!= NULL
, "disp == NULL\n");
7209 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
7210 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
7211 ok(cell
!= NULL
, "cell == NULL\n");
7212 if (SUCCEEDED(hres
))
7213 IHTMLTableCell_Release(cell
);
7214 test_tr_possess(elem
, row
, 2, "td2");
7215 IDispatch_Release(disp
);
7218 static void test_tr_elem(IHTMLElement
*elem
)
7220 IHTMLElementCollection
*col
;
7225 VARIANT vbg
, vDefaultbg
;
7227 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
7229 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
7230 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7235 hres
= IHTMLTableRow_get_cells(row
, &col
);
7236 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7237 ok(col
!= NULL
, "get_cells returned NULL\n");
7239 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
7240 IHTMLElementCollection_Release(col
);
7242 bstr
= a2bstr("left");
7243 hres
= IHTMLTableRow_put_align(row
, bstr
);
7244 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7245 SysFreeString(bstr
);
7248 hres
= IHTMLTableRow_get_align(row
, &bstr
);
7249 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7250 ok(bstr
!= NULL
, "get_align returned NULL\n");
7251 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7252 SysFreeString(bstr
);
7254 bstr
= a2bstr("top");
7255 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
7256 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
7257 SysFreeString(bstr
);
7260 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
7261 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
7262 ok(bstr
!= NULL
, "get_valign returned NULL\n");
7263 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
7264 SysFreeString(bstr
);
7267 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
7268 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7269 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
7272 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
7273 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
7274 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
7276 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
7277 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7278 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7279 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7281 V_VT(&vbg
) = VT_BSTR
;
7282 V_BSTR(&vbg
) = a2bstr("red");
7283 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7284 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7287 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7288 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7289 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7290 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7294 V_I4(&vbg
) = 0xff0000;
7295 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7296 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7299 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7300 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7301 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7302 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7305 /* Restore Original */
7306 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
7307 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7308 VariantClear(&vDefaultbg
);
7310 test_tr_modify(elem
, row
);
7312 IHTMLTableRow_Release(row
);
7315 static void test_td_elem(IHTMLDocument2
*doc
, IHTMLElement
*div
)
7317 IHTMLTableCell
*cell
;
7322 VARIANT vbg
, vDefaultbg
;
7324 test_elem_set_innerhtml((IUnknown
*)div
,
7325 "<table id=\"tbl\"><tbody>"
7327 " <tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td><td></td></tr>"
7329 "</tbody></table>");
7331 elem
= get_doc_elem_by_id(doc
, "td1");
7332 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7333 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7334 IHTMLElement_Release(elem
);
7337 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7338 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7339 ok(!lval
, "Expected 0, got %d\n", lval
);
7341 str
= a2bstr("left");
7342 hres
= IHTMLTableCell_put_align(cell
, str
);
7343 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7347 hres
= IHTMLTableCell_get_align(cell
, &str
);
7348 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7349 ok(str
!= NULL
, "str is NULL\n");
7350 if (str
!= NULL
&& hres
== S_OK
) {
7351 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7355 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7356 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7357 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7358 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7360 V_VT(&vbg
) = VT_BSTR
;
7361 V_BSTR(&vbg
) = a2bstr("red");
7362 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7363 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7366 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7367 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7368 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7369 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7373 V_I4(&vbg
) = 0xff0000;
7374 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7375 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7378 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7379 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7380 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7381 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7384 /* Restore Original */
7385 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7386 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7387 VariantClear(&vDefaultbg
);
7389 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7390 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7391 ok(lval
== 1, "rowSpan = %d\n", lval
);
7393 hres
= IHTMLTableCell_put_rowSpan(cell
, -1);
7394 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7396 hres
= IHTMLTableCell_put_rowSpan(cell
, 0);
7397 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7399 hres
= IHTMLTableCell_put_rowSpan(cell
, 2);
7400 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7402 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7403 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7404 ok(lval
== 2, "rowSpan = %d\n", lval
);
7406 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7407 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7408 ok(lval
== 1, "rowSpan = %d\n", lval
);
7410 hres
= IHTMLTableCell_put_colSpan(cell
, -1);
7411 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7413 hres
= IHTMLTableCell_put_colSpan(cell
, 0);
7414 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7416 hres
= IHTMLTableCell_put_colSpan(cell
, 2);
7417 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7419 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7420 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7421 ok(lval
== 2, "rowSpan = %d\n", lval
);
7423 IHTMLTableCell_Release(cell
);
7426 static void test_label_elem(IHTMLElement
*elem
)
7428 IHTMLLabelElement
*label
;
7432 label
= get_label_iface((IUnknown
*)elem
);
7435 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7436 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7437 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7441 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7442 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7445 str
= (void*)0xdeadbeef;
7446 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7447 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7448 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7451 str
= a2bstr("abc");
7452 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7453 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7457 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7458 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7459 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7462 IHTMLLabelElement_Release(label
);
7465 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7466 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7471 V_VT(&v
) = VT_ERROR
;
7472 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7473 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7474 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7476 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7478 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7482 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7483 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7488 V_VT(&v
) = VT_ERROR
;
7489 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7490 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7491 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7493 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7495 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7499 static void test_table_modify(IHTMLTable
*table
)
7506 test_table_length(table
, 2);
7508 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7509 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7510 ok(disp
!= NULL
, "disp == NULL\n");
7511 test_table_length(table
, 3);
7512 if (hres
!= S_OK
|| disp
== NULL
)
7515 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7516 IDispatch_Release(disp
);
7518 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7519 ok(row
!= NULL
, "row == NULL\n");
7522 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7523 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7524 ok(index
== 0, "index = %d, expected 0\n", index
);
7526 IHTMLTableRow_Release(row
);
7528 hres
= IHTMLTable_deleteRow(table
, 0);
7529 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7530 test_table_length(table
, 2);
7533 static void test_table_elem(IHTMLElement
*elem
)
7535 IHTMLElementCollection
*col
;
7537 IHTMLTable3
*table3
;
7542 VARIANT vbg
, vDefaultbg
;
7544 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7545 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7546 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7548 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7549 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7553 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7554 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7559 hres
= IHTMLTable_get_rows(table
, &col
);
7560 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7561 ok(col
!= NULL
, "get_rows returned NULL\n");
7563 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7564 IHTMLElementCollection_Release(col
);
7566 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7568 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7569 test_elem_tag((IUnknown
*)node
, "TABLE");
7570 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7571 IHTMLDOMNode_Release(node
);
7573 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7574 test_elem_tag((IUnknown
*)node
, "TABLE");
7575 test_elem_all((IUnknown
*)node
, NULL
, 0);
7576 IHTMLDOMNode_Release(node
);
7579 hres
= IHTMLTable_get_tBodies(table
, &col
);
7580 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7581 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7583 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7584 IHTMLElementCollection_Release(col
);
7586 test_table_cell_spacing(table
, NULL
);
7590 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7591 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7592 test_table_cell_spacing(table
, "10");
7595 V_BSTR(&v
) = a2bstr("11");
7596 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7597 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7598 test_table_cell_spacing(table
, "11");
7601 test_table_cell_padding(table
, NULL
);
7605 hres
= IHTMLTable_put_cellPadding(table
, v
);
7606 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7607 test_table_cell_padding(table
, "10");
7610 V_BSTR(&v
) = a2bstr("11");
7611 hres
= IHTMLTable_put_cellPadding(table
, v
);
7612 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7613 test_table_cell_padding(table
, "11");
7618 hres
= IHTMLTable_put_cellPadding(table
, v
);
7619 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7620 test_table_cell_padding(table
, "5");
7622 bstr
= a2bstr("left");
7623 hres
= IHTMLTable_put_align(table
, bstr
);
7624 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7625 SysFreeString(bstr
);
7628 hres
= IHTMLTable_get_align(table
, &bstr
);
7629 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7630 ok(bstr
!= NULL
, "get_align returned NULL\n");
7631 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7632 SysFreeString(bstr
);
7634 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7635 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7636 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7637 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7639 V_VT(&vbg
) = VT_BSTR
;
7640 V_BSTR(&vbg
) = a2bstr("red");
7641 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7642 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7645 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7646 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7647 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7648 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7652 V_I4(&vbg
) = 0xff0000;
7653 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7654 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7657 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7658 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7659 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7660 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7663 /* Restore Original */
7664 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7665 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7666 VariantClear(&vDefaultbg
);
7669 V_BSTR(&v
) = a2bstr("11");
7670 hres
= IHTMLTable_put_width(table
, v
);
7671 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7673 hres
= IHTMLTable_get_width(table
, &v
);
7674 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7675 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7679 V_BSTR(&v
) = a2bstr("11.9");
7680 hres
= IHTMLTable_put_width(table
, v
);
7681 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7683 hres
= IHTMLTable_get_width(table
, &v
);
7684 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7685 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7689 V_BSTR(&v
) = a2bstr("40.2%");
7690 hres
= IHTMLTable_put_width(table
, v
);
7691 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7693 hres
= IHTMLTable_get_width(table
, &v
);
7694 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7695 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7700 hres
= IHTMLTable_put_width(table
, v
);
7701 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7702 hres
= IHTMLTable_get_width(table
, &v
);
7703 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7704 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7709 hres
= IHTMLTable_put_width(table
, v
);
7710 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7711 hres
= IHTMLTable_get_width(table
, &v
);
7712 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7713 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7716 bstr
= a2bstr("box");
7717 hres
= IHTMLTable_put_frame(table
, bstr
);
7718 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7719 SysFreeString(bstr
);
7720 hres
= IHTMLTable_get_frame(table
, &bstr
);
7721 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7722 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7723 SysFreeString(bstr
);
7725 test_table_modify(table
);
7726 bstr
= a2bstr("summary");
7727 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7728 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7729 SysFreeString(bstr
);
7731 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7732 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7733 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7734 SysFreeString(bstr
);
7736 IHTMLTable3_Release(table3
);
7737 IHTMLTable_Release(table
);
7740 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7749 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7750 hres
= SafeArrayAccessData(sa
, (void**)&var
);
7751 ok(hres
== S_OK
, "Failed to access array data: %08x\n", hres
);
7752 V_VT(var
) = VT_BSTR
;
7753 V_BSTR(var
) = a2bstr(text
);
7754 SafeArrayUnaccessData(sa
);
7757 hres
= IHTMLDocument2_writeln(doc
, sa
);
7759 hres
= IHTMLDocument2_write(doc
, sa
);
7760 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7762 SafeArrayDestroy(sa
);
7765 static void doc_complex_write(IHTMLDocument2
*doc
)
7767 SAFEARRAYBOUND dim
= {5, 0};
7772 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7773 hres
= SafeArrayAccessData(sa
, (void**)&args
);
7774 ok(hres
== S_OK
, "Failed to access array data: %08x\n", hres
);
7776 V_VT(args
) = VT_BSTR
;
7777 V_BSTR(args
) = a2bstr("<body i4val=\"");
7778 V_VT(args
+1) = VT_I4
;
7780 V_VT(args
+2) = VT_BSTR
;
7781 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7782 V_VT(args
+3) = VT_R8
;
7783 V_R8(args
+3) = 3.14;
7784 V_VT(args
+4) = VT_BSTR
;
7785 V_BSTR(args
+4) = a2bstr("\">");
7786 SafeArrayUnaccessData(sa
);
7788 hres
= IHTMLDocument2_write(doc
, sa
);
7789 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7791 SafeArrayDestroy(sa
);
7794 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7796 IHTMLDocument2
*window_doc
, *elem_doc
;
7797 IHTMLFrameElement3
*frame_elem3
;
7798 IHTMLWindow2
*content_window
;
7801 content_window
= get_frame_content_window(frame_elem
);
7802 test_ifaces((IUnknown
*)content_window
, window_iids
);
7803 window_doc
= get_window_doc(content_window
);
7804 IHTMLWindow2_Release(content_window
);
7806 elem_doc
= get_elem_doc(frame_elem
);
7807 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7810 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7811 if(SUCCEEDED(hres
)) {
7812 IDispatch
*disp
= NULL
;
7814 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7815 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7816 ok(disp
!= NULL
, "contentDocument == NULL\n");
7817 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7819 IDispatch_Release(disp
);
7820 IHTMLFrameElement3_Release(frame_elem3
);
7822 win_skip("IHTMLFrameElement3 not supported\n");
7826 IHTMLDocument2_Release(elem_doc
);
7827 IHTMLDocument2_Release(window_doc
);
7830 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7831 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7833 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7837 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7838 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7839 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7841 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7843 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7845 IHTMLIFrameElement2_Release(iframe
);
7848 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7849 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7851 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7856 V_BSTR(&v
) = a2bstr(val
);
7857 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7858 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7860 IHTMLIFrameElement2_Release(iframe
);
7863 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7864 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7866 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7870 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7871 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7872 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7874 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7876 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7878 IHTMLIFrameElement2_Release(iframe
);
7881 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7882 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7884 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7889 V_BSTR(&v
) = a2bstr(val
);
7890 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7891 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7893 IHTMLIFrameElement2_Release(iframe
);
7896 static void test_iframe_elem(IHTMLElement
*elem
)
7898 IHTMLDocument2
*content_doc
, *owner_doc
;
7899 IHTMLIFrameElement3
*iframe3
;
7900 IHTMLElementCollection
*col
;
7901 IHTMLWindow2
*content_window
;
7908 static const elem_type_t all_types
[] = {
7916 test_frame_doc((IUnknown
*)elem
, TRUE
);
7917 test_framebase((IUnknown
*)elem
);
7919 content_window
= get_frame_content_window((IUnknown
*)elem
);
7920 test_ifaces((IUnknown
*)content_window
, window_iids
);
7921 test_window_length(content_window
, 0);
7923 content_doc
= get_window_doc(content_window
);
7924 IHTMLWindow2_Release(content_window
);
7926 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7927 if(SUCCEEDED(hres
)) {
7928 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7929 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7930 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7931 IDispatch_Release(disp
);
7933 IHTMLIFrameElement3_Release(iframe3
);
7935 win_skip("IHTMLIFrameElement3 not supported\n");
7938 test_iframe_height(elem
, NULL
);
7939 set_iframe_height(elem
, "100px");
7940 set_iframe_height(elem
, "50%");
7941 test_iframe_height(elem
, "50%");
7943 test_iframe_width(elem
, NULL
);
7944 set_iframe_width(elem
, "150px");
7945 set_iframe_width(elem
, "70%");
7946 test_iframe_width(elem
, "70%");
7947 test_framebase_src(elem
, "about:blank");
7949 str
= a2bstr("text/html");
7950 V_VT(&errv
) = VT_ERROR
;
7952 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7954 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7955 ok(disp
!= NULL
, "disp == NULL\n");
7956 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7957 IDispatch_Release(disp
);
7959 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7960 doc_complex_write(content_doc
);
7961 doc_write(content_doc
, TRUE
, "<br />");
7962 doc_write(content_doc
, TRUE
, "</html>");
7964 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7965 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7966 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7967 IHTMLElementCollection_Release(col
);
7969 body
= doc_get_body(content_doc
);
7970 test_elem_attr(body
, "i4val", "4");
7971 test_elem_attr(body
, "r8val", "3.14");
7972 IHTMLElement_Release(body
);
7974 hres
= IHTMLDocument2_close(content_doc
);
7975 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7977 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7978 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7980 IHTMLDocument2_Release(content_doc
);
7983 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7984 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7989 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7990 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7991 todo_wine_if(is_todo
) {
7993 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7995 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
8001 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
8002 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
8004 BSTR str
= a2bstr(csstext
);
8007 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
8008 todo_wine_if(is_todo
)
8009 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
8013 static void test_stylesheet(IDispatch
*disp
)
8015 IHTMLStyleSheetRulesCollection
*col
= NULL
;
8016 IHTMLStyleSheet
*stylesheet
;
8020 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, "[object]");
8022 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
8023 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
8025 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
8026 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
8027 ok(col
!= NULL
, "col == NULL\n");
8029 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, NULL
, "[object]");
8030 IHTMLStyleSheetRulesCollection_Release(col
);
8032 href
= (void*)0xdeadbeef;
8033 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
8034 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
8035 ok(href
== NULL
, "got href != NULL\n");
8036 SysFreeString(href
);
8038 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
8039 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
8040 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
8041 set_stylesheet_csstext(stylesheet
, "", FALSE
);
8042 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
8043 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
8044 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
8046 IHTMLStyleSheet_Release(stylesheet
);
8049 static void test_stylesheets(IHTMLDocument2
*doc
)
8051 IHTMLStyleSheetsCollection
*col
= NULL
;
8056 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
8057 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
8058 ok(col
!= NULL
, "col == NULL\n");
8060 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, NULL
, "[object]");
8062 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
8063 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8064 ok(len
== 1, "len=%d\n", len
);
8070 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8071 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
8072 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8073 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8074 test_stylesheet(V_DISPATCH(&res
));
8081 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8082 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8083 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
8086 IHTMLStyleSheetsCollection_Release(col
);
8089 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
8091 IDispatchEx
*dispex
;
8093 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
8101 static const WCHAR w0
[] = {'0',0};
8102 static const WCHAR w100
[] = {'1','0','0',0};
8104 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
8105 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
8107 bstr
= SysAllocString(w0
);
8108 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8109 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8110 SysFreeString(bstr
);
8113 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
8114 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
8115 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
8116 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
8117 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
8118 type
= get_node_type((IUnknown
*)node
);
8119 ok(type
== 3, "type=%d\n", type
);
8120 IHTMLDOMNode_Release(node
);
8123 bstr
= SysAllocString(w100
);
8124 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8125 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
8126 SysFreeString(bstr
);
8128 IDispatchEx_Release(dispex
);
8131 static void test_enum_children(IUnknown
*unk
, unsigned len
)
8133 IEnumVARIANT
*enum_var
;
8138 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
8139 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
8141 for(i
=0; i
<len
; i
++) {
8143 V_VT(&v
) = VT_ERROR
;
8144 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
8145 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
8147 ok(fetched
== 1, "fetched = %d\n", fetched
);
8148 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
8149 IDispatch_Release(V_DISPATCH(&v
));
8152 fetched
= 0xdeadbeef;
8154 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
8155 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
8156 ok(fetched
== 0, "fetched = %d\n", fetched
);
8157 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8159 hres
= IEnumVARIANT_Reset(enum_var
);
8160 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8162 fetched
= 0xdeadbeef;
8164 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
8165 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
8166 ok(fetched
== 0, "fetched = %d\n", fetched
);
8167 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8169 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
8170 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
8172 hres
= IEnumVARIANT_Reset(enum_var
);
8173 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8175 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
8176 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
8178 IEnumVARIANT_Release(enum_var
);
8181 static void test_selectors(IHTMLDocument2
*doc
, IHTMLElement
*div
)
8183 IHTMLDOMChildrenCollection
*collection
;
8184 IDocumentSelector
*doc_selector
;
8185 IElementSelector
*elem_selector
;
8189 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8191 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentSelector
, (void**)&doc_selector
);
8192 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDocumentSelector iface: %08x\n", hres
);
8194 win_skip("IDocumentSelector tests skipped.\n");
8199 str
= a2bstr("nomatch");
8200 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8201 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8202 ok(collection
!= NULL
, "collection == NULL\n");
8203 test_children_collection_length(collection
, 0);
8204 IHTMLDOMChildrenCollection_Release(collection
);
8208 str
= a2bstr(".cl1");
8209 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8210 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8211 ok(collection
!= NULL
, "collection == NULL\n");
8212 test_children_collection_length(collection
, 2);
8213 IHTMLDOMChildrenCollection_Release(collection
);
8216 IDocumentSelector_Release(doc_selector
);
8218 hres
= IHTMLElement_QueryInterface(div
, &IID_IElementSelector
, (void**)&elem_selector
);
8219 ok(hres
== S_OK
, "Could not get IElementSelector iface: %08x\n", hres
);
8222 str
= a2bstr("nomatch");
8223 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8224 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8225 ok(collection
!= NULL
, "collection == NULL\n");
8226 test_children_collection_length(collection
, 0);
8227 IHTMLDOMChildrenCollection_Release(collection
);
8231 str
= a2bstr(".cl1");
8232 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8233 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8234 ok(collection
!= NULL
, "collection == NULL\n");
8235 test_children_collection_length(collection
, 2);
8236 IHTMLDOMChildrenCollection_Release(collection
);
8239 IElementSelector_Release(elem_selector
);
8242 static void test_elemsbyclass(IHTMLElement
*div
)
8244 IHTMLElementCollection
*collection
;
8245 IHTMLElement6
*elem
;
8249 static const elem_type_t types
[] = {ET_DIV
, ET_FORM
};
8251 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8253 hres
= IHTMLElement_QueryInterface(div
, &IID_IHTMLElement6
, (void**)&elem
);
8254 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IHTMLElement6 iface: %08x\n", hres
);
8256 win_skip("IHTMLElement6 tests skipped.\n");
8261 str
= a2bstr("nomatch");
8262 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8263 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8264 ok(collection
!= NULL
, "collection == NULL\n");
8265 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
8266 IHTMLElementCollection_Release(collection
);
8270 str
= a2bstr("cl1");
8271 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8272 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8273 ok(collection
!= NULL
, "collection == NULL\n");
8274 test_elem_collection((IUnknown
*)collection
, types
, sizeof(types
)/sizeof(*types
));
8275 IHTMLElementCollection_Release(collection
);
8278 IHTMLElement6_Release(elem
);
8281 static void test_elems(IHTMLDocument2
*doc
)
8283 IHTMLElementCollection
*col
;
8284 IHTMLDOMChildrenCollection
*child_col
;
8285 IHTMLElement
*elem
, *elem2
, *elem3
;
8286 IHTMLDOMNode
*node
, *node2
;
8287 IHTMLWindow2
*window
;
8291 IHTMLElementCollection
*collection
;
8292 IHTMLDocument3
*doc3
;
8295 static const elem_type_t all_types
[] = {
8328 static const elem_type_t item_types
[] = {
8334 hres
= IHTMLDocument2_get_all(doc
, &col
);
8335 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8336 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8337 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
8339 elem
= get_elem_col_item_idx(col
, 0);
8340 test_elem_source_index(elem
, 0);
8341 IHTMLElement_Release(elem
);
8343 elem
= get_elem_col_item_idx(col
, 3);
8344 test_elem_source_index(elem
, 3);
8345 IHTMLElement_Release(elem
);
8347 IHTMLElementCollection_Release(col
);
8349 hres
= IHTMLDocument2_get_images(doc
, &collection
);
8350 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
8353 static const elem_type_t images_types
[] = {ET_IMG
};
8354 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8356 IHTMLElementCollection_Release(collection
);
8359 hres
= IHTMLDocument2_get_links(doc
, &collection
);
8360 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
8363 static const elem_type_t images_types
[] = {ET_A
};
8364 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8366 IHTMLElementCollection_Release(collection
);
8369 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
8370 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
8373 static const elem_type_t anchor_types
[] = {ET_A
};
8374 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
8376 IHTMLElementCollection_Release(collection
);
8379 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
8380 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
8382 static const elem_type_t script_types
[] = {ET_SCRIPT
};
8383 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
8384 IHTMLElementCollection_Release(collection
);
8387 test_plugins_col(doc
);
8389 elem
= get_doc_elem(doc
);
8390 test_elem_istextedit(elem
, VARIANT_FALSE
);
8391 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
8392 IHTMLElement_Release(elem
);
8394 get_elem_by_id(doc
, "xxx", FALSE
);
8395 elem
= get_doc_elem_by_id(doc
, "xxx");
8396 ok(!elem
, "elem != NULL\n");
8398 elem
= get_doc_elem_by_id(doc
, "s");
8399 ok(elem
!= NULL
, "elem == NULL\n");
8401 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
8402 test_elem_attr(elem
, "xxx", NULL
);
8403 test_elem_attr(elem
, "id", "s");
8404 test_elem_class((IUnknown
*)elem
, NULL
);
8405 test_elem_set_class((IUnknown
*)elem
, "cl");
8406 test_elem_set_class((IUnknown
*)elem
, NULL
);
8407 test_elem_tabindex((IUnknown
*)elem
, 0);
8408 test_elem_set_tabindex((IUnknown
*)elem
, 1);
8409 test_elem_filters((IUnknown
*)elem
);
8410 test_elem_istextedit(elem
, VARIANT_FALSE
);
8412 node
= test_node_get_parent((IUnknown
*)elem
);
8413 ok(node
!= NULL
, "node == NULL\n");
8414 test_node_name((IUnknown
*)node
, "BODY");
8415 node2
= test_node_get_parent((IUnknown
*)node
);
8416 IHTMLDOMNode_Release(node
);
8417 ok(node2
!= NULL
, "node == NULL\n");
8418 test_node_name((IUnknown
*)node2
, "HTML");
8419 node
= test_node_get_parent((IUnknown
*)node2
);
8420 IHTMLDOMNode_Release(node2
);
8421 ok(node
!= NULL
, "node == NULL\n");
8424 test_node_name((IUnknown
*)node
, "#document");
8425 type
= get_node_type((IUnknown
*)node
);
8426 ok(type
== 9, "type=%d, expected 9\n", type
);
8427 node2
= test_node_get_parent((IUnknown
*)node
);
8428 IHTMLDOMNode_Release(node
);
8429 ok(node2
== NULL
, "node != NULL\n");
8432 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8433 ok(elem2
!= NULL
, "elem2 == NULL\n");
8434 test_node_name((IUnknown
*)elem2
, "BODY");
8436 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
8437 ok(elem3
!= NULL
, "elem3 == NULL\n");
8438 test_node_name((IUnknown
*)elem3
, "HTML");
8440 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
8441 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
8442 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
8443 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
8444 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
8445 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
8446 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
8447 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
8448 IHTMLElement_Release(elem2
);
8450 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
8451 ok(elem2
== NULL
, "elem2 != NULL\n");
8452 test_elem_source_index(elem3
, 0);
8453 IHTMLElement_Release(elem3
);
8455 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
8456 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
8457 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
8459 test_elem_innertext(elem
, "opt1opt2");
8461 IHTMLElement_Release(elem
);
8464 elem
= get_elem_by_id(doc
, "s", TRUE
);
8466 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8467 IHTMLDocument2
*doc_node
, *elem_doc
;
8469 test_select_elem(select
);
8471 test_elem_istextedit(elem
, VARIANT_FALSE
);
8472 test_elem_title((IUnknown
*)select
, NULL
);
8473 test_elem_set_title((IUnknown
*)select
, "Title");
8474 test_elem_title((IUnknown
*)select
, "Title");
8475 test_elem_offset((IUnknown
*)select
, "BODY");
8476 test_elem_bounding_client_rect((IUnknown
*)select
);
8478 node
= get_first_child((IUnknown
*)select
);
8479 ok(node
!= NULL
, "node == NULL\n");
8481 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8482 IHTMLDOMNode_Release(node
);
8485 type
= get_node_type((IUnknown
*)select
);
8486 ok(type
== 1, "type=%d\n", type
);
8488 IHTMLSelectElement_Release(select
);
8490 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8492 doc_node
= get_doc_node(doc
);
8493 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8494 IHTMLDocument2_Release(doc_node
);
8495 IHTMLDocument2_Release(elem_doc
);
8497 IHTMLElement_Release(elem
);
8500 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8502 IHTMLScriptElement
*script
;
8505 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8506 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8508 test_elem_language(elem
, NULL
);
8509 test_elem_istextedit(elem
, VARIANT_FALSE
);
8515 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8516 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8517 hres
= IHTMLScriptElement_get_type(script
, &type
);
8518 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8519 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8521 type
= a2bstr("text/javascript");
8522 hres
= IHTMLScriptElement_put_type (script
, type
);
8523 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8524 SysFreeString(type
);
8525 hres
= IHTMLScriptElement_get_type(script
, &type
);
8526 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8527 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8528 SysFreeString(type
);
8530 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8533 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8534 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8536 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8537 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8538 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8540 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8541 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8543 str
= (BSTR
)0xdeadbeef;
8544 hres
= IHTMLScriptElement_get_src(script
, &str
);
8545 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8546 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8549 IHTMLScriptElement_Release(script
);
8551 set_elem_language(elem
, "vbscript");
8552 set_elem_language(elem
, "xxx");
8555 elem
= get_elem_by_id(doc
, "in", TRUE
);
8557 IHTMLInputElement
*input
;
8559 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8560 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8562 test_elem_id((IUnknown
*)elem
, "in");
8563 test_elem_put_id((IUnknown
*)elem
, "newin");
8564 test_input_get_disabled(input
, VARIANT_FALSE
);
8565 test_input_set_disabled(input
, VARIANT_TRUE
);
8566 test_input_set_disabled(input
, VARIANT_FALSE
);
8567 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8568 test_input_get_disabled(input
, VARIANT_TRUE
);
8569 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8570 test_input_get_disabled(input
, VARIANT_FALSE
);
8571 test_elem_client_size((IUnknown
*)elem
);
8572 test_input_type(input
, "text");
8573 test_elem_istextedit(elem
, VARIANT_TRUE
);
8575 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8576 test_node_put_value_str((IUnknown
*)elem
, "test");
8577 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8578 test_input_value((IUnknown
*)elem
, NULL
);
8579 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8580 test_input_put_value((IUnknown
*)elem
, "test");
8581 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8582 test_elem_class((IUnknown
*)elem
, "testclass");
8583 test_elem_tabindex((IUnknown
*)elem
, 2);
8584 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8585 test_elem_title((IUnknown
*)elem
, "test title");
8587 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8588 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8589 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8591 test_input_get_checked(input
, VARIANT_FALSE
);
8592 test_input_set_checked(input
, VARIANT_TRUE
);
8593 test_input_set_checked(input
, VARIANT_FALSE
);
8595 test_input_maxlength(input
, 0x7fffffff);
8596 test_input_set_maxlength(input
, 30);
8598 test_input_name(input
, NULL
);
8599 test_input_set_name(input
, "test");
8601 test_input_src(input
, NULL
);
8602 test_input_set_src(input
, "about:blank");
8604 test_input_set_size(input
, 15, S_OK
);
8605 test_input_get_size(input
, 15);
8606 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8607 test_input_get_size(input
, 15);
8608 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8609 test_input_get_size(input
, 15);
8611 test_input_readOnly(input
, VARIANT_TRUE
);
8612 test_input_readOnly(input
, VARIANT_FALSE
);
8614 test_elem_lang(elem
, NULL
);
8615 set_elem_lang(elem
, "en-us");
8617 IHTMLInputElement_Release(input
);
8618 IHTMLElement_Release(elem
);
8621 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8623 test_img_align((IUnknown
*)elem
, "left");
8624 test_img_name((IUnknown
*)elem
, "WineImg");
8625 test_img_src((IUnknown
*)elem
, "", NULL
);
8626 test_img_set_src((IUnknown
*)elem
, "about:blank");
8627 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8628 test_img_alt((IUnknown
*)elem
, NULL
);
8629 test_img_set_alt((IUnknown
*)elem
, "alt test");
8630 test_img_name((IUnknown
*)elem
, "WineImg");
8631 test_img_complete(elem
, VARIANT_FALSE
);
8632 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8633 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8634 IHTMLElement_Release(elem
);
8637 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8639 test_dynamic_properties(elem
);
8640 test_attr_collection(elem
);
8641 test_contenteditable((IUnknown
*)elem
);
8642 IHTMLElement_Release(elem
);
8645 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8647 test_style_media((IUnknown
*)elem
, NULL
);
8648 test_style_put_media((IUnknown
*)elem
, "screen");
8649 test_style_type((IUnknown
*)elem
, NULL
);
8650 test_style_put_type((IUnknown
*)elem
, "text/css");
8651 IHTMLElement_Release(elem
);
8654 elem
= get_doc_elem_by_id(doc
, "tbl");
8655 ok(elem
!= NULL
, "elem == NULL\n");
8657 test_table_elem(elem
);
8658 IHTMLElement_Release(elem
);
8661 elem
= get_doc_elem_by_id(doc
, "labelid");
8662 ok(elem
!= NULL
, "elem == NULL\n");
8664 test_label_elem(elem
);
8665 IHTMLElement_Release(elem
);
8668 elem
= get_doc_elem_by_id(doc
, "row2");
8669 ok(elem
!= NULL
, "elem == NULL\n");
8672 IHTMLElement_Release(elem
);
8675 elem
= get_doc_elem_by_id(doc
, "ifr");
8676 ok(elem
!= NULL
, "elem == NULL\n");
8678 test_iframe_elem(elem
);
8679 IHTMLElement_Release(elem
);
8682 elem
= get_doc_elem_by_id(doc
, "btnid");
8683 ok(elem
!= NULL
, "elem == NULL\n");
8685 test_button_elem(elem
);
8686 test_button_get_disabled(elem
, VARIANT_FALSE
);
8687 test_button_set_disabled(elem
, VARIANT_TRUE
);
8688 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8689 test_button_get_disabled(elem
, VARIANT_FALSE
);
8690 IHTMLElement_Release(elem
);
8693 elem
= get_doc_elem_by_id(doc
, "objid");
8694 ok(elem
!= NULL
, "elem == NULL\n");
8696 test_object_vspace((IUnknown
*)elem
, 100);
8697 test_object_name(elem
, "objname");
8698 set_object_name(elem
, "test");
8699 set_object_name(elem
, NULL
);
8700 IHTMLElement_Release(elem
);
8703 elem
= get_elem_by_id(doc
, "a", TRUE
);
8705 test_anchor_href((IUnknown
*)elem
, "http://test/");
8707 /* Change the href */
8708 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8709 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8710 test_anchor_hostname((IUnknown
*)elem
, "test1");
8712 /* Restore the href */
8713 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8714 test_anchor_href((IUnknown
*)elem
, "http://test/");
8715 test_anchor_hostname((IUnknown
*)elem
, "test");
8716 test_anchor_hash(elem
, NULL
);
8719 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8721 test_anchor_rel((IUnknown
*)elem
, NULL
);
8722 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8723 test_anchor_rel((IUnknown
*)elem
, "Next");
8725 /* Change the target */
8726 test_anchor_put_target((IUnknown
*)elem
, "wine");
8727 test_anchor_get_target((IUnknown
*)elem
, "wine");
8729 /* Restore the target */
8730 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8731 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8733 test_anchor_name((IUnknown
*)elem
, "x");
8734 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8735 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8736 test_anchor_put_name((IUnknown
*)elem
, "x");
8738 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8739 test_anchor_hash(elem
, "#hash");
8740 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8742 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8743 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8744 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8745 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8747 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8748 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8750 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8751 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8753 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8754 as part of the pathname, and cannot be accessed by get_search. */
8755 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8756 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8758 IHTMLElement_Release(elem
);
8761 elem
= get_doc_elem_by_id(doc
, "metaid");
8763 test_meta_name((IUnknown
*)elem
, "meta name");
8764 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8765 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8766 test_meta_charset((IUnknown
*)elem
, NULL
);
8767 set_meta_charset((IUnknown
*)elem
, "utf-8");
8768 IHTMLElement_Release(elem
);
8771 elem
= doc_get_body(doc
);
8773 node
= get_first_child((IUnknown
*)elem
);
8774 ok(node
!= NULL
, "node == NULL\n");
8776 test_ifaces((IUnknown
*)node
, text_iids
);
8777 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
8779 node2
= get_first_child((IUnknown
*)node
);
8780 ok(!node2
, "node2 != NULL\n");
8782 type
= get_node_type((IUnknown
*)node
);
8783 ok(type
== 3, "type=%d\n", type
);
8785 test_node_get_value_str((IUnknown
*)node
, "text test");
8786 test_node_put_value_str((IUnknown
*)elem
, "test text");
8787 test_node_get_value_str((IUnknown
*)node
, "text test");
8789 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8790 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8791 ok(!disp
, "disp != NULL\n");
8793 IHTMLDOMNode_Release(node
);
8796 child_col
= get_child_nodes((IUnknown
*)elem
);
8797 ok(child_col
!= NULL
, "child_coll == NULL\n");
8802 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, NULL
, "[object]");
8803 length
= test_children_collection_length(child_col
, -1);
8806 node
= get_child_item(child_col
, 0);
8807 ok(node
!= NULL
, "node == NULL\n");
8811 type
= get_node_type((IUnknown
*)node
);
8812 ok(type
== 3, "type=%d\n", type
);
8813 node2
= node_get_next((IUnknown
*)node
);
8815 prev
= node_get_prev((IUnknown
*)node2
);
8816 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8817 IHTMLDOMNode_Release(prev
);
8819 IHTMLDOMNode_Release(node
);
8822 node
= get_child_item(child_col
, 1);
8823 ok(node
!= NULL
, "node == NULL\n");
8825 type
= get_node_type((IUnknown
*)node
);
8826 ok(type
== 8, "type=%d\n", type
);
8828 test_elem_id((IUnknown
*)node
, NULL
);
8829 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8830 IHTMLDOMNode_Release(node2
);
8831 IHTMLDOMNode_Release(node
);
8834 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8835 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8837 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8838 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8840 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8841 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8843 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8844 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8846 test_child_col_disp(child_col
);
8848 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8849 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8851 test_enum_children(enum_unk
, length
);
8853 IUnknown_Release(enum_unk
);
8855 IHTMLDOMChildrenCollection_Release(child_col
);
8858 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8859 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8860 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8862 IHTMLElement_Release(elem
);
8864 elem
= get_doc_elem_by_id(doc
, "frm");
8865 ok(elem
!= NULL
, "elem == NULL\n");
8867 test_form_length((IUnknown
*)elem
, 0);
8868 test_form_elements((IUnknown
*)elem
);
8869 IHTMLElement_Release(elem
);
8872 test_stylesheets(doc
);
8873 test_create_option_elem(doc
);
8874 test_create_img_elem(doc
);
8876 elem
= get_doc_elem_by_id(doc
, "tbl");
8877 ok(elem
!= NULL
, "elem = NULL\n");
8878 test_elem_set_innertext(elem
, "inner text");
8879 IHTMLElement_Release(elem
);
8881 test_doc_title(doc
, "test");
8882 test_doc_set_title(doc
, "test title");
8883 test_doc_title(doc
, "test title");
8886 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8887 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8890 IDispatchEx
*dispex
;
8891 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8892 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8896 BSTR str
= a2bstr("Testing");
8897 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8898 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8899 ok(pid
!= -1, "pid == -1\n");
8901 IDispatchEx_Release(dispex
);
8904 IDispatch_Release(disp
);
8906 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8908 elem
= get_doc_elem_by_id(doc
, "y");
8909 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8910 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8911 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8912 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8913 node
= node_get_next((IUnknown
*)elem
);
8914 ok(!node
, "node = %p\n", node
);
8916 elem2
= get_doc_elem_by_id(doc
, "x");
8917 test_elem_tag((IUnknown
*)elem2
, "A");
8918 node
= node_get_next((IUnknown
*)elem2
);
8919 IHTMLDOMNode_Release(node
);
8920 IHTMLElement_Release(elem2
);
8921 IHTMLElement_Release(elem
);
8923 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8924 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8926 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8927 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8929 IHTMLDocument3_Release(doc3
);
8931 elem
= get_elem_by_id(doc
, "s", TRUE
);
8933 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8935 test_select_put_length((IUnknown
*)elem
, 3);
8936 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8937 test_select_put_length((IUnknown
*)elem
, 1);
8938 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8939 IHTMLElement_Release(elem
);
8942 window
= get_doc_window(doc
);
8943 test_window_name(window
, NULL
);
8944 set_window_name(window
, "test name");
8945 test_window_length(window
, 1);
8946 IHTMLWindow2_Release(window
);
8949 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
8951 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
8952 IHTMLElement4
*elem4
;
8956 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8958 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8960 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
8961 test_ifaces((IUnknown
*)attr
, attr_iids
);
8962 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8963 test_attr_specified(attr
, VARIANT_TRUE
);
8964 test_attr_parent(attr
);
8966 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8967 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8968 IHTMLDOMAttribute_Release(attr2
);
8970 get_attr_node_value(attr
, &v
, VT_BSTR
);
8971 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8975 V_BSTR(&v
) = a2bstr("divid2");
8976 put_attr_node_value(attr
, v
);
8979 get_attr_node_value(attr
, &v
, VT_BSTR
);
8980 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8983 put_attr_value(attr
, "divid3");
8985 get_attr_node_value(attr
, &v
, VT_BSTR
);
8986 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8989 IHTMLDOMAttribute_Release(attr
);
8991 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8992 get_attr_node_value(attr
, &v
, VT_BSTR
);
8993 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8997 V_BSTR(&v
) = a2bstr("newvalue");
8998 put_attr_node_value(attr
, v
);
9001 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
9002 get_attr_node_value(attr
, &v
, VT_BSTR
);
9003 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9006 test_attr_specified(attr
, VARIANT_TRUE
);
9007 IHTMLDOMAttribute_Release(attr
);
9011 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
9012 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
9013 get_attr_node_value(attr
, &v
, VT_I4
);
9014 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
9015 test_attr_specified(attr
, VARIANT_TRUE
);
9019 put_attr_node_value(attr
, v
);
9021 get_attr_node_value(attr
, &v
, VT_I4
);
9022 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
9024 put_attr_value(attr
, "160");
9025 get_attr_node_value(attr
, &v
, VT_BSTR
);
9026 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9029 IHTMLDOMAttribute_Release(attr
);
9031 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
9032 test_attr_specified(attr
, VARIANT_FALSE
);
9033 test_attr_expando(attr
, VARIANT_FALSE
);
9034 IHTMLDOMAttribute_Release(attr
);
9036 /* Test created, detached attribute. */
9037 attr
= create_attr((IUnknown
*)doc
, "Test");
9039 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
9040 test_ifaces((IUnknown
*)attr
, attr_iids
);
9041 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9043 test_attr_node_name(attr
, "Test");
9044 test_attr_expando(attr
, VARIANT_FALSE
);
9046 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9050 put_attr_node_value(attr
, v
);
9052 get_attr_node_value(attr
, &v
, VT_I4
);
9053 ok(V_I4(&v
) == 1, "nodeValue = %d\n", V_I4(&v
));
9054 test_attr_value(attr
, "1");
9056 V_VT(&v
) = VT_EMPTY
;
9057 put_attr_node_value(attr
, v
);
9058 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9061 V_BSTR(&v
) = a2bstr("testing");
9062 put_attr_node_value(attr
, v
);
9063 SysFreeString(V_BSTR(&v
));
9064 test_attr_value(attr
, "testing");
9066 elem4
= get_elem4_iface((IUnknown
*)elem
);
9068 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
9069 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9070 ok(!attr2
, "attr2 != NULL\n");
9072 test_elem_attr(elem
, "Test", "testing");
9073 put_attr_value(attr
, "new value");
9074 test_elem_attr(elem
, "Test", "new value");
9076 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9077 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9078 IHTMLDOMAttribute_Release(attr2
);
9080 attr3
= create_attr((IUnknown
*)doc
, "Test");
9081 put_attr_value(attr3
, "replace test");
9083 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9084 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9085 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9086 IHTMLDOMAttribute_Release(attr2
);
9088 test_elem_attr(elem
, "Test", "replace test");
9089 test_attr_value(attr
, "new value");
9090 test_attr_value(attr3
, "replace test");
9092 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9093 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
9094 IHTMLDOMAttribute_Release(attr2
);
9096 put_attr_value(attr
, "new value2");
9097 test_elem_attr(elem
, "Test", "replace test");
9098 test_attr_value(attr
, "new value2");
9099 test_attr_value(attr3
, "replace test");
9101 put_attr_value(attr3
, "new replace value");
9102 test_elem_attr(elem
, "Test", "new replace value");
9103 test_attr_value(attr
, "new value2");
9104 test_attr_value(attr3
, "new replace value");
9106 /* Attached attributes cause errors. */
9107 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9108 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9109 IHTMLDOMAttribute_Release(attr3
);
9111 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9112 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
9113 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9114 IHTMLDOMAttribute_Release(attr2
);
9116 IHTMLElement4_Release(elem4
);
9117 IHTMLDOMAttribute_Release(attr
);
9120 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
9124 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9125 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
9126 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9128 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9129 IHTMLElement_Release(elem
);
9132 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9133 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
9134 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9136 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
9137 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
9138 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
9139 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
9140 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9141 IHTMLElement_Release(elem
);
9145 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
9146 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
9148 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
9149 IHTMLElementCollection
*col
;
9150 BSTR str
= a2bstr(name
);
9153 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
9154 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
9155 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
9157 IHTMLDocument3_Release(doc3
);
9162 static void test_elem_names(IHTMLDocument2
*doc
)
9164 IHTMLElementCollection
*col
;
9169 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
9171 body
= doc_get_body(doc
);
9173 test_elem_set_innerhtml((IUnknown
*)body
,
9174 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
9175 col
= doc_get_elems_by_name(doc
, "test");
9176 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
9177 IHTMLElementCollection_Release(col
);
9179 col
= doc_get_elems_by_name(doc
, "yyy");
9180 test_elem_collection((IUnknown
*)col
, NULL
, 0);
9181 IHTMLElementCollection_Release(col
);
9183 /* case insensivity test */
9184 col
= doc_get_elems_by_name(doc
, "Xxx");
9185 hres
= IHTMLElementCollection_get_length(col
, &len
);
9186 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
9187 todo_wine
ok(len
== 1, "len = %d\n", len
);
9188 IHTMLElementCollection_Release(col
);
9190 IHTMLElement_Release(body
);
9193 static void test_elems2(IHTMLDocument2
*doc
)
9195 IHTMLElement
*elem
, *elem2
, *div
;
9197 static const elem_type_t outer_types
[] = {
9202 div
= get_doc_elem_by_id(doc
, "divid");
9204 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
9206 test_link_disabled(elem
, VARIANT_FALSE
);
9207 test_link_rel(elem
, "stylesheet");
9208 test_link_rev(elem
, NULL
);
9209 test_link_type(elem
, "text/css");
9210 test_link_href(elem
, "about:blank");
9211 test_link_media(elem
, "all");
9212 link_put_disabled(elem
, VARIANT_TRUE
);
9213 link_put_rel(elem
, "prev");
9214 link_put_rev(elem
, "next");
9215 link_put_type(elem
, "text/plain");
9216 link_put_href(elem
, "about:prev");
9217 IHTMLElement_Release(elem
);
9220 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
9221 elem2
= get_doc_elem_by_id(doc
, "innerid");
9222 ok(elem2
!= NULL
, "elem2 == NULL\n");
9223 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
9224 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
9225 IHTMLElement_Release(elem2
);
9227 elem2
= get_doc_elem_by_id(doc
, "aid");
9228 ok(elem2
!= NULL
, "elem2 == NULL\n");
9229 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
9230 test_elem_all((IUnknown
*)div
, outer_types
, 1);
9231 IHTMLElement_Release(elem2
);
9233 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
9234 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9236 IHTMLFormElement
*form
;
9238 test_textarea_value((IUnknown
*)elem
, NULL
);
9239 test_textarea_put_value((IUnknown
*)elem
, "test");
9240 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
9241 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
9242 test_textarea_put_value((IUnknown
*)elem
, "test");
9243 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9244 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
9245 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9246 test_textarea_type((IUnknown
*)elem
);
9248 form
= get_textarea_form((IUnknown
*)elem
);
9249 ok(!form
, "form = %p\n", form
);
9251 test_elem_istextedit(elem
, VARIANT_TRUE
);
9253 IHTMLElement_Release(elem
);
9256 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
9257 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9259 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
9260 IHTMLElement_Release(elem
);
9263 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
9264 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9266 IHTMLFormElement
*form
;
9268 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
9269 ok(elem2
!= NULL
, "elem2 == NULL\n");
9271 form
= get_textarea_form((IUnknown
*)elem
);
9272 ok(form
!= NULL
, "form = NULL\n");
9273 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9275 IHTMLFormElement_Release(form
);
9276 IHTMLElement_Release(elem2
);
9277 IHTMLElement_Release(elem
);
9280 test_elem_set_innerhtml((IUnknown
*)div
,
9281 "<input value=\"val\" id =\"inputid\" />");
9282 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9284 test_input_defaultValue((IUnknown
*)elem
, "val");
9285 test_input_put_value((IUnknown
*)elem
, "test");
9286 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
9287 test_input_value((IUnknown
*)elem
, "test");
9288 IHTMLElement_Release(elem
);
9291 test_elem_set_innerhtml((IUnknown
*)div
, "");
9292 test_insert_adjacent_elems(doc
, div
);
9294 test_elem_set_innerhtml((IUnknown
*)div
,
9295 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
9296 elem
= get_elem_by_id(doc
, "form", TRUE
);
9298 test_form_length((IUnknown
*)elem
, 2);
9299 test_form_item(elem
);
9300 test_form_action((IUnknown
*)elem
, NULL
);
9301 test_form_put_action((IUnknown
*)elem
, "about:blank");
9302 test_form_method((IUnknown
*)elem
, "get");
9303 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
9304 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
9305 test_form_method((IUnknown
*)elem
, "post");
9306 test_form_name((IUnknown
*)elem
, NULL
);
9307 test_form_put_name((IUnknown
*)elem
, "Name");
9308 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
9309 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
9310 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
9311 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
9312 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
9313 test_form_elements((IUnknown
*)elem
);
9314 test_form_reset((IUnknown
*)elem
);
9315 test_form_target((IUnknown
*)elem
);
9316 IHTMLElement_Release(elem
);
9318 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9319 test_input_get_form((IUnknown
*)elem
, "form");
9320 IHTMLElement_Release(elem
);
9323 test_elem_set_innerhtml((IUnknown
*)div
,
9324 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select><button id=\"btnid\"></button></form>");
9325 elem
= get_elem_by_id(doc
, "sform", TRUE
);
9326 elem2
= get_elem_by_id(doc
, "form", TRUE
);
9328 IHTMLFormElement
*form
;
9330 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9331 IHTMLElement_Release(elem
);
9333 elem
= get_elem_by_id(doc
, "oform", TRUE
);
9335 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9336 IHTMLElement_Release(elem
);
9339 elem
= get_elem_by_id(doc
, "btnid", TRUE
);
9341 form
= get_button_form(elem
);
9342 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9343 IHTMLFormElement_Release(form
);
9345 IHTMLElement_Release(elem
);
9346 IHTMLElement_Release(elem2
);
9349 test_selectors(doc
, div
);
9350 test_elemsbyclass(div
);
9352 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"elemid\">test</div>");
9353 elem
= get_elem_by_id(doc
, "elemid", TRUE
);
9355 test_elem_outertext(elem
, "test");
9356 test_elem_set_outertext(elem
, "outer text");
9357 test_elem_outertext(elem
, NULL
);
9358 test_elem_all((IUnknown
*)div
, NULL
, 0);
9359 elem2
= test_elem_get_parent((IUnknown
*)elem
);
9360 ok(!elem2
, "parent != NULL\n");
9361 IHTMLElement_Release(elem
);
9364 test_elem_set_innerhtml((IUnknown
*)div
, "<map><area id=\"areaid\"></area></map>");
9365 elem
= get_elem_by_id(doc
, "areaid", TRUE
);
9367 test_elem_type((IUnknown
*)elem
, ET_AREA
);
9368 IHTMLElement_Release(elem
);
9371 test_td_elem(doc
, div
);
9372 test_attr(doc
, div
);
9373 test_blocked(doc
, div
);
9374 test_elem_names(doc
);
9376 IHTMLElement_Release(div
);
9379 static void test_create_elems(IHTMLDocument2
*doc
)
9381 IHTMLElement
*elem
, *body
, *elem2
;
9382 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
9383 IHTMLDocument5
*doc5
;
9390 static const elem_type_t types1
[] = { ET_TESTG
};
9392 elem
= test_create_elem(doc
, "TEST");
9393 test_elem_tag((IUnknown
*)elem
, "TEST");
9394 type
= get_node_type((IUnknown
*)elem
);
9395 ok(type
== 1, "type=%d\n", type
);
9396 test_ifaces((IUnknown
*)elem
, elem_iids
);
9397 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
, "[object]");
9398 test_elem_source_index(elem
, -1);
9400 body
= doc_get_body(doc
);
9401 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9403 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
9404 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
9405 elem2
= get_elem_iface((IUnknown
*)node
);
9406 IHTMLElement_Release(elem2
);
9408 hres
= IHTMLElement_get_all(body
, &disp
);
9409 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9410 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
9411 IDispatch_Release(disp
);
9413 test_node_remove_child((IUnknown
*)body
, node
);
9415 hres
= IHTMLElement_get_all(body
, &disp
);
9416 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9417 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
9418 IDispatch_Release(disp
);
9419 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9421 IHTMLElement_Release(elem
);
9422 IHTMLDOMNode_Release(node
);
9424 node
= test_create_text(doc
, "abc");
9425 test_ifaces((IUnknown
*)node
, text_iids
);
9426 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
9427 test_text_length((IUnknown
*)node
, 3);
9428 test_text_data((IUnknown
*)node
, "abc");
9429 set_text_data((IUnknown
*)node
, "test");
9430 test_text_data((IUnknown
*)node
, "test");
9431 text_append_data((IUnknown
*)node
, " append");
9432 test_text_data((IUnknown
*)node
, "test append");
9433 text_append_data((IUnknown
*)node
, NULL
);
9434 test_text_data((IUnknown
*)node
, "test append");
9435 set_text_data((IUnknown
*)node
, "test");
9437 V_VT(&var
) = VT_NULL
;
9438 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9439 IHTMLDOMNode_Release(node
);
9441 node
= test_create_text(doc
, "insert ");
9443 V_VT(&var
) = VT_DISPATCH
;
9444 V_DISPATCH(&var
) = (IDispatch
*)node2
;
9445 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9446 IHTMLDOMNode_Release(node
);
9447 IHTMLDOMNode_Release(node2
);
9448 IHTMLDOMNode_Release(node3
);
9450 test_elem_innertext(body
, "insert test");
9451 test_elem_innerhtml((IUnknown
*)body
, "insert test");
9453 node
= test_create_text(doc
, " Test");
9454 V_VT(&var
) = VT_DISPATCH
;
9455 V_DISPATCH(&var
) = NULL
;
9456 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9457 test_elem_innertext(body
, "insert test Test");
9458 IHTMLDOMNode_Release(node
);
9460 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
9462 str
= a2bstr("testing");
9463 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
9465 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
9468 type
= get_node_type((IUnknown
*)comment
);
9469 ok(type
== 8, "type=%d, expected 8\n", type
);
9471 test_node_get_value_str((IUnknown
*)comment
, "testing");
9472 test_elem_title((IUnknown
*)comment
, NULL
);
9473 test_elem_set_title((IUnknown
*)comment
, "comment title");
9474 test_elem_title((IUnknown
*)comment
, "comment title");
9475 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
9476 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
9477 test_comment_attrs((IUnknown
*)comment
);
9479 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
9480 test_comment_text((IUnknown
*)node2
, "<!--testing-->");
9481 IHTMLDOMNode_Release(node2
);
9483 test_elem_getelembytag((IUnknown
*)comment
, ET_COMMENT
, 0, NULL
);
9485 IHTMLDOMNode_Release(comment
);
9488 IHTMLDocument5_Release(doc5
);
9491 IHTMLElement_Release(body
);
9494 static void test_replacechild_elems(IHTMLDocument2
*doc
)
9497 IHTMLDOMNode
*node
, *node2
, *node3
;
9498 IHTMLDOMNode
*nodeBody
, *nodeNew
;
9502 body
= doc_get_body(doc
);
9504 node
= test_create_text(doc
, "insert");
9506 V_VT(&var
) = VT_NULL
;
9507 V_DISPATCH(&var
) = NULL
;
9508 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9509 IHTMLDOMNode_Release(node
);
9511 test_elem_innertext(body
, "insert");
9513 node3
= test_create_text(doc
, "replaced");
9515 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
9517 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
9518 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
9520 test_elem_innertext(body
, "replaced");
9522 IHTMLDOMNode_Release(node2
);
9523 IHTMLDOMNode_Release(node3
);
9524 IHTMLDOMNode_Release(nodeBody
);
9526 IHTMLElement_Release(body
);
9529 static void test_noscript(IHTMLDocument2
*doc
)
9531 IHTMLElementCollection
*col
;
9535 static const elem_type_t all_types
[] = {
9544 static const elem_type_t body_all_types
[] = {
9549 hres
= IHTMLDocument2_get_all(doc
, &col
);
9550 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9551 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9552 IHTMLElementCollection_Release(col
);
9554 body
= doc_get_body(doc
);
9555 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
9556 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
9557 IHTMLElement_Release(body
);
9560 static void test_doctype(IHTMLDocument2
*doc
)
9562 IHTMLDocument2
*doc_node
;
9563 IHTMLDOMNode
*doctype
;
9566 doc_node
= get_doc_node(doc
);
9567 doctype
= get_first_child((IUnknown
*)doc_node
);
9568 IHTMLDocument2_Release(doc_node
);
9570 type
= get_node_type((IUnknown
*)doctype
);
9571 ok(type
== 8, "type = %d\n", type
);
9573 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9574 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9575 IHTMLDOMNode_Release(doctype
);
9578 static void test_null_write(IHTMLDocument2
*doc
)
9582 doc_write(doc
, FALSE
, NULL
);
9583 doc_write(doc
, TRUE
, NULL
);
9585 hres
= IHTMLDocument2_write(doc
, NULL
);
9587 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9589 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9591 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9594 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9596 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9597 IHTMLStyleElement
*style_elem
;
9598 IHTMLElement
*doc_elem
, *elem
;
9601 static const elem_type_t all_types
[] = {
9609 static const elem_type_t all_types2
[] = {
9618 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
9620 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9621 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9623 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
9625 doc_elem
= get_doc_elem(doc
);
9627 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9628 IHTMLElement_Release(doc_elem
);
9630 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9631 IHTMLElement_Release(elem
);
9632 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9635 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9636 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9637 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9638 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9640 IHTMLStyleSheet_Release(stylesheet2
);
9641 IHTMLStyleSheet_Release(stylesheet
);
9643 IHTMLStyleElement_Release(style_elem
);
9646 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9648 IOleCommandTarget
*cmdtrg
;
9651 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9652 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9654 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9655 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9657 IOleCommandTarget_Release(cmdtrg
);
9660 static void test_indent(IHTMLDocument2
*doc
)
9662 IHTMLElementCollection
*col
;
9663 IHTMLTxtRange
*range
;
9666 static const elem_type_t all_types
[] = {
9675 static const elem_type_t indent_types
[] = {
9686 hres
= IHTMLDocument2_get_all(doc
, &col
);
9687 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9688 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9689 IHTMLElementCollection_Release(col
);
9691 range
= test_create_body_range(doc
);
9692 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9693 IHTMLTxtRange_Release(range
);
9695 hres
= IHTMLDocument2_get_all(doc
, &col
);
9696 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9697 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9698 IHTMLElementCollection_Release(col
);
9701 static void test_cond_comment(IHTMLDocument2
*doc
)
9703 IHTMLElementCollection
*col
;
9706 static const elem_type_t all_types
[] = {
9714 hres
= IHTMLDocument2_get_all(doc
, &col
);
9715 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9716 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9717 IHTMLElementCollection_Release(col
);
9720 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9722 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9723 return E_NOINTERFACE
;
9726 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9731 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9736 static const IUnknownVtbl UnknownVtbl
= {
9737 Unknown_QueryInterface
,
9741 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9743 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9745 IHTMLWindow2
*frame2
, *parent
, *top
;
9746 IHTMLDocument2
*parent_doc
, *top_doc
;
9747 IHTMLWindow4
*frame
;
9748 IHTMLFrameBase
*frame_elem
;
9749 IObjectIdentity
*obj_ident
;
9750 ITravelLogClient
*tlc
;
9753 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9754 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9758 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9759 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9760 IHTMLWindow4_Release(frame
);
9764 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9765 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9766 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9767 IHTMLFrameBase_Release(frame_elem
);
9769 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9770 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9774 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9775 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9777 IHTMLWindow2_Release(frame2
);
9781 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9782 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9783 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9784 if(hres
== E_NOINTERFACE
) {
9785 win_skip("IID_ITravelLogClient not available\n");
9788 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9790 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9791 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9792 ITravelLogClient_Release(tlc
);
9795 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9796 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9797 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9798 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9799 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9800 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9802 IObjectIdentity_Release(obj_ident
);
9804 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9805 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9806 IHTMLWindow2_Release(parent
);
9808 IHTMLWindow2_Release(frame2
);
9812 test_doc_title(parent_doc
, "frameset test");
9813 IHTMLDocument2_Release(parent_doc
);
9816 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9817 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9818 IHTMLWindow2_Release(frame2
);
9822 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9823 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9824 IHTMLWindow2_Release(top
);
9828 test_doc_title(top_doc
, "frameset test");
9829 IHTMLDocument2_Release(top_doc
);
9832 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9834 VARIANT index_var
, result_var
;
9838 /* test result length */
9839 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9840 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9841 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9843 /* test first frame */
9844 V_VT(&index_var
) = VT_I4
;
9845 V_I4(&index_var
) = 0;
9846 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9847 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9848 if(SUCCEEDED(hres
)) {
9849 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9850 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9852 VariantClear(&result_var
);
9854 /* test second frame */
9855 V_I4(&index_var
) = 1;
9856 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9857 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9858 if(SUCCEEDED(hres
)) {
9859 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9860 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9862 VariantClear(&result_var
);
9864 /* fail on next frame */
9865 V_I4(&index_var
) = 3;
9866 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9867 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9868 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9869 VariantClear(&result_var
);
9871 /* string argument (element id lookup) */
9872 V_VT(&index_var
) = VT_BSTR
;
9873 V_BSTR(&index_var
) = a2bstr(frid
);
9874 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9875 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9876 if(SUCCEEDED(hres
)) {
9877 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9878 test_frame(V_DISPATCH(&result_var
), frid
);
9880 VariantClear(&result_var
);
9881 VariantClear(&index_var
);
9883 /* invalid argument */
9884 V_VT(&index_var
) = VT_BOOL
;
9885 V_BOOL(&index_var
) = VARIANT_TRUE
;
9886 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9887 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9888 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9889 VariantClear(&result_var
);
9892 static void test_frameset(IHTMLDocument2
*doc
)
9894 IHTMLWindow2
*window
;
9895 IHTMLFramesCollection2
*frames
;
9896 IHTMLDocument6
*doc6
;
9900 window
= get_doc_window(doc
);
9902 /* test using IHTMLFramesCollection object */
9904 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9905 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9909 test_frames_collection(frames
, "fr1");
9910 IHTMLFramesCollection2_Release(frames
);
9912 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9913 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9917 test_frames_collection(frames
, "fr1");
9918 IHTMLFramesCollection2_Release(frames
);
9920 /* test using IHTMLWindow2 inheritance */
9921 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9923 /* getElementById with node name attributes */
9924 elem
= get_doc_elem_by_id(doc
, "nm1");
9925 test_elem_id((IUnknown
*)elem
, "fr1");
9927 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
9928 if(SUCCEEDED(hres
)) {
9929 IHTMLElement2
*elem2
;
9932 str
= a2bstr("nm1");
9933 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9934 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9935 ok(!elem2
, "elem = %p\n", elem2
);
9938 str
= a2bstr("fr1");
9939 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9940 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9941 ok(elem2
!= NULL
, "elem2 is NULL\n");
9942 test_elem_id((IUnknown
*)elem2
, "fr1");
9945 IHTMLDocument6_Release(doc6
);
9947 win_skip("IHTMLDocument6 not supported\n");
9950 test_framebase((IUnknown
*)elem
);
9951 test_framebase_name(elem
, "nm1");
9952 test_framebase_put_name(elem
, "frame name");
9953 test_framebase_put_name(elem
, NULL
);
9954 test_framebase_put_name(elem
, "nm1");
9955 test_framebase_src(elem
, "about:blank");
9956 IHTMLElement_Release(elem
);
9958 /* get_name with no name attr */
9959 elem
= get_doc_elem_by_id(doc
, "fr3");
9960 test_framebase_name(elem
, NULL
);
9961 test_framebase_put_name(elem
, "frame name");
9962 test_framebase_put_name(elem
, NULL
);
9963 IHTMLElement_Release(elem
);
9965 IHTMLWindow2_Release(window
);
9968 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9970 IHTMLDocument2
*frag
;
9971 IHTMLDocument3
*doc3
;
9974 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9975 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9977 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9978 IHTMLDocument3_Release(doc3
);
9979 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9980 ok(frag
!= NULL
, "frag == NULL\n");
9985 static void test_docfrag(IHTMLDocument2
*doc
)
9987 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9988 IHTMLElement
*div
, *body
, *br
;
9989 IHTMLElementCollection
*col
;
9990 IHTMLLocation
*location
;
9993 static const elem_type_t all_types
[] = {
10002 frag
= create_docfrag(doc
);
10004 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
10006 body
= (void*)0xdeadbeef;
10007 hres
= IHTMLDocument2_get_body(frag
, &body
);
10008 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
10009 ok(!body
, "body != NULL\n");
10011 location
= (void*)0xdeadbeef;
10012 hres
= IHTMLDocument2_get_location(frag
, &location
);
10013 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
10014 ok(location
== (void*)0xdeadbeef, "location changed\n");
10016 br
= test_create_elem(doc
, "BR");
10017 test_elem_source_index(br
, -1);
10018 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
10019 test_elem_source_index(br
, 0);
10020 IHTMLElement_Release(br
);
10022 test_doc_getelembytag(frag
, "a", ET_A
, 0);
10023 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
10025 div
= get_elem_by_id(doc
, "divid", TRUE
);
10026 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
10027 IHTMLElement_Release(div
);
10029 hres
= IHTMLDocument2_get_all(doc
, &col
);
10030 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
10031 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
10032 IHTMLElementCollection_Release(col
);
10034 div
= test_create_elem(frag
, "div");
10035 owner_doc
= get_owner_doc((IUnknown
*)div
);
10036 doc_node
= get_doc_node(doc
);
10037 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
10038 IHTMLDocument2_Release(doc_node
);
10039 IHTMLDocument2_Release(owner_doc
);
10040 IHTMLElement_Release(div
);
10042 IHTMLDocument2_Release(frag
);
10045 static void check_quirks_mode(IHTMLDocument2
*doc
)
10047 test_compatmode(doc
, "BackCompat");
10050 static void check_strict_mode(IHTMLDocument2
*doc
)
10052 test_compatmode(doc
, "CSS1Compat");
10055 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
10057 IHTMLElement
*elem
;
10061 hres
= IHTMLDocument2_get_body(doc
, &elem
);
10062 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
10064 /* body.offsetHeight value depends on window size in quirks mode */
10065 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
10066 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
10067 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
10068 IHTMLElement_Release(elem
);
10071 static IHTMLDocument2
*notif_doc
;
10072 static BOOL doc_complete
;
10074 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
10075 REFIID riid
, void**ppv
)
10077 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
10082 ok(0, "unexpected call\n");
10083 return E_NOINTERFACE
;
10086 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
10091 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
10096 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
10098 if(dispID
== DISPID_READYSTATE
){
10102 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
10103 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
10105 if(!strcmp_wa(state
, "complete"))
10106 doc_complete
= TRUE
;
10108 SysFreeString(state
);
10114 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
10116 ok(0, "unexpected call\n");
10120 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
10121 PropertyNotifySink_QueryInterface
,
10122 PropertyNotifySink_AddRef
,
10123 PropertyNotifySink_Release
,
10124 PropertyNotifySink_OnChanged
,
10125 PropertyNotifySink_OnRequestEdit
10128 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
10130 static HRESULT
cs_qi(REFIID
,void **);
10131 static IOleDocumentView
*view
;
10132 static HWND container_hwnd
;
10134 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
10136 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
10138 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
10139 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
10142 return E_NOINTERFACE
;
10145 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
10150 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
10155 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
10160 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
10165 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
10170 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
10171 LPCBORDERWIDTHS pborderwidths
)
10176 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
10177 LPCBORDERWIDTHS pborderwidths
)
10182 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
10183 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
10188 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10189 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
10194 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10195 HOLEMENU holemenu
, HWND hwndActiveObject
)
10197 ok(0, "unexpected call\n");
10201 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
10203 ok(0, "unexpected call\n");
10207 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
10212 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
10217 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
10219 ok(0, "unexpected call\n");
10223 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
10224 InPlaceFrame_QueryInterface
,
10225 InPlaceFrame_AddRef
,
10226 InPlaceFrame_Release
,
10227 InPlaceFrame_GetWindow
,
10228 InPlaceFrame_ContextSensitiveHelp
,
10229 InPlaceFrame_GetBorder
,
10230 InPlaceFrame_RequestBorderSpace
,
10231 InPlaceFrame_SetBorderSpace
,
10232 InPlaceFrame_SetActiveObject
,
10233 InPlaceFrame_InsertMenus
,
10234 InPlaceFrame_SetMenu
,
10235 InPlaceFrame_RemoveMenus
,
10236 InPlaceFrame_SetStatusText
,
10237 InPlaceFrame_EnableModeless
,
10238 InPlaceFrame_TranslateAccelerator
10241 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
10243 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
10245 return cs_qi(riid
, ppv
);
10248 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
10253 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
10258 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
10260 *phwnd
= container_hwnd
;
10264 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
10266 ok(0, "unexpected call\n");
10270 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
10275 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
10280 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
10285 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
10286 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
10287 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
10289 static const RECT rect
= {0,0,500,500};
10291 *ppFrame
= &InPlaceFrame
;
10293 *lprcPosRect
= rect
;
10294 *lprcClipRect
= rect
;
10296 lpFrameInfo
->fMDIApp
= FALSE
;
10297 lpFrameInfo
->hwndFrame
= container_hwnd
;
10298 lpFrameInfo
->haccel
= NULL
;
10299 lpFrameInfo
->cAccelEntries
= 0;
10304 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
10309 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
10314 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
10319 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
10324 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
10329 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
10334 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
10335 InPlaceSite_QueryInterface
,
10336 InPlaceSite_AddRef
,
10337 InPlaceSite_Release
,
10338 InPlaceSite_GetWindow
,
10339 InPlaceSite_ContextSensitiveHelp
,
10340 InPlaceSite_CanInPlaceActivate
,
10341 InPlaceSite_OnInPlaceActivate
,
10342 InPlaceSite_OnUIActivate
,
10343 InPlaceSite_GetWindowContext
,
10344 InPlaceSite_Scroll
,
10345 InPlaceSite_OnUIDeactivate
,
10346 InPlaceSite_OnInPlaceDeactivate
,
10347 InPlaceSite_DiscardUndoState
,
10348 InPlaceSite_DeactivateAndUndo
,
10349 InPlaceSite_OnPosRectChange
,
10352 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
10354 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
10356 return cs_qi(riid
, ppv
);
10359 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
10364 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
10369 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
10371 ok(0, "unexpected call\n");
10375 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
10378 ok(0, "unexpected call\n");
10382 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
10387 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
10389 ok(0, "unexpected call\n");
10393 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
10395 ok(0, "unexpected call\n");
10399 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
10401 ok(0, "unexpected call\n");
10405 static const IOleClientSiteVtbl ClientSiteVtbl
= {
10406 ClientSite_QueryInterface
,
10408 ClientSite_Release
,
10409 ClientSite_SaveObject
,
10410 ClientSite_GetMoniker
,
10411 ClientSite_GetContainer
,
10412 ClientSite_ShowObject
,
10413 ClientSite_OnShowWindow
,
10414 ClientSite_RequestNewObjectLayout
10417 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
10419 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
10421 return cs_qi(riid
, ppv
);
10424 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
10429 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
10434 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
10436 RECT rect
= {0,0,500,500};
10437 IOleDocument
*document
;
10440 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
10441 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
10443 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
10444 IOleDocument_Release(document
);
10445 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
10447 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
10448 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
10450 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
10451 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
10453 hres
= IOleDocumentView_SetRect(view
, &rect
);
10454 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
10456 hres
= IOleDocumentView_Show(view
, TRUE
);
10457 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
10462 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
10463 DocumentSite_QueryInterface
,
10464 DocumentSite_AddRef
,
10465 DocumentSite_Release
,
10466 DocumentSite_ActivateMe
10469 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
10471 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
10475 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
10476 *ppv
= &ClientSite
;
10477 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
10478 *ppv
= &DocumentSite
;
10479 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
10480 *ppv
= &InPlaceSite
;
10482 return *ppv
? S_OK
: E_NOINTERFACE
;
10485 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
10487 IOleObject
*oleobj
;
10491 IOleDocumentView_Show(view
, FALSE
);
10492 IOleDocumentView_CloseView(view
, 0);
10493 IOleDocumentView_SetInPlaceSite(view
, NULL
);
10494 IOleDocumentView_Release(view
);
10498 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
10499 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
10501 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
10502 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
10505 IHlinkTarget
*hlink
;
10507 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
10508 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
10510 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
10511 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
10513 IHlinkTarget_Release(hlink
);
10516 IOleObject_Release(oleobj
);
10519 static IHTMLDocument2
*create_doc_with_string(const char *str
)
10521 IPersistStreamInit
*init
;
10523 IHTMLDocument2
*doc
;
10528 notif_doc
= doc
= create_document();
10532 doc_complete
= FALSE
;
10534 mem
= GlobalAlloc(0, len
);
10535 memcpy(mem
, str
, len
);
10536 hr
= CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
10537 ok(hr
== S_OK
, "Failed to create a stream, hr %#x.\n", hr
);
10539 hr
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
10540 ok(hr
== S_OK
, "Failed to get IPersistStreamInit, hr %#x.\n", hr
);
10542 IPersistStreamInit_Load(init
, stream
);
10543 IPersistStreamInit_Release(init
);
10544 IStream_Release(stream
);
10549 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
10551 IConnectionPointContainer
*container
;
10552 IConnectionPoint
*cp
;
10556 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
10557 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
10559 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
10560 IConnectionPointContainer_Release(container
);
10561 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
10563 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
10564 IConnectionPoint_Release(cp
);
10565 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
10568 typedef void (*domtest_t
)(IHTMLDocument2
*);
10570 static void run_domtest(const char *str
, domtest_t test
)
10572 IHTMLDocument2
*doc
;
10576 doc
= create_doc_with_string(str
);
10580 set_client_site(doc
, TRUE
);
10581 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
10583 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
10584 TranslateMessage(&msg
);
10585 DispatchMessageW(&msg
);
10590 set_client_site(doc
, FALSE
);
10591 ref
= IHTMLDocument2_Release(doc
);
10592 ok(!ref
|| broken(ref
== 1), /* Vista */
10593 "ref = %d\n", ref
);
10596 static float expected_document_mode
;
10598 static void test_document_mode(IHTMLDocument2
*doc2
)
10600 IEventTarget
*event_target
;
10601 IHTMLDocument2
*doc_node
;
10602 IHTMLDocument6
*doc
;
10603 IHTMLElement
*body
;
10607 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument6
, (void**)&doc
);
10608 if(hres
== E_NOINTERFACE
) {
10609 win_skip("IHTMLDocument6 not supported\n");
10612 ok(hres
== S_OK
, "Could not get IHTMLDocument6 interface: %08x\n", hres
);
10614 V_VT(&v
) = VT_EMPTY
;
10615 hres
= IHTMLDocument6_get_documentMode(doc
, &v
);
10616 ok(hres
== S_OK
, "get_documentMode failed: %08x\n", hres
);
10617 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
10618 ok(V_R4(&v
) == expected_document_mode
, "documentMode = %f\n", V_R4(&v
));
10619 IHTMLDocument6_Release(doc
);
10621 doc_node
= get_doc_node(doc2
);
10623 hres
= IHTMLDocument2_QueryInterface(doc_node
, &IID_IEventTarget
, (void**)&event_target
);
10624 if(expected_document_mode
>= 9) {
10625 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10626 IEventTarget_Release(event_target
);
10628 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10631 IHTMLDocument2_Release(doc_node
);
10634 body
= doc_get_body(doc2
);
10636 hres
= IHTMLElement_QueryInterface(body
, &IID_IEventTarget
, (void**)&event_target
);
10637 if(expected_document_mode
>= 9) {
10638 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10639 IEventTarget_Release(event_target
);
10641 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10644 IHTMLElement_Release(body
);
10647 static void test_quirks_mode(void)
10649 run_domtest("<html></html>", check_quirks_mode
);
10650 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10651 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10652 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10654 expected_document_mode
= 5;
10655 run_domtest("<html><body></body></html>", test_document_mode
);
10660 expected_document_mode
= 9;
10661 run_domtest("<!DOCTYPE html>\n"
10664 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10668 "</html>", test_document_mode
);
10670 expected_document_mode
= 8;
10671 run_domtest("<!DOCTYPE html>\n"
10674 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
10675 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10679 "</html>", test_document_mode
);
10682 static void check_ie(void)
10684 IHTMLDocument2
*doc
;
10685 IHTMLDocument7
*doc7
;
10688 doc
= create_document();
10692 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
10693 if(SUCCEEDED(hres
)) {
10695 IHTMLDocument7_Release(doc7
);
10698 trace("is_ie9plus %x\n", is_ie9plus
);
10700 IHTMLDocument2_Release(doc
);
10705 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10706 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10707 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10709 CoInitialize(NULL
);
10710 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10711 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10715 run_domtest(doc_str1
, test_doc_elem
);
10716 run_domtest(doc_str1
, test_get_set_attr
);
10717 run_domtest(range_test_str
, test_txtrange
);
10718 run_domtest(range_test2_str
, test_txtrange2
);
10719 if (winetest_interactive
|| ! is_ie_hardened()) {
10720 run_domtest(elem_test_str
, test_elems
);
10721 run_domtest(elem_test2_str
, test_elems2
);
10722 run_domtest(noscript_str
, test_noscript
);
10724 skip("IE running in Enhanced Security Configuration\n");
10726 run_domtest(doc_blank
, test_create_elems
);
10727 run_domtest(doc_blank
, test_defaults
);
10728 run_domtest(doc_blank
, test_null_write
);
10729 run_domtest(emptydiv_str
, test_create_stylesheet
);
10730 run_domtest(indent_test_str
, test_indent
);
10731 run_domtest(cond_comment_str
, test_cond_comment
);
10732 run_domtest(frameset_str
, test_frameset
);
10733 run_domtest(emptydiv_str
, test_docfrag
);
10734 run_domtest(doc_blank
, test_replacechild_elems
);
10735 run_domtest(doctype_str
, test_doctype
);
10737 test_quirks_mode();
10739 DestroyWindow(container_hwnd
);