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 const char doc_blank
[] = "<html></html>";
45 static const char doc_str1
[] = "<html><body>test</body></html>";
46 static const char range_test_str
[] =
47 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
48 static const char range_test2_str
[] =
49 "<html><body>abc<hr />123<br /><hr />def</body></html>";
50 static const char elem_test_str
[] =
51 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
52 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
53 "<link id=\"linkid\"></head>"
54 "<body onload=\"Testing()\">text test<!-- a comment -->"
55 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
56 "<label for=\"in\" id=\"labelid\">Label:</label>"
57 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
58 "<button id=\"btnid\" type=\"submit\"></button>"
59 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
60 "<textarea id=\"X\">text text</textarea>"
61 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
62 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
63 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
64 "<img id=\"imgid\" name=\"WineImg\"/>"
65 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
66 "<form id=\"frm\"></form>"
67 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
69 static const char elem_test2_str
[] =
70 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
71 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
72 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
75 static const char indent_test_str
[] =
76 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
77 static const char cond_comment_str
[] =
78 "<html><head><title>test</title></head><body>"
79 "<!--[if gte IE 4]> <br> <![endif]-->"
81 static const char frameset_str
[] =
82 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
83 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
84 "<frame src=\"about:blank\" id=\"fr3\">"
86 static const char emptydiv_str
[] =
87 "<html><head><title>emptydiv test</title></head>"
88 "<body><div id=\"divid\"></div></body></html>";
89 static const char noscript_str
[] =
90 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
91 "<body><noscript><div>test</div></noscript></body></html>";
92 static const char doctype_str
[] =
94 "<html><head><title>emptydiv test</title></head>"
95 "<body><div id=\"divid\"></div></body></html>";
97 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
98 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
99 static WCHAR wordW
[] = {'w','o','r','d',0};
139 static const IID
* const none_iids
[] = {
144 static const IID
* const doc_node_iids
[] = {
152 &IID_IDocumentSelector
,
154 &IID_IConnectionPointContainer
,
155 &IID_IInternetHostSecurityManager
,
158 &IID_IProvideClassInfo
,
162 static const IID
* const doc_obj_iids
[] = {
168 &IID_IDocumentSelector
,
170 &IID_IConnectionPointContainer
,
174 &IID_IProvideClassInfo
,
175 &IID_ITargetContainer
,
179 #define ELEM_IFACES \
181 &IID_IHTMLDOMNode2, \
183 &IID_IHTMLElement2, \
184 &IID_IHTMLElement3, \
185 &IID_IHTMLElement4, \
186 &IID_IHTMLUniqueName, \
189 static const IID
* const elem_iids
[] = {
191 &IID_IConnectionPointContainer
,
195 static const IID
* const body_iids
[] = {
197 &IID_IHTMLTextContainer
,
198 &IID_IHTMLBodyElement
,
199 &IID_IConnectionPointContainer
,
203 static const IID
* const anchor_iids
[] = {
205 &IID_IHTMLAnchorElement
,
206 &IID_IConnectionPointContainer
,
210 static const IID
* const input_iids
[] = {
212 &IID_IHTMLInputElement
,
213 &IID_IHTMLInputTextElement
,
214 &IID_IConnectionPointContainer
,
218 static const IID
*const button_iids
[] = {
220 &IID_IHTMLButtonElement
,
221 &IID_IConnectionPointContainer
,
225 static const IID
*const area_iids
[] = {
227 &IID_IHTMLAreaElement
,
228 &IID_IConnectionPointContainer
,
232 static const IID
* const label_iids
[] = {
234 &IID_IHTMLLabelElement
,
235 &IID_IConnectionPointContainer
,
239 static const IID
* const select_iids
[] = {
241 &IID_IHTMLSelectElement
,
242 &IID_IConnectionPointContainer
,
246 static const IID
* const textarea_iids
[] = {
248 &IID_IHTMLTextAreaElement
,
249 &IID_IConnectionPointContainer
,
253 static const IID
* const option_iids
[] = {
255 &IID_IHTMLOptionElement
,
256 &IID_IConnectionPointContainer
,
260 static const IID
* const table_iids
[] = {
265 &IID_IConnectionPointContainer
,
269 static const IID
* const script_iids
[] = {
271 &IID_IHTMLScriptElement
,
272 &IID_IConnectionPointContainer
,
276 static const IID
* const text_iids
[] = {
279 &IID_IHTMLDOMTextNode
,
280 &IID_IHTMLDOMTextNode2
,
284 static const IID
* const attr_iids
[] = {
285 &IID_IHTMLDOMAttribute
,
286 &IID_IHTMLDOMAttribute2
,
291 static const IID
* const location_iids
[] = {
297 static const IID
* const window_iids
[] = {
302 &IID_IServiceProvider
,
306 static const IID
* const comment_iids
[] = {
308 &IID_IHTMLCommentElement
,
309 &IID_IConnectionPointContainer
,
313 static const IID
* const img_iids
[] = {
315 &IID_IHTMLImgElement
,
316 &IID_IConnectionPointContainer
,
320 static const IID
* const tr_iids
[] = {
323 &IID_IConnectionPointContainer
,
327 static const IID
* const td_iids
[] = {
330 &IID_IConnectionPointContainer
,
334 static const IID
* const frame_iids
[] = {
337 &IID_IHTMLFrameBase2
,
338 &IID_IConnectionPointContainer
,
342 static const IID
* const html_iids
[] = {
344 &IID_IHTMLHtmlElement
,
345 &IID_IConnectionPointContainer
,
349 static const IID
* const head_iids
[] = {
351 &IID_IHTMLHeadElement
,
352 &IID_IConnectionPointContainer
,
356 static const IID
* const title_iids
[] = {
358 &IID_IHTMLTitleElement
,
359 &IID_IConnectionPointContainer
,
363 static const IID
* const meta_iids
[] = {
365 &IID_IHTMLMetaElement
,
366 &IID_IConnectionPointContainer
,
370 static const IID
* const link_iids
[] = {
372 &IID_IHTMLLinkElement
,
373 &IID_IConnectionPointContainer
,
377 static const IID
* const object_iids
[] = {
379 &IID_IHTMLObjectElement
,
380 &IID_IHTMLObjectElement2
,
381 /* FIXME: No IConnectionPointContainer */
385 static const IID
* const embed_iids
[] = {
387 &IID_IHTMLEmbedElement
,
388 /* FIXME: No IConnectionPointContainer */
392 static const IID
* const iframe_iids
[] = {
395 &IID_IHTMLFrameBase2
,
396 &IID_IHTMLIFrameElement
,
397 &IID_IHTMLIFrameElement2
,
398 &IID_IConnectionPointContainer
,
402 static const IID
* const form_iids
[] = {
404 &IID_IHTMLFormElement
,
405 &IID_IConnectionPointContainer
,
406 &DIID_DispHTMLFormElement
,
410 static const IID
* const styleelem_iids
[] = {
412 &IID_IHTMLStyleElement
,
413 &IID_IConnectionPointContainer
,
417 static const IID
* const generic_iids
[] = {
419 &IID_IHTMLGenericElement
,
420 &IID_IConnectionPointContainer
,
424 static const IID
* const style_iids
[] = {
435 static const IID
* const cstyle_iids
[] = {
439 &IID_IHTMLCurrentStyle
,
440 &IID_IHTMLCurrentStyle2
,
441 &IID_IHTMLCurrentStyle3
,
445 static const IID
* const img_factory_iids
[] = {
449 &IID_IHTMLImageElementFactory
,
453 static const IID
* const selection_iids
[] = {
457 &IID_IHTMLSelectionObject
,
458 &IID_IHTMLSelectionObject2
,
469 static const elem_type_info_t elem_type_infos
[] = {
470 {"", none_iids
, NULL
},
471 {"HTML", html_iids
, &DIID_DispHTMLHtmlElement
, &CLSID_HTMLHtmlElement
},
472 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
, &CLSID_HTMLHeadElement
},
473 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
, &CLSID_HTMLTitleElement
},
474 {"BODY", body_iids
, &DIID_DispHTMLBody
, &CLSID_HTMLBody
},
475 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
, &CLSID_HTMLAnchorElement
},
476 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
},
477 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
, &CLSID_HTMLSelectElement
},
478 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
, &CLSID_HTMLTextAreaElement
},
479 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
},
480 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
, &CLSID_HTMLStyleElement
},
481 {"BLOCKQUOTE",elem_iids
, NULL
},
482 {"P", elem_iids
, NULL
},
483 {"BR", elem_iids
, NULL
},
484 {"TABLE", table_iids
, &DIID_DispHTMLTable
, &CLSID_HTMLTable
},
485 {"TBODY", elem_iids
, NULL
},
486 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
, &CLSID_HTMLScriptElement
},
487 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
, &CLSID_HTMLUnknownElement
},
488 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
},
489 {"!", comment_iids
, &DIID_DispHTMLCommentElement
, &CLSID_HTMLCommentElement
},
490 {"IMG", img_iids
, &DIID_DispHTMLImg
, &CLSID_HTMLImg
},
491 {"TR", tr_iids
, &DIID_DispHTMLTableRow
, &CLSID_HTMLTableRow
},
492 {"TD", td_iids
, &DIID_DispHTMLTableCell
, &CLSID_HTMLTableCell
},
493 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
, &CLSID_HTMLIFrame
},
494 {"FORM", form_iids
, &DIID_DispHTMLFormElement
, &CLSID_HTMLFormElement
},
495 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
, &CLSID_HTMLFrameElement
},
496 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
, &CLSID_HTMLObjectElement
},
497 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
, &CLSID_HTMLEmbed
},
498 {"DIV", elem_iids
, NULL
},
499 {"META", meta_iids
, &DIID_DispHTMLMetaElement
, &CLSID_HTMLMetaElement
},
500 {"NOSCRIPT", elem_iids
, /* &DIID_DispHTMLNoShowElement */},
501 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
, &CLSID_HTMLLinkElement
},
502 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
, &CLSID_HTMLLabelElement
},
503 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
, &CLSID_HTMLButtonElement
},
504 {"AREA", area_iids
, &DIID_DispHTMLAreaElement
, &CLSID_HTMLAreaElement
}
507 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
510 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
511 return lstrcmpA(stra
, buf
);
514 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
519 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
520 prefix_len
= lstrlenA(prefix
);
525 return !lstrcmpA(buf
, prefix
);
528 static BSTR
a2bstr(const char *str
)
536 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
537 ret
= SysAllocStringLen(NULL
, len
);
538 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
543 static const char *debugstr_variant(const VARIANT
*var
)
545 static char buf
[400];
555 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
558 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
561 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
564 sprintf(buf
, "{vt %d}", V_VT(var
));
571 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
573 IUnknown
*unk1
, *unk2
;
578 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
579 IUnknown_Release(unk1
);
580 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
581 IUnknown_Release(unk2
);
586 static IHTMLDocument2
*create_document(void)
589 IHTMLDocument5
*doc5
;
592 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
593 &IID_IHTMLDocument2
, (void**)&doc
);
594 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
598 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
600 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
601 IHTMLDocument2_Release(doc
);
605 IHTMLDocument5_Release(doc5
);
609 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
610 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
615 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
616 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
620 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
621 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
623 const IID
* const *piid
;
627 for(piid
= iids
; *piid
; piid
++) {
628 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
629 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
631 IUnknown_Release(unk
);
635 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
636 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
641 unk
= (void*)0xdeadbeef;
642 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
643 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
644 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
647 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
648 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
650 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
657 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
658 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
659 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
661 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
662 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
664 if(SUCCEEDED(hres
)) {
667 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
668 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
670 *iid
= type_attr
->guid
;
674 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
675 ITypeInfo_Release(typeinfo
);
678 IDispatchEx_Release(dispex
);
682 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
683 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
685 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
686 DISPPARAMS dp
= {NULL
,NULL
,0,0};
691 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
692 IDispatchEx_Release(dispex
);
693 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
695 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
696 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
700 #define test_class_info(a,b) _test_class_info(__LINE__,a,b)
701 static void _test_class_info(unsigned line
, IUnknown
*unk
, const CLSID
*clsid
)
703 IProvideMultipleClassInfo
*multiple_classinfo
;
704 IProvideClassInfo2
*classinfo
;
710 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
711 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
715 hres
= IProvideClassInfo2_GetClassInfo(classinfo
, &typeinfo
);
716 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
719 IProvideClassInfo2_Release(classinfo
);
723 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
724 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
727 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, clsid
),
728 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
729 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
730 "unexpected typekind %d\n", type_attr
->typekind
);
731 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
734 ITypeInfo_Release(typeinfo
);
735 IProvideClassInfo2_Release(classinfo
);
737 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideMultipleClassInfo
, (void**)&multiple_classinfo
);
738 if(IsEqualGUID(clsid
, &CLSID_HTMLXMLHttpRequest
)) {
739 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
741 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08x\n", hres
);
743 hres
= IProvideMultipleClassInfo_GetMultiTypeInfoCount(multiple_classinfo
, &count
);
744 ok_(__FILE__
,line
)(hres
== S_OK
, "GetMultiTypeInfoCount failed: %08x\n", hres
);
745 ok_(__FILE__
,line
)(count
> 0, "count = %u\n", count
);
747 IProvideMultipleClassInfo_Release(multiple_classinfo
);
751 #define test_disp2(a,b,c,d,e) _test_disp2(__LINE__,a,b,c,d,e)
752 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const CLSID
*clsid
, const char *val
)
758 if(_test_get_dispid(line
, unk
, &iid
))
759 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(diid2
&& IsEqualGUID(&iid
, diid2
)),
760 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
762 if(!IsEqualGUID(diid
, &DIID_DispHTMLWindow2
) && !IsEqualGUID(diid
, &DIID_DispHTMLLocation
)) {
763 u
= (void*)0xdeadbeef;
764 hres
= IUnknown_QueryInterface(unk
, &IID_IMarshal
, (void**)&u
);
765 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IMarshal iface\n");
766 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
769 u
= (void*)0xdeadbeef;
770 hres
= IUnknown_QueryInterface(unk
, &IID_IManagedObject
, (void**)&u
);
771 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IManagedObject iface\n");
772 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
775 _test_disp_value(line
, unk
, val
);
778 _test_class_info(line
, unk
, clsid
);
780 u
= (void*)0xdeadbeef;
781 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&u
);
782 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IProvideClassInfo iface\n");
783 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
787 #define test_disp(a,b,c,d) _test_disp(__LINE__,a,b,c,d)
788 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const CLSID
*clsid
, const char *val
)
790 return _test_disp2(line
, unk
, diid
, NULL
, clsid
, val
);
793 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
794 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
796 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
797 DISPPARAMS dp
= {val
, NULL
, 1, 0};
804 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
806 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
808 memset(&ei
, 0, sizeof(ei
));
809 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
810 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
814 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
815 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
820 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
821 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
825 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
826 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
831 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
832 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
836 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
837 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
842 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
843 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
847 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
848 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
853 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
854 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
858 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
859 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
861 IHTMLDocument3
*doc3
;
864 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
865 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
870 #define get_node_iface(u) _get_node_iface(__LINE__,u)
871 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
876 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
877 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
881 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
882 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
887 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
888 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
892 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
893 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
898 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
899 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
903 #define get_img_iface(u) _get_img_iface(__LINE__,u)
904 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
906 IHTMLImgElement
*img
;
909 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
910 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
914 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
915 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
917 IHTMLAnchorElement
*anchor
;
920 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
921 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
925 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
926 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
928 IHTMLTextAreaElement
*textarea
;
931 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
932 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
936 #define get_select_iface(u) _get_select_iface(__LINE__,u)
937 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
939 IHTMLSelectElement
*select
;
942 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
943 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
947 #define get_option_iface(u) _get_option_iface(__LINE__,u)
948 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
950 IHTMLOptionElement
*option
;
953 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
954 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
958 #define get_form_iface(u) _get_form_iface(__LINE__,u)
959 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
961 IHTMLFormElement
*form
;
964 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
965 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
969 #define get_text_iface(u) _get_text_iface(__LINE__,u)
970 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
972 IHTMLDOMTextNode
*text
;
975 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
976 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
980 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
981 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
983 IHTMLDOMTextNode2
*text2
;
986 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
987 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
991 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
992 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
994 IHTMLCommentElement
*comment
;
997 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
998 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
1002 #define get_object_iface(u) _get_object_iface(__LINE__,u)
1003 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
1005 IHTMLObjectElement
*obj
;
1008 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
1009 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
1013 #define get_style_iface(u) _get_style_iface(__LINE__,u)
1014 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
1016 IHTMLStyleElement
*obj
;
1019 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
1020 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
1024 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
1025 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
1027 IHTMLMetaElement
*ret
;
1030 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
1031 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
1035 #define get_link_iface(u) _get_link_iface(__LINE__,u)
1036 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
1038 IHTMLLinkElement
*ret
;
1041 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
1042 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
1046 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
1047 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
1049 IHTMLIFrameElement2
*ret
;
1052 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1053 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1057 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1058 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1060 IHTMLButtonElement
*ret
;
1063 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1064 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1068 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1069 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1071 IHTMLLabelElement
*ret
;
1074 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1075 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1079 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1080 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1082 IHTMLDOMAttribute2
*ret
;
1085 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1086 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1090 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1091 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1093 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1094 IHTMLElement6
*elem
;
1098 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1099 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1100 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1101 SysFreeString(name
);
1103 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement6
, (void**)&elem
);
1104 if(SUCCEEDED(hres
)) {
1105 hres
= IHTMLElement6_get_nodeName(elem
, &name
);
1106 ok_(__FILE__
, line
) (hres
== S_OK
, "(elem) get_nodeName failed: %08x\n", hres
);
1107 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "(elem) got name: %s, expected %s\n",
1108 wine_dbgstr_w(name
), exname
);
1109 SysFreeString(name
);
1110 IHTMLElement6_Release(elem
);
1113 IHTMLDOMNode_Release(node
);
1116 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1117 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1119 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1120 IDispatch
*disp
= (void*)0xdeadbeef;
1121 IHTMLDocument2
*doc
= NULL
;
1124 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1125 IHTMLDOMNode2_Release(node
);
1126 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1129 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1130 IDispatch_Release(disp
);
1131 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1137 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1138 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1140 IHTMLWindow2
*window
;
1144 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1145 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1146 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1151 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1152 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1154 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1155 IHTMLDOMNode
*ret
= NULL
;
1158 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1159 IHTMLDOMNode_Release(node
);
1160 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1161 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1167 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1168 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1170 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1171 IHTMLElement6
*elem6
;
1175 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1176 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1177 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1180 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement6
, (void**)&elem6
);
1181 if(SUCCEEDED(hres
)) {
1182 hres
= IHTMLElement6_get_tagName(elem6
, &tag
);
1183 ok_(__FILE__
, line
)(hres
== S_OK
, "(elem6) get_tagName failed: %08x\n", hres
);
1184 ok_(__FILE__
, line
)(!strcmp_wa(tag
, extag
), "(elem6) got tag: %s, expected %s\n",
1185 wine_dbgstr_w(tag
), extag
);
1187 IHTMLElement6_Release(elem6
);
1190 IHTMLElement_Release(elem
);
1193 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1194 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1196 const char *expected_value
= "[object]";
1198 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1199 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1201 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
) {
1203 expected_value
= NULL
;
1204 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, elem_type_infos
[type
].clsid
, expected_value
);
1208 #define get_node_type(n) _get_node_type(__LINE__,n)
1209 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1211 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1215 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1216 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1218 IHTMLDOMNode_Release(node
);
1223 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1224 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1226 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1227 IHTMLDOMChildrenCollection
*col
= NULL
;
1231 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1232 IHTMLDOMNode_Release(node
);
1233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1237 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1238 IDispatch_Release(disp
);
1239 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1244 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1245 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1247 IHTMLDOMNode
*node
= NULL
;
1251 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1252 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1254 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1255 IDispatch_Release(disp
);
1260 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1261 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1267 VariantInit(&value
);
1270 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1272 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1275 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1276 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1278 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1281 VariantClear(&value
);
1284 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1285 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1287 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1288 IHTMLElement
*off_parent
;
1292 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1293 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1295 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1298 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1299 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1301 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1302 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1304 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1305 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1307 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1308 IHTMLElement_Release(off_parent
);
1310 IHTMLElement_Release(elem
);
1313 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1314 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1316 LONG l
= 0xdeadbeef;
1319 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1320 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1321 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1324 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1325 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1327 IHTMLWindow2
*window
;
1328 IHTMLDocument2
*ret
;
1331 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1332 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1334 hres
= IHTMLWindow2_get_document(window
, &ret
);
1335 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1336 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1341 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1342 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1347 hres
= IHTMLWindow2_get_name(window
, &name
);
1348 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1350 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1352 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1353 SysFreeString(name
);
1356 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1357 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1363 hres
= IHTMLWindow2_put_name(window
, str
);
1365 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1367 _test_window_name(line
, window
, name
);
1370 #define test_window_status(d) _test_window_status(__LINE__,d)
1371 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1376 status
= (void*)0xdeadbeef;
1377 hres
= IHTMLWindow2_get_status(window
, &status
);
1378 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1379 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1380 SysFreeString(status
);
1383 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1384 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1389 str
= a2bstr(status
);
1390 hres
= IHTMLWindow2_put_status(window
, str
);
1392 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1395 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1396 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1401 hres
= IHTMLWindow2_get_length(window
, &length
);
1402 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1403 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1406 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1407 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1409 IHTMLFrameBase2
*base2
;
1410 IHTMLWindow2
*window
;
1413 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1414 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1417 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1418 IHTMLFrameBase2_Release(base2
);
1419 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1420 ok(window
!= NULL
, "contentWindow = NULL\n");
1425 static void test_get_set_attr(IHTMLDocument2
*doc
)
1428 IHTMLDocument3
*doc3
;
1433 /* grab an element to test with */
1434 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1435 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1437 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1438 IHTMLDocument3_Release(doc3
);
1439 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1441 /* get a non-present attribute */
1442 bstr
= a2bstr("notAnAttribute");
1443 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1444 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1445 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1447 SysFreeString(bstr
);
1449 /* get a present attribute */
1450 bstr
= a2bstr("scrollHeight");
1451 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1452 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1453 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1455 SysFreeString(bstr
);
1457 /* create a new BSTR attribute */
1458 bstr
= a2bstr("newAttribute");
1460 V_VT(&val
) = VT_BSTR
;
1461 V_BSTR(&val
) = a2bstr("the value");
1462 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1463 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1466 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1467 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1468 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1469 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
)));
1472 /* overwrite the attribute with a BOOL */
1473 V_VT(&val
) = VT_BOOL
;
1474 V_BOOL(&val
) = VARIANT_TRUE
;
1475 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1476 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1479 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1480 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1481 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1482 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1485 SysFreeString(bstr
);
1487 /* case-insensitive */
1488 bstr
= a2bstr("newattribute");
1489 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1490 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1491 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1492 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1495 /* overwrite the attribute with null */
1496 V_VT(&val
) = VT_NULL
;
1497 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1498 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1500 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1501 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1502 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1503 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1506 SysFreeString(bstr
);
1507 IHTMLElement_Release(elem
);
1510 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1511 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1514 IHTMLDocument3
*doc3
;
1517 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1518 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1519 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1520 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1521 IHTMLDocument3_Release(doc3
);
1526 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1527 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1529 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1533 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1534 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1535 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1538 _test_disp_value(line
, unk
, exhref
);
1541 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1542 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1544 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1548 str
= a2bstr(exhref
);
1549 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1550 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1553 _test_disp_value(line
, unk
, exhref
);
1556 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1557 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1559 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1563 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1564 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1566 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1568 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1572 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1573 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1575 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1579 str
= a2bstr(exrel
);
1580 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1581 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1585 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1586 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1588 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1592 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1593 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1595 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1597 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1601 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1602 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1604 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1608 str
= target
? a2bstr(target
) : NULL
;
1609 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1610 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1614 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1615 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1617 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1621 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1622 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1624 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1626 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1630 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1631 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1633 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1637 str
= name
? a2bstr(name
) : NULL
;
1638 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1639 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1642 _test_anchor_name(line
, unk
, name
);
1645 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1646 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1648 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1652 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1653 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1655 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1657 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1661 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1662 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1664 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1668 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1669 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1670 if ( ! str
&& allowbroken
)
1671 win_skip("skip ie6 incorrect behavior\n");
1673 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1675 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1679 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1680 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1682 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1686 str
= search
? a2bstr(search
) : NULL
;
1687 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1688 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1692 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1693 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1695 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1699 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1700 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1702 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1704 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1708 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1709 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1714 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1715 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1716 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1717 SysFreeString(bstr
);
1720 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1721 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1726 bstr
= a2bstr(text
);
1727 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1728 SysFreeString(bstr
);
1729 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1731 _test_option_text(line
, option
, text
);
1734 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1735 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1740 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1741 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1742 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1743 SysFreeString(bstr
);
1746 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1747 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1752 bstr
= a2bstr(value
);
1753 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1754 SysFreeString(bstr
);
1755 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1757 _test_option_value(line
, option
, value
);
1760 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1761 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1763 VARIANT_BOOL b
= 0x100;
1766 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1767 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1768 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1771 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1772 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1776 hres
= IHTMLOptionElement_put_selected(option
, b
);
1777 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1778 _test_option_selected(line
, option
, b
);
1781 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1782 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1787 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1788 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1791 hres
= IHTMLOptionElement_get_index(option
, &val
);
1792 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1793 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1794 "value = %d, expected = %d\n", val
, exval
);
1797 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1798 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1802 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1803 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1806 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1807 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1812 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1813 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1816 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1817 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1818 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1821 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1823 test_option_defaultSelected(option
, VARIANT_FALSE
);
1824 test_option_selected(option
, VARIANT_FALSE
);
1826 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1827 test_option_defaultSelected(option
, VARIANT_FALSE
);
1828 test_option_selected(option
, VARIANT_FALSE
);
1830 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1831 test_option_defaultSelected(option
, VARIANT_TRUE
);
1832 test_option_selected(option
, VARIANT_FALSE
);
1834 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1835 test_option_defaultSelected(option
, VARIANT_FALSE
);
1836 test_option_selected(option
, VARIANT_FALSE
);
1838 test_option_put_selected(option
, VARIANT_TRUE
);
1839 test_option_selected(option
, VARIANT_TRUE
);
1840 test_option_defaultSelected(option
, VARIANT_FALSE
);
1842 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1843 test_option_defaultSelected(option
, VARIANT_TRUE
);
1844 test_option_selected(option
, VARIANT_TRUE
);
1846 /* Restore defaultSelected */
1847 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1848 test_option_put_selected(option
, VARIANT_FALSE
);
1851 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1852 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1854 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1855 BSTR value
= (void*)0xdeadbeef;
1858 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1859 IHTMLTextAreaElement_Release(textarea
);
1860 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1862 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1864 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1865 SysFreeString(value
);
1868 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1869 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1871 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1872 BSTR tmp
= a2bstr(value
);
1875 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1876 IHTMLTextAreaElement_Release(textarea
);
1877 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1880 _test_textarea_value(line
, unk
, value
);
1883 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1884 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1886 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1887 BSTR value
= (void*)0xdeadbeef;
1890 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1891 IHTMLTextAreaElement_Release(textarea
);
1892 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1894 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1896 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1897 SysFreeString(value
);
1900 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1901 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1903 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1904 BSTR tmp
= a2bstr(value
);
1907 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1908 IHTMLTextAreaElement_Release(textarea
);
1909 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1912 _test_textarea_defaultvalue(line
, unk
, value
);
1915 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1916 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1918 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1919 VARIANT_BOOL b
= 0x100;
1922 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1923 IHTMLTextAreaElement_Release(textarea
);
1924 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1925 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1928 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1929 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1931 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1934 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1935 IHTMLTextAreaElement_Release(textarea
);
1936 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1938 _test_textarea_readonly(line
, unk
, b
);
1941 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1942 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1944 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1945 BSTR type
= (void*)0xdeadbeef;
1948 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1949 IHTMLTextAreaElement_Release(textarea
);
1950 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1951 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1952 SysFreeString(type
);
1955 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1956 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1958 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1959 IHTMLFormElement
*form
;
1962 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1963 IHTMLTextAreaElement_Release(textarea
);
1964 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1969 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1970 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1972 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1976 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1977 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1978 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1980 IHTMLCommentElement_Release(comment
);
1981 SysFreeString(text
);
1984 #define create_attr(a,b) _create_attr(__LINE__,a,b)
1985 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
1987 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
1988 BSTR str
= a2bstr("Test");
1989 IHTMLDOMAttribute
*attr
;
1992 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
1993 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
1995 IHTMLDocument5_Release(doc
);
2000 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
2001 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2003 VARIANT_BOOL specified
;
2006 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
2007 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
2008 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
2011 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
2012 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2014 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2015 VARIANT_BOOL expando
;
2018 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
2019 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
2020 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
2022 IHTMLDOMAttribute2_Release(attr2
);
2025 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
2026 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
2028 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2032 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
2033 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
2035 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
2037 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
2039 IHTMLDOMAttribute2_Release(attr2
);
2043 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
2044 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
2046 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2047 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
2048 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
2049 IHTMLDOMAttribute
*attr
;
2050 BSTR name
= a2bstr("test");
2054 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2055 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2056 ok(attr
== NULL
, "attr != NULL\n");
2060 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2061 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2063 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2064 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2065 ok(attr
!= NULL
, "attr == NULL\n");
2067 test_attr_expando(attr
, VARIANT_TRUE
);
2069 IHTMLDOMAttribute_Release(attr
);
2070 IHTMLCommentElement_Release(comment
);
2071 IHTMLElement_Release(elem
);
2072 IHTMLElement4_Release(elem4
);
2073 SysFreeString(name
);
2076 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2077 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2079 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2084 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2085 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
2086 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
2087 IHTMLObjectElement_Release(object
);
2090 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2091 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
2093 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2097 str
= (void*)0xdeadbeef;
2098 hres
= IHTMLObjectElement_get_name(object
, &str
);
2099 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2101 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2103 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2105 IHTMLObjectElement_Release(object
);
2108 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2109 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2111 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2116 hres
= IHTMLObjectElement_put_name(object
, str
);
2117 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2119 IHTMLObjectElement_Release(object
);
2121 _test_object_name(line
, elem
, name
);
2124 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2125 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2126 const char *txt
, const char *val
)
2128 IHTMLOptionElementFactory
*factory
;
2129 IHTMLOptionElement
*option
;
2130 IHTMLWindow2
*window
;
2131 VARIANT text
, value
, empty
;
2134 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2135 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2137 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2138 IHTMLWindow2_Release(window
);
2139 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2141 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, NULL
, "[object]");
2143 V_VT(&text
) = VT_BSTR
;
2144 V_BSTR(&text
) = a2bstr(txt
);
2145 V_VT(&value
) = VT_BSTR
;
2146 V_BSTR(&value
) = a2bstr(val
);
2147 V_VT(&empty
) = VT_EMPTY
;
2149 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2150 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2152 IHTMLOptionElementFactory_Release(factory
);
2153 VariantClear(&text
);
2154 VariantClear(&value
);
2156 _test_option_text(line
, option
, txt
);
2157 _test_option_value(line
, option
, val
);
2158 _test_option_selected(line
, option
, VARIANT_FALSE
);
2163 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2164 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2169 hres
= IHTMLImgElement_get_width(img
, &found
);
2170 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2171 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2174 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2175 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2179 hres
= IHTMLImgElement_put_width(img
, width
);
2180 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2182 _test_img_width(line
, img
, width
);
2185 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2186 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2191 hres
= IHTMLImgElement_get_height(img
, &found
);
2192 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2193 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2196 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2197 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2201 hres
= IHTMLImgElement_put_height(img
, height
);
2202 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2204 _test_img_height(line
, img
, height
);
2207 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2208 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2209 LONG wdth
, LONG hght
)
2211 IHTMLImageElementFactory
*factory
;
2212 IHTMLImgElement
*img
;
2213 IHTMLWindow2
*window
;
2214 VARIANT width
, height
;
2218 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2221 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2222 IHTMLWindow2_Release(window
);
2223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2225 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2226 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, NULL
, "[object]");
2229 snprintf(buf
, 16, "%d", wdth
);
2230 V_VT(&width
) = VT_BSTR
;
2231 V_BSTR(&width
) = a2bstr(buf
);
2233 V_VT(&width
) = VT_EMPTY
;
2238 snprintf(buf
, 16, "%d", hght
);
2239 V_VT(&height
) = VT_BSTR
;
2240 V_BSTR(&height
) = a2bstr(buf
);
2242 V_VT(&height
) = VT_EMPTY
;
2246 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2247 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2249 IHTMLImageElementFactory_Release(factory
);
2250 VariantClear(&width
);
2251 VariantClear(&height
);
2253 if(SUCCEEDED(hres
)) {
2254 _test_img_width(line
, img
, wdth
);
2255 _test_img_height(line
, img
, hght
);
2262 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2263 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2265 LONG len
= 0xdeadbeef;
2268 hres
= IHTMLSelectElement_get_length(select
, &len
);
2269 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2270 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2273 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2274 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2276 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2279 hres
= IHTMLSelectElement_put_length(select
, length
);
2280 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2281 _test_select_length(line
, select
, length
);
2282 IHTMLSelectElement_Release(select
);
2285 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2286 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2288 LONG idx
= 0xdeadbeef;
2291 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2292 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2293 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2296 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2297 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2301 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2302 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2303 _test_select_selidx(line
, select
, index
);
2306 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2307 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2312 hres
= IHTMLSelectElement_get_value(select
, &val
);
2313 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2315 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2317 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2321 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2322 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2328 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2329 SysFreeString(bstr
);
2330 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2333 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2334 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2339 hres
= IHTMLSelectElement_get_type(select
, &type
);
2340 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2341 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2342 SysFreeString(type
);
2345 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2346 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2348 VARIANT_BOOL b
= 100;
2351 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2352 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2353 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2356 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2357 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2361 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2362 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2364 _test_select_multiple(line
, select
, val
);
2367 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2368 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2373 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2374 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2377 hres
= IHTMLSelectElement_get_size(select
, &val
);
2378 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2379 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2382 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2383 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2387 hres
= IHTMLSelectElement_put_size(select
, val
);
2388 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2391 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2392 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2398 hres
= IHTMLSelectElement_get_name(select
, &text
);
2399 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2401 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2402 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2403 wine_dbgstr_w(text
), extext
);
2404 SysFreeString(text
);
2406 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2409 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2410 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2415 bstr
= a2bstr(text
);
2417 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2418 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2419 SysFreeString(bstr
);
2422 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2423 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2428 hres
= IHTMLTxtRange_get_text(range
, &text
);
2429 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2432 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2433 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2435 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2438 SysFreeString(text
);
2442 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2443 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2447 hres
= IHTMLTxtRange_collapse(range
, b
);
2448 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2449 _test_range_text(line
, range
, NULL
);
2452 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2453 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2454 VARIANT_BOOL exb
, const char *extext
)
2456 VARIANT_BOOL b
= 0xe0e0;
2459 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2460 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2461 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2462 _test_range_text(line
, range
, extext
);
2465 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2466 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2468 LONG c
= 0xdeadbeef;
2471 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2472 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2473 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2474 _test_range_text(line
, range
, NULL
);
2477 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2478 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2479 LPWSTR unit
, LONG cnt
, LONG excnt
)
2481 LONG c
= 0xdeadbeef;
2484 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2485 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2486 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2489 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2490 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2492 LONG c
= 0xdeadbeef;
2495 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2496 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2497 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2500 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2501 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2504 BSTR bstr
= a2bstr(text
);
2506 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2507 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2508 SysFreeString(bstr
);
2509 _test_range_text(line
, range
, NULL
);
2512 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2513 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2519 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2520 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2521 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2524 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2525 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2531 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2532 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2533 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2536 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2537 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2538 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2541 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2542 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2546 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2547 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2549 BSTR str
= a2bstr(html
);
2552 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2553 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2557 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2558 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2563 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2564 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2566 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2568 IHTMLElement_Release(elem
);
2571 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2572 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2574 VARIANT name
, index
;
2579 V_VT(&index
) = VT_EMPTY
;
2580 V_VT(&name
) = VT_I4
;
2582 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2583 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2584 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2586 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2587 IDispatch_Release(disp
);
2591 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2592 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2593 const elem_type_t
*elem_types
, LONG exlen
)
2595 IHTMLElementCollection
*col
;
2596 IEnumVARIANT
*enum_var
;
2601 VARIANT name
, index
, v
, vs
[5];
2602 IDispatch
*disp
, *disp2
;
2605 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2606 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2608 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, NULL
, "[object]");
2610 hres
= IHTMLElementCollection_get_length(col
, &len
);
2611 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2612 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2617 V_VT(&index
) = VT_EMPTY
;
2619 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2620 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2622 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2623 IUnknown_Release(enum_unk
);
2624 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2626 for(i
=0; i
<len
; i
++) {
2627 V_VT(&name
) = VT_I4
;
2629 disp
= (void*)0xdeadbeef;
2630 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2631 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2632 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2633 if(FAILED(hres
) || !disp
)
2636 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2639 V_VT(&name
) = VT_UINT
;
2641 disp2
= (void*)0xdeadbeef;
2642 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2643 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2644 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2646 IDispatch_Release(disp2
);
2650 V_VT(&v
) = VT_ERROR
;
2651 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2652 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2654 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2655 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2656 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2657 IDispatch_Release(V_DISPATCH(&v
));
2659 IDispatch_Release(disp
);
2662 fetched
= 0xdeadbeef;
2664 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2665 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2666 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2667 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2669 hres
= IEnumVARIANT_Reset(enum_var
);
2670 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2672 fetched
= 0xdeadbeef;
2674 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2675 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2676 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2677 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2679 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2680 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2682 memset(vs
, 0, sizeof(vs
));
2684 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2685 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2686 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2688 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2689 IDispatch_Release(V_DISPATCH(vs
));
2692 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2693 IDispatch_Release(V_DISPATCH(vs
+1));
2696 hres
= IEnumVARIANT_Reset(enum_var
);
2697 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2699 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2700 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2702 IEnumVARIANT_Release(enum_var
);
2704 V_VT(&name
) = VT_I4
;
2706 disp
= (void*)0xdeadbeef;
2707 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2708 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2709 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2711 V_VT(&name
) = VT_UI4
;
2713 disp
= (void*)0xdeadbeef;
2714 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2715 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2716 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2718 V_VT(&name
) = VT_INT
;
2720 disp
= (void*)0xdeadbeef;
2721 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2722 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2723 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2725 V_VT(&name
) = VT_UINT
;
2727 disp
= (void*)0xdeadbeef;
2728 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2729 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2730 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2732 V_VT(&name
) = VT_I4
;
2734 disp
= (void*)0xdeadbeef;
2735 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2736 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2737 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2739 IHTMLElementCollection_Release(col
);
2742 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2743 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2745 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2749 hres
= IHTMLElement_get_all(elem
, &disp
);
2750 IHTMLElement_Release(elem
);
2751 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2753 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2754 IDispatch_Release(disp
);
2757 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2758 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2760 IHTMLElementCollection
*col
;
2763 hres
= IHTMLDocument2_get_all(doc
, &col
);
2764 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2766 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2767 IHTMLElementCollection_Release(col
);
2770 #define test_children_collection_length(a,b) _test_children_collection_length(__LINE__,a,b)
2771 static LONG
_test_children_collection_length(unsigned line
, IHTMLDOMChildrenCollection
*collection
, LONG exlen
)
2776 hres
= IHTMLDOMChildrenCollection_get_length(collection
, &length
);
2777 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2779 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
2784 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2785 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2787 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2788 IHTMLElementCollection
*col
= NULL
;
2789 elem_type_t
*types
= NULL
;
2794 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2795 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2797 IHTMLElement2_Release(elem
);
2798 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2799 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2802 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2803 for(i
=0; i
<exlen
; i
++)
2807 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2809 HeapFree(GetProcessHeap(), 0, types
);
2812 *ret
= get_elem_col_item_idx(col
, 0);
2813 IHTMLElementCollection_Release(col
);
2816 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2817 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2819 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2820 IHTMLElementCollection
*col
= NULL
;
2821 elem_type_t
*types
= NULL
;
2826 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2827 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2829 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2830 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2833 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2834 for(i
=0; i
<exlen
; i
++)
2838 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2840 HeapFree(GetProcessHeap(), 0, types
);
2841 IHTMLElementCollection_Release(col
);
2842 IHTMLDocument3_Release(doc
);
2845 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2846 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2851 hres
= IHTMLElement_get_innerText(elem
, &text
);
2852 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2854 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2855 wine_dbgstr_w(text
), extext
);
2857 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2858 SysFreeString(text
);
2861 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2862 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2864 IHTMLDOMChildrenCollection
*col
;
2869 hres
= IHTMLElement_put_innerText(elem
, str
);
2870 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2873 _test_elem_innertext(line
, elem
, text
);
2876 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2877 ok(col
!= NULL
, "col == NULL\n");
2882 _test_children_collection_length(line
, col
, 1);
2884 node
= _get_child_item(line
, col
, 0);
2885 ok(node
!= NULL
, "node == NULL\n");
2887 type
= _get_node_type(line
, (IUnknown
*)node
);
2888 ok(type
== 3, "type=%d\n", type
);
2889 IHTMLDOMNode_Release(node
);
2892 IHTMLDOMChildrenCollection_Release(col
);
2897 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
2898 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2903 hres
= IHTMLElement_get_outerText(elem
, &text
);
2904 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08x\n", hres
);
2906 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_outerText returned %s expected %s\n",
2907 wine_dbgstr_w(text
), extext
);
2909 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2910 SysFreeString(text
);
2913 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
2914 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2916 BSTR str
= a2bstr(text
);
2919 hres
= IHTMLElement_put_outerText(elem
, str
);
2920 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08x\n", hres
);
2924 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
2925 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
2927 BSTR str
= a2bstr("test");
2930 hres
= IHTMLElement_put_outerText(elem
, str
);
2931 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08x\n", hres
);
2935 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2936 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2938 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2942 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2943 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2945 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2947 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2949 IHTMLElement_Release(elem
);
2950 SysFreeString(html
);
2953 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2954 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2956 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2960 html
= a2bstr(inner_html
);
2961 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2962 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2964 IHTMLElement_Release(elem
);
2965 SysFreeString(html
);
2968 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2969 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2971 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2975 html
= a2bstr(outer_html
);
2976 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2977 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2979 IHTMLElement_Release(elem
);
2980 SysFreeString(html
);
2983 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2984 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2986 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2990 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2991 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2992 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2994 IHTMLElement_Release(elem
);
2995 SysFreeString(html
);
2998 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2999 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
3005 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
3006 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
3007 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
3010 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
3011 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
3017 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
3018 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
3019 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
3022 #define get_first_child(n) _get_first_child(__LINE__,n)
3023 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
3025 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3026 IHTMLDOMNode
*child
= NULL
;
3029 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
3030 IHTMLDOMNode_Release(node
);
3031 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
3036 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
3037 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3039 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3040 VARIANT_BOOL b
= 0xdead;
3043 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
3044 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
3045 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
3047 IHTMLDOMNode_Release(node
);
3050 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
3051 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
3053 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3054 IHTMLDOMNode
*parent
;
3057 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
3058 IHTMLDOMNode_Release(node
);
3059 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3064 #define node_get_next(u) _node_get_next(__LINE__,u)
3065 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
3067 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3071 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
3072 IHTMLDOMNode_Release(node
);
3073 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
3078 #define node_get_prev(u) _node_get_prev(__LINE__,u)
3079 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
3081 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3085 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3086 IHTMLDOMNode_Release(node
);
3087 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
3092 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3093 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3095 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3096 IHTMLElement
*parent
;
3099 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3100 IHTMLElement_Release(elem
);
3101 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
3106 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3107 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3109 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3110 VARIANT_BOOL disabled
= 100;
3114 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3115 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3116 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3117 IHTMLElement3_Release(elem3
);
3120 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3121 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3123 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3127 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3128 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3130 IHTMLElement3_Release(elem3
);
3131 _test_elem3_get_disabled(line
, unk
, b
);
3134 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3135 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3137 VARIANT_BOOL disabled
= 100;
3140 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3141 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3142 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3144 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3147 static void test_select_remove(IHTMLSelectElement
*select
)
3151 hres
= IHTMLSelectElement_remove(select
, 3);
3152 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3153 test_select_length(select
, 2);
3155 hres
= IHTMLSelectElement_remove(select
, -1);
3156 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3157 test_select_length(select
, 2);
3159 hres
= IHTMLSelectElement_remove(select
, 0);
3160 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3161 test_select_length(select
, 1);
3164 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3165 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3167 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3171 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3172 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3173 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3174 IHTMLDOMTextNode_Release(text
);
3177 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3178 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3180 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3184 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3185 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3186 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3187 IHTMLDOMTextNode_Release(text
);
3191 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3192 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3194 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3195 BSTR str
= a2bstr(data
);
3198 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3199 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3200 IHTMLDOMTextNode_Release(text
);
3204 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3205 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3207 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3208 BSTR str
= a2bstr(data
);
3211 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3212 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3213 IHTMLDOMTextNode2_Release(text
);
3217 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3218 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3222 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3225 _test_select_get_disabled(line
, select
, b
);
3228 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3229 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3231 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3235 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3236 IHTMLElement2_Release(elem
);
3237 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3239 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3241 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3246 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3247 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3249 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3250 BSTR dir
= a2bstr(dira
);
3253 hres
= IHTMLElement2_put_dir(elem
, dir
);
3254 IHTMLElement2_Release(elem
);
3255 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3258 _test_elem_dir(line
, unk
, dira
);
3261 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3262 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3264 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3265 IHTMLTextContainer
*txtcont
;
3266 LONG l
= -1, l2
= -1;
3269 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3270 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3271 IHTMLElement2_Release(elem
);
3273 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3274 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3276 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3277 IHTMLTextContainer_Release(txtcont
);
3278 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3279 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3284 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3285 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3287 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3288 IHTMLTextContainer
*txtcont
;
3289 LONG l
= -1, l2
= -1;
3292 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3293 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3294 IHTMLElement2_Release(elem
);
3296 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3297 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3299 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3300 IHTMLTextContainer_Release(txtcont
);
3301 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3302 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3307 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3308 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3310 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3311 IHTMLTextContainer
*txtcont
;
3312 LONG l
= -1, l2
= -1;
3315 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3316 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3317 IHTMLElement2_Release(elem
);
3319 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3320 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3322 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3323 IHTMLTextContainer_Release(txtcont
);
3324 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3325 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3330 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3331 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3333 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3334 IHTMLTextContainer
*txtcont
;
3335 LONG l
= -1, l2
= -1;
3338 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3339 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3341 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3342 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3343 IHTMLElement2_Release(elem
);
3345 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3346 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3348 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3349 IHTMLTextContainer_Release(txtcont
);
3350 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3351 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3354 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3355 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3357 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3361 hres
= IHTMLImgElement_get_src(img
, &src
);
3362 IHTMLImgElement_Release(img
);
3363 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3364 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3365 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3369 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3370 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3372 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3377 hres
= IHTMLImgElement_put_src(img
, tmp
);
3378 IHTMLImgElement_Release(img
);
3380 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3383 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3384 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3386 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3390 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3391 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3393 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3395 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3399 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3400 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3402 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3407 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3408 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3411 _test_img_alt(line
, unk
, alt
);
3414 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3415 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3417 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3421 tmp
= a2bstr(align
);
3422 hres
= IHTMLImgElement_put_align(img
, tmp
);
3423 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3426 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3427 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3428 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3432 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3433 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3435 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3439 hres
= IHTMLImgElement_get_name(img
, &sName
);
3440 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3441 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3442 IHTMLImgElement_Release(img
);
3443 SysFreeString(sName
);
3446 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3447 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3449 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3450 VARIANT_BOOL b
= 100;
3453 hres
= IHTMLImgElement_get_complete(img
, &b
);
3454 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3455 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3456 IHTMLImgElement_Release(img
);
3459 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3460 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3462 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3463 VARIANT_BOOL b
= 100;
3466 hres
= IHTMLImgElement_put_isMap(img
, v
);
3467 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3469 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3470 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3471 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3473 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3474 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3475 IHTMLImgElement_Release(img
);
3478 static void test_dynamic_properties(IHTMLElement
*elem
)
3480 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3481 IDispatchEx
*dispex
;
3482 BSTR name
, attr1
= SysAllocString(attr1W
);
3486 DISPID id
= DISPID_STARTENUM
;
3489 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3490 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3492 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3493 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3494 ok(succ
, "removeAttribute set succ to FALSE\n");
3497 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3498 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3502 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3503 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3505 if(!strcmp_wa(name
, "attr1"))
3506 ok(0, "attr1 should be removed\n");
3507 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3509 SysFreeString(name
);
3511 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3512 IDispatchEx_Release(dispex
);
3514 V_VT(&val
) = VT_BSTR
;
3515 V_BSTR(&val
) = attr1
;
3516 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3517 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3518 SysFreeString(attr1
);
3521 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3522 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3527 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3528 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3529 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3533 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3534 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3536 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3537 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3540 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3541 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3542 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3543 IHTMLDOMAttribute2_Release(attr2
);
3546 static void test_attr_collection_disp(IDispatch
*disp
)
3548 IDispatchEx
*dispex
;
3549 IHTMLDOMAttribute
*attr
;
3550 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3557 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3558 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3561 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3562 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3563 SysFreeString(bstr
);
3566 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3567 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3568 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3569 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3572 bstr
= a2bstr("attr1");
3573 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3574 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3575 SysFreeString(bstr
);
3578 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3579 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3580 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3581 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3582 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3583 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3585 test_attr_node_name(attr
, "attr1");
3587 IHTMLDOMAttribute_Release(attr
);
3590 IDispatchEx_Release(dispex
);
3593 static void test_attr_collection(IHTMLElement
*elem
)
3595 static const WCHAR testW
[] = {'t','e','s','t',0};
3598 IDispatch
*disp
, *attr
;
3599 IHTMLDOMAttribute
*dom_attr
;
3600 IHTMLAttributeCollection
*attr_col
;
3601 BSTR name
= SysAllocString(testW
);
3603 LONG i
, len
, checked
;
3606 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3607 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3609 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3610 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3612 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3613 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3614 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3615 IDispatch_Release(attr
);
3616 IHTMLDOMNode_Release(node
);
3618 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3619 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3621 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3622 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3626 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3627 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3628 SysFreeString(name
);
3630 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3631 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3632 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3635 for(i
=0; i
<len
; i
++) {
3638 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3639 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3641 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3642 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3643 IDispatch_Release(attr
);
3645 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3646 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3648 if(!strcmp_wa(name
, "id")) {
3650 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3651 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3652 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3653 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3654 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3655 test_attr_value(dom_attr
, "attr");
3656 } else if(!strcmp_wa(name
, "attr1")) {
3658 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3659 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3660 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3661 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3662 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3663 test_attr_value(dom_attr
, "attr1");
3664 } else if(!strcmp_wa(name
, "attr2")) {
3666 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3667 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3668 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3669 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3670 test_attr_value(dom_attr
, "");
3671 } else if(!strcmp_wa(name
, "attr3")) {
3673 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3674 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3675 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3676 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3677 test_attr_value(dom_attr
, "attr3");
3678 } else if(!strcmp_wa(name
, "test")) {
3680 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3681 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3682 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3683 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3684 test_attr_value(dom_attr
, "1");
3687 IHTMLDOMAttribute_Release(dom_attr
);
3688 SysFreeString(name
);
3691 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3694 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3695 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3697 V_VT(&id
) = VT_BSTR
;
3698 V_BSTR(&id
) = a2bstr("nonexisting");
3699 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3700 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3703 test_attr_collection_disp(disp
);
3705 IDispatch_Release(disp
);
3706 IHTMLAttributeCollection_Release(attr_col
);
3709 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3710 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3712 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3713 BSTR id
= (void*)0xdeadbeef;
3716 hres
= IHTMLElement_get_id(elem
, &id
);
3717 IHTMLElement_Release(elem
);
3718 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3721 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3723 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3728 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3729 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3731 BSTR lang
= (void*)0xdeadbeef;
3734 hres
= IHTMLElement_get_language(elem
, &lang
);
3735 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3738 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3740 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3742 SysFreeString(lang
);
3745 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3746 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3748 BSTR str
= a2bstr(lang
);
3751 hres
= IHTMLElement_put_language(elem
, str
);
3752 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3755 _test_elem_language(line
, elem
, lang
);
3758 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3759 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3761 BSTR lang
= (void*)0xdeadbeef;
3764 hres
= IHTMLElement_get_lang(elem
, &lang
);
3765 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3768 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3770 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3772 SysFreeString(lang
);
3775 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3776 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3778 BSTR str
= a2bstr(lang
);
3781 hres
= IHTMLElement_put_lang(elem
, str
);
3782 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3785 _test_elem_lang(line
, elem
, lang
);
3788 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3789 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3791 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3792 BSTR tmp
= a2bstr(new_id
);
3795 hres
= IHTMLElement_put_id(elem
, tmp
);
3796 IHTMLElement_Release(elem
);
3798 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3800 _test_elem_id(line
, unk
, new_id
);
3803 static void test_contenteditable(IUnknown
*unk
)
3805 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3807 BSTR str
, strDefault
;
3809 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3810 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3812 str
= a2bstr("true");
3813 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3814 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3816 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3817 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3818 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3821 /* Restore origin contentEditable */
3822 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3823 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3824 SysFreeString(strDefault
);
3826 IHTMLElement3_Release(elem3
);
3829 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3830 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3835 hres
= IHTMLInputElement_get_type(input
, &type
);
3836 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3837 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3838 SysFreeString(type
);
3841 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3842 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3844 BSTR name
= (BSTR
)0xdeadbeef;
3847 hres
= IHTMLInputElement_get_name(input
, &name
);
3848 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3850 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3852 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3853 SysFreeString(name
);
3856 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3857 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3859 BSTR tmp
= a2bstr(name
);
3862 hres
= IHTMLInputElement_put_name(input
, tmp
);
3863 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3866 _test_input_name(line
, input
, name
);
3869 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3870 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3872 VARIANT_BOOL disabled
= 100;
3875 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3876 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3877 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3879 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3882 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3883 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3887 hres
= IHTMLInputElement_put_disabled(input
, b
);
3888 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3890 _test_input_get_disabled(line
, input
, b
);
3893 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3894 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3896 VARIANT_BOOL checked
= 100;
3899 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3900 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3901 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3904 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3905 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3909 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3910 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3912 _test_input_get_defaultchecked(line
, input
, b
);
3915 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3916 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3918 VARIANT_BOOL checked
= 100;
3921 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3922 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3923 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3926 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3927 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3931 hres
= IHTMLInputElement_put_checked(input
, b
);
3932 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3934 _test_input_get_checked(line
, input
, b
);
3937 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3938 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3940 LONG maxlength
= 0xdeadbeef;
3943 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3944 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3945 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3948 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3949 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3953 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3954 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3956 _test_input_maxlength(line
, input
, l
);
3959 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3960 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3962 IHTMLInputElement
*input
;
3966 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3967 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3971 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3972 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3974 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3976 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3977 SysFreeString(bstr
);
3978 IHTMLInputElement_Release(input
);
3981 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3982 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3984 IHTMLInputElement
*input
;
3985 IHTMLFormElement
*form
;
3989 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3990 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3991 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3992 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3993 if(FAILED(hres
) || input
== NULL
)
3996 hres
= IHTMLInputElement_get_form(input
, &form
);
3997 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3998 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3999 if(FAILED(hres
) || form
== NULL
){
4000 IHTMLInputElement_Release(input
);
4004 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
4005 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
4006 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
4007 if(FAILED(hres
) || elem
== NULL
){
4008 IHTMLInputElement_Release(input
);
4009 IHTMLFormElement_Release(form
);
4013 _test_elem_id(line
, (IUnknown
*)elem
, id
);
4015 IHTMLInputElement_Release(input
);
4016 IHTMLFormElement_Release(form
);
4017 IHTMLElement_Release(elem
);
4020 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
4021 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
4023 IHTMLInputElement
*input
;
4027 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4028 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4033 hres
= IHTMLInputElement_put_value(input
, bstr
);
4034 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
4035 SysFreeString(bstr
);
4036 IHTMLInputElement_Release(input
);
4038 _test_input_value(line
, unk
, val
);
4041 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
4042 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
4044 IHTMLInputElement
*input
;
4048 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4049 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4053 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
4054 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4056 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
4058 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
4060 IHTMLInputElement_Release(input
);
4063 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
4064 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
4066 IHTMLInputElement
*input
;
4070 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4071 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4076 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
4077 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4079 IHTMLInputElement_Release(input
);
4081 _test_input_defaultValue(line
, unk
, val
);
4084 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4085 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
4090 hres
= IHTMLInputElement_get_src(input
, &src
);
4091 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
4093 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
4095 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4099 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4100 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
4106 hres
= IHTMLInputElement_put_src(input
, tmp
);
4108 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
4110 _test_input_src(line
, input
, src
);
4113 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4114 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4118 hres
= IHTMLInputElement_put_size(input
, size
);
4119 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
4122 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4123 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4128 hres
= IHTMLInputElement_get_size(input
, &size
);
4129 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
4130 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
4132 hres
= IHTMLInputElement_get_size(input
, NULL
);
4133 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
4136 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4137 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4140 VARIANT_BOOL b
= 100;
4142 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4143 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
4145 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4146 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
4147 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4150 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4151 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
4153 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4154 BSTR
class = (void*)0xdeadbeef;
4157 hres
= IHTMLElement_get_className(elem
, &class);
4158 IHTMLElement_Release(elem
);
4159 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4161 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4163 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4164 SysFreeString(class);
4167 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4168 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4170 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4174 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4175 IHTMLElement2_Release(elem2
);
4176 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4177 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4180 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4181 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4183 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4186 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4187 IHTMLElement2_Release(elem2
);
4188 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4190 _test_elem_tabindex(line
, unk
, index
);
4193 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4194 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4196 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4200 hres
= IHTMLStyleElement_get_media(style
, &media
);
4201 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4203 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4205 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4207 IHTMLStyleElement_Release(style
);
4208 SysFreeString(media
);
4211 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4212 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4214 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4218 str
= a2bstr(media
);
4219 hres
= IHTMLStyleElement_put_media(style
, str
);
4220 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4221 IHTMLStyleElement_Release(style
);
4224 _test_style_media(line
, unk
, media
);
4227 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4228 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4230 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4234 hres
= IHTMLStyleElement_get_type(style
, &type
);
4235 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4237 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4239 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4241 IHTMLStyleElement_Release(style
);
4242 SysFreeString(type
);
4245 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4246 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4248 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4253 hres
= IHTMLStyleElement_put_type(style
, str
);
4254 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4255 IHTMLStyleElement_Release(style
);
4258 _test_style_type(line
, unk
, type
);
4261 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4262 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4264 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4266 IHTMLFiltersCollection
*filters
;
4268 hres
= IHTMLElement_get_filters(elem
, &filters
);
4269 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4270 "get_filters failed: %08x\n", hres
);
4274 IDispatchEx
*dispex
;
4276 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4277 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4278 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4280 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4281 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4282 "Could not get IDispatchEx interface: %08x\n", hres
);
4283 if(SUCCEEDED(hres
)) {
4284 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, NULL
, "[object]");
4285 IDispatchEx_Release(dispex
);
4288 IHTMLFiltersCollection_Release(filters
);
4291 IHTMLElement_Release(elem
);
4294 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4295 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4297 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4301 tmp
= class ? a2bstr(class) : NULL
;
4302 hres
= IHTMLElement_put_className(elem
, tmp
);
4303 IHTMLElement_Release(elem
);
4304 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4307 _test_elem_class(line
, unk
, class);
4310 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4311 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4313 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4317 hres
= IHTMLElement_get_title(elem
, &title
);
4318 IHTMLElement_Release(elem
);
4319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4321 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4323 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4325 SysFreeString(title
);
4328 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4329 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4331 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4335 tmp
= a2bstr(title
);
4336 hres
= IHTMLElement_put_title(elem
, tmp
);
4337 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4339 IHTMLElement_Release(elem
);
4343 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4344 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4346 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4350 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4351 IHTMLDOMNode_Release(node
);
4352 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4355 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4356 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4358 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4364 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4365 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4367 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4371 V_VT(&var
) = VT_BSTR
;
4372 V_BSTR(&var
) = a2bstr(val
);
4374 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4375 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4376 IHTMLDOMNode_Release(node
);
4380 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4381 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4383 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4387 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4388 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4389 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4390 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4392 IHTMLElement2_Release(elem
);
4395 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4396 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4398 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4402 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4403 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4404 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4406 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4407 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4408 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4410 IHTMLElement2_Release(elem
);
4413 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4414 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4416 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4417 LONG len
= 0xdeadbeef;
4420 hres
= IHTMLFormElement_get_length(form
, &len
);
4421 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4422 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4424 IHTMLFormElement_Release(form
);
4427 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4428 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4430 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4431 BSTR action
= (void*)0xdeadbeef;
4434 hres
= IHTMLFormElement_get_action(form
, &action
);
4435 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4437 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4439 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4441 SysFreeString(action
);
4442 IHTMLFormElement_Release(form
);
4445 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4446 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4448 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4449 BSTR tmp
= a2bstr(action
);
4452 hres
= IHTMLFormElement_put_action(form
, tmp
);
4453 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4455 IHTMLFormElement_Release(form
);
4457 _test_form_action(line
, unk
, action
);
4460 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4461 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4463 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4464 BSTR method
= (void*)0xdeadbeef;
4467 hres
= IHTMLFormElement_get_method(form
, &method
);
4468 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4470 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4472 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4474 SysFreeString(method
);
4475 IHTMLFormElement_Release(form
);
4478 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4479 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4481 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4482 BSTR tmp
= a2bstr(method
);
4485 hres
= IHTMLFormElement_put_method(form
, tmp
);
4486 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4488 IHTMLFormElement_Release(form
);
4490 if(exp_hres
== S_OK
)
4491 _test_form_method(line
, unk
, method
);
4494 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4495 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4497 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4498 BSTR name
= (void*)0xdeadbeef;
4501 hres
= IHTMLFormElement_get_name(form
, &name
);
4502 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4504 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4506 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4508 SysFreeString(name
);
4509 IHTMLFormElement_Release(form
);
4512 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4513 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4515 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4516 BSTR tmp
= a2bstr(name
);
4519 hres
= IHTMLFormElement_put_name(form
, tmp
);
4520 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4522 IHTMLFormElement_Release(form
);
4524 _test_form_name(line
, unk
, name
);
4527 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4528 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4530 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4531 BSTR encoding
= (void*)0xdeadbeef;
4534 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4535 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4537 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4539 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4541 SysFreeString(encoding
);
4542 IHTMLFormElement_Release(form
);
4545 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4546 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4548 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4549 BSTR tmp
= a2bstr(encoding
);
4552 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4553 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4555 IHTMLFormElement_Release(form
);
4557 if(exp_hres
== S_OK
)
4558 _test_form_encoding(line
, unk
, encoding
);
4561 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4562 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4564 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4569 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4570 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4571 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4572 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4574 IDispatch_Release(disp
);
4575 IHTMLFormElement_Release(form
);
4578 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4579 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4581 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4584 hres
= IHTMLFormElement_reset(form
);
4585 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4587 IHTMLFormElement_Release(form
);
4590 static void test_form_target(IUnknown
*unk
)
4592 IHTMLFormElement
*form
= get_form_iface(unk
);
4595 static const char target
[] = "_blank";
4597 str
= a2bstr(target
);
4598 hres
= IHTMLFormElement_put_target(form
, str
);
4599 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4602 hres
= IHTMLFormElement_get_target(form
, &str
);
4603 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4604 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4607 IHTMLFormElement_Release(form
);
4610 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4612 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4613 IHTMLFormElement
*form
;
4616 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4617 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4619 hres
= IHTMLSelectElement_get_form(select
, &form
);
4620 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4621 ok(form
!= NULL
, "form == NULL\n");
4623 test_form_length((IUnknown
*)form
, 2);
4624 test_form_elements((IUnknown
*)form
);
4625 test_form_name((IUnknown
*)form
, "form_name");
4627 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4629 IHTMLSelectElement_Release(select
);
4630 IHTMLFormElement_Release(form
);
4633 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4635 IHTMLFormElement
*form
;
4638 form
= (IHTMLFormElement
*)0xdeadbeef;
4639 hres
= IHTMLSelectElement_get_form(select
, &form
);
4640 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4641 ok(form
== NULL
, "got %p\n", form
);
4644 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4645 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4647 IHTMLMetaElement
*meta
;
4651 meta
= _get_metaelem_iface(line
, unk
);
4652 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4653 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4654 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4655 SysFreeString(name
);
4656 IHTMLMetaElement_Release(meta
);
4659 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4660 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4662 IHTMLMetaElement
*meta
;
4663 BSTR content
= NULL
;
4666 meta
= _get_metaelem_iface(line
, unk
);
4667 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4668 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4669 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4670 SysFreeString(content
);
4671 IHTMLMetaElement_Release(meta
);
4674 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4675 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4677 IHTMLMetaElement
*meta
;
4681 meta
= _get_metaelem_iface(line
, unk
);
4682 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4683 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4684 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4686 IHTMLMetaElement_Release(meta
);
4689 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4690 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4692 IHTMLMetaElement
*meta
;
4696 meta
= _get_metaelem_iface(line
, unk
);
4697 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4698 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4700 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4702 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4704 IHTMLMetaElement_Release(meta
);
4707 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4708 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4710 BSTR val
= a2bstr(vala
);
4711 IHTMLMetaElement
*meta
;
4714 meta
= _get_metaelem_iface(line
, unk
);
4715 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4716 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4718 IHTMLMetaElement_Release(meta
);
4720 _test_meta_charset(line
, unk
, vala
);
4723 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4724 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4726 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4730 str
= a2bstr(exval
);
4731 hres
= IHTMLLinkElement_put_media(link
, str
);
4732 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4735 hres
= IHTMLLinkElement_get_media(link
, &str
);
4736 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4737 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4739 IHTMLLinkElement_Release(link
);
4742 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4743 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4745 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4746 VARIANT_BOOL b
= 10;
4749 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4750 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4751 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4753 IHTMLLinkElement_Release(link
);
4756 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4757 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4759 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4762 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4763 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4764 IHTMLLinkElement_Release(link
);
4765 _test_link_disabled(line
, elem
, v
);
4768 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4769 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4771 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4775 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4776 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4778 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4780 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4783 IHTMLLinkElement_Release(link
);
4786 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4787 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4789 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4790 BSTR str
= a2bstr(v
);
4793 hres
= IHTMLLinkElement_put_rel(link
, str
);
4794 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4796 IHTMLLinkElement_Release(link
);
4797 _test_link_rel(line
, elem
, v
);
4800 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4801 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4803 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4807 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4808 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4810 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4812 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4815 IHTMLLinkElement_Release(link
);
4818 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4819 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4821 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4822 BSTR str
= a2bstr(v
);
4825 hres
= IHTMLLinkElement_put_rev(link
, str
);
4826 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4828 IHTMLLinkElement_Release(link
);
4829 _test_link_rev(line
, elem
, v
);
4832 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4833 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4835 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4839 hres
= IHTMLLinkElement_get_type(link
, &type
);
4840 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4842 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4844 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4845 SysFreeString(type
);
4847 IHTMLLinkElement_Release(link
);
4850 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4851 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4856 str
= (void*)0xdeadbeef;
4857 hres
= IHTMLScriptElement_get_text(script
, &str
);
4858 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4859 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4863 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4864 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4866 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4867 BSTR str
= a2bstr(v
);
4870 hres
= IHTMLLinkElement_put_type(link
, str
);
4871 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4873 IHTMLLinkElement_Release(link
);
4874 _test_link_type(line
, elem
, v
);
4877 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4878 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4880 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4884 hres
= IHTMLLinkElement_get_href(link
, &href
);
4885 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4887 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4889 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4890 SysFreeString(href
);
4892 IHTMLLinkElement_Release(link
);
4895 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4896 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4898 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4899 BSTR str
= a2bstr(v
);
4902 hres
= IHTMLLinkElement_put_href(link
, str
);
4903 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4905 IHTMLLinkElement_Release(link
);
4906 _test_link_href(line
, elem
, v
);
4909 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4910 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4912 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4913 IHTMLDocument2
*doc
;
4918 hres
= IHTMLElement_get_document(elem
, &disp
);
4919 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4920 ok(disp
!= NULL
, "disp == NULL\n");
4922 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4923 IDispatch_Release(disp
);
4924 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4929 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4930 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4932 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4933 BSTR str
= a2bstr(attr_name
);
4934 IHTMLDOMAttribute
*attr
;
4937 attr
= (void*)0xdeadbeef;
4938 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4939 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4941 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4943 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4945 IHTMLElement4_Release(elem
);
4950 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4951 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4956 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4957 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4958 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4961 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4962 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4966 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4967 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4970 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4971 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4973 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4974 BSTR str
= a2bstr(value
);
4977 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4978 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4980 IHTMLDOMAttribute2_Release(attr2
);
4984 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4985 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4987 IHTMLDocument2
*doc
;
4991 hres
= IHTMLWindow2_get_document(window
, &doc
);
4992 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4993 ok(doc
!= NULL
, "disp == NULL\n");
4998 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4999 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
5004 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5005 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
5006 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
5011 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
5012 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
5014 IHTMLElement
*elem
= NULL
;
5019 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
5020 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5021 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
5027 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
5028 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
5030 IHTMLDocument3
*doc3
;
5031 IHTMLDOMNode
*node
= NULL
;
5035 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5036 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
5039 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
5040 IHTMLDocument3_Release(doc3
);
5042 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5043 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
5048 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
5049 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5051 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5052 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
5053 IHTMLDOMNode
*new_child
= NULL
;
5056 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
5057 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
5058 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5059 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5061 IHTMLDOMNode_Release(node
);
5062 IHTMLDOMNode_Release(child
);
5067 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
5068 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
5070 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5071 IHTMLDOMNode
*new_child
= NULL
;
5074 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
5075 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
5076 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5077 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5079 IHTMLDOMNode_Release(node
);
5084 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
5085 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
5087 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5088 IHTMLDOMNode
*new_node
= NULL
;
5091 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5092 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
5093 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5094 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5096 IHTMLDOMNode_Release(node
);
5097 IHTMLDOMNode_Release(new_node
);
5100 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5101 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
5106 hres
= IHTMLDocument2_get_title(doc
, &title
);
5107 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5108 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5109 SysFreeString(title
);
5112 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5113 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
5118 tmp
= a2bstr(title
);
5119 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5120 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5124 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5126 IHTMLRect
*rect
, *rect2
;
5127 IHTMLElement2
*elem2
;
5131 elem2
= get_elem2_iface(unk
);
5132 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5133 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5134 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5135 IHTMLElement2_Release(elem2
);
5136 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5137 ok(rect
!= NULL
, "rect == NULL\n");
5138 ok(rect
!= rect2
, "rect == rect2\n");
5139 IHTMLRect_Release(rect2
);
5141 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, NULL
, "[object]");
5144 hres
= IHTMLRect_get_top(rect
, &l
);
5145 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
5146 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5149 hres
= IHTMLRect_get_left(rect
, &l
);
5150 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
5151 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5154 hres
= IHTMLRect_get_bottom(rect
, &l
);
5155 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
5156 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5159 hres
= IHTMLRect_get_right(rect
, &l
);
5160 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
5161 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5163 IHTMLRect_Release(rect
);
5166 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5167 const elem_type_t
*elem_types
, LONG len
)
5170 VARIANT name
, index
;
5174 V_VT(&index
) = VT_EMPTY
;
5175 V_VT(&name
) = VT_BSTR
;
5176 V_BSTR(&name
) = a2bstr(n
);
5178 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5179 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5181 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5182 IDispatch_Release(disp
);
5184 V_VT(&index
) = VT_I4
;
5186 for(i
=0; i
<len
; i
++) {
5188 disp
= (void*)0xdeadbeef;
5189 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5190 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5191 ok(disp
!= NULL
, "disp == NULL\n");
5192 if(FAILED(hres
) || !disp
)
5195 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5197 IDispatch_Release(disp
);
5201 disp
= (void*)0xdeadbeef;
5202 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5203 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5204 ok(disp
== NULL
, "disp != NULL\n");
5207 disp
= (void*)0xdeadbeef;
5208 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5209 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5210 ok(disp
== NULL
, "disp != NULL\n");
5212 SysFreeString(V_BSTR(&name
));
5215 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5217 IHTMLElementCollection
*col
;
5219 IDispatch
*disp
= (void*)0xdeadbeef;
5220 VARIANT name
, index
;
5223 hres
= IHTMLDocument2_get_all(doc
, &col
);
5224 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5225 ok(col
!= NULL
, "col == NULL\n");
5226 if(FAILED(hres
) || !col
)
5229 V_VT(&index
) = VT_EMPTY
;
5230 V_VT(&name
) = VT_BSTR
;
5231 V_BSTR(&name
) = a2bstr(id
);
5233 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5234 IHTMLElementCollection_Release(col
);
5235 SysFreeString(V_BSTR(&name
));
5236 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5237 if(!expect_success
) {
5238 ok(disp
== NULL
, "disp != NULL\n");
5242 ok(disp
!= NULL
, "disp == NULL\n");
5246 elem
= get_elem_iface((IUnknown
*)disp
);
5247 IDispatch_Release(disp
);
5252 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5254 IHTMLDocument3
*doc3
;
5259 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5260 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5263 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5265 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5267 IHTMLDocument3_Release(doc3
);
5272 static void test_select_elem(IHTMLSelectElement
*select
)
5274 IDispatch
*disp
, *disp2
;
5275 VARIANT name
, index
;
5278 test_select_type(select
, "select-one");
5279 test_select_length(select
, 2);
5280 test_select_selidx(select
, 0);
5281 test_select_put_selidx(select
, 1);
5283 test_select_set_value(select
, "val1");
5284 test_select_value(select
, "val1");
5286 test_select_size(select
, 0);
5287 test_select_set_size(select
, 1, S_OK
);
5288 test_select_size(select
, 1);
5290 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5291 test_select_size(select
, 1);
5292 test_select_set_size(select
, 3, S_OK
);
5293 test_select_size(select
, 3);
5295 test_select_name(select
, NULL
);
5296 test_select_set_name(select
, "select-name");
5297 test_select_name(select
, "select-name");
5298 test_select_form_notfound(select
);
5300 test_select_get_disabled(select
, VARIANT_FALSE
);
5301 test_select_set_disabled(select
, VARIANT_TRUE
);
5302 test_select_set_disabled(select
, VARIANT_FALSE
);
5305 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5306 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5307 ok(disp
!= NULL
, "options == NULL\n");
5308 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5309 IDispatch_Release(disp
);
5311 V_VT(&index
) = VT_EMPTY
;
5312 V_VT(&name
) = VT_I4
;
5314 disp
= (void*)0xdeadbeef;
5315 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5316 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5317 ok(!disp
, "disp = %p\n", disp
);
5320 disp
= (void*)0xdeadbeef;
5321 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5322 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5323 ok(!disp
, "disp = %p\n", disp
);
5326 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5327 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5330 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5331 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5332 ok(disp
!= NULL
, "disp = NULL\n");
5333 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5335 V_VT(&index
) = VT_I4
;
5338 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5339 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5340 ok(disp2
!= NULL
, "disp = NULL\n");
5341 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5342 IDispatch_Release(disp2
);
5343 IDispatch_Release(disp
);
5345 test_select_multiple(select
, VARIANT_FALSE
);
5346 test_select_set_multiple(select
, VARIANT_TRUE
);
5347 test_select_remove(select
);
5350 static void test_form_item(IHTMLElement
*elem
)
5352 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5353 IDispatch
*disp
, *disp2
;
5354 VARIANT name
, index
;
5357 V_VT(&index
) = VT_EMPTY
;
5358 V_VT(&name
) = VT_I4
;
5360 disp
= (void*)0xdeadbeef;
5361 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5362 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5363 ok(!disp
, "disp = %p\n", disp
);
5366 disp
= (void*)0xdeadbeef;
5367 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5368 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5369 ok(!disp
, "disp = %p\n", disp
);
5372 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5373 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5376 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5377 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5378 ok(disp
!= NULL
, "disp = NULL\n");
5379 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5381 V_VT(&index
) = VT_I4
;
5384 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5385 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5386 ok(disp2
!= NULL
, "disp = NULL\n");
5387 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5388 IDispatch_Release(disp2
);
5389 IDispatch_Release(disp
);
5392 static void test_create_option_elem(IHTMLDocument2
*doc
)
5394 IHTMLOptionElement
*option
;
5396 option
= create_option_elem(doc
, "test text", "test value");
5398 test_option_put_text(option
, "new text");
5399 test_option_put_value(option
, "new value");
5400 test_option_get_index(option
, 0);
5401 test_option_defaultSelected_property(option
);
5402 test_option_put_selected(option
, VARIANT_TRUE
);
5403 test_option_put_selected(option
, VARIANT_FALSE
);
5405 IHTMLOptionElement_Release(option
);
5408 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5410 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5411 IHTMLFormElement
*form
;
5414 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5415 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5417 hres
= IHTMLOptionElement_get_form(option
, &form
);
5418 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5419 ok(form
!= NULL
, "form == NULL\n");
5421 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5423 IHTMLOptionElement_Release(option
);
5424 IHTMLFormElement_Release(form
);
5427 static void test_create_img_elem(IHTMLDocument2
*doc
)
5429 IHTMLImgElement
*img
;
5431 img
= create_img_elem(doc
, 10, 15);
5434 test_img_put_width(img
, 5);
5435 test_img_put_height(img
, 20);
5437 IHTMLImgElement_Release(img
);
5441 img
= create_img_elem(doc
, -1, -1);
5444 test_img_put_width(img
, 5);
5445 test_img_put_height(img
, 20);
5447 IHTMLImgElement_Release(img
);
5451 #define test_doc_selection_type(a,b) _test_doc_selection_type(__LINE__,a,b)
5452 static void _test_doc_selection_type(unsigned line
, IHTMLDocument2
*doc
, const char *type
)
5454 IHTMLSelectionObject2
*selection2
;
5455 IHTMLSelectionObject
*selection
;
5459 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5460 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5462 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5463 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5464 ok_(__FILE__
,line
)(!strcmp_wa(str
, type
), "type = %s, expected %s\n", wine_dbgstr_w(str
), type
);
5467 hres
= IHTMLSelectionObject_QueryInterface(selection
, &IID_IHTMLSelectionObject2
, (void**)&selection2
);
5468 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLSelectionObject2 iface: %08x\n", hres
);
5470 IHTMLSelectionObject_Release(selection
);
5472 hres
= IHTMLSelectionObject2_get_typeDetail(selection2
, &str
);
5473 ok_(__FILE__
,line
)(hres
== S_OK
, "get_typeDetail failed: %08x\n", hres
);
5474 ok_(__FILE__
,line
)(!strcmp_wa(str
, "undefined"), "typeDetail = %s\n", wine_dbgstr_w(str
));
5477 IHTMLSelectionObject2_Release(selection2
);
5480 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5481 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5483 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5484 IHTMLElement
*ret_elem
= NULL
;
5485 BSTR str
= a2bstr(where
);
5488 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5489 IHTMLElement2_Release(elem2
);
5491 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5492 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5493 IHTMLElement_Release(ret_elem
);
5496 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5498 IHTMLElement
*elem
, *elem2
;
5500 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5501 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5503 elem
= test_create_elem(doc
, "BR");
5504 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5505 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5506 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5507 IHTMLElement_Release(elem
);
5509 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5511 elem
= test_create_elem(doc
, "BR");
5512 insert_adjacent_elem(parent
, "beforeend", elem
);
5514 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5516 elem2
= test_create_elem(doc
, "DIV");
5517 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5518 IHTMLElement_Release(elem2
);
5519 IHTMLElement_Release(elem
);
5521 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5524 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5526 IHTMLBodyElement
*body
;
5527 IHTMLTxtRange
*range
;
5531 elem
= doc_get_body(doc
);
5532 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5533 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5534 IHTMLElement_Release(elem
);
5536 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5537 IHTMLBodyElement_Release(body
);
5538 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5543 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5544 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5549 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5550 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5555 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5556 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5557 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5559 BSTR str
= a2bstr(how
);
5562 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5563 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5567 static void test_txtrange(IHTMLDocument2
*doc
)
5569 IHTMLTxtRange
*body_range
, *range
, *range2
;
5570 IHTMLSelectionObject
*selection
;
5571 IDispatch
*disp_range
;
5575 body_range
= test_create_body_range(doc
);
5577 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, NULL
, "[object]");
5579 test_range_text(body_range
, "test abc 123\r\nit's text");
5581 range
= range_duplicate(body_range
);
5582 range2
= range_duplicate(body_range
);
5584 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5586 test_range_text(range
, "test abc 123\r\nit's text");
5587 test_range_text(body_range
, "test abc 123\r\nit's text");
5589 test_range_collapse(range
, TRUE
);
5590 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5591 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5592 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5593 IHTMLTxtRange_Release(range2
);
5595 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5596 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5597 test_range_move(range
, characterW
, 2, 2);
5598 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5600 test_range_collapse(range
, FALSE
);
5601 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5603 test_range_collapse(range
, FALSE
);
5604 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5605 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5606 test_range_move(range
, characterW
, 2, 2);
5607 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5608 test_range_moveend(range
, characterW
, -5, -5);
5609 test_range_text(range
, NULL
);
5610 test_range_moveend(range
, characterW
, 3, 3);
5611 test_range_text(range
, "c 1");
5612 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5613 test_range_collapse(range
, TRUE
);
5614 test_range_move(range
, characterW
, 4, 4);
5615 test_range_moveend(range
, characterW
, 1, 1);
5616 test_range_text(range
, " ");
5617 test_range_move(range
, wordW
, 1, 1);
5618 test_range_moveend(range
, characterW
, 2, 2);
5619 test_range_text(range
, "ab");
5621 IHTMLTxtRange_Release(range
);
5623 range
= range_duplicate(body_range
);
5625 test_range_text(range
, "test abc 123\r\nit's text");
5626 test_range_move(range
, characterW
, 3, 3);
5627 test_range_moveend(range
, characterW
, 1, 1);
5628 test_range_text(range
, "t");
5629 test_range_moveend(range
, characterW
, 3, 3);
5630 test_range_text(range
, "t ab");
5631 test_range_moveend(range
, characterW
, -2, -2);
5632 test_range_text(range
, "t ");
5633 test_range_move(range
, characterW
, 6, 6);
5634 test_range_moveend(range
, characterW
, 3, 3);
5635 test_range_text(range
, "123");
5636 test_range_moveend(range
, characterW
, 2, 2);
5637 test_range_text(range
, "123\r\ni");
5639 IHTMLTxtRange_Release(range
);
5641 range
= range_duplicate(body_range
);
5643 test_range_move(range
, wordW
, 1, 1);
5644 test_range_moveend(range
, characterW
, 2, 2);
5645 test_range_text(range
, "ab");
5647 test_range_move(range
, characterW
, -2, -2);
5648 test_range_moveend(range
, characterW
, 2, 2);
5649 test_range_text(range
, "t ");
5651 test_range_move(range
, wordW
, 3, 3);
5652 test_range_move(range
, wordW
, -2, -2);
5653 test_range_moveend(range
, characterW
, 2, 2);
5654 test_range_text(range
, "ab");
5656 test_range_move(range
, characterW
, -6, -5);
5657 test_range_moveend(range
, characterW
, -1, 0);
5658 test_range_moveend(range
, characterW
, -6, 0);
5659 test_range_move(range
, characterW
, 2, 2);
5660 test_range_moveend(range
, characterW
, 2, 2);
5661 test_range_text(range
, "st");
5662 test_range_moveend(range
, characterW
, -6, -4);
5663 test_range_moveend(range
, characterW
, 2, 2);
5665 IHTMLTxtRange_Release(range
);
5667 range
= range_duplicate(body_range
);
5669 test_range_move(range
, wordW
, 2, 2);
5670 test_range_moveend(range
, characterW
, 2, 2);
5671 test_range_text(range
, "12");
5673 test_range_move(range
, characterW
, 15, 14);
5674 test_range_move(range
, characterW
, -2, -2);
5675 test_range_moveend(range
, characterW
, 3, 2);
5676 test_range_text(range
, "t");
5677 test_range_moveend(range
, characterW
, -1, -1);
5678 test_range_text(range
, "t");
5679 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5680 test_range_move(range
, characterW
, -2, -2);
5681 test_range_moveend(range
, characterW
, 2, 2);
5682 test_range_text(range
, "s ");
5683 test_range_move(range
, characterW
, 100, 7);
5684 test_range_move(range
, wordW
, 1, 0);
5685 test_range_move(range
, characterW
, -2, -2);
5686 test_range_moveend(range
, characterW
, 3, 2);
5687 test_range_text(range
, "t");
5689 IHTMLTxtRange_Release(range
);
5691 range
= range_duplicate(body_range
);
5693 test_range_collapse(range
, TRUE
);
5694 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5695 test_range_put_text(range
, "word");
5696 test_range_text(body_range
, "wordabc 123\r\nit's text");
5697 test_range_text(range
, NULL
);
5698 test_range_moveend(range
, characterW
, 3, 3);
5699 test_range_text(range
, "abc");
5700 test_range_movestart(range
, characterW
, -2, -2);
5701 test_range_text(range
, "rdabc");
5702 test_range_movestart(range
, characterW
, 3, 3);
5703 test_range_text(range
, "bc");
5704 test_range_movestart(range
, characterW
, 4, 4);
5705 test_range_text(range
, NULL
);
5706 test_range_movestart(range
, characterW
, -3, -3);
5707 test_range_text(range
, "c 1");
5708 test_range_movestart(range
, characterW
, -7, -6);
5709 test_range_text(range
, "wordabc 1");
5710 test_range_movestart(range
, characterW
, 100, 22);
5711 test_range_text(range
, NULL
);
5713 IHTMLTxtRange_Release(range
);
5715 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5716 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5718 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, NULL
, "[object]");
5719 test_ifaces((IUnknown
*)selection
, selection_iids
);
5721 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5722 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5723 IHTMLSelectionObject_Release(selection
);
5725 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5726 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5727 IDispatch_Release(disp_range
);
5729 test_range_text(range
, NULL
);
5730 test_range_moveend(range
, characterW
, 3, 3);
5731 test_range_text(range
, "wor");
5732 test_range_parent(range
, ET_BODY
);
5733 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5734 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5735 test_range_move(range
, characterW
, 3, 3);
5736 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5737 test_range_moveend(range
, characterW
, -4, -4);
5738 test_range_put_text(range
, "abc def ");
5739 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5740 test_range_move(range
, wordW
, 1, 1);
5741 test_range_movestart(range
, characterW
, -1, -1);
5742 test_range_text(range
, " ");
5743 test_range_move(range
, wordW
, 1, 1);
5744 test_range_moveend(range
, characterW
, 3, 3);
5745 test_range_text(range
, "def");
5746 test_range_put_text(range
, "xyz");
5747 test_range_moveend(range
, characterW
, 1, 1);
5748 test_range_move(range
, wordW
, 1, 1);
5749 test_range_moveend(range
, characterW
, 2, 2);
5750 test_range_text(range
, "ab");
5752 body
= doc_get_body(doc
);
5754 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5755 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5757 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5758 test_range_parent(range
, ET_BODY
);
5760 test_range_move(range
, wordW
, 1, 1);
5761 test_range_moveend(range
, characterW
, 12, 12);
5762 test_range_text(range
, "xyz abc 123");
5764 test_range_collapse(range
, VARIANT_TRUE
);
5765 test_range_paste_html(range
, "<br>paste<br>");
5766 test_range_text(range
, NULL
);
5768 test_range_moveend(range
, characterW
, 3, 3);
5769 test_range_text(range
, "xyz");
5771 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5772 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5774 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5776 test_range_move(range
, wordW
, 2, 2);
5777 test_range_collapse(range
, VARIANT_TRUE
);
5778 test_range_moveend(range
, characterW
, 5, 5);
5779 test_range_text(range
, "paste");
5781 range2
= range_duplicate(range
);
5783 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5784 test_range_text(range
, "abc \r\npaste");
5786 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5787 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5789 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5790 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5792 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5793 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5794 test_range_text(range
, "abc ");
5796 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5797 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5799 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5800 test_range_text(range
, "abc ");
5802 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5804 hres
= IHTMLTxtRange_select(range
);
5805 ok(hres
== S_OK
, "select failed: %08x\n", hres
);
5807 test_doc_selection_type(doc
, "Text");
5809 IHTMLTxtRange_Release(range
);
5810 IHTMLTxtRange_Release(range2
);
5811 IHTMLTxtRange_Release(body_range
);
5812 IHTMLElement_Release(body
);
5816 static void test_txtrange2(IHTMLDocument2
*doc
)
5818 IHTMLTxtRange
*range
;
5820 range
= test_create_body_range(doc
);
5822 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5823 test_range_move(range
, characterW
, 5, 5);
5824 test_range_moveend(range
, characterW
, 1, 1);
5825 test_range_text(range
, "2");
5826 test_range_move(range
, characterW
, -3, -3);
5827 test_range_moveend(range
, characterW
, 3, 3);
5828 test_range_text(range
, "c\r\n\r\n1");
5829 test_range_collapse(range
, VARIANT_FALSE
);
5830 test_range_moveend(range
, characterW
, 4, 4);
5831 test_range_text(range
, "23");
5832 test_range_moveend(range
, characterW
, 1, 1);
5833 test_range_text(range
, "23\r\n\r\n\r\nd");
5834 test_range_moveend(range
, characterW
, -1, -1);
5835 test_range_text(range
, "23");
5836 test_range_moveend(range
, characterW
, -1, -1);
5837 test_range_text(range
, "23");
5838 test_range_moveend(range
, characterW
, -2, -2);
5839 test_range_text(range
, "2");
5841 IHTMLTxtRange_Release(range
);
5844 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5845 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5847 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5851 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5852 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5853 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5856 IHTMLDocument5_Release(doc
);
5859 static void test_location(IHTMLDocument2
*doc
)
5861 IHTMLLocation
*location
, *location2
;
5862 IHTMLWindow2
*window
;
5867 hres
= IHTMLDocument2_get_location(doc
, &location
);
5868 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5870 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5871 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5873 ok(location
== location2
, "location != location2\n");
5874 IHTMLLocation_Release(location2
);
5876 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5877 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5879 hres
= IHTMLWindow2_get_location(window
, &location2
);
5880 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5881 ok(location
== location2
, "location != location2\n");
5882 IHTMLLocation_Release(location2
);
5884 test_ifaces((IUnknown
*)location
, location_iids
);
5885 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, NULL
, "about:blank");
5887 hres
= IHTMLLocation_get_pathname(location
, &str
);
5888 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5889 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5892 hres
= IHTMLLocation_get_href(location
, NULL
);
5893 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5895 hres
= IHTMLLocation_get_href(location
, &str
);
5896 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5897 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5900 ref
= IHTMLLocation_Release(location
);
5901 ok(!ref
, "location should be destroyed here\n");
5904 static void test_plugins_col(IHTMLDocument2
*doc
)
5906 IHTMLPluginsCollection
*col
, *col2
;
5907 IHTMLWindow2
*window
;
5913 window
= get_doc_window(doc
);
5914 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5915 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5916 IHTMLWindow2_Release(window
);
5918 hres
= IOmNavigator_get_plugins(nav
, &col
);
5919 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5921 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5922 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5923 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5924 IHTMLPluginsCollection_Release(col2
);
5926 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, NULL
, "[object]");
5929 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5930 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5931 ok(!len
, "length = %d\n", len
);
5933 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5934 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5936 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5937 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5939 ref
= IHTMLPluginsCollection_Release(col
);
5940 ok(!ref
, "ref=%d\n", ref
);
5942 IOmNavigator_Release(nav
);
5945 static void test_mime_types_col(IOmNavigator
*nav
)
5947 IHTMLMimeTypesCollection
*col
, *col2
;
5952 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5953 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5955 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5956 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5957 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5958 IHTMLMimeTypesCollection_Release(col2
);
5960 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, NULL
, "[object]");
5962 length
= 0xdeadbeef;
5963 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5964 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5965 ok(!length
, "length = %d\n", length
);
5967 ref
= IHTMLMimeTypesCollection_Release(col
);
5968 ok(!ref
, "ref=%d\n", ref
);
5971 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5972 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5974 BSTR str
= (void*)0xdeadbeef;
5975 IHTMLFrameBase
*fbase
;
5978 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5979 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5981 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5982 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5984 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5986 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5989 IHTMLFrameBase_Release(fbase
);
5992 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5993 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5995 IHTMLFrameBase
*fbase
;
5999 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6000 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6002 str
= name
? a2bstr(name
) : NULL
;
6003 hres
= IHTMLFrameBase_put_name(fbase
, str
);
6004 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
6007 _test_framebase_name(line
, elem
, name
);
6008 IHTMLFrameBase_Release(fbase
);
6011 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
6012 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
6014 BSTR str
= (void*)0xdeadbeef;
6015 IHTMLFrameBase
*fbase
;
6018 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6019 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6021 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
6022 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
6024 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
6026 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
6029 IHTMLFrameBase_Release(fbase
);
6032 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
6033 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6038 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
6039 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
6040 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
6042 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6044 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6048 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
6049 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6055 V_BSTR(&v
) = a2bstr(val
);
6056 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
6057 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
6061 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
6062 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6067 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
6068 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
6069 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
6071 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6073 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6077 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
6078 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6084 V_BSTR(&v
) = a2bstr(val
);
6085 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
6086 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
6090 static void test_framebase(IUnknown
*unk
)
6092 IHTMLFrameBase
*fbase
;
6096 /* get/put scrolling */
6097 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6098 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6100 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6101 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6102 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6106 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6107 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6110 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6111 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6112 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6115 str
= a2bstr("junk");
6116 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6117 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6118 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6121 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6122 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6123 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6126 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6127 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6128 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6131 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6132 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
6135 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6136 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6137 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6140 test_framebase_marginheight(fbase
, NULL
);
6141 set_framebase_marginheight(fbase
, "1px");
6142 test_framebase_marginheight(fbase
, "1");
6144 test_framebase_marginwidth(fbase
, NULL
);
6145 set_framebase_marginwidth(fbase
, "2px");
6146 test_framebase_marginwidth(fbase
, "2");
6148 IHTMLFrameBase_Release(fbase
);
6151 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6152 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6157 if(pLCIDToLocaleName
) {
6158 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
6159 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
6160 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6162 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6163 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6167 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6168 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6170 IHTMLElementCollection
*col
;
6174 hres
= IHTMLTable_get_rows(table
, &col
);
6175 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6176 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6177 if (hres
!= S_OK
|| col
== NULL
)
6179 hres
= IHTMLElementCollection_get_length(col
, &len
);
6180 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6181 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
6183 IHTMLElementCollection_Release(col
);
6186 static void test_navigator(IHTMLDocument2
*doc
)
6188 IHTMLWindow2
*window
;
6189 IOmNavigator
*navigator
, *navigator2
;
6197 static const WCHAR v40
[] = {'4','.','0'};
6199 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6200 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6202 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6203 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6204 ok(navigator
!= NULL
, "navigator == NULL\n");
6205 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, NULL
, "[object]");
6207 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6208 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6209 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6210 IOmNavigator_Release(navigator2
);
6212 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6213 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6214 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6215 IOmNavigator_Release(navigator2
);
6217 IHTMLWindow2_Release(window
);
6219 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6220 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6221 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6222 SysFreeString(bstr
);
6225 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6226 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6227 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6228 SysFreeString(bstr
);
6231 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6232 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6233 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6234 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6235 SysFreeString(bstr
);
6238 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6239 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6240 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6241 SysFreeString(bstr
);
6244 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6245 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6246 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6247 SysFreeString(bstr
);
6250 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6251 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6252 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6253 SysFreeString(bstr
);
6255 if (pGetUserDefaultUILanguage
)
6258 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6259 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6260 test_language_string(bstr
, pGetUserDefaultUILanguage());
6261 SysFreeString(bstr
);
6264 win_skip("GetUserDefaultUILanguage not available\n");
6267 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6268 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6269 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6270 SysFreeString(bstr
);
6272 hres
= IOmNavigator_toString(navigator
, NULL
);
6273 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6276 hres
= IOmNavigator_toString(navigator
, &bstr
);
6277 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6278 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6279 SysFreeString(bstr
);
6282 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6283 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6284 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6287 hres
= ObtainUserAgentString(0, buf
, &size
);
6288 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6291 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6292 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6293 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6294 SysFreeString(bstr
);
6296 if(!strncmp(buf
, "Mozilla/", 8)) {
6298 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6299 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6300 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6301 SysFreeString(bstr
);
6303 skip("nonstandard user agent\n");
6307 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6308 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6309 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6310 SysFreeString(bstr
);
6312 test_mime_types_col(navigator
);
6314 ref
= IOmNavigator_Release(navigator
);
6315 ok(!ref
, "navigator should be destroyed here\n");
6318 static void test_screen(IHTMLWindow2
*window
)
6320 IHTMLScreen
*screen
, *screen2
;
6321 IDispatchEx
*dispex
;
6328 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6329 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6330 ok(screen
!= NULL
, "screen == NULL\n");
6333 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6334 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6335 ok(screen2
!= NULL
, "screen == NULL\n");
6336 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6337 IHTMLScreen_Release(screen2
);
6339 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6340 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6341 if(SUCCEEDED(hres
)) {
6342 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, NULL
, "[object]");
6343 IDispatchEx_Release(dispex
);
6346 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6348 exl
= GetDeviceCaps(hdc
, HORZRES
);
6350 hres
= IHTMLScreen_get_width(screen
, &l
);
6351 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6352 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6354 exl
= GetDeviceCaps(hdc
, VERTRES
);
6356 hres
= IHTMLScreen_get_height(screen
, &l
);
6357 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6358 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6360 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6362 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6363 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6364 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6368 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6371 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6372 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6373 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6376 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6377 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6378 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6380 IHTMLScreen_Release(screen
);
6383 static void test_default_selection(IHTMLDocument2
*doc
)
6385 IHTMLSelectionObject
*selection
;
6386 IHTMLTxtRange
*range
;
6390 test_doc_selection_type(doc
, "None");
6392 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6393 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6395 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6396 IHTMLSelectionObject_Release(selection
);
6397 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6399 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6400 IDispatch_Release(disp
);
6401 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6403 test_range_text(range
, NULL
);
6404 IHTMLTxtRange_Release(range
);
6407 static void test_doc_dir(IHTMLDocument2
*doc2
)
6409 IHTMLDocument3
*doc
= get_doc3_iface(doc2
);
6413 dir
= (BSTR
)0xdeadbeef;
6414 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6415 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6416 ok(!dir
, "dir = %s\n", wine_dbgstr_w(dir
));
6418 dir
= a2bstr("rtl");
6419 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6420 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6424 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6425 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6426 ok(!strcmp_wa(dir
, "rtl"), "dir = %s\n", wine_dbgstr_w(dir
));
6429 dir
= a2bstr("ltr");
6430 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6431 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6435 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6436 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6437 ok(!strcmp_wa(dir
, "ltr"), "dir = %s\n", wine_dbgstr_w(dir
));
6440 IHTMLDocument3_Release(doc
);
6443 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6445 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6446 IHTMLUniqueName
*unique_name
;
6452 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6454 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6455 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6456 ok(SysStringLen(id
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6458 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6459 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6460 ok(SysStringLen(id2
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6462 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6464 id
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6465 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6466 id2
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6467 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6472 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6473 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6475 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6476 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6478 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6479 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6480 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6482 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6483 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6484 ok(num
, "num = 0\n");
6486 sprintf(buf
, "ms__id%u", num
);
6487 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6492 IHTMLUniqueName_Release(unique_name
);
6493 IHTMLDocument3_Release(doc3
);
6496 static void test_doc_elem(IHTMLDocument2
*doc
)
6498 IHTMLDocument2
*doc_node
, *owner_doc
;
6500 IHTMLDocument3
*doc3
;
6504 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6505 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6507 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6508 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6509 ok(!strcmp_wa(bstr
, "[object]"),
6510 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6511 SysFreeString(bstr
);
6513 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6514 IHTMLDocument3_Release(doc3
);
6515 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6517 test_node_name((IUnknown
*)elem
, "HTML");
6518 test_elem_tag((IUnknown
*)elem
, "HTML");
6519 test_elem_set_outertext_fail(elem
);
6521 doc_node
= get_doc_node(doc
);
6522 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6523 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6524 IHTMLDocument2_Release(owner_doc
);
6526 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6527 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6528 IHTMLDocument2_Release(doc_node
);
6530 test_elem_client_rect((IUnknown
*)elem
);
6531 test_unique_id(doc
, elem
);
6534 IHTMLElement_Release(elem
);
6537 static void test_default_body(IHTMLBodyElement
*body
)
6544 bstr
= (void*)0xdeadbeef;
6545 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6546 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6547 ok(bstr
== NULL
, "bstr != NULL\n");
6549 l
= elem_get_scroll_height((IUnknown
*)body
);
6550 ok(l
!= -1, "scrollHeight == -1\n");
6551 l
= elem_get_scroll_width((IUnknown
*)body
);
6552 ok(l
!= -1, "scrollWidth == -1\n");
6553 l
= elem_get_scroll_top((IUnknown
*)body
);
6554 ok(!l
, "scrollTop = %d\n", l
);
6555 elem_get_scroll_left((IUnknown
*)body
);
6557 test_elem_dir((IUnknown
*)body
, NULL
);
6558 set_elem_dir((IUnknown
*)body
, "ltr");
6560 /* get_text tests */
6561 hres
= IHTMLBodyElement_get_text(body
, &v
);
6562 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6563 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6564 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6566 /* get_text - Invalid Text */
6568 V_BSTR(&v
) = a2bstr("Invalid");
6569 hres
= IHTMLBodyElement_put_text(body
, v
);
6570 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6574 hres
= IHTMLBodyElement_get_text(body
, &v
);
6575 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6576 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6577 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6580 /* get_text - Valid Text */
6582 V_BSTR(&v
) = a2bstr("#FF0000");
6583 hres
= IHTMLBodyElement_put_text(body
, v
);
6584 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6588 hres
= IHTMLBodyElement_get_text(body
, &v
);
6589 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6590 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6591 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6595 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6596 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6601 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6602 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6603 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6607 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6608 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6610 BSTR str
= a2bstr(val
);
6613 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6614 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6617 _test_body_scroll(line
, body
, val
);
6620 static void test_body_funs(IHTMLBodyElement
*body
)
6622 VARIANT vbg
, vDefaultbg
;
6625 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6626 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6627 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6628 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6630 V_VT(&vbg
) = VT_BSTR
;
6631 V_BSTR(&vbg
) = a2bstr("red");
6632 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6633 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6636 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6637 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6638 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6639 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6642 /* Restore Original */
6643 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6644 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6645 VariantClear(&vDefaultbg
);
6647 test_body_scroll(body
, NULL
);
6648 set_body_scroll(body
, "yes");
6649 set_body_scroll(body
, "no");
6650 set_body_scroll(body
, "auto");
6653 static void test_history(IHTMLWindow2
*window
)
6655 IOmHistory
*history
, *history2
;
6659 hres
= IHTMLWindow2_get_history(window
, &history
);
6660 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6661 ok(history
!= NULL
, "history = NULL\n");
6663 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, NULL
, "[object]");
6666 hres
= IHTMLWindow2_get_history(window
, &history2
);
6667 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6668 ok(history2
!= NULL
, "history2 = NULL\n");
6669 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6671 IOmHistory_Release(history2
);
6672 IOmHistory_Release(history
);
6675 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6679 IHTMLXMLHttpRequestFactory
*factory
;
6680 IHTMLXMLHttpRequest
*xml
;
6682 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6683 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6684 ok(V_VT(&var
) == VT_DISPATCH
, "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6687 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6688 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6689 ok(factory
!= NULL
, "factory == NULL\n");
6692 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6693 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6694 ok(xml
!= NULL
, "xml == NULL\n");
6695 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, &CLSID_HTMLXMLHttpRequest
, "[object]");
6697 IHTMLXMLHttpRequest_Release(xml
);
6698 IHTMLXMLHttpRequestFactory_Release(factory
);
6702 static void test_window(IHTMLDocument2
*doc
)
6704 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6705 IHTMLWindow5
*window5
;
6706 IHTMLDocument2
*doc2
= NULL
;
6713 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6714 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6715 test_ifaces((IUnknown
*)window
, window_iids
);
6716 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6718 IUnknown_Release(unk
);
6720 win_skip("IID_ITravelLogClient not supported\n");
6722 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, &CLSID_HTMLWindow2
, "[object]");
6724 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6725 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6726 ok(doc2
!= NULL
, "doc2 == NULL\n");
6728 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6729 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6731 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6732 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6734 unk
= (void*)0xdeadbeef;
6735 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6736 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6737 ok(!unk
, "unk = %p\n", unk
);
6739 IHTMLDocument2_Release(doc2
);
6741 hres
= IHTMLWindow2_get_window(window
, &window2
);
6742 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6743 ok(window2
!= NULL
, "window2 == NULL\n");
6745 hres
= IHTMLWindow2_get_self(window
, &self
);
6746 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6747 ok(window2
!= NULL
, "self == NULL\n");
6749 ok(self
== window2
, "self != window2\n");
6751 IHTMLWindow2_Release(window2
);
6754 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6755 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6756 ok(disp
== (void*)window
, "disp != window\n");
6757 IDispatch_Release(disp
);
6759 hres
= IHTMLWindow2_toString(window
, NULL
);
6760 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6763 hres
= IHTMLWindow2_toString(window
, &str
);
6764 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6765 ok(!strcmp_wa(str
, "[object]") ||
6766 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6769 V_VT(&v
) = VT_ERROR
;
6770 hres
= IHTMLWindow2_get_opener(window
, &v
);
6771 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6772 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6775 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6776 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6777 ok(parent
!= NULL
, "parent == NULL\n");
6778 ok(parent
== self
, "parent != window\n");
6779 IHTMLWindow2_Release(parent
);
6780 IHTMLWindow2_Release(self
);
6782 test_window_name(window
, NULL
);
6783 set_window_name(window
, "test");
6784 test_window_length(window
, 0);
6785 test_screen(window
);
6786 test_window_status(window
);
6787 set_window_status(window
, "Test!");
6788 test_history(window
);
6790 hres
= IHTMLWindow2_moveBy(window
, 0, 0);
6791 ok(hres
== S_FALSE
, "moveBy failed: %08x\n", hres
);
6793 hres
= IHTMLWindow2_resizeBy(window
, 0, 0);
6794 ok(hres
== S_FALSE
, "resizeBy failed: %08x\n", hres
);
6796 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6797 if(SUCCEEDED(hres
)) {
6798 ok(window5
!= NULL
, "window5 == NULL\n");
6799 test_xmlhttprequest(window5
);
6800 IHTMLWindow5_Release(window5
);
6802 win_skip("IHTMLWindow5 not supported!\n");
6805 IHTMLWindow2_Release(window
);
6808 static void test_dom_implementation(IHTMLDocument2
*doc
)
6810 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6811 IHTMLDOMImplementation
*dom_implementation
;
6817 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6818 IHTMLDocument5_Release(doc5
);
6819 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6820 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6822 str
= a2bstr("test");
6824 V_BSTR(&v
) = a2bstr("1.0");
6826 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6829 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6830 ok(!b
, "hasFeature returned %x\n", b
);
6832 IHTMLDOMImplementation_Release(dom_implementation
);
6835 static void test_xhr(IHTMLDocument2
*doc
)
6837 IHTMLWindow2
*window
;
6838 IDispatchEx
*dispex
;
6843 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6844 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6846 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6847 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6849 str
= a2bstr("XMLHttpRequest");
6850 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6851 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6854 IHTMLWindow2_Release(window
);
6857 static void test_defaults(IHTMLDocument2
*doc
)
6859 IHTMLStyleSheetsCollection
*stylesheetcol
;
6860 IHTMLCurrentStyle
*cstyle
;
6861 IHTMLBodyElement
*body
;
6862 IHTMLElement2
*elem2
;
6870 IHTMLElementCollection
*collection
;
6872 elem
= doc_get_body(doc
);
6874 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6875 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6877 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6878 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6881 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6882 IHTMLElementCollection_Release(collection
);
6885 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6886 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6888 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6889 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6892 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6893 IHTMLElementCollection_Release(collection
);
6896 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6897 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6899 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6900 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6903 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6904 IHTMLElementCollection_Release(collection
);
6907 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6908 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6910 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6911 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6914 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6915 IHTMLElementCollection_Release(collection
);
6918 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6919 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6921 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6922 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6925 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6926 IHTMLElementCollection_Release(collection
);
6931 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6932 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6933 test_default_body(body
);
6934 test_body_funs(body
);
6935 IHTMLBodyElement_Release(body
);
6937 test_elem_set_outertext_fail(elem
);
6939 test_elem_istextedit(elem
, VARIANT_TRUE
);
6941 hres
= IHTMLElement_get_style(elem
, &style
);
6942 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6944 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, NULL
, "[object]");
6945 test_ifaces((IUnknown
*)style
, style_iids
);
6946 IHTMLStyle_Release(style
);
6949 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6950 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6951 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6955 test_compatmode(doc
, "BackCompat");
6957 test_navigator(doc
);
6958 test_plugins_col(doc
);
6960 elem2
= get_elem2_iface((IUnknown
*)elem
);
6961 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6962 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6963 if(SUCCEEDED(hres
)) {
6966 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, NULL
, "[object]");
6967 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6969 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6971 IUnknown_Release(unk
);
6974 /*IE6 doesn't have interface */
6975 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6978 IHTMLCurrentStyle_Release(cstyle
);
6980 IHTMLElement2_Release(elem2
);
6982 IHTMLElement_Release(elem
);
6984 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6985 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6988 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6989 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6990 ok(l
== 0, "length = %d\n", l
);
6992 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6994 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6995 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6997 str
= a2bstr("xxx");
6999 V_VT(&v
) = VT_EMPTY
;
7000 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7001 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
7002 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
7005 str
= a2bstr("respectvisibilityindesign");
7008 V_BOOL(&v
) = VARIANT_TRUE
;
7009 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7010 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
7013 test_default_selection(doc
);
7014 test_doc_title(doc
, "");
7015 test_dom_implementation(doc
);
7018 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
7019 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
7021 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7025 str
= (void*)0xdeadbeef;
7026 hres
= IHTMLButtonElement_get_name(button
, &str
);
7027 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7029 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
7031 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
7033 IHTMLButtonElement_Release(button
);
7036 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
7037 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
7039 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7040 BSTR str
= a2bstr(name
);
7043 hres
= IHTMLButtonElement_put_name(button
, str
);
7044 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7046 IHTMLButtonElement_Release(button
);
7048 _test_button_name(line
, elem
, name
);
7051 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
7052 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
7054 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7055 VARIANT_BOOL disabled
= 100;
7058 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
7059 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
7060 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
7061 IHTMLButtonElement_Release(button
);
7063 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
7066 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
7067 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
7069 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7072 hres
= IHTMLButtonElement_put_disabled(button
, b
);
7073 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
7074 IHTMLButtonElement_Release(button
);
7076 _test_button_get_disabled(line
, elem
, b
);
7079 #define test_button_type(a,b) _test_button_type(__LINE__,a,b)
7080 static void _test_button_type(unsigned line
, IHTMLElement
*elem
, const char *extype
)
7082 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7086 hres
= IHTMLButtonElement_get_type(button
, &str
);
7087 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7088 ok_(__FILE__
,line
)(!strcmp_wa(str
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(str
), extype
);
7091 IHTMLButtonElement_Release(button
);
7094 #define test_button_value(a,b) _test_button_value(__LINE__,a,b)
7095 static void _test_button_value(unsigned line
, IHTMLElement
*elem
, const char *exvalue
)
7097 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7101 hres
= IHTMLButtonElement_get_value(button
, &str
);
7102 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
7104 ok_(__FILE__
,line
)(!strcmp_wa(str
, exvalue
), "value = %s, expected %s\n", wine_dbgstr_w(str
), exvalue
);
7106 ok_(__FILE__
,line
)(!str
, "value = %s, expected NULL\n", wine_dbgstr_w(str
));
7109 IHTMLButtonElement_Release(button
);
7112 #define set_button_value(a,b) _set_button_value(__LINE__,a,b)
7113 static void _set_button_value(unsigned line
, IHTMLElement
*elem
, const char *value
)
7115 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7116 BSTR str
= a2bstr(value
);
7119 hres
= IHTMLButtonElement_put_value(button
, str
);
7120 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
7121 IHTMLButtonElement_Release(button
);
7124 _test_button_value(line
, elem
, value
);
7127 #define get_button_form(a) _get_button_form(__LINE__,a)
7128 static IHTMLFormElement
*_get_button_form(unsigned line
, IHTMLElement
*elem
)
7130 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7131 IHTMLFormElement
*form
;
7134 hres
= IHTMLButtonElement_get_form(button
, &form
);
7135 ok_(__FILE__
,line
)(hres
== S_OK
, "get_form failed: %08x\n", hres
);
7136 IHTMLButtonElement_Release(button
);
7141 static void test_button_elem(IHTMLElement
*elem
)
7143 IHTMLFormElement
*form
;
7145 test_button_name(elem
, NULL
);
7146 set_button_name(elem
, "button name");
7147 test_button_type(elem
, "submit");
7148 test_button_value(elem
, NULL
);
7149 set_button_value(elem
, "val");
7151 form
= get_button_form(elem
);
7152 ok(!form
, "form != NULL\n");
7154 test_elem_istextedit(elem
, VARIANT_TRUE
);
7157 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
7158 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
7159 IHTMLTableRow
*row
, LONG len
, const char *id
)
7161 IHTMLElementCollection
*col
;
7167 hres
= IHTMLTableRow_get_cells(row
, &col
);
7168 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7169 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
7171 hres
= IHTMLElementCollection_get_length(col
, &lval
);
7172 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
7173 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
7175 V_VT(&var
) = VT_BSTR
;
7176 V_BSTR(&var
) = a2bstr(id
);
7177 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
7178 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
7179 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
7182 IDispatch_Release(disp
);
7183 IHTMLElementCollection_Release(col
);
7186 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
7190 IHTMLTableCell
*cell
;
7192 hres
= IHTMLTableRow_deleteCell(row
, 0);
7193 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
7194 test_tr_possess(elem
, row
, 1, "td2");
7196 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
7197 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
7198 ok(disp
!= NULL
, "disp == NULL\n");
7199 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
7200 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
7201 ok(cell
!= NULL
, "cell == NULL\n");
7202 if (SUCCEEDED(hres
))
7203 IHTMLTableCell_Release(cell
);
7204 test_tr_possess(elem
, row
, 2, "td2");
7205 IDispatch_Release(disp
);
7208 static void test_tr_elem(IHTMLElement
*elem
)
7210 IHTMLElementCollection
*col
;
7215 VARIANT vbg
, vDefaultbg
;
7217 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
7219 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
7220 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7225 hres
= IHTMLTableRow_get_cells(row
, &col
);
7226 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7227 ok(col
!= NULL
, "get_cells returned NULL\n");
7229 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
7230 IHTMLElementCollection_Release(col
);
7232 bstr
= a2bstr("left");
7233 hres
= IHTMLTableRow_put_align(row
, bstr
);
7234 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7235 SysFreeString(bstr
);
7238 hres
= IHTMLTableRow_get_align(row
, &bstr
);
7239 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7240 ok(bstr
!= NULL
, "get_align returned NULL\n");
7241 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7242 SysFreeString(bstr
);
7244 bstr
= a2bstr("top");
7245 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
7246 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
7247 SysFreeString(bstr
);
7250 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
7251 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
7252 ok(bstr
!= NULL
, "get_valign returned NULL\n");
7253 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
7254 SysFreeString(bstr
);
7257 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
7258 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7259 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
7262 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
7263 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
7264 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
7266 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
7267 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7268 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7269 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7271 V_VT(&vbg
) = VT_BSTR
;
7272 V_BSTR(&vbg
) = a2bstr("red");
7273 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7274 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7277 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7278 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7279 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7280 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7284 V_I4(&vbg
) = 0xff0000;
7285 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7286 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7289 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7290 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7291 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7292 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7295 /* Restore Original */
7296 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
7297 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7298 VariantClear(&vDefaultbg
);
7300 test_tr_modify(elem
, row
);
7302 IHTMLTableRow_Release(row
);
7305 static void test_td_elem(IHTMLDocument2
*doc
, IHTMLElement
*div
)
7307 IHTMLTableCell
*cell
;
7312 VARIANT vbg
, vDefaultbg
;
7314 test_elem_set_innerhtml((IUnknown
*)div
,
7315 "<table id=\"tbl\"><tbody>"
7317 " <tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td><td></td></tr>"
7319 "</tbody></table>");
7321 elem
= get_doc_elem_by_id(doc
, "td1");
7322 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7323 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7324 IHTMLElement_Release(elem
);
7327 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7328 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7329 ok(!lval
, "Expected 0, got %d\n", lval
);
7331 str
= a2bstr("left");
7332 hres
= IHTMLTableCell_put_align(cell
, str
);
7333 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7337 hres
= IHTMLTableCell_get_align(cell
, &str
);
7338 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7339 ok(str
!= NULL
, "str is NULL\n");
7340 if (str
!= NULL
&& hres
== S_OK
) {
7341 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7345 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7346 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7347 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7348 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7350 V_VT(&vbg
) = VT_BSTR
;
7351 V_BSTR(&vbg
) = a2bstr("red");
7352 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7353 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7356 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7357 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7358 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7359 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7363 V_I4(&vbg
) = 0xff0000;
7364 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7365 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7368 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7369 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7370 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7371 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7374 /* Restore Original */
7375 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7376 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7377 VariantClear(&vDefaultbg
);
7379 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7380 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7381 ok(lval
== 1, "rowSpan = %d\n", lval
);
7383 hres
= IHTMLTableCell_put_rowSpan(cell
, -1);
7384 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7386 hres
= IHTMLTableCell_put_rowSpan(cell
, 0);
7387 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7389 hres
= IHTMLTableCell_put_rowSpan(cell
, 2);
7390 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7392 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7393 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7394 ok(lval
== 2, "rowSpan = %d\n", lval
);
7396 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7397 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7398 ok(lval
== 1, "rowSpan = %d\n", lval
);
7400 hres
= IHTMLTableCell_put_colSpan(cell
, -1);
7401 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7403 hres
= IHTMLTableCell_put_colSpan(cell
, 0);
7404 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7406 hres
= IHTMLTableCell_put_colSpan(cell
, 2);
7407 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7409 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7410 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7411 ok(lval
== 2, "rowSpan = %d\n", lval
);
7413 IHTMLTableCell_Release(cell
);
7416 static void test_label_elem(IHTMLElement
*elem
)
7418 IHTMLLabelElement
*label
;
7422 label
= get_label_iface((IUnknown
*)elem
);
7425 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7426 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7427 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7431 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7432 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7435 str
= (void*)0xdeadbeef;
7436 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7437 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7438 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7441 str
= a2bstr("abc");
7442 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7443 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7447 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7448 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7449 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7452 IHTMLLabelElement_Release(label
);
7455 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7456 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7461 V_VT(&v
) = VT_ERROR
;
7462 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7463 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7464 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7466 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7468 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7472 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7473 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7478 V_VT(&v
) = VT_ERROR
;
7479 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7480 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7481 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7483 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7485 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7489 static void test_table_modify(IHTMLTable
*table
)
7496 test_table_length(table
, 2);
7498 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7499 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7500 ok(disp
!= NULL
, "disp == NULL\n");
7501 test_table_length(table
, 3);
7502 if (hres
!= S_OK
|| disp
== NULL
)
7505 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7506 IDispatch_Release(disp
);
7508 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7509 ok(row
!= NULL
, "row == NULL\n");
7512 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7513 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7514 ok(index
== 0, "index = %d, expected 0\n", index
);
7516 IHTMLTableRow_Release(row
);
7518 hres
= IHTMLTable_deleteRow(table
, 0);
7519 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7520 test_table_length(table
, 2);
7523 static void test_table_elem(IHTMLElement
*elem
)
7525 IHTMLElementCollection
*col
;
7527 IHTMLTable3
*table3
;
7532 VARIANT vbg
, vDefaultbg
;
7534 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7535 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7536 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7538 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7539 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7543 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7544 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7549 hres
= IHTMLTable_get_rows(table
, &col
);
7550 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7551 ok(col
!= NULL
, "get_rows returned NULL\n");
7553 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7554 IHTMLElementCollection_Release(col
);
7556 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7558 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7559 test_elem_tag((IUnknown
*)node
, "TABLE");
7560 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7561 IHTMLDOMNode_Release(node
);
7563 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7564 test_elem_tag((IUnknown
*)node
, "TABLE");
7565 test_elem_all((IUnknown
*)node
, NULL
, 0);
7566 IHTMLDOMNode_Release(node
);
7569 hres
= IHTMLTable_get_tBodies(table
, &col
);
7570 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7571 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7573 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7574 IHTMLElementCollection_Release(col
);
7576 test_table_cell_spacing(table
, NULL
);
7580 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7581 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7582 test_table_cell_spacing(table
, "10");
7585 V_BSTR(&v
) = a2bstr("11");
7586 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7587 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7588 test_table_cell_spacing(table
, "11");
7591 test_table_cell_padding(table
, NULL
);
7595 hres
= IHTMLTable_put_cellPadding(table
, v
);
7596 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7597 test_table_cell_padding(table
, "10");
7600 V_BSTR(&v
) = a2bstr("11");
7601 hres
= IHTMLTable_put_cellPadding(table
, v
);
7602 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7603 test_table_cell_padding(table
, "11");
7608 hres
= IHTMLTable_put_cellPadding(table
, v
);
7609 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7610 test_table_cell_padding(table
, "5");
7612 bstr
= a2bstr("left");
7613 hres
= IHTMLTable_put_align(table
, bstr
);
7614 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7615 SysFreeString(bstr
);
7618 hres
= IHTMLTable_get_align(table
, &bstr
);
7619 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7620 ok(bstr
!= NULL
, "get_align returned NULL\n");
7621 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7622 SysFreeString(bstr
);
7624 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7625 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7626 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7627 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7629 V_VT(&vbg
) = VT_BSTR
;
7630 V_BSTR(&vbg
) = a2bstr("red");
7631 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7632 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7635 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7636 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7637 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7638 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7642 V_I4(&vbg
) = 0xff0000;
7643 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7644 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7647 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7648 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7649 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7650 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7653 /* Restore Original */
7654 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7655 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7656 VariantClear(&vDefaultbg
);
7659 V_BSTR(&v
) = a2bstr("11");
7660 hres
= IHTMLTable_put_width(table
, v
);
7661 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7663 hres
= IHTMLTable_get_width(table
, &v
);
7664 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7665 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7669 V_BSTR(&v
) = a2bstr("11.9");
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("40.2%");
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
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7690 hres
= IHTMLTable_put_width(table
, v
);
7691 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7692 hres
= IHTMLTable_get_width(table
, &v
);
7693 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7694 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7699 hres
= IHTMLTable_put_width(table
, v
);
7700 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7701 hres
= IHTMLTable_get_width(table
, &v
);
7702 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7703 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7706 bstr
= a2bstr("box");
7707 hres
= IHTMLTable_put_frame(table
, bstr
);
7708 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7709 SysFreeString(bstr
);
7710 hres
= IHTMLTable_get_frame(table
, &bstr
);
7711 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7712 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7713 SysFreeString(bstr
);
7715 test_table_modify(table
);
7716 bstr
= a2bstr("summary");
7717 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7718 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7719 SysFreeString(bstr
);
7721 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7722 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7723 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7724 SysFreeString(bstr
);
7726 IHTMLTable3_Release(table3
);
7727 IHTMLTable_Release(table
);
7730 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7739 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7740 SafeArrayAccessData(sa
, (void**)&var
);
7741 V_VT(var
) = VT_BSTR
;
7742 V_BSTR(var
) = a2bstr(text
);
7743 SafeArrayUnaccessData(sa
);
7746 hres
= IHTMLDocument2_writeln(doc
, sa
);
7748 hres
= IHTMLDocument2_write(doc
, sa
);
7749 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7751 SafeArrayDestroy(sa
);
7754 static void doc_complex_write(IHTMLDocument2
*doc
)
7756 SAFEARRAYBOUND dim
= {5, 0};
7761 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7762 SafeArrayAccessData(sa
, (void**)&args
);
7764 V_VT(args
) = VT_BSTR
;
7765 V_BSTR(args
) = a2bstr("<body i4val=\"");
7766 V_VT(args
+1) = VT_I4
;
7768 V_VT(args
+2) = VT_BSTR
;
7769 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7770 V_VT(args
+3) = VT_R8
;
7771 V_R8(args
+3) = 3.14;
7772 V_VT(args
+4) = VT_BSTR
;
7773 V_BSTR(args
+4) = a2bstr("\">");
7774 SafeArrayUnaccessData(sa
);
7776 hres
= IHTMLDocument2_write(doc
, sa
);
7777 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7779 SafeArrayDestroy(sa
);
7782 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7784 IHTMLDocument2
*window_doc
, *elem_doc
;
7785 IHTMLFrameElement3
*frame_elem3
;
7786 IHTMLWindow2
*content_window
;
7789 content_window
= get_frame_content_window(frame_elem
);
7790 test_ifaces((IUnknown
*)content_window
, window_iids
);
7791 window_doc
= get_window_doc(content_window
);
7792 IHTMLWindow2_Release(content_window
);
7794 elem_doc
= get_elem_doc(frame_elem
);
7795 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7798 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7799 if(SUCCEEDED(hres
)) {
7800 IDispatch
*disp
= NULL
;
7802 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7803 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7804 ok(disp
!= NULL
, "contentDocument == NULL\n");
7805 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7807 IDispatch_Release(disp
);
7808 IHTMLFrameElement3_Release(frame_elem3
);
7810 win_skip("IHTMLFrameElement3 not supported\n");
7814 IHTMLDocument2_Release(elem_doc
);
7815 IHTMLDocument2_Release(window_doc
);
7818 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7819 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7821 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7825 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7826 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7827 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7829 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7831 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7833 IHTMLIFrameElement2_Release(iframe
);
7836 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7837 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7839 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7844 V_BSTR(&v
) = a2bstr(val
);
7845 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7846 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7848 IHTMLIFrameElement2_Release(iframe
);
7851 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7852 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7854 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7858 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7859 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7860 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7862 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7864 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7866 IHTMLIFrameElement2_Release(iframe
);
7869 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7870 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7872 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7877 V_BSTR(&v
) = a2bstr(val
);
7878 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7879 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7881 IHTMLIFrameElement2_Release(iframe
);
7884 static void test_iframe_elem(IHTMLElement
*elem
)
7886 IHTMLDocument2
*content_doc
, *owner_doc
;
7887 IHTMLIFrameElement3
*iframe3
;
7888 IHTMLElementCollection
*col
;
7889 IHTMLWindow2
*content_window
;
7896 static const elem_type_t all_types
[] = {
7904 test_frame_doc((IUnknown
*)elem
, TRUE
);
7905 test_framebase((IUnknown
*)elem
);
7907 content_window
= get_frame_content_window((IUnknown
*)elem
);
7908 test_ifaces((IUnknown
*)content_window
, window_iids
);
7909 test_window_length(content_window
, 0);
7911 content_doc
= get_window_doc(content_window
);
7912 IHTMLWindow2_Release(content_window
);
7914 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7915 if(SUCCEEDED(hres
)) {
7916 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7917 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7918 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7919 IDispatch_Release(disp
);
7921 IHTMLIFrameElement3_Release(iframe3
);
7923 win_skip("IHTMLIFrameElement3 not supported\n");
7926 test_iframe_height(elem
, NULL
);
7927 set_iframe_height(elem
, "100px");
7928 set_iframe_height(elem
, "50%");
7929 test_iframe_height(elem
, "50%");
7931 test_iframe_width(elem
, NULL
);
7932 set_iframe_width(elem
, "150px");
7933 set_iframe_width(elem
, "70%");
7934 test_iframe_width(elem
, "70%");
7935 test_framebase_src(elem
, "about:blank");
7937 str
= a2bstr("text/html");
7938 V_VT(&errv
) = VT_ERROR
;
7940 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7942 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7943 ok(disp
!= NULL
, "disp == NULL\n");
7944 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7945 IDispatch_Release(disp
);
7947 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7948 doc_complex_write(content_doc
);
7949 doc_write(content_doc
, TRUE
, "<br />");
7950 doc_write(content_doc
, TRUE
, "</html>");
7952 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7953 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7954 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7955 IHTMLElementCollection_Release(col
);
7957 body
= doc_get_body(content_doc
);
7958 test_elem_attr(body
, "i4val", "4");
7959 test_elem_attr(body
, "r8val", "3.14");
7960 IHTMLElement_Release(body
);
7962 hres
= IHTMLDocument2_close(content_doc
);
7963 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7965 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7966 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7968 IHTMLDocument2_Release(content_doc
);
7971 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7972 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7977 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7978 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7979 todo_wine_if(is_todo
) {
7981 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7983 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7989 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
7990 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7992 BSTR str
= a2bstr(csstext
);
7995 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7996 todo_wine_if(is_todo
)
7997 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
8001 static void test_stylesheet(IDispatch
*disp
)
8003 IHTMLStyleSheetRulesCollection
*col
= NULL
;
8004 IHTMLStyleSheet
*stylesheet
;
8008 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, "[object]");
8010 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
8011 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
8013 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
8014 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
8015 ok(col
!= NULL
, "col == NULL\n");
8017 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, NULL
, "[object]");
8018 IHTMLStyleSheetRulesCollection_Release(col
);
8020 href
= (void*)0xdeadbeef;
8021 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
8022 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
8023 ok(href
== NULL
, "got href != NULL\n");
8024 SysFreeString(href
);
8026 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
8027 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
8028 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
8029 set_stylesheet_csstext(stylesheet
, "", FALSE
);
8030 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
8031 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
8032 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
8034 IHTMLStyleSheet_Release(stylesheet
);
8037 static void test_stylesheets(IHTMLDocument2
*doc
)
8039 IHTMLStyleSheetsCollection
*col
= NULL
;
8044 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
8045 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
8046 ok(col
!= NULL
, "col == NULL\n");
8048 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, NULL
, "[object]");
8050 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
8051 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8052 ok(len
== 1, "len=%d\n", len
);
8058 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8059 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
8060 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8061 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8062 test_stylesheet(V_DISPATCH(&res
));
8069 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8070 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8071 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
8074 IHTMLStyleSheetsCollection_Release(col
);
8077 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
8079 IDispatchEx
*dispex
;
8081 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
8089 static const WCHAR w0
[] = {'0',0};
8090 static const WCHAR w100
[] = {'1','0','0',0};
8092 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
8093 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
8095 bstr
= SysAllocString(w0
);
8096 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8097 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8098 SysFreeString(bstr
);
8101 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
8102 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
8103 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
8104 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
8105 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
8106 type
= get_node_type((IUnknown
*)node
);
8107 ok(type
== 3, "type=%d\n", type
);
8108 IHTMLDOMNode_Release(node
);
8111 bstr
= SysAllocString(w100
);
8112 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8113 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
8114 SysFreeString(bstr
);
8116 IDispatchEx_Release(dispex
);
8119 static void test_enum_children(IUnknown
*unk
, unsigned len
)
8121 IEnumVARIANT
*enum_var
;
8126 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
8127 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
8129 for(i
=0; i
<len
; i
++) {
8131 V_VT(&v
) = VT_ERROR
;
8132 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
8133 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
8135 ok(fetched
== 1, "fetched = %d\n", fetched
);
8136 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
8137 IDispatch_Release(V_DISPATCH(&v
));
8140 fetched
= 0xdeadbeef;
8142 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
8143 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
8144 ok(fetched
== 0, "fetched = %d\n", fetched
);
8145 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8147 hres
= IEnumVARIANT_Reset(enum_var
);
8148 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8150 fetched
= 0xdeadbeef;
8152 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
8153 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
8154 ok(fetched
== 0, "fetched = %d\n", fetched
);
8155 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8157 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
8158 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
8160 hres
= IEnumVARIANT_Reset(enum_var
);
8161 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8163 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
8164 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
8166 IEnumVARIANT_Release(enum_var
);
8169 static void test_selectors(IHTMLDocument2
*doc
, IHTMLElement
*div
)
8171 IHTMLDOMChildrenCollection
*collection
;
8172 IDocumentSelector
*doc_selector
;
8173 IElementSelector
*elem_selector
;
8177 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8179 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentSelector
, (void**)&doc_selector
);
8180 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDocumentSelector iface: %08x\n", hres
);
8182 win_skip("IDocumentSelector tests skipped.\n");
8187 str
= a2bstr("nomatch");
8188 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8189 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8190 ok(collection
!= NULL
, "collection == NULL\n");
8191 test_children_collection_length(collection
, 0);
8192 IHTMLDOMChildrenCollection_Release(collection
);
8196 str
= a2bstr(".cl1");
8197 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8198 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8199 ok(collection
!= NULL
, "collection == NULL\n");
8200 test_children_collection_length(collection
, 2);
8201 IHTMLDOMChildrenCollection_Release(collection
);
8204 IDocumentSelector_Release(doc_selector
);
8206 hres
= IHTMLElement_QueryInterface(div
, &IID_IElementSelector
, (void**)&elem_selector
);
8207 ok(hres
== S_OK
, "Could not get IElementSelector iface: %08x\n", hres
);
8210 str
= a2bstr("nomatch");
8211 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8212 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8213 ok(collection
!= NULL
, "collection == NULL\n");
8214 test_children_collection_length(collection
, 0);
8215 IHTMLDOMChildrenCollection_Release(collection
);
8219 str
= a2bstr(".cl1");
8220 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8221 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8222 ok(collection
!= NULL
, "collection == NULL\n");
8223 test_children_collection_length(collection
, 2);
8224 IHTMLDOMChildrenCollection_Release(collection
);
8227 IElementSelector_Release(elem_selector
);
8230 static void test_elemsbyclass(IHTMLElement
*div
)
8232 IHTMLElementCollection
*collection
;
8233 IHTMLElement6
*elem
;
8237 static const elem_type_t types
[] = {ET_DIV
, ET_FORM
};
8239 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8241 hres
= IHTMLElement_QueryInterface(div
, &IID_IHTMLElement6
, (void**)&elem
);
8242 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IHTMLElement6 iface: %08x\n", hres
);
8244 win_skip("IHTMLElement6 tests skipped.\n");
8249 str
= a2bstr("nomatch");
8250 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8251 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8252 ok(collection
!= NULL
, "collection == NULL\n");
8253 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
8254 IHTMLElementCollection_Release(collection
);
8258 str
= a2bstr("cl1");
8259 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8260 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8261 ok(collection
!= NULL
, "collection == NULL\n");
8262 test_elem_collection((IUnknown
*)collection
, types
, sizeof(types
)/sizeof(*types
));
8263 IHTMLElementCollection_Release(collection
);
8266 IHTMLElement6_Release(elem
);
8269 static void test_elems(IHTMLDocument2
*doc
)
8271 IHTMLElementCollection
*col
;
8272 IHTMLDOMChildrenCollection
*child_col
;
8273 IHTMLElement
*elem
, *elem2
, *elem3
;
8274 IHTMLDOMNode
*node
, *node2
;
8275 IHTMLWindow2
*window
;
8279 IHTMLElementCollection
*collection
;
8280 IHTMLDocument3
*doc3
;
8283 static const elem_type_t all_types
[] = {
8316 static const elem_type_t item_types
[] = {
8322 hres
= IHTMLDocument2_get_all(doc
, &col
);
8323 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8324 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8325 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
8327 elem
= get_elem_col_item_idx(col
, 0);
8328 test_elem_source_index(elem
, 0);
8329 IHTMLElement_Release(elem
);
8331 elem
= get_elem_col_item_idx(col
, 3);
8332 test_elem_source_index(elem
, 3);
8333 IHTMLElement_Release(elem
);
8335 IHTMLElementCollection_Release(col
);
8337 hres
= IHTMLDocument2_get_images(doc
, &collection
);
8338 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
8341 static const elem_type_t images_types
[] = {ET_IMG
};
8342 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8344 IHTMLElementCollection_Release(collection
);
8347 hres
= IHTMLDocument2_get_links(doc
, &collection
);
8348 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
8351 static const elem_type_t images_types
[] = {ET_A
};
8352 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8354 IHTMLElementCollection_Release(collection
);
8357 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
8358 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
8361 static const elem_type_t anchor_types
[] = {ET_A
};
8362 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
8364 IHTMLElementCollection_Release(collection
);
8367 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
8368 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
8370 static const elem_type_t script_types
[] = {ET_SCRIPT
};
8371 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
8372 IHTMLElementCollection_Release(collection
);
8375 test_plugins_col(doc
);
8377 elem
= get_doc_elem(doc
);
8378 test_elem_istextedit(elem
, VARIANT_FALSE
);
8379 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
8380 IHTMLElement_Release(elem
);
8382 get_elem_by_id(doc
, "xxx", FALSE
);
8383 elem
= get_doc_elem_by_id(doc
, "xxx");
8384 ok(!elem
, "elem != NULL\n");
8386 elem
= get_doc_elem_by_id(doc
, "s");
8387 ok(elem
!= NULL
, "elem == NULL\n");
8389 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
8390 test_elem_attr(elem
, "xxx", NULL
);
8391 test_elem_attr(elem
, "id", "s");
8392 test_elem_class((IUnknown
*)elem
, NULL
);
8393 test_elem_set_class((IUnknown
*)elem
, "cl");
8394 test_elem_set_class((IUnknown
*)elem
, NULL
);
8395 test_elem_tabindex((IUnknown
*)elem
, 0);
8396 test_elem_set_tabindex((IUnknown
*)elem
, 1);
8397 test_elem_filters((IUnknown
*)elem
);
8398 test_elem_istextedit(elem
, VARIANT_FALSE
);
8400 node
= test_node_get_parent((IUnknown
*)elem
);
8401 ok(node
!= NULL
, "node == NULL\n");
8402 test_node_name((IUnknown
*)node
, "BODY");
8403 node2
= test_node_get_parent((IUnknown
*)node
);
8404 IHTMLDOMNode_Release(node
);
8405 ok(node2
!= NULL
, "node == NULL\n");
8406 test_node_name((IUnknown
*)node2
, "HTML");
8407 node
= test_node_get_parent((IUnknown
*)node2
);
8408 IHTMLDOMNode_Release(node2
);
8409 ok(node
!= NULL
, "node == NULL\n");
8412 test_node_name((IUnknown
*)node
, "#document");
8413 type
= get_node_type((IUnknown
*)node
);
8414 ok(type
== 9, "type=%d, expected 9\n", type
);
8415 node2
= test_node_get_parent((IUnknown
*)node
);
8416 IHTMLDOMNode_Release(node
);
8417 ok(node2
== NULL
, "node != NULL\n");
8420 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8421 ok(elem2
!= NULL
, "elem2 == NULL\n");
8422 test_node_name((IUnknown
*)elem2
, "BODY");
8424 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
8425 ok(elem3
!= NULL
, "elem3 == NULL\n");
8426 test_node_name((IUnknown
*)elem3
, "HTML");
8428 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
8429 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
8430 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
8431 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
8432 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
8433 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
8434 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
8435 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
8436 IHTMLElement_Release(elem2
);
8438 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
8439 ok(elem2
== NULL
, "elem2 != NULL\n");
8440 test_elem_source_index(elem3
, 0);
8441 IHTMLElement_Release(elem3
);
8443 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
8444 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
8445 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
8447 test_elem_innertext(elem
, "opt1opt2");
8449 IHTMLElement_Release(elem
);
8452 elem
= get_elem_by_id(doc
, "s", TRUE
);
8454 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8455 IHTMLDocument2
*doc_node
, *elem_doc
;
8457 test_select_elem(select
);
8459 test_elem_istextedit(elem
, VARIANT_FALSE
);
8460 test_elem_title((IUnknown
*)select
, NULL
);
8461 test_elem_set_title((IUnknown
*)select
, "Title");
8462 test_elem_title((IUnknown
*)select
, "Title");
8463 test_elem_offset((IUnknown
*)select
, "BODY");
8464 test_elem_bounding_client_rect((IUnknown
*)select
);
8466 node
= get_first_child((IUnknown
*)select
);
8467 ok(node
!= NULL
, "node == NULL\n");
8469 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8470 IHTMLDOMNode_Release(node
);
8473 type
= get_node_type((IUnknown
*)select
);
8474 ok(type
== 1, "type=%d\n", type
);
8476 IHTMLSelectElement_Release(select
);
8478 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8480 doc_node
= get_doc_node(doc
);
8481 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8482 IHTMLDocument2_Release(doc_node
);
8483 IHTMLDocument2_Release(elem_doc
);
8485 IHTMLElement_Release(elem
);
8488 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8490 IHTMLScriptElement
*script
;
8493 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8494 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8496 test_elem_language(elem
, NULL
);
8497 test_elem_istextedit(elem
, VARIANT_FALSE
);
8503 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8504 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8505 hres
= IHTMLScriptElement_get_type(script
, &type
);
8506 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8507 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8509 type
= a2bstr("text/javascript");
8510 hres
= IHTMLScriptElement_put_type (script
, type
);
8511 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8512 SysFreeString(type
);
8513 hres
= IHTMLScriptElement_get_type(script
, &type
);
8514 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8515 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8516 SysFreeString(type
);
8518 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8521 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8522 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8524 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8525 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8526 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8528 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8529 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8531 str
= (BSTR
)0xdeadbeef;
8532 hres
= IHTMLScriptElement_get_src(script
, &str
);
8533 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8534 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8537 IHTMLScriptElement_Release(script
);
8539 set_elem_language(elem
, "vbscript");
8540 set_elem_language(elem
, "xxx");
8543 elem
= get_elem_by_id(doc
, "in", TRUE
);
8545 IHTMLInputElement
*input
;
8547 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8548 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8550 test_elem_id((IUnknown
*)elem
, "in");
8551 test_elem_put_id((IUnknown
*)elem
, "newin");
8552 test_input_get_disabled(input
, VARIANT_FALSE
);
8553 test_input_set_disabled(input
, VARIANT_TRUE
);
8554 test_input_set_disabled(input
, VARIANT_FALSE
);
8555 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8556 test_input_get_disabled(input
, VARIANT_TRUE
);
8557 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8558 test_input_get_disabled(input
, VARIANT_FALSE
);
8559 test_elem_client_size((IUnknown
*)elem
);
8560 test_input_type(input
, "text");
8561 test_elem_istextedit(elem
, VARIANT_TRUE
);
8563 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8564 test_node_put_value_str((IUnknown
*)elem
, "test");
8565 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8566 test_input_value((IUnknown
*)elem
, NULL
);
8567 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8568 test_input_put_value((IUnknown
*)elem
, "test");
8569 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8570 test_elem_class((IUnknown
*)elem
, "testclass");
8571 test_elem_tabindex((IUnknown
*)elem
, 2);
8572 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8573 test_elem_title((IUnknown
*)elem
, "test title");
8575 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8576 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8577 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8579 test_input_get_checked(input
, VARIANT_FALSE
);
8580 test_input_set_checked(input
, VARIANT_TRUE
);
8581 test_input_set_checked(input
, VARIANT_FALSE
);
8583 test_input_maxlength(input
, 0x7fffffff);
8584 test_input_set_maxlength(input
, 30);
8586 test_input_name(input
, NULL
);
8587 test_input_set_name(input
, "test");
8589 test_input_src(input
, NULL
);
8590 test_input_set_src(input
, "about:blank");
8592 test_input_set_size(input
, 15, S_OK
);
8593 test_input_get_size(input
, 15);
8594 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8595 test_input_get_size(input
, 15);
8596 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8597 test_input_get_size(input
, 15);
8599 test_input_readOnly(input
, VARIANT_TRUE
);
8600 test_input_readOnly(input
, VARIANT_FALSE
);
8602 test_elem_lang(elem
, NULL
);
8603 set_elem_lang(elem
, "en-us");
8605 IHTMLInputElement_Release(input
);
8606 IHTMLElement_Release(elem
);
8609 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8611 test_img_align((IUnknown
*)elem
, "left");
8612 test_img_name((IUnknown
*)elem
, "WineImg");
8613 test_img_src((IUnknown
*)elem
, "", NULL
);
8614 test_img_set_src((IUnknown
*)elem
, "about:blank");
8615 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8616 test_img_alt((IUnknown
*)elem
, NULL
);
8617 test_img_set_alt((IUnknown
*)elem
, "alt test");
8618 test_img_name((IUnknown
*)elem
, "WineImg");
8619 test_img_complete(elem
, VARIANT_FALSE
);
8620 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8621 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8622 IHTMLElement_Release(elem
);
8625 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8627 test_dynamic_properties(elem
);
8628 test_attr_collection(elem
);
8629 test_contenteditable((IUnknown
*)elem
);
8630 IHTMLElement_Release(elem
);
8633 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8635 test_style_media((IUnknown
*)elem
, NULL
);
8636 test_style_put_media((IUnknown
*)elem
, "screen");
8637 test_style_type((IUnknown
*)elem
, NULL
);
8638 test_style_put_type((IUnknown
*)elem
, "text/css");
8639 IHTMLElement_Release(elem
);
8642 elem
= get_doc_elem_by_id(doc
, "tbl");
8643 ok(elem
!= NULL
, "elem == NULL\n");
8645 test_table_elem(elem
);
8646 IHTMLElement_Release(elem
);
8649 elem
= get_doc_elem_by_id(doc
, "labelid");
8650 ok(elem
!= NULL
, "elem == NULL\n");
8652 test_label_elem(elem
);
8653 IHTMLElement_Release(elem
);
8656 elem
= get_doc_elem_by_id(doc
, "row2");
8657 ok(elem
!= NULL
, "elem == NULL\n");
8660 IHTMLElement_Release(elem
);
8663 elem
= get_doc_elem_by_id(doc
, "ifr");
8664 ok(elem
!= NULL
, "elem == NULL\n");
8666 test_iframe_elem(elem
);
8667 IHTMLElement_Release(elem
);
8670 elem
= get_doc_elem_by_id(doc
, "btnid");
8671 ok(elem
!= NULL
, "elem == NULL\n");
8673 test_button_elem(elem
);
8674 test_button_get_disabled(elem
, VARIANT_FALSE
);
8675 test_button_set_disabled(elem
, VARIANT_TRUE
);
8676 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8677 test_button_get_disabled(elem
, VARIANT_FALSE
);
8678 IHTMLElement_Release(elem
);
8681 elem
= get_doc_elem_by_id(doc
, "objid");
8682 ok(elem
!= NULL
, "elem == NULL\n");
8684 test_object_vspace((IUnknown
*)elem
, 100);
8685 test_object_name(elem
, "objname");
8686 set_object_name(elem
, "test");
8687 set_object_name(elem
, NULL
);
8688 IHTMLElement_Release(elem
);
8691 elem
= get_elem_by_id(doc
, "a", TRUE
);
8693 test_anchor_href((IUnknown
*)elem
, "http://test/");
8695 /* Change the href */
8696 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8697 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8698 test_anchor_hostname((IUnknown
*)elem
, "test1");
8700 /* Restore the href */
8701 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8702 test_anchor_href((IUnknown
*)elem
, "http://test/");
8703 test_anchor_hostname((IUnknown
*)elem
, "test");
8704 test_anchor_hash(elem
, NULL
);
8707 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8709 test_anchor_rel((IUnknown
*)elem
, NULL
);
8710 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8711 test_anchor_rel((IUnknown
*)elem
, "Next");
8713 /* Change the target */
8714 test_anchor_put_target((IUnknown
*)elem
, "wine");
8715 test_anchor_get_target((IUnknown
*)elem
, "wine");
8717 /* Restore the target */
8718 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8719 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8721 test_anchor_name((IUnknown
*)elem
, "x");
8722 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8723 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8724 test_anchor_put_name((IUnknown
*)elem
, "x");
8726 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8727 test_anchor_hash(elem
, "#hash");
8728 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8730 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8731 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8732 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8733 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8735 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8736 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8738 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8739 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8741 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8742 as part of the pathname, and cannot be accessed by get_search. */
8743 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8744 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8746 IHTMLElement_Release(elem
);
8749 elem
= get_doc_elem_by_id(doc
, "metaid");
8751 test_meta_name((IUnknown
*)elem
, "meta name");
8752 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8753 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8754 test_meta_charset((IUnknown
*)elem
, NULL
);
8755 set_meta_charset((IUnknown
*)elem
, "utf-8");
8756 IHTMLElement_Release(elem
);
8759 elem
= doc_get_body(doc
);
8761 node
= get_first_child((IUnknown
*)elem
);
8762 ok(node
!= NULL
, "node == NULL\n");
8764 test_ifaces((IUnknown
*)node
, text_iids
);
8765 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
8767 node2
= get_first_child((IUnknown
*)node
);
8768 ok(!node2
, "node2 != NULL\n");
8770 type
= get_node_type((IUnknown
*)node
);
8771 ok(type
== 3, "type=%d\n", type
);
8773 test_node_get_value_str((IUnknown
*)node
, "text test");
8774 test_node_put_value_str((IUnknown
*)elem
, "test text");
8775 test_node_get_value_str((IUnknown
*)node
, "text test");
8777 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8778 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8779 ok(!disp
, "disp != NULL\n");
8781 IHTMLDOMNode_Release(node
);
8784 child_col
= get_child_nodes((IUnknown
*)elem
);
8785 ok(child_col
!= NULL
, "child_coll == NULL\n");
8790 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, NULL
, "[object]");
8791 length
= test_children_collection_length(child_col
, -1);
8794 node
= get_child_item(child_col
, 0);
8795 ok(node
!= NULL
, "node == NULL\n");
8799 type
= get_node_type((IUnknown
*)node
);
8800 ok(type
== 3, "type=%d\n", type
);
8801 node2
= node_get_next((IUnknown
*)node
);
8803 prev
= node_get_prev((IUnknown
*)node2
);
8804 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8805 IHTMLDOMNode_Release(prev
);
8807 IHTMLDOMNode_Release(node
);
8810 node
= get_child_item(child_col
, 1);
8811 ok(node
!= NULL
, "node == NULL\n");
8813 type
= get_node_type((IUnknown
*)node
);
8814 ok(type
== 8, "type=%d\n", type
);
8816 test_elem_id((IUnknown
*)node
, NULL
);
8817 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8818 IHTMLDOMNode_Release(node2
);
8819 IHTMLDOMNode_Release(node
);
8822 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8823 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8825 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8826 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8828 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8829 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8831 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8832 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8834 test_child_col_disp(child_col
);
8836 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8837 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8839 test_enum_children(enum_unk
, length
);
8841 IUnknown_Release(enum_unk
);
8843 IHTMLDOMChildrenCollection_Release(child_col
);
8846 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8847 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8848 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8850 IHTMLElement_Release(elem
);
8852 elem
= get_doc_elem_by_id(doc
, "frm");
8853 ok(elem
!= NULL
, "elem == NULL\n");
8855 test_form_length((IUnknown
*)elem
, 0);
8856 test_form_elements((IUnknown
*)elem
);
8857 IHTMLElement_Release(elem
);
8860 test_stylesheets(doc
);
8861 test_create_option_elem(doc
);
8862 test_create_img_elem(doc
);
8864 elem
= get_doc_elem_by_id(doc
, "tbl");
8865 ok(elem
!= NULL
, "elem = NULL\n");
8866 test_elem_set_innertext(elem
, "inner text");
8867 IHTMLElement_Release(elem
);
8869 test_doc_title(doc
, "test");
8870 test_doc_set_title(doc
, "test title");
8871 test_doc_title(doc
, "test title");
8874 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8875 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8878 IDispatchEx
*dispex
;
8879 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8880 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8884 BSTR str
= a2bstr("Testing");
8885 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8886 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8887 ok(pid
!= -1, "pid == -1\n");
8889 IDispatchEx_Release(dispex
);
8892 IDispatch_Release(disp
);
8894 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8896 elem
= get_doc_elem_by_id(doc
, "y");
8897 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8898 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8899 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8900 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8901 node
= node_get_next((IUnknown
*)elem
);
8902 ok(!node
, "node = %p\n", node
);
8904 elem2
= get_doc_elem_by_id(doc
, "x");
8905 test_elem_tag((IUnknown
*)elem2
, "A");
8906 node
= node_get_next((IUnknown
*)elem2
);
8907 IHTMLDOMNode_Release(node
);
8908 IHTMLElement_Release(elem2
);
8909 IHTMLElement_Release(elem
);
8911 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8912 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8914 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8915 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8917 IHTMLDocument3_Release(doc3
);
8919 elem
= get_elem_by_id(doc
, "s", TRUE
);
8921 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8923 test_select_put_length((IUnknown
*)elem
, 3);
8924 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8925 test_select_put_length((IUnknown
*)elem
, 1);
8926 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8927 IHTMLElement_Release(elem
);
8930 window
= get_doc_window(doc
);
8931 test_window_name(window
, NULL
);
8932 set_window_name(window
, "test name");
8933 test_window_length(window
, 1);
8934 IHTMLWindow2_Release(window
);
8937 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
8939 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
8940 IHTMLElement4
*elem4
;
8944 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8946 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8948 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
8949 test_ifaces((IUnknown
*)attr
, attr_iids
);
8950 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8951 test_attr_specified(attr
, VARIANT_TRUE
);
8952 test_attr_parent(attr
);
8954 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8955 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8956 IHTMLDOMAttribute_Release(attr2
);
8958 get_attr_node_value(attr
, &v
, VT_BSTR
);
8959 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8963 V_BSTR(&v
) = a2bstr("divid2");
8964 put_attr_node_value(attr
, v
);
8967 get_attr_node_value(attr
, &v
, VT_BSTR
);
8968 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8971 put_attr_value(attr
, "divid3");
8973 get_attr_node_value(attr
, &v
, VT_BSTR
);
8974 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8977 IHTMLDOMAttribute_Release(attr
);
8979 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8980 get_attr_node_value(attr
, &v
, VT_BSTR
);
8981 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8985 V_BSTR(&v
) = a2bstr("newvalue");
8986 put_attr_node_value(attr
, v
);
8989 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8990 get_attr_node_value(attr
, &v
, VT_BSTR
);
8991 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8994 test_attr_specified(attr
, VARIANT_TRUE
);
8995 IHTMLDOMAttribute_Release(attr
);
8999 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
9000 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
9001 get_attr_node_value(attr
, &v
, VT_I4
);
9002 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
9003 test_attr_specified(attr
, VARIANT_TRUE
);
9007 put_attr_node_value(attr
, v
);
9009 get_attr_node_value(attr
, &v
, VT_I4
);
9010 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
9012 put_attr_value(attr
, "160");
9013 get_attr_node_value(attr
, &v
, VT_BSTR
);
9014 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9017 IHTMLDOMAttribute_Release(attr
);
9019 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
9020 test_attr_specified(attr
, VARIANT_FALSE
);
9021 test_attr_expando(attr
, VARIANT_FALSE
);
9022 IHTMLDOMAttribute_Release(attr
);
9024 /* Test created, detached attribute. */
9025 attr
= create_attr((IUnknown
*)doc
, "Test");
9027 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
9028 test_ifaces((IUnknown
*)attr
, attr_iids
);
9029 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9031 test_attr_node_name(attr
, "Test");
9032 test_attr_expando(attr
, VARIANT_FALSE
);
9034 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9038 put_attr_node_value(attr
, v
);
9040 get_attr_node_value(attr
, &v
, VT_I4
);
9041 ok(V_I4(&v
) == 1, "nodeValue = %d\n", V_I4(&v
));
9042 test_attr_value(attr
, "1");
9044 V_VT(&v
) = VT_EMPTY
;
9045 put_attr_node_value(attr
, v
);
9046 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9049 V_BSTR(&v
) = a2bstr("testing");
9050 put_attr_node_value(attr
, v
);
9051 SysFreeString(V_BSTR(&v
));
9052 test_attr_value(attr
, "testing");
9054 elem4
= get_elem4_iface((IUnknown
*)elem
);
9056 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
9057 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9058 ok(!attr2
, "attr2 != NULL\n");
9060 test_elem_attr(elem
, "Test", "testing");
9061 put_attr_value(attr
, "new value");
9062 test_elem_attr(elem
, "Test", "new value");
9064 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9065 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9066 IHTMLDOMAttribute_Release(attr2
);
9068 attr3
= create_attr((IUnknown
*)doc
, "Test");
9069 put_attr_value(attr3
, "replace test");
9071 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9072 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9073 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9074 IHTMLDOMAttribute_Release(attr2
);
9076 test_elem_attr(elem
, "Test", "replace test");
9077 test_attr_value(attr
, "new value");
9078 test_attr_value(attr3
, "replace test");
9080 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9081 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
9082 IHTMLDOMAttribute_Release(attr2
);
9084 put_attr_value(attr
, "new value2");
9085 test_elem_attr(elem
, "Test", "replace test");
9086 test_attr_value(attr
, "new value2");
9087 test_attr_value(attr3
, "replace test");
9089 put_attr_value(attr3
, "new replace value");
9090 test_elem_attr(elem
, "Test", "new replace value");
9091 test_attr_value(attr
, "new value2");
9092 test_attr_value(attr3
, "new replace value");
9094 /* Attached attributes cause errors. */
9095 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9096 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9097 IHTMLDOMAttribute_Release(attr3
);
9099 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9100 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
9101 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9102 IHTMLDOMAttribute_Release(attr2
);
9104 IHTMLElement4_Release(elem4
);
9105 IHTMLDOMAttribute_Release(attr
);
9108 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
9112 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9113 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
9114 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9116 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9117 IHTMLElement_Release(elem
);
9120 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9121 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
9122 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9124 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
9125 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
9126 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
9127 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
9128 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9129 IHTMLElement_Release(elem
);
9133 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
9134 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
9136 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
9137 IHTMLElementCollection
*col
;
9138 BSTR str
= a2bstr(name
);
9141 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
9142 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
9143 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
9145 IHTMLDocument3_Release(doc3
);
9150 static void test_elem_names(IHTMLDocument2
*doc
)
9152 IHTMLElementCollection
*col
;
9157 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
9159 body
= doc_get_body(doc
);
9161 test_elem_set_innerhtml((IUnknown
*)body
,
9162 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
9163 col
= doc_get_elems_by_name(doc
, "test");
9164 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
9165 IHTMLElementCollection_Release(col
);
9167 col
= doc_get_elems_by_name(doc
, "yyy");
9168 test_elem_collection((IUnknown
*)col
, NULL
, 0);
9169 IHTMLElementCollection_Release(col
);
9171 /* case insensivity test */
9172 col
= doc_get_elems_by_name(doc
, "Xxx");
9173 hres
= IHTMLElementCollection_get_length(col
, &len
);
9174 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
9175 todo_wine
ok(len
== 1, "len = %d\n", len
);
9176 IHTMLElementCollection_Release(col
);
9178 IHTMLElement_Release(body
);
9181 static void test_elems2(IHTMLDocument2
*doc
)
9183 IHTMLElement
*elem
, *elem2
, *div
;
9185 static const elem_type_t outer_types
[] = {
9190 div
= get_doc_elem_by_id(doc
, "divid");
9192 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
9194 test_link_disabled(elem
, VARIANT_FALSE
);
9195 test_link_rel(elem
, "stylesheet");
9196 test_link_rev(elem
, NULL
);
9197 test_link_type(elem
, "text/css");
9198 test_link_href(elem
, "about:blank");
9199 test_link_media(elem
, "all");
9200 link_put_disabled(elem
, VARIANT_TRUE
);
9201 link_put_rel(elem
, "prev");
9202 link_put_rev(elem
, "next");
9203 link_put_type(elem
, "text/plain");
9204 link_put_href(elem
, "about:prev");
9205 IHTMLElement_Release(elem
);
9208 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
9209 elem2
= get_doc_elem_by_id(doc
, "innerid");
9210 ok(elem2
!= NULL
, "elem2 == NULL\n");
9211 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
9212 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
9213 IHTMLElement_Release(elem2
);
9215 elem2
= get_doc_elem_by_id(doc
, "aid");
9216 ok(elem2
!= NULL
, "elem2 == NULL\n");
9217 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
9218 test_elem_all((IUnknown
*)div
, outer_types
, 1);
9219 IHTMLElement_Release(elem2
);
9221 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
9222 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9224 IHTMLFormElement
*form
;
9226 test_textarea_value((IUnknown
*)elem
, NULL
);
9227 test_textarea_put_value((IUnknown
*)elem
, "test");
9228 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
9229 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
9230 test_textarea_put_value((IUnknown
*)elem
, "test");
9231 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9232 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
9233 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9234 test_textarea_type((IUnknown
*)elem
);
9236 form
= get_textarea_form((IUnknown
*)elem
);
9237 ok(!form
, "form = %p\n", form
);
9239 test_elem_istextedit(elem
, VARIANT_TRUE
);
9241 IHTMLElement_Release(elem
);
9244 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
9245 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9247 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
9248 IHTMLElement_Release(elem
);
9251 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
9252 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9254 IHTMLFormElement
*form
;
9256 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
9257 ok(elem2
!= NULL
, "elem2 == NULL\n");
9259 form
= get_textarea_form((IUnknown
*)elem
);
9260 ok(form
!= NULL
, "form = NULL\n");
9261 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9263 IHTMLFormElement_Release(form
);
9264 IHTMLElement_Release(elem2
);
9265 IHTMLElement_Release(elem
);
9268 test_elem_set_innerhtml((IUnknown
*)div
,
9269 "<input value=\"val\" id =\"inputid\" />");
9270 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9272 test_input_defaultValue((IUnknown
*)elem
, "val");
9273 test_input_put_value((IUnknown
*)elem
, "test");
9274 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
9275 test_input_value((IUnknown
*)elem
, "test");
9276 IHTMLElement_Release(elem
);
9279 test_elem_set_innerhtml((IUnknown
*)div
, "");
9280 test_insert_adjacent_elems(doc
, div
);
9282 test_elem_set_innerhtml((IUnknown
*)div
,
9283 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
9284 elem
= get_elem_by_id(doc
, "form", TRUE
);
9286 test_form_length((IUnknown
*)elem
, 2);
9287 test_form_item(elem
);
9288 test_form_action((IUnknown
*)elem
, NULL
);
9289 test_form_put_action((IUnknown
*)elem
, "about:blank");
9290 test_form_method((IUnknown
*)elem
, "get");
9291 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
9292 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
9293 test_form_method((IUnknown
*)elem
, "post");
9294 test_form_name((IUnknown
*)elem
, NULL
);
9295 test_form_put_name((IUnknown
*)elem
, "Name");
9296 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
9297 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
9298 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
9299 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
9300 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
9301 test_form_elements((IUnknown
*)elem
);
9302 test_form_reset((IUnknown
*)elem
);
9303 test_form_target((IUnknown
*)elem
);
9304 IHTMLElement_Release(elem
);
9306 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9307 test_input_get_form((IUnknown
*)elem
, "form");
9308 IHTMLElement_Release(elem
);
9311 test_elem_set_innerhtml((IUnknown
*)div
,
9312 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select><button id=\"btnid\"></button></form>");
9313 elem
= get_elem_by_id(doc
, "sform", TRUE
);
9314 elem2
= get_elem_by_id(doc
, "form", TRUE
);
9316 IHTMLFormElement
*form
;
9318 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9319 IHTMLElement_Release(elem
);
9321 elem
= get_elem_by_id(doc
, "oform", TRUE
);
9323 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9324 IHTMLElement_Release(elem
);
9327 elem
= get_elem_by_id(doc
, "btnid", TRUE
);
9329 form
= get_button_form(elem
);
9330 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9331 IHTMLFormElement_Release(form
);
9333 IHTMLElement_Release(elem
);
9334 IHTMLElement_Release(elem2
);
9337 test_selectors(doc
, div
);
9338 test_elemsbyclass(div
);
9340 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"elemid\">test</div>");
9341 elem
= get_elem_by_id(doc
, "elemid", TRUE
);
9343 test_elem_outertext(elem
, "test");
9344 test_elem_set_outertext(elem
, "outer text");
9345 test_elem_outertext(elem
, NULL
);
9346 test_elem_all((IUnknown
*)div
, NULL
, 0);
9347 elem2
= test_elem_get_parent((IUnknown
*)elem
);
9348 ok(!elem2
, "parent != NULL\n");
9349 IHTMLElement_Release(elem
);
9352 test_elem_set_innerhtml((IUnknown
*)div
, "<map><area id=\"areaid\"></area></map>");
9353 elem
= get_elem_by_id(doc
, "areaid", TRUE
);
9355 test_elem_type((IUnknown
*)elem
, ET_AREA
);
9356 IHTMLElement_Release(elem
);
9359 test_td_elem(doc
, div
);
9360 test_attr(doc
, div
);
9361 test_blocked(doc
, div
);
9362 test_elem_names(doc
);
9364 IHTMLElement_Release(div
);
9367 static void test_create_elems(IHTMLDocument2
*doc
)
9369 IHTMLElement
*elem
, *body
, *elem2
;
9370 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
9371 IHTMLDocument5
*doc5
;
9378 static const elem_type_t types1
[] = { ET_TESTG
};
9380 elem
= test_create_elem(doc
, "TEST");
9381 test_elem_tag((IUnknown
*)elem
, "TEST");
9382 type
= get_node_type((IUnknown
*)elem
);
9383 ok(type
== 1, "type=%d\n", type
);
9384 test_ifaces((IUnknown
*)elem
, elem_iids
);
9385 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
, "[object]");
9386 test_elem_source_index(elem
, -1);
9388 body
= doc_get_body(doc
);
9389 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9391 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
9392 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
9393 elem2
= get_elem_iface((IUnknown
*)node
);
9394 IHTMLElement_Release(elem2
);
9396 hres
= IHTMLElement_get_all(body
, &disp
);
9397 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9398 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
9399 IDispatch_Release(disp
);
9401 test_node_remove_child((IUnknown
*)body
, node
);
9403 hres
= IHTMLElement_get_all(body
, &disp
);
9404 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9405 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
9406 IDispatch_Release(disp
);
9407 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9409 IHTMLElement_Release(elem
);
9410 IHTMLDOMNode_Release(node
);
9412 node
= test_create_text(doc
, "abc");
9413 test_ifaces((IUnknown
*)node
, text_iids
);
9414 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
9415 test_text_length((IUnknown
*)node
, 3);
9416 test_text_data((IUnknown
*)node
, "abc");
9417 set_text_data((IUnknown
*)node
, "test");
9418 test_text_data((IUnknown
*)node
, "test");
9419 text_append_data((IUnknown
*)node
, " append");
9420 test_text_data((IUnknown
*)node
, "test append");
9421 text_append_data((IUnknown
*)node
, NULL
);
9422 test_text_data((IUnknown
*)node
, "test append");
9423 set_text_data((IUnknown
*)node
, "test");
9425 V_VT(&var
) = VT_NULL
;
9426 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9427 IHTMLDOMNode_Release(node
);
9429 node
= test_create_text(doc
, "insert ");
9431 V_VT(&var
) = VT_DISPATCH
;
9432 V_DISPATCH(&var
) = (IDispatch
*)node2
;
9433 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9434 IHTMLDOMNode_Release(node
);
9435 IHTMLDOMNode_Release(node2
);
9436 IHTMLDOMNode_Release(node3
);
9438 test_elem_innertext(body
, "insert test");
9439 test_elem_innerhtml((IUnknown
*)body
, "insert test");
9441 node
= test_create_text(doc
, " Test");
9442 V_VT(&var
) = VT_DISPATCH
;
9443 V_DISPATCH(&var
) = NULL
;
9444 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9445 test_elem_innertext(body
, "insert test Test");
9446 IHTMLDOMNode_Release(node
);
9448 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
9450 str
= a2bstr("testing");
9451 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
9453 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
9456 type
= get_node_type((IUnknown
*)comment
);
9457 ok(type
== 8, "type=%d, expected 8\n", type
);
9459 test_node_get_value_str((IUnknown
*)comment
, "testing");
9460 test_elem_title((IUnknown
*)comment
, NULL
);
9461 test_elem_set_title((IUnknown
*)comment
, "comment title");
9462 test_elem_title((IUnknown
*)comment
, "comment title");
9463 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
9464 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
9465 test_comment_attrs((IUnknown
*)comment
);
9467 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
9468 test_comment_text((IUnknown
*)node2
, "<!--testing-->");
9469 IHTMLDOMNode_Release(node2
);
9471 test_elem_getelembytag((IUnknown
*)comment
, ET_COMMENT
, 0, NULL
);
9473 IHTMLDOMNode_Release(comment
);
9476 IHTMLDocument5_Release(doc5
);
9479 IHTMLElement_Release(body
);
9482 static void test_replacechild_elems(IHTMLDocument2
*doc
)
9485 IHTMLDOMNode
*node
, *node2
, *node3
;
9486 IHTMLDOMNode
*nodeBody
, *nodeNew
;
9490 body
= doc_get_body(doc
);
9492 node
= test_create_text(doc
, "insert");
9494 V_VT(&var
) = VT_NULL
;
9495 V_DISPATCH(&var
) = NULL
;
9496 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9497 IHTMLDOMNode_Release(node
);
9499 test_elem_innertext(body
, "insert");
9501 node3
= test_create_text(doc
, "replaced");
9503 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
9505 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
9506 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
9508 test_elem_innertext(body
, "replaced");
9510 IHTMLDOMNode_Release(node2
);
9511 IHTMLDOMNode_Release(node3
);
9512 IHTMLDOMNode_Release(nodeBody
);
9514 IHTMLElement_Release(body
);
9517 static void test_noscript(IHTMLDocument2
*doc
)
9519 IHTMLElementCollection
*col
;
9523 static const elem_type_t all_types
[] = {
9532 static const elem_type_t body_all_types
[] = {
9537 hres
= IHTMLDocument2_get_all(doc
, &col
);
9538 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9539 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9540 IHTMLElementCollection_Release(col
);
9542 body
= doc_get_body(doc
);
9543 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
9544 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
9545 IHTMLElement_Release(body
);
9548 static void test_doctype(IHTMLDocument2
*doc
)
9550 IHTMLDocument2
*doc_node
;
9551 IHTMLDOMNode
*doctype
;
9554 doc_node
= get_doc_node(doc
);
9555 doctype
= get_first_child((IUnknown
*)doc_node
);
9556 IHTMLDocument2_Release(doc_node
);
9558 type
= get_node_type((IUnknown
*)doctype
);
9559 ok(type
== 8, "type = %d\n", type
);
9561 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9562 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9563 IHTMLDOMNode_Release(doctype
);
9566 static void test_null_write(IHTMLDocument2
*doc
)
9570 doc_write(doc
, FALSE
, NULL
);
9571 doc_write(doc
, TRUE
, NULL
);
9573 hres
= IHTMLDocument2_write(doc
, NULL
);
9575 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9577 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9579 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9582 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9584 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9585 IHTMLStyleElement
*style_elem
;
9586 IHTMLElement
*doc_elem
, *elem
;
9589 static const elem_type_t all_types
[] = {
9597 static const elem_type_t all_types2
[] = {
9606 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
9608 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9609 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9611 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
9613 doc_elem
= get_doc_elem(doc
);
9615 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9616 IHTMLElement_Release(doc_elem
);
9618 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9619 IHTMLElement_Release(elem
);
9620 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9623 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9624 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9625 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9626 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9628 IHTMLStyleSheet_Release(stylesheet2
);
9629 IHTMLStyleSheet_Release(stylesheet
);
9631 IHTMLStyleElement_Release(style_elem
);
9634 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9636 IOleCommandTarget
*cmdtrg
;
9639 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9640 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9642 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9643 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9645 IOleCommandTarget_Release(cmdtrg
);
9648 static void test_indent(IHTMLDocument2
*doc
)
9650 IHTMLElementCollection
*col
;
9651 IHTMLTxtRange
*range
;
9654 static const elem_type_t all_types
[] = {
9663 static const elem_type_t indent_types
[] = {
9674 hres
= IHTMLDocument2_get_all(doc
, &col
);
9675 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9676 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9677 IHTMLElementCollection_Release(col
);
9679 range
= test_create_body_range(doc
);
9680 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9681 IHTMLTxtRange_Release(range
);
9683 hres
= IHTMLDocument2_get_all(doc
, &col
);
9684 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9685 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9686 IHTMLElementCollection_Release(col
);
9689 static void test_cond_comment(IHTMLDocument2
*doc
)
9691 IHTMLElementCollection
*col
;
9694 static const elem_type_t all_types
[] = {
9702 hres
= IHTMLDocument2_get_all(doc
, &col
);
9703 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9704 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9705 IHTMLElementCollection_Release(col
);
9708 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9710 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9711 return E_NOINTERFACE
;
9714 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9719 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9724 static const IUnknownVtbl UnknownVtbl
= {
9725 Unknown_QueryInterface
,
9729 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9731 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9733 IHTMLWindow2
*frame2
, *parent
, *top
;
9734 IHTMLDocument2
*parent_doc
, *top_doc
;
9735 IHTMLWindow4
*frame
;
9736 IHTMLFrameBase
*frame_elem
;
9737 IObjectIdentity
*obj_ident
;
9738 ITravelLogClient
*tlc
;
9741 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9742 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9746 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9747 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9748 IHTMLWindow4_Release(frame
);
9752 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9753 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9754 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9755 IHTMLFrameBase_Release(frame_elem
);
9757 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9758 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9762 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9763 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9765 IHTMLWindow2_Release(frame2
);
9769 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9770 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9771 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9772 if(hres
== E_NOINTERFACE
) {
9773 win_skip("IID_ITravelLogClient not available\n");
9776 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9778 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9779 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9780 ITravelLogClient_Release(tlc
);
9783 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9784 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9785 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9786 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9787 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9788 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9790 IObjectIdentity_Release(obj_ident
);
9792 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9793 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9794 IHTMLWindow2_Release(parent
);
9796 IHTMLWindow2_Release(frame2
);
9800 test_doc_title(parent_doc
, "frameset test");
9801 IHTMLDocument2_Release(parent_doc
);
9804 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9805 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9806 IHTMLWindow2_Release(frame2
);
9810 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9811 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9812 IHTMLWindow2_Release(top
);
9816 test_doc_title(top_doc
, "frameset test");
9817 IHTMLDocument2_Release(top_doc
);
9820 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9822 VARIANT index_var
, result_var
;
9826 /* test result length */
9827 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9828 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9829 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9831 /* test first frame */
9832 V_VT(&index_var
) = VT_I4
;
9833 V_I4(&index_var
) = 0;
9834 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9835 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9836 if(SUCCEEDED(hres
)) {
9837 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9838 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9840 VariantClear(&result_var
);
9842 /* test second frame */
9843 V_I4(&index_var
) = 1;
9844 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9845 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9846 if(SUCCEEDED(hres
)) {
9847 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9848 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9850 VariantClear(&result_var
);
9852 /* fail on next frame */
9853 V_I4(&index_var
) = 3;
9854 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9855 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9856 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9857 VariantClear(&result_var
);
9859 /* string argument (element id lookup) */
9860 V_VT(&index_var
) = VT_BSTR
;
9861 V_BSTR(&index_var
) = a2bstr(frid
);
9862 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9863 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9864 if(SUCCEEDED(hres
)) {
9865 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9866 test_frame(V_DISPATCH(&result_var
), frid
);
9868 VariantClear(&result_var
);
9869 VariantClear(&index_var
);
9871 /* invalid argument */
9872 V_VT(&index_var
) = VT_BOOL
;
9873 V_BOOL(&index_var
) = VARIANT_TRUE
;
9874 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9875 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9876 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9877 VariantClear(&result_var
);
9880 static void test_frameset(IHTMLDocument2
*doc
)
9882 IHTMLWindow2
*window
;
9883 IHTMLFramesCollection2
*frames
;
9884 IHTMLDocument6
*doc6
;
9888 window
= get_doc_window(doc
);
9890 /* test using IHTMLFramesCollection object */
9892 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9893 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9897 test_frames_collection(frames
, "fr1");
9898 IHTMLFramesCollection2_Release(frames
);
9900 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9901 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9905 test_frames_collection(frames
, "fr1");
9906 IHTMLFramesCollection2_Release(frames
);
9908 /* test using IHTMLWindow2 inheritance */
9909 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9911 /* getElementById with node name attributes */
9912 elem
= get_doc_elem_by_id(doc
, "nm1");
9913 test_elem_id((IUnknown
*)elem
, "fr1");
9915 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
9916 if(SUCCEEDED(hres
)) {
9917 IHTMLElement2
*elem2
;
9920 str
= a2bstr("nm1");
9921 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9922 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9923 ok(!elem2
, "elem = %p\n", elem2
);
9926 str
= a2bstr("fr1");
9927 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9928 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9929 ok(elem2
!= NULL
, "elem2 is NULL\n");
9930 test_elem_id((IUnknown
*)elem2
, "fr1");
9933 IHTMLDocument6_Release(doc6
);
9935 win_skip("IHTMLDocument6 not supported\n");
9938 test_framebase((IUnknown
*)elem
);
9939 test_framebase_name(elem
, "nm1");
9940 test_framebase_put_name(elem
, "frame name");
9941 test_framebase_put_name(elem
, NULL
);
9942 test_framebase_put_name(elem
, "nm1");
9943 test_framebase_src(elem
, "about:blank");
9944 IHTMLElement_Release(elem
);
9946 /* get_name with no name attr */
9947 elem
= get_doc_elem_by_id(doc
, "fr3");
9948 test_framebase_name(elem
, NULL
);
9949 test_framebase_put_name(elem
, "frame name");
9950 test_framebase_put_name(elem
, NULL
);
9951 IHTMLElement_Release(elem
);
9953 IHTMLWindow2_Release(window
);
9956 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9958 IHTMLDocument2
*frag
;
9959 IHTMLDocument3
*doc3
;
9962 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9963 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9965 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9966 IHTMLDocument3_Release(doc3
);
9967 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9968 ok(frag
!= NULL
, "frag == NULL\n");
9973 static void test_docfrag(IHTMLDocument2
*doc
)
9975 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9976 IHTMLElement
*div
, *body
, *br
;
9977 IHTMLElementCollection
*col
;
9978 IHTMLLocation
*location
;
9981 static const elem_type_t all_types
[] = {
9990 frag
= create_docfrag(doc
);
9992 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
9994 body
= (void*)0xdeadbeef;
9995 hres
= IHTMLDocument2_get_body(frag
, &body
);
9996 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
9997 ok(!body
, "body != NULL\n");
9999 location
= (void*)0xdeadbeef;
10000 hres
= IHTMLDocument2_get_location(frag
, &location
);
10001 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
10002 ok(location
== (void*)0xdeadbeef, "location changed\n");
10004 br
= test_create_elem(doc
, "BR");
10005 test_elem_source_index(br
, -1);
10006 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
10007 test_elem_source_index(br
, 0);
10008 IHTMLElement_Release(br
);
10010 test_doc_getelembytag(frag
, "a", ET_A
, 0);
10011 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
10013 div
= get_elem_by_id(doc
, "divid", TRUE
);
10014 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
10015 IHTMLElement_Release(div
);
10017 hres
= IHTMLDocument2_get_all(doc
, &col
);
10018 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
10019 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
10020 IHTMLElementCollection_Release(col
);
10022 div
= test_create_elem(frag
, "div");
10023 owner_doc
= get_owner_doc((IUnknown
*)div
);
10024 doc_node
= get_doc_node(doc
);
10025 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
10026 IHTMLDocument2_Release(doc_node
);
10027 IHTMLDocument2_Release(owner_doc
);
10028 IHTMLElement_Release(div
);
10030 IHTMLDocument2_Release(frag
);
10033 static void check_quirks_mode(IHTMLDocument2
*doc
)
10035 test_compatmode(doc
, "BackCompat");
10038 static void check_strict_mode(IHTMLDocument2
*doc
)
10040 test_compatmode(doc
, "CSS1Compat");
10043 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
10045 IHTMLElement
*elem
;
10049 hres
= IHTMLDocument2_get_body(doc
, &elem
);
10050 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
10052 /* body.offsetHeight value depends on window size in quirks mode */
10053 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
10054 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
10055 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
10056 IHTMLElement_Release(elem
);
10059 static IHTMLDocument2
*notif_doc
;
10060 static BOOL doc_complete
;
10062 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
10063 REFIID riid
, void**ppv
)
10065 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
10070 ok(0, "unexpected call\n");
10071 return E_NOINTERFACE
;
10074 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
10079 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
10084 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
10086 if(dispID
== DISPID_READYSTATE
){
10090 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
10091 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
10093 if(!strcmp_wa(state
, "complete"))
10094 doc_complete
= TRUE
;
10096 SysFreeString(state
);
10102 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
10104 ok(0, "unexpected call\n");
10108 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
10109 PropertyNotifySink_QueryInterface
,
10110 PropertyNotifySink_AddRef
,
10111 PropertyNotifySink_Release
,
10112 PropertyNotifySink_OnChanged
,
10113 PropertyNotifySink_OnRequestEdit
10116 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
10118 static HRESULT
cs_qi(REFIID
,void **);
10119 static IOleDocumentView
*view
;
10120 static HWND container_hwnd
;
10122 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
10124 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
10126 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
10127 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
10130 return E_NOINTERFACE
;
10133 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
10138 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
10143 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
10148 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
10153 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
10158 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
10159 LPCBORDERWIDTHS pborderwidths
)
10164 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
10165 LPCBORDERWIDTHS pborderwidths
)
10170 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
10171 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
10176 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10177 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
10182 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10183 HOLEMENU holemenu
, HWND hwndActiveObject
)
10185 ok(0, "unexpected call\n");
10189 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
10191 ok(0, "unexpected call\n");
10195 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
10200 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
10205 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
10207 ok(0, "unexpected call\n");
10211 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
10212 InPlaceFrame_QueryInterface
,
10213 InPlaceFrame_AddRef
,
10214 InPlaceFrame_Release
,
10215 InPlaceFrame_GetWindow
,
10216 InPlaceFrame_ContextSensitiveHelp
,
10217 InPlaceFrame_GetBorder
,
10218 InPlaceFrame_RequestBorderSpace
,
10219 InPlaceFrame_SetBorderSpace
,
10220 InPlaceFrame_SetActiveObject
,
10221 InPlaceFrame_InsertMenus
,
10222 InPlaceFrame_SetMenu
,
10223 InPlaceFrame_RemoveMenus
,
10224 InPlaceFrame_SetStatusText
,
10225 InPlaceFrame_EnableModeless
,
10226 InPlaceFrame_TranslateAccelerator
10229 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
10231 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
10233 return cs_qi(riid
, ppv
);
10236 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
10241 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
10246 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
10248 *phwnd
= container_hwnd
;
10252 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
10254 ok(0, "unexpected call\n");
10258 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
10263 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
10268 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
10273 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
10274 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
10275 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
10277 static const RECT rect
= {0,0,500,500};
10279 *ppFrame
= &InPlaceFrame
;
10281 *lprcPosRect
= rect
;
10282 *lprcClipRect
= rect
;
10284 lpFrameInfo
->fMDIApp
= FALSE
;
10285 lpFrameInfo
->hwndFrame
= container_hwnd
;
10286 lpFrameInfo
->haccel
= NULL
;
10287 lpFrameInfo
->cAccelEntries
= 0;
10292 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
10297 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
10302 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
10307 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
10312 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
10317 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
10322 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
10323 InPlaceSite_QueryInterface
,
10324 InPlaceSite_AddRef
,
10325 InPlaceSite_Release
,
10326 InPlaceSite_GetWindow
,
10327 InPlaceSite_ContextSensitiveHelp
,
10328 InPlaceSite_CanInPlaceActivate
,
10329 InPlaceSite_OnInPlaceActivate
,
10330 InPlaceSite_OnUIActivate
,
10331 InPlaceSite_GetWindowContext
,
10332 InPlaceSite_Scroll
,
10333 InPlaceSite_OnUIDeactivate
,
10334 InPlaceSite_OnInPlaceDeactivate
,
10335 InPlaceSite_DiscardUndoState
,
10336 InPlaceSite_DeactivateAndUndo
,
10337 InPlaceSite_OnPosRectChange
,
10340 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
10342 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
10344 return cs_qi(riid
, ppv
);
10347 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
10352 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
10357 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
10359 ok(0, "unexpected call\n");
10363 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
10366 ok(0, "unexpected call\n");
10370 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
10375 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
10377 ok(0, "unexpected call\n");
10381 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
10383 ok(0, "unexpected call\n");
10387 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
10389 ok(0, "unexpected call\n");
10393 static const IOleClientSiteVtbl ClientSiteVtbl
= {
10394 ClientSite_QueryInterface
,
10396 ClientSite_Release
,
10397 ClientSite_SaveObject
,
10398 ClientSite_GetMoniker
,
10399 ClientSite_GetContainer
,
10400 ClientSite_ShowObject
,
10401 ClientSite_OnShowWindow
,
10402 ClientSite_RequestNewObjectLayout
10405 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
10407 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
10409 return cs_qi(riid
, ppv
);
10412 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
10417 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
10422 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
10424 RECT rect
= {0,0,500,500};
10425 IOleDocument
*document
;
10428 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
10429 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
10431 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
10432 IOleDocument_Release(document
);
10433 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
10435 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
10436 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
10438 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
10439 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
10441 hres
= IOleDocumentView_SetRect(view
, &rect
);
10442 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
10444 hres
= IOleDocumentView_Show(view
, TRUE
);
10445 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
10450 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
10451 DocumentSite_QueryInterface
,
10452 DocumentSite_AddRef
,
10453 DocumentSite_Release
,
10454 DocumentSite_ActivateMe
10457 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
10459 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
10463 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
10464 *ppv
= &ClientSite
;
10465 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
10466 *ppv
= &DocumentSite
;
10467 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
10468 *ppv
= &InPlaceSite
;
10470 return *ppv
? S_OK
: E_NOINTERFACE
;
10473 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
10475 IOleObject
*oleobj
;
10479 IOleDocumentView_Show(view
, FALSE
);
10480 IOleDocumentView_CloseView(view
, 0);
10481 IOleDocumentView_SetInPlaceSite(view
, NULL
);
10482 IOleDocumentView_Release(view
);
10486 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
10487 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
10489 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
10490 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
10493 IHlinkTarget
*hlink
;
10495 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
10496 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
10498 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
10499 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
10501 IHlinkTarget_Release(hlink
);
10504 IOleObject_Release(oleobj
);
10507 static IHTMLDocument2
*create_doc_with_string(const char *str
)
10509 IPersistStreamInit
*init
;
10511 IHTMLDocument2
*doc
;
10515 notif_doc
= doc
= create_document();
10519 doc_complete
= FALSE
;
10521 mem
= GlobalAlloc(0, len
);
10522 memcpy(mem
, str
, len
);
10523 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
10525 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
10527 IPersistStreamInit_Load(init
, stream
);
10528 IPersistStreamInit_Release(init
);
10529 IStream_Release(stream
);
10534 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
10536 IConnectionPointContainer
*container
;
10537 IConnectionPoint
*cp
;
10541 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
10542 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
10544 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
10545 IConnectionPointContainer_Release(container
);
10546 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
10548 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
10549 IConnectionPoint_Release(cp
);
10550 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
10553 typedef void (*domtest_t
)(IHTMLDocument2
*);
10555 static void run_domtest(const char *str
, domtest_t test
)
10557 IHTMLDocument2
*doc
;
10561 doc
= create_doc_with_string(str
);
10565 set_client_site(doc
, TRUE
);
10566 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
10568 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
10569 TranslateMessage(&msg
);
10570 DispatchMessageW(&msg
);
10575 set_client_site(doc
, FALSE
);
10576 ref
= IHTMLDocument2_Release(doc
);
10577 ok(!ref
|| broken(ref
== 1), /* Vista */
10578 "ref = %d\n", ref
);
10581 static float expected_document_mode
;
10583 static void test_document_mode(IHTMLDocument2
*doc2
)
10585 IEventTarget
*event_target
;
10586 IHTMLDocument2
*doc_node
;
10587 IHTMLDocument6
*doc
;
10588 IHTMLElement
*body
;
10592 if(expected_document_mode
>= 9) {
10593 IHTMLDocument7
*doc7
;
10594 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument7
, (void**)&doc7
);
10596 win_skip("IHTMLDocument7 interface not supported: %08x\n", hres
);
10599 IHTMLDocument7_Release(doc7
);
10602 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument6
, (void**)&doc
);
10603 ok(hres
== S_OK
, "Could not get IHTMLDocument6 interface: %08x\n", hres
);
10605 V_VT(&v
) = VT_EMPTY
;
10606 hres
= IHTMLDocument6_get_documentMode(doc
, &v
);
10607 ok(hres
== S_OK
, "get_documentMode failed: %08x\n", hres
);
10608 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
10609 ok(V_R4(&v
) == expected_document_mode
, "documentMode = %f\n", V_R4(&v
));
10610 IHTMLDocument6_Release(doc
);
10612 doc_node
= get_doc_node(doc2
);
10614 hres
= IHTMLDocument2_QueryInterface(doc_node
, &IID_IEventTarget
, (void**)&event_target
);
10615 if(expected_document_mode
>= 9) {
10616 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10617 IEventTarget_Release(event_target
);
10619 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10622 IHTMLDocument2_Release(doc_node
);
10625 body
= doc_get_body(doc2
);
10627 hres
= IHTMLElement_QueryInterface(body
, &IID_IEventTarget
, (void**)&event_target
);
10628 if(expected_document_mode
>= 9) {
10629 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08x\n", hres
);
10630 IEventTarget_Release(event_target
);
10632 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08x\n", hres
);
10635 IHTMLElement_Release(body
);
10638 static void test_quirks_mode(void)
10640 run_domtest("<html></html>", check_quirks_mode
);
10641 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10642 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10643 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10645 expected_document_mode
= 5;
10646 run_domtest("<html><body></body></html>", test_document_mode
);
10648 expected_document_mode
= 9;
10649 run_domtest("<!DOCTYPE html>\n"
10652 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10656 "</html>", test_document_mode
);
10658 expected_document_mode
= 8;
10659 run_domtest("<!DOCTYPE html>\n"
10662 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
10663 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10667 "</html>", test_document_mode
);
10672 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10673 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10674 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10676 CoInitialize(NULL
);
10677 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10678 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10680 run_domtest(doc_str1
, test_doc_elem
);
10681 run_domtest(doc_str1
, test_get_set_attr
);
10682 run_domtest(range_test_str
, test_txtrange
);
10683 run_domtest(range_test2_str
, test_txtrange2
);
10684 if (winetest_interactive
|| ! is_ie_hardened()) {
10685 run_domtest(elem_test_str
, test_elems
);
10686 run_domtest(elem_test2_str
, test_elems2
);
10687 run_domtest(noscript_str
, test_noscript
);
10689 skip("IE running in Enhanced Security Configuration\n");
10691 run_domtest(doc_blank
, test_create_elems
);
10692 run_domtest(doc_blank
, test_defaults
);
10693 run_domtest(doc_blank
, test_null_write
);
10694 run_domtest(emptydiv_str
, test_create_stylesheet
);
10695 run_domtest(indent_test_str
, test_indent
);
10696 run_domtest(cond_comment_str
, test_cond_comment
);
10697 run_domtest(frameset_str
, test_frameset
);
10698 run_domtest(emptydiv_str
, test_docfrag
);
10699 run_domtest(doc_blank
, test_replacechild_elems
);
10700 run_domtest(doctype_str
, test_doctype
);
10702 test_quirks_mode();
10704 DestroyWindow(container_hwnd
);