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
);
1097 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1098 IHTMLDOMNode_Release(node
);
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
);
1102 SysFreeString(name
);
1105 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1106 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1108 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1109 IDispatch
*disp
= (void*)0xdeadbeef;
1110 IHTMLDocument2
*doc
= NULL
;
1113 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1114 IHTMLDOMNode2_Release(node
);
1115 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1118 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1119 IDispatch_Release(disp
);
1120 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1126 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1127 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1129 IHTMLWindow2
*window
;
1133 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1134 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1135 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1140 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1141 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1143 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1144 IHTMLDOMNode
*ret
= NULL
;
1147 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1148 IHTMLDOMNode_Release(node
);
1149 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1150 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1156 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1157 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1159 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1163 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1164 IHTMLElement_Release(elem
);
1165 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1166 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1171 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1172 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1174 const char *expected_value
= "[object]";
1176 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1177 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1179 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
) {
1181 expected_value
= NULL
;
1182 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, elem_type_infos
[type
].clsid
, expected_value
);
1186 #define get_node_type(n) _get_node_type(__LINE__,n)
1187 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1189 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1193 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1194 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1196 IHTMLDOMNode_Release(node
);
1201 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1202 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1204 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1205 IHTMLDOMChildrenCollection
*col
= NULL
;
1209 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1210 IHTMLDOMNode_Release(node
);
1211 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1215 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1216 IDispatch_Release(disp
);
1217 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1222 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1223 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1225 IHTMLDOMNode
*node
= NULL
;
1229 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1230 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1232 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1233 IDispatch_Release(disp
);
1238 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1239 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1245 VariantInit(&value
);
1248 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1250 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1253 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1254 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1256 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1259 VariantClear(&value
);
1262 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1263 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1265 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1266 IHTMLElement
*off_parent
;
1270 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1271 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1273 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1274 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1276 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1277 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1279 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1280 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1282 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1283 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1285 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1286 IHTMLElement_Release(off_parent
);
1288 IHTMLElement_Release(elem
);
1291 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1292 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1294 LONG l
= 0xdeadbeef;
1297 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1298 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1299 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1302 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1303 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1305 IHTMLWindow2
*window
;
1306 IHTMLDocument2
*ret
;
1309 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1310 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1312 hres
= IHTMLWindow2_get_document(window
, &ret
);
1313 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1314 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1319 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1320 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1325 hres
= IHTMLWindow2_get_name(window
, &name
);
1326 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1328 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1330 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1331 SysFreeString(name
);
1334 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1335 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1341 hres
= IHTMLWindow2_put_name(window
, str
);
1343 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1345 _test_window_name(line
, window
, name
);
1348 #define test_window_status(d) _test_window_status(__LINE__,d)
1349 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1354 status
= (void*)0xdeadbeef;
1355 hres
= IHTMLWindow2_get_status(window
, &status
);
1356 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1357 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1358 SysFreeString(status
);
1361 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1362 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1367 str
= a2bstr(status
);
1368 hres
= IHTMLWindow2_put_status(window
, str
);
1370 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1373 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1374 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1379 hres
= IHTMLWindow2_get_length(window
, &length
);
1380 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1381 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1384 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1385 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1387 IHTMLFrameBase2
*base2
;
1388 IHTMLWindow2
*window
;
1391 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1392 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1395 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1396 IHTMLFrameBase2_Release(base2
);
1397 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1398 ok(window
!= NULL
, "contentWindow = NULL\n");
1403 static void test_get_set_attr(IHTMLDocument2
*doc
)
1406 IHTMLDocument3
*doc3
;
1411 /* grab an element to test with */
1412 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1413 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1415 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1416 IHTMLDocument3_Release(doc3
);
1417 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1419 /* get a non-present attribute */
1420 bstr
= a2bstr("notAnAttribute");
1421 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1422 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1423 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1425 SysFreeString(bstr
);
1427 /* get a present attribute */
1428 bstr
= a2bstr("scrollHeight");
1429 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1430 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1431 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1433 SysFreeString(bstr
);
1435 /* create a new BSTR attribute */
1436 bstr
= a2bstr("newAttribute");
1438 V_VT(&val
) = VT_BSTR
;
1439 V_BSTR(&val
) = a2bstr("the value");
1440 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1441 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1444 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1445 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1446 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1447 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
)));
1450 /* overwrite the attribute with a BOOL */
1451 V_VT(&val
) = VT_BOOL
;
1452 V_BOOL(&val
) = VARIANT_TRUE
;
1453 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1454 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1457 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1458 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1459 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1460 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1463 SysFreeString(bstr
);
1465 /* case-insensitive */
1466 bstr
= a2bstr("newattribute");
1467 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1468 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1469 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1470 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1473 /* overwrite the attribute with null */
1474 V_VT(&val
) = VT_NULL
;
1475 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1476 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1478 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1479 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1480 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1481 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1484 SysFreeString(bstr
);
1485 IHTMLElement_Release(elem
);
1488 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1489 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1492 IHTMLDocument3
*doc3
;
1495 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1496 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1497 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1498 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1499 IHTMLDocument3_Release(doc3
);
1504 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1505 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1507 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1511 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1512 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1513 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1516 _test_disp_value(line
, unk
, exhref
);
1519 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1520 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1522 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1526 str
= a2bstr(exhref
);
1527 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1528 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1531 _test_disp_value(line
, unk
, exhref
);
1534 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1535 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1537 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1541 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1542 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1544 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1546 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1550 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1551 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1553 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1557 str
= a2bstr(exrel
);
1558 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1559 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1563 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1564 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1566 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1570 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1571 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1573 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1575 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1579 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1580 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1582 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1586 str
= target
? a2bstr(target
) : NULL
;
1587 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1588 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1592 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1593 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1595 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1599 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1600 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1602 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1604 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1608 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1609 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1611 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1615 str
= name
? a2bstr(name
) : NULL
;
1616 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1617 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1620 _test_anchor_name(line
, unk
, name
);
1623 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1624 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1626 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1630 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1631 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1633 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1635 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1639 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1640 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1642 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1646 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1647 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1648 if ( ! str
&& allowbroken
)
1649 win_skip("skip ie6 incorrect behavior\n");
1651 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1653 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1657 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1658 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1660 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1664 str
= search
? a2bstr(search
) : NULL
;
1665 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1666 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1670 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1671 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1673 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1677 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1678 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1680 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1682 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1686 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1687 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1692 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1693 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1694 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1695 SysFreeString(bstr
);
1698 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1699 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1704 bstr
= a2bstr(text
);
1705 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1706 SysFreeString(bstr
);
1707 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1709 _test_option_text(line
, option
, text
);
1712 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1713 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1718 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1719 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1720 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1721 SysFreeString(bstr
);
1724 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1725 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1730 bstr
= a2bstr(value
);
1731 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1732 SysFreeString(bstr
);
1733 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1735 _test_option_value(line
, option
, value
);
1738 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1739 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1741 VARIANT_BOOL b
= 0x100;
1744 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1745 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1746 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1749 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1750 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1754 hres
= IHTMLOptionElement_put_selected(option
, b
);
1755 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1756 _test_option_selected(line
, option
, b
);
1759 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1760 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1765 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1766 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1769 hres
= IHTMLOptionElement_get_index(option
, &val
);
1770 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1771 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1772 "value = %d, expected = %d\n", val
, exval
);
1775 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1776 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1780 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1781 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1784 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1785 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1790 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1791 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1794 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1795 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1796 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1799 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1801 test_option_defaultSelected(option
, VARIANT_FALSE
);
1802 test_option_selected(option
, VARIANT_FALSE
);
1804 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1805 test_option_defaultSelected(option
, VARIANT_FALSE
);
1806 test_option_selected(option
, VARIANT_FALSE
);
1808 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1809 test_option_defaultSelected(option
, VARIANT_TRUE
);
1810 test_option_selected(option
, VARIANT_FALSE
);
1812 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1813 test_option_defaultSelected(option
, VARIANT_FALSE
);
1814 test_option_selected(option
, VARIANT_FALSE
);
1816 test_option_put_selected(option
, VARIANT_TRUE
);
1817 test_option_selected(option
, VARIANT_TRUE
);
1818 test_option_defaultSelected(option
, VARIANT_FALSE
);
1820 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1821 test_option_defaultSelected(option
, VARIANT_TRUE
);
1822 test_option_selected(option
, VARIANT_TRUE
);
1824 /* Restore defaultSelected */
1825 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1826 test_option_put_selected(option
, VARIANT_FALSE
);
1829 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1830 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1832 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1833 BSTR value
= (void*)0xdeadbeef;
1836 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1837 IHTMLTextAreaElement_Release(textarea
);
1838 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1840 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1842 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1843 SysFreeString(value
);
1846 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1847 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1849 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1850 BSTR tmp
= a2bstr(value
);
1853 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1854 IHTMLTextAreaElement_Release(textarea
);
1855 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1858 _test_textarea_value(line
, unk
, value
);
1861 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1862 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1864 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1865 BSTR value
= (void*)0xdeadbeef;
1868 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1869 IHTMLTextAreaElement_Release(textarea
);
1870 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1872 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1874 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1875 SysFreeString(value
);
1878 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1879 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1881 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1882 BSTR tmp
= a2bstr(value
);
1885 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1886 IHTMLTextAreaElement_Release(textarea
);
1887 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1890 _test_textarea_defaultvalue(line
, unk
, value
);
1893 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1894 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1896 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1897 VARIANT_BOOL b
= 0x100;
1900 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1901 IHTMLTextAreaElement_Release(textarea
);
1902 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1903 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1906 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1907 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1909 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1912 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1913 IHTMLTextAreaElement_Release(textarea
);
1914 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1916 _test_textarea_readonly(line
, unk
, b
);
1919 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1920 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1922 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1923 BSTR type
= (void*)0xdeadbeef;
1926 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1927 IHTMLTextAreaElement_Release(textarea
);
1928 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1929 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1930 SysFreeString(type
);
1933 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1934 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1936 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1937 IHTMLFormElement
*form
;
1940 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1941 IHTMLTextAreaElement_Release(textarea
);
1942 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1947 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1948 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1950 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1954 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1955 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1956 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1958 IHTMLCommentElement_Release(comment
);
1959 SysFreeString(text
);
1962 #define create_attr(a,b) _create_attr(__LINE__,a,b)
1963 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
1965 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
1966 BSTR str
= a2bstr("Test");
1967 IHTMLDOMAttribute
*attr
;
1970 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
1971 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
1973 IHTMLDocument5_Release(doc
);
1978 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
1979 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1981 VARIANT_BOOL specified
;
1984 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
1985 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
1986 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
1989 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
1990 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1992 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1993 VARIANT_BOOL expando
;
1996 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
1997 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
1998 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
2000 IHTMLDOMAttribute2_Release(attr2
);
2003 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
2004 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
2006 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2010 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
2011 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
2013 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
2015 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
2017 IHTMLDOMAttribute2_Release(attr2
);
2021 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
2022 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
2024 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2025 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
2026 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
2027 IHTMLDOMAttribute
*attr
;
2028 BSTR name
= a2bstr("test");
2032 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2033 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2034 ok(attr
== NULL
, "attr != NULL\n");
2038 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2039 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2041 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2042 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
2043 ok(attr
!= NULL
, "attr == NULL\n");
2045 test_attr_expando(attr
, VARIANT_TRUE
);
2047 IHTMLDOMAttribute_Release(attr
);
2048 IHTMLCommentElement_Release(comment
);
2049 IHTMLElement_Release(elem
);
2050 IHTMLElement4_Release(elem4
);
2051 SysFreeString(name
);
2054 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2055 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2057 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2062 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2063 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
2064 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
2065 IHTMLObjectElement_Release(object
);
2068 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2069 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
2071 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2075 str
= (void*)0xdeadbeef;
2076 hres
= IHTMLObjectElement_get_name(object
, &str
);
2077 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2079 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2081 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2083 IHTMLObjectElement_Release(object
);
2086 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2087 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2089 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2094 hres
= IHTMLObjectElement_put_name(object
, str
);
2095 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2097 IHTMLObjectElement_Release(object
);
2099 _test_object_name(line
, elem
, name
);
2102 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2103 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2104 const char *txt
, const char *val
)
2106 IHTMLOptionElementFactory
*factory
;
2107 IHTMLOptionElement
*option
;
2108 IHTMLWindow2
*window
;
2109 VARIANT text
, value
, empty
;
2112 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2113 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2115 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2116 IHTMLWindow2_Release(window
);
2117 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2119 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, NULL
, "[object]");
2121 V_VT(&text
) = VT_BSTR
;
2122 V_BSTR(&text
) = a2bstr(txt
);
2123 V_VT(&value
) = VT_BSTR
;
2124 V_BSTR(&value
) = a2bstr(val
);
2125 V_VT(&empty
) = VT_EMPTY
;
2127 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2128 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2130 IHTMLOptionElementFactory_Release(factory
);
2131 VariantClear(&text
);
2132 VariantClear(&value
);
2134 _test_option_text(line
, option
, txt
);
2135 _test_option_value(line
, option
, val
);
2136 _test_option_selected(line
, option
, VARIANT_FALSE
);
2141 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2142 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2147 hres
= IHTMLImgElement_get_width(img
, &found
);
2148 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2149 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2152 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2153 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2157 hres
= IHTMLImgElement_put_width(img
, width
);
2158 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2160 _test_img_width(line
, img
, width
);
2163 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2164 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2169 hres
= IHTMLImgElement_get_height(img
, &found
);
2170 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2171 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2174 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2175 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2179 hres
= IHTMLImgElement_put_height(img
, height
);
2180 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2182 _test_img_height(line
, img
, height
);
2185 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2186 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2187 LONG wdth
, LONG hght
)
2189 IHTMLImageElementFactory
*factory
;
2190 IHTMLImgElement
*img
;
2191 IHTMLWindow2
*window
;
2192 VARIANT width
, height
;
2196 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2197 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2199 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2200 IHTMLWindow2_Release(window
);
2201 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2203 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2204 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, NULL
, "[object]");
2207 snprintf(buf
, 16, "%d", wdth
);
2208 V_VT(&width
) = VT_BSTR
;
2209 V_BSTR(&width
) = a2bstr(buf
);
2211 V_VT(&width
) = VT_EMPTY
;
2216 snprintf(buf
, 16, "%d", hght
);
2217 V_VT(&height
) = VT_BSTR
;
2218 V_BSTR(&height
) = a2bstr(buf
);
2220 V_VT(&height
) = VT_EMPTY
;
2224 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2225 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2227 IHTMLImageElementFactory_Release(factory
);
2228 VariantClear(&width
);
2229 VariantClear(&height
);
2231 if(SUCCEEDED(hres
)) {
2232 _test_img_width(line
, img
, wdth
);
2233 _test_img_height(line
, img
, hght
);
2240 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2241 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2243 LONG len
= 0xdeadbeef;
2246 hres
= IHTMLSelectElement_get_length(select
, &len
);
2247 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2248 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2251 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2252 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2254 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2257 hres
= IHTMLSelectElement_put_length(select
, length
);
2258 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2259 _test_select_length(line
, select
, length
);
2260 IHTMLSelectElement_Release(select
);
2263 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2264 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2266 LONG idx
= 0xdeadbeef;
2269 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2270 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2271 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2274 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2275 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2279 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2280 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2281 _test_select_selidx(line
, select
, index
);
2284 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2285 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2290 hres
= IHTMLSelectElement_get_value(select
, &val
);
2291 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2293 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2295 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2299 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2300 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2306 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2307 SysFreeString(bstr
);
2308 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2311 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2312 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2317 hres
= IHTMLSelectElement_get_type(select
, &type
);
2318 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2319 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2320 SysFreeString(type
);
2323 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2324 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2326 VARIANT_BOOL b
= 100;
2329 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2330 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2331 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2334 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2335 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2339 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2340 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2342 _test_select_multiple(line
, select
, val
);
2345 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2346 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2351 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2352 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2355 hres
= IHTMLSelectElement_get_size(select
, &val
);
2356 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2357 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2360 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2361 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2365 hres
= IHTMLSelectElement_put_size(select
, val
);
2366 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2369 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2370 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2376 hres
= IHTMLSelectElement_get_name(select
, &text
);
2377 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2379 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2380 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2381 wine_dbgstr_w(text
), extext
);
2382 SysFreeString(text
);
2384 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2387 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2388 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2393 bstr
= a2bstr(text
);
2395 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2396 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2397 SysFreeString(bstr
);
2400 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2401 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2406 hres
= IHTMLTxtRange_get_text(range
, &text
);
2407 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2410 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2411 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2413 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2416 SysFreeString(text
);
2420 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2421 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2425 hres
= IHTMLTxtRange_collapse(range
, b
);
2426 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2427 _test_range_text(line
, range
, NULL
);
2430 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2431 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2432 VARIANT_BOOL exb
, const char *extext
)
2434 VARIANT_BOOL b
= 0xe0e0;
2437 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2438 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2439 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2440 _test_range_text(line
, range
, extext
);
2443 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2444 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2446 LONG c
= 0xdeadbeef;
2449 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2450 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2451 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2452 _test_range_text(line
, range
, NULL
);
2455 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2456 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2457 LPWSTR unit
, LONG cnt
, LONG excnt
)
2459 LONG c
= 0xdeadbeef;
2462 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2463 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2464 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2467 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2468 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2470 LONG c
= 0xdeadbeef;
2473 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2474 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2475 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2478 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2479 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2482 BSTR bstr
= a2bstr(text
);
2484 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2485 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2486 SysFreeString(bstr
);
2487 _test_range_text(line
, range
, NULL
);
2490 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2491 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2497 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2498 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2499 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2502 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2503 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2509 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2510 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2511 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2514 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2515 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2516 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2519 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2520 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2524 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2525 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2527 BSTR str
= a2bstr(html
);
2530 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2531 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2535 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2536 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2541 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2542 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2544 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2546 IHTMLElement_Release(elem
);
2549 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2550 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2552 VARIANT name
, index
;
2557 V_VT(&index
) = VT_EMPTY
;
2558 V_VT(&name
) = VT_I4
;
2560 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2561 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2562 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2564 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2565 IDispatch_Release(disp
);
2569 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2570 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2571 const elem_type_t
*elem_types
, LONG exlen
)
2573 IHTMLElementCollection
*col
;
2574 IEnumVARIANT
*enum_var
;
2579 VARIANT name
, index
, v
, vs
[5];
2580 IDispatch
*disp
, *disp2
;
2583 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2584 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2586 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, NULL
, "[object]");
2588 hres
= IHTMLElementCollection_get_length(col
, &len
);
2589 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2590 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2595 V_VT(&index
) = VT_EMPTY
;
2597 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2598 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2600 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2601 IUnknown_Release(enum_unk
);
2602 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2604 for(i
=0; i
<len
; i
++) {
2605 V_VT(&name
) = VT_I4
;
2607 disp
= (void*)0xdeadbeef;
2608 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2609 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2610 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2611 if(FAILED(hres
) || !disp
)
2614 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2617 V_VT(&name
) = VT_UINT
;
2619 disp2
= (void*)0xdeadbeef;
2620 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2621 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2622 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2624 IDispatch_Release(disp2
);
2628 V_VT(&v
) = VT_ERROR
;
2629 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2630 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2632 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2633 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2634 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2635 IDispatch_Release(V_DISPATCH(&v
));
2637 IDispatch_Release(disp
);
2640 fetched
= 0xdeadbeef;
2642 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2643 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2644 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2645 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2647 hres
= IEnumVARIANT_Reset(enum_var
);
2648 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2650 fetched
= 0xdeadbeef;
2652 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2653 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2654 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2655 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2657 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2658 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2660 memset(vs
, 0, sizeof(vs
));
2662 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2663 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2664 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2666 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2667 IDispatch_Release(V_DISPATCH(vs
));
2670 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2671 IDispatch_Release(V_DISPATCH(vs
+1));
2674 hres
= IEnumVARIANT_Reset(enum_var
);
2675 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2677 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2678 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2680 IEnumVARIANT_Release(enum_var
);
2682 V_VT(&name
) = VT_I4
;
2684 disp
= (void*)0xdeadbeef;
2685 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2686 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2687 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2689 V_VT(&name
) = VT_UI4
;
2691 disp
= (void*)0xdeadbeef;
2692 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2693 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2694 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2696 V_VT(&name
) = VT_INT
;
2698 disp
= (void*)0xdeadbeef;
2699 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2700 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2701 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2703 V_VT(&name
) = VT_UINT
;
2705 disp
= (void*)0xdeadbeef;
2706 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2707 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2708 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2710 V_VT(&name
) = VT_I4
;
2712 disp
= (void*)0xdeadbeef;
2713 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2714 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2715 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2717 IHTMLElementCollection_Release(col
);
2720 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2721 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2723 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2727 hres
= IHTMLElement_get_all(elem
, &disp
);
2728 IHTMLElement_Release(elem
);
2729 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2731 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2732 IDispatch_Release(disp
);
2735 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2736 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2738 IHTMLElementCollection
*col
;
2741 hres
= IHTMLDocument2_get_all(doc
, &col
);
2742 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2744 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2745 IHTMLElementCollection_Release(col
);
2748 #define test_children_collection_length(a,b) _test_children_collection_length(__LINE__,a,b)
2749 static LONG
_test_children_collection_length(unsigned line
, IHTMLDOMChildrenCollection
*collection
, LONG exlen
)
2754 hres
= IHTMLDOMChildrenCollection_get_length(collection
, &length
);
2755 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2757 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
2762 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2763 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2765 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2766 IHTMLElementCollection
*col
= NULL
;
2767 elem_type_t
*types
= NULL
;
2772 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2773 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2775 IHTMLElement2_Release(elem
);
2776 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2777 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2780 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2781 for(i
=0; i
<exlen
; i
++)
2785 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2787 HeapFree(GetProcessHeap(), 0, types
);
2790 *ret
= get_elem_col_item_idx(col
, 0);
2791 IHTMLElementCollection_Release(col
);
2794 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2795 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2797 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2798 IHTMLElementCollection
*col
= NULL
;
2799 elem_type_t
*types
= NULL
;
2804 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2805 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2807 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2808 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2811 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2812 for(i
=0; i
<exlen
; i
++)
2816 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2818 HeapFree(GetProcessHeap(), 0, types
);
2819 IHTMLElementCollection_Release(col
);
2820 IHTMLDocument3_Release(doc
);
2823 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2824 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2829 hres
= IHTMLElement_get_innerText(elem
, &text
);
2830 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2832 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2833 wine_dbgstr_w(text
), extext
);
2835 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2836 SysFreeString(text
);
2839 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2840 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2842 IHTMLDOMChildrenCollection
*col
;
2847 hres
= IHTMLElement_put_innerText(elem
, str
);
2848 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2851 _test_elem_innertext(line
, elem
, text
);
2854 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2855 ok(col
!= NULL
, "col == NULL\n");
2860 _test_children_collection_length(line
, col
, 1);
2862 node
= _get_child_item(line
, col
, 0);
2863 ok(node
!= NULL
, "node == NULL\n");
2865 type
= _get_node_type(line
, (IUnknown
*)node
);
2866 ok(type
== 3, "type=%d\n", type
);
2867 IHTMLDOMNode_Release(node
);
2870 IHTMLDOMChildrenCollection_Release(col
);
2875 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
2876 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2881 hres
= IHTMLElement_get_outerText(elem
, &text
);
2882 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08x\n", hres
);
2884 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_outerText returned %s expected %s\n",
2885 wine_dbgstr_w(text
), extext
);
2887 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2888 SysFreeString(text
);
2891 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
2892 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2894 BSTR str
= a2bstr(text
);
2897 hres
= IHTMLElement_put_outerText(elem
, str
);
2898 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08x\n", hres
);
2902 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
2903 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
2905 BSTR str
= a2bstr("test");
2908 hres
= IHTMLElement_put_outerText(elem
, str
);
2909 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08x\n", hres
);
2913 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2914 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2916 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2920 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2921 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2923 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2925 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2927 IHTMLElement_Release(elem
);
2928 SysFreeString(html
);
2931 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2932 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2934 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2938 html
= a2bstr(inner_html
);
2939 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2940 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2942 IHTMLElement_Release(elem
);
2943 SysFreeString(html
);
2946 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2947 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2949 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2953 html
= a2bstr(outer_html
);
2954 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2955 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2957 IHTMLElement_Release(elem
);
2958 SysFreeString(html
);
2961 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2962 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2964 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2968 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2969 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2970 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2972 IHTMLElement_Release(elem
);
2973 SysFreeString(html
);
2976 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2977 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2983 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2984 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2985 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2988 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
2989 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
2995 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
2996 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
2997 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
3000 #define get_first_child(n) _get_first_child(__LINE__,n)
3001 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
3003 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3004 IHTMLDOMNode
*child
= NULL
;
3007 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
3008 IHTMLDOMNode_Release(node
);
3009 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
3014 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
3015 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3017 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3018 VARIANT_BOOL b
= 0xdead;
3021 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
3022 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
3023 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
3025 IHTMLDOMNode_Release(node
);
3028 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
3029 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
3031 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3032 IHTMLDOMNode
*parent
;
3035 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
3036 IHTMLDOMNode_Release(node
);
3037 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3042 #define node_get_next(u) _node_get_next(__LINE__,u)
3043 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
3045 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3049 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
3050 IHTMLDOMNode_Release(node
);
3051 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
3056 #define node_get_prev(u) _node_get_prev(__LINE__,u)
3057 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
3059 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3063 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3064 IHTMLDOMNode_Release(node
);
3065 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
3070 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3071 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3073 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3074 IHTMLElement
*parent
;
3077 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3078 IHTMLElement_Release(elem
);
3079 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
3084 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3085 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3087 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3088 VARIANT_BOOL disabled
= 100;
3092 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3093 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3094 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3095 IHTMLElement3_Release(elem3
);
3098 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3099 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3101 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3105 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3106 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3108 IHTMLElement3_Release(elem3
);
3109 _test_elem3_get_disabled(line
, unk
, b
);
3112 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3113 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3115 VARIANT_BOOL disabled
= 100;
3118 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3119 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3120 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3122 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3125 static void test_select_remove(IHTMLSelectElement
*select
)
3129 hres
= IHTMLSelectElement_remove(select
, 3);
3130 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3131 test_select_length(select
, 2);
3133 hres
= IHTMLSelectElement_remove(select
, -1);
3134 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3135 test_select_length(select
, 2);
3137 hres
= IHTMLSelectElement_remove(select
, 0);
3138 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3139 test_select_length(select
, 1);
3142 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3143 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3145 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3149 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3150 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3151 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3152 IHTMLDOMTextNode_Release(text
);
3155 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3156 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3158 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3162 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3163 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3164 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3165 IHTMLDOMTextNode_Release(text
);
3169 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3170 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3172 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3173 BSTR str
= a2bstr(data
);
3176 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3177 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3178 IHTMLDOMTextNode_Release(text
);
3182 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3183 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3185 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3186 BSTR str
= a2bstr(data
);
3189 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3190 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3191 IHTMLDOMTextNode2_Release(text
);
3195 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3196 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3200 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3201 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3203 _test_select_get_disabled(line
, select
, b
);
3206 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3207 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3209 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3213 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3214 IHTMLElement2_Release(elem
);
3215 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3217 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3219 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3224 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3225 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3227 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3228 BSTR dir
= a2bstr(dira
);
3231 hres
= IHTMLElement2_put_dir(elem
, dir
);
3232 IHTMLElement2_Release(elem
);
3233 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3236 _test_elem_dir(line
, unk
, dira
);
3239 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3240 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3242 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3243 IHTMLTextContainer
*txtcont
;
3244 LONG l
= -1, l2
= -1;
3247 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3248 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3249 IHTMLElement2_Release(elem
);
3251 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3252 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3254 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3255 IHTMLTextContainer_Release(txtcont
);
3256 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3257 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3262 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3263 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3265 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3266 IHTMLTextContainer
*txtcont
;
3267 LONG l
= -1, l2
= -1;
3270 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3271 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3272 IHTMLElement2_Release(elem
);
3274 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3275 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3277 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3278 IHTMLTextContainer_Release(txtcont
);
3279 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3280 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3285 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3286 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3288 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3289 IHTMLTextContainer
*txtcont
;
3290 LONG l
= -1, l2
= -1;
3293 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3294 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3295 IHTMLElement2_Release(elem
);
3297 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3298 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3300 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3301 IHTMLTextContainer_Release(txtcont
);
3302 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3303 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3308 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3309 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3311 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3312 IHTMLTextContainer
*txtcont
;
3313 LONG l
= -1, l2
= -1;
3316 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3317 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3319 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3320 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3321 IHTMLElement2_Release(elem
);
3323 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3324 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3326 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3327 IHTMLTextContainer_Release(txtcont
);
3328 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3329 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3332 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3333 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3335 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3339 hres
= IHTMLImgElement_get_src(img
, &src
);
3340 IHTMLImgElement_Release(img
);
3341 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3342 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3343 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3347 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3348 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3350 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3355 hres
= IHTMLImgElement_put_src(img
, tmp
);
3356 IHTMLImgElement_Release(img
);
3358 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3361 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3362 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3364 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3368 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3369 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3371 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3373 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3377 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3378 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3380 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3385 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3386 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3389 _test_img_alt(line
, unk
, alt
);
3392 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3393 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3395 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3399 tmp
= a2bstr(align
);
3400 hres
= IHTMLImgElement_put_align(img
, tmp
);
3401 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3404 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3405 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3406 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3410 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3411 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3413 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3417 hres
= IHTMLImgElement_get_name(img
, &sName
);
3418 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3419 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3420 IHTMLImgElement_Release(img
);
3421 SysFreeString(sName
);
3424 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3425 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3427 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3428 VARIANT_BOOL b
= 100;
3431 hres
= IHTMLImgElement_get_complete(img
, &b
);
3432 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3433 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3434 IHTMLImgElement_Release(img
);
3437 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3438 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3440 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3441 VARIANT_BOOL b
= 100;
3444 hres
= IHTMLImgElement_put_isMap(img
, v
);
3445 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3447 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3448 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3449 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3451 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3452 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3453 IHTMLImgElement_Release(img
);
3456 static void test_dynamic_properties(IHTMLElement
*elem
)
3458 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3459 IDispatchEx
*dispex
;
3460 BSTR name
, attr1
= SysAllocString(attr1W
);
3464 DISPID id
= DISPID_STARTENUM
;
3467 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3468 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3470 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3471 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3472 ok(succ
, "removeAttribute set succ to FALSE\n");
3475 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3476 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3480 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3481 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3483 if(!strcmp_wa(name
, "attr1"))
3484 ok(0, "attr1 should be removed\n");
3485 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3487 SysFreeString(name
);
3489 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3490 IDispatchEx_Release(dispex
);
3492 V_VT(&val
) = VT_BSTR
;
3493 V_BSTR(&val
) = attr1
;
3494 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3495 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3496 SysFreeString(attr1
);
3499 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3500 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3505 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3506 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3507 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3511 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3512 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3514 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3515 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3518 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3519 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3520 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3521 IHTMLDOMAttribute2_Release(attr2
);
3524 static void test_attr_collection_disp(IDispatch
*disp
)
3526 IDispatchEx
*dispex
;
3527 IHTMLDOMAttribute
*attr
;
3528 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3535 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3536 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3539 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3540 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3541 SysFreeString(bstr
);
3544 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3545 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3546 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3547 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3550 bstr
= a2bstr("attr1");
3551 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3552 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3553 SysFreeString(bstr
);
3556 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3557 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3558 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3559 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3560 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3561 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3563 test_attr_node_name(attr
, "attr1");
3565 IHTMLDOMAttribute_Release(attr
);
3568 IDispatchEx_Release(dispex
);
3571 static void test_attr_collection(IHTMLElement
*elem
)
3573 static const WCHAR testW
[] = {'t','e','s','t',0};
3576 IDispatch
*disp
, *attr
;
3577 IHTMLDOMAttribute
*dom_attr
;
3578 IHTMLAttributeCollection
*attr_col
;
3579 BSTR name
= SysAllocString(testW
);
3581 LONG i
, len
, checked
;
3584 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3585 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3587 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3588 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3590 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3591 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3592 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3593 IDispatch_Release(attr
);
3594 IHTMLDOMNode_Release(node
);
3596 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3597 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3599 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3600 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3604 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3605 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3606 SysFreeString(name
);
3608 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3609 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3610 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3613 for(i
=0; i
<len
; i
++) {
3616 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3617 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3619 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3620 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3621 IDispatch_Release(attr
);
3623 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3624 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3626 if(!strcmp_wa(name
, "id")) {
3628 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3629 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3630 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3631 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3632 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3633 test_attr_value(dom_attr
, "attr");
3634 } else if(!strcmp_wa(name
, "attr1")) {
3636 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3637 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3638 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3639 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3640 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3641 test_attr_value(dom_attr
, "attr1");
3642 } else if(!strcmp_wa(name
, "attr2")) {
3644 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3645 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3646 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3647 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3648 test_attr_value(dom_attr
, "");
3649 } else if(!strcmp_wa(name
, "attr3")) {
3651 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3652 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3653 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3654 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3655 test_attr_value(dom_attr
, "attr3");
3656 } else if(!strcmp_wa(name
, "test")) {
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_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3661 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3662 test_attr_value(dom_attr
, "1");
3665 IHTMLDOMAttribute_Release(dom_attr
);
3666 SysFreeString(name
);
3669 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3672 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3673 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3675 V_VT(&id
) = VT_BSTR
;
3676 V_BSTR(&id
) = a2bstr("nonexisting");
3677 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3678 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3681 test_attr_collection_disp(disp
);
3683 IDispatch_Release(disp
);
3684 IHTMLAttributeCollection_Release(attr_col
);
3687 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3688 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3690 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3691 BSTR id
= (void*)0xdeadbeef;
3694 hres
= IHTMLElement_get_id(elem
, &id
);
3695 IHTMLElement_Release(elem
);
3696 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3699 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3701 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3706 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3707 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3709 BSTR lang
= (void*)0xdeadbeef;
3712 hres
= IHTMLElement_get_language(elem
, &lang
);
3713 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3716 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3718 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3720 SysFreeString(lang
);
3723 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3724 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3726 BSTR str
= a2bstr(lang
);
3729 hres
= IHTMLElement_put_language(elem
, str
);
3730 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3733 _test_elem_language(line
, elem
, lang
);
3736 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3737 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3739 BSTR lang
= (void*)0xdeadbeef;
3742 hres
= IHTMLElement_get_lang(elem
, &lang
);
3743 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3746 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3748 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3750 SysFreeString(lang
);
3753 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3754 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3756 BSTR str
= a2bstr(lang
);
3759 hres
= IHTMLElement_put_lang(elem
, str
);
3760 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3763 _test_elem_lang(line
, elem
, lang
);
3766 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3767 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3769 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3770 BSTR tmp
= a2bstr(new_id
);
3773 hres
= IHTMLElement_put_id(elem
, tmp
);
3774 IHTMLElement_Release(elem
);
3776 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3778 _test_elem_id(line
, unk
, new_id
);
3781 static void test_contenteditable(IUnknown
*unk
)
3783 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3785 BSTR str
, strDefault
;
3787 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3788 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3790 str
= a2bstr("true");
3791 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3792 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3794 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3795 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3796 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3799 /* Restore origin contentEditable */
3800 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3801 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3802 SysFreeString(strDefault
);
3804 IHTMLElement3_Release(elem3
);
3807 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3808 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3813 hres
= IHTMLInputElement_get_type(input
, &type
);
3814 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3815 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3816 SysFreeString(type
);
3819 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3820 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3822 BSTR name
= (BSTR
)0xdeadbeef;
3825 hres
= IHTMLInputElement_get_name(input
, &name
);
3826 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3828 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3830 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3831 SysFreeString(name
);
3834 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3835 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3837 BSTR tmp
= a2bstr(name
);
3840 hres
= IHTMLInputElement_put_name(input
, tmp
);
3841 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3844 _test_input_name(line
, input
, name
);
3847 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3848 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3850 VARIANT_BOOL disabled
= 100;
3853 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3854 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3855 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3857 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3860 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3861 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3865 hres
= IHTMLInputElement_put_disabled(input
, b
);
3866 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3868 _test_input_get_disabled(line
, input
, b
);
3871 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3872 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3874 VARIANT_BOOL checked
= 100;
3877 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3878 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3879 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3882 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3883 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3887 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3888 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3890 _test_input_get_defaultchecked(line
, input
, b
);
3893 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3894 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3896 VARIANT_BOOL checked
= 100;
3899 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3900 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3901 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3904 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3905 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3909 hres
= IHTMLInputElement_put_checked(input
, b
);
3910 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3912 _test_input_get_checked(line
, input
, b
);
3915 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3916 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3918 LONG maxlength
= 0xdeadbeef;
3921 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3922 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3923 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3926 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3927 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3931 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3932 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3934 _test_input_maxlength(line
, input
, l
);
3937 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3938 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3940 IHTMLInputElement
*input
;
3944 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3945 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3949 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3950 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3952 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3954 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3955 SysFreeString(bstr
);
3956 IHTMLInputElement_Release(input
);
3959 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3960 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3962 IHTMLInputElement
*input
;
3963 IHTMLFormElement
*form
;
3967 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3968 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3969 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3970 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3971 if(FAILED(hres
) || input
== NULL
)
3974 hres
= IHTMLInputElement_get_form(input
, &form
);
3975 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3976 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3977 if(FAILED(hres
) || form
== NULL
){
3978 IHTMLInputElement_Release(input
);
3982 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3983 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3984 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3985 if(FAILED(hres
) || elem
== NULL
){
3986 IHTMLInputElement_Release(input
);
3987 IHTMLFormElement_Release(form
);
3991 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3993 IHTMLInputElement_Release(input
);
3994 IHTMLFormElement_Release(form
);
3995 IHTMLElement_Release(elem
);
3998 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3999 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
4001 IHTMLInputElement
*input
;
4005 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4006 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4011 hres
= IHTMLInputElement_put_value(input
, bstr
);
4012 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
4013 SysFreeString(bstr
);
4014 IHTMLInputElement_Release(input
);
4016 _test_input_value(line
, unk
, val
);
4019 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
4020 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
4022 IHTMLInputElement
*input
;
4026 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4027 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
4031 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
4032 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4034 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
4036 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
4038 IHTMLInputElement_Release(input
);
4041 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
4042 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
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
);
4054 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
4055 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
4057 IHTMLInputElement_Release(input
);
4059 _test_input_defaultValue(line
, unk
, val
);
4062 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4063 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
4068 hres
= IHTMLInputElement_get_src(input
, &src
);
4069 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
4071 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
4073 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4077 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4078 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
4084 hres
= IHTMLInputElement_put_src(input
, tmp
);
4086 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
4088 _test_input_src(line
, input
, src
);
4091 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4092 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4096 hres
= IHTMLInputElement_put_size(input
, size
);
4097 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
4100 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4101 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4106 hres
= IHTMLInputElement_get_size(input
, &size
);
4107 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
4108 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
4110 hres
= IHTMLInputElement_get_size(input
, NULL
);
4111 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
4114 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4115 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4118 VARIANT_BOOL b
= 100;
4120 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4121 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
4123 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4124 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
4125 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4128 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4129 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
4131 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4132 BSTR
class = (void*)0xdeadbeef;
4135 hres
= IHTMLElement_get_className(elem
, &class);
4136 IHTMLElement_Release(elem
);
4137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4139 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4141 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4142 SysFreeString(class);
4145 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4146 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4148 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4152 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4153 IHTMLElement2_Release(elem2
);
4154 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4155 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4158 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4159 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4161 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4164 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4165 IHTMLElement2_Release(elem2
);
4166 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4168 _test_elem_tabindex(line
, unk
, index
);
4171 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4172 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4174 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4178 hres
= IHTMLStyleElement_get_media(style
, &media
);
4179 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4181 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4183 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4185 IHTMLStyleElement_Release(style
);
4186 SysFreeString(media
);
4189 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4190 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4192 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4196 str
= a2bstr(media
);
4197 hres
= IHTMLStyleElement_put_media(style
, str
);
4198 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4199 IHTMLStyleElement_Release(style
);
4202 _test_style_media(line
, unk
, media
);
4205 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4206 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4208 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4212 hres
= IHTMLStyleElement_get_type(style
, &type
);
4213 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4215 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4217 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4219 IHTMLStyleElement_Release(style
);
4220 SysFreeString(type
);
4223 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4224 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4226 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4231 hres
= IHTMLStyleElement_put_type(style
, str
);
4232 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4233 IHTMLStyleElement_Release(style
);
4236 _test_style_type(line
, unk
, type
);
4239 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4240 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4242 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4244 IHTMLFiltersCollection
*filters
;
4246 hres
= IHTMLElement_get_filters(elem
, &filters
);
4247 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4248 "get_filters failed: %08x\n", hres
);
4252 IDispatchEx
*dispex
;
4254 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4255 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4256 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4258 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4259 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4260 "Could not get IDispatchEx interface: %08x\n", hres
);
4261 if(SUCCEEDED(hres
)) {
4262 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, NULL
, "[object]");
4263 IDispatchEx_Release(dispex
);
4266 IHTMLFiltersCollection_Release(filters
);
4269 IHTMLElement_Release(elem
);
4272 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4273 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4275 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4279 tmp
= class ? a2bstr(class) : NULL
;
4280 hres
= IHTMLElement_put_className(elem
, tmp
);
4281 IHTMLElement_Release(elem
);
4282 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4285 _test_elem_class(line
, unk
, class);
4288 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4289 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4291 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4295 hres
= IHTMLElement_get_title(elem
, &title
);
4296 IHTMLElement_Release(elem
);
4297 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4299 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4301 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4303 SysFreeString(title
);
4306 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4307 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4309 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4313 tmp
= a2bstr(title
);
4314 hres
= IHTMLElement_put_title(elem
, tmp
);
4315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4317 IHTMLElement_Release(elem
);
4321 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4322 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4324 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4328 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4329 IHTMLDOMNode_Release(node
);
4330 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4333 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4334 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4336 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4342 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4343 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4345 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4349 V_VT(&var
) = VT_BSTR
;
4350 V_BSTR(&var
) = a2bstr(val
);
4352 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4353 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4354 IHTMLDOMNode_Release(node
);
4358 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4359 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4361 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4365 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4366 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4367 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4368 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4370 IHTMLElement2_Release(elem
);
4373 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4374 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4376 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4380 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4381 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4382 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4384 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4385 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4386 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4388 IHTMLElement2_Release(elem
);
4391 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4392 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4394 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4395 LONG len
= 0xdeadbeef;
4398 hres
= IHTMLFormElement_get_length(form
, &len
);
4399 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4400 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4402 IHTMLFormElement_Release(form
);
4405 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4406 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4408 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4409 BSTR action
= (void*)0xdeadbeef;
4412 hres
= IHTMLFormElement_get_action(form
, &action
);
4413 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4415 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4417 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4419 SysFreeString(action
);
4420 IHTMLFormElement_Release(form
);
4423 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4424 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4426 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4427 BSTR tmp
= a2bstr(action
);
4430 hres
= IHTMLFormElement_put_action(form
, tmp
);
4431 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4433 IHTMLFormElement_Release(form
);
4435 _test_form_action(line
, unk
, action
);
4438 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4439 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4441 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4442 BSTR method
= (void*)0xdeadbeef;
4445 hres
= IHTMLFormElement_get_method(form
, &method
);
4446 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4448 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4450 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4452 SysFreeString(method
);
4453 IHTMLFormElement_Release(form
);
4456 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4457 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4459 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4460 BSTR tmp
= a2bstr(method
);
4463 hres
= IHTMLFormElement_put_method(form
, tmp
);
4464 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4466 IHTMLFormElement_Release(form
);
4468 if(exp_hres
== S_OK
)
4469 _test_form_method(line
, unk
, method
);
4472 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4473 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4475 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4476 BSTR name
= (void*)0xdeadbeef;
4479 hres
= IHTMLFormElement_get_name(form
, &name
);
4480 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4482 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4484 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4486 SysFreeString(name
);
4487 IHTMLFormElement_Release(form
);
4490 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4491 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4493 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4494 BSTR tmp
= a2bstr(name
);
4497 hres
= IHTMLFormElement_put_name(form
, tmp
);
4498 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4500 IHTMLFormElement_Release(form
);
4502 _test_form_name(line
, unk
, name
);
4505 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4506 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4508 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4509 BSTR encoding
= (void*)0xdeadbeef;
4512 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4513 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4515 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4517 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4519 SysFreeString(encoding
);
4520 IHTMLFormElement_Release(form
);
4523 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4524 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4526 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4527 BSTR tmp
= a2bstr(encoding
);
4530 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4531 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4533 IHTMLFormElement_Release(form
);
4535 if(exp_hres
== S_OK
)
4536 _test_form_encoding(line
, unk
, encoding
);
4539 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4540 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4542 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4547 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4548 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4549 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4550 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4552 IDispatch_Release(disp
);
4553 IHTMLFormElement_Release(form
);
4556 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4557 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4559 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4562 hres
= IHTMLFormElement_reset(form
);
4563 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4565 IHTMLFormElement_Release(form
);
4568 static void test_form_target(IUnknown
*unk
)
4570 IHTMLFormElement
*form
= get_form_iface(unk
);
4573 static const char target
[] = "_blank";
4575 str
= a2bstr(target
);
4576 hres
= IHTMLFormElement_put_target(form
, str
);
4577 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4580 hres
= IHTMLFormElement_get_target(form
, &str
);
4581 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4582 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4585 IHTMLFormElement_Release(form
);
4588 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4590 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4591 IHTMLFormElement
*form
;
4594 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4595 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4597 hres
= IHTMLSelectElement_get_form(select
, &form
);
4598 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4599 ok(form
!= NULL
, "form == NULL\n");
4601 test_form_length((IUnknown
*)form
, 2);
4602 test_form_elements((IUnknown
*)form
);
4603 test_form_name((IUnknown
*)form
, "form_name");
4605 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4607 IHTMLSelectElement_Release(select
);
4608 IHTMLFormElement_Release(form
);
4611 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4613 IHTMLFormElement
*form
;
4616 form
= (IHTMLFormElement
*)0xdeadbeef;
4617 hres
= IHTMLSelectElement_get_form(select
, &form
);
4618 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4619 ok(form
== NULL
, "got %p\n", form
);
4622 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4623 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4625 IHTMLMetaElement
*meta
;
4629 meta
= _get_metaelem_iface(line
, unk
);
4630 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4631 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4632 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4633 SysFreeString(name
);
4634 IHTMLMetaElement_Release(meta
);
4637 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4638 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4640 IHTMLMetaElement
*meta
;
4641 BSTR content
= NULL
;
4644 meta
= _get_metaelem_iface(line
, unk
);
4645 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4646 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4647 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4648 SysFreeString(content
);
4649 IHTMLMetaElement_Release(meta
);
4652 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4653 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4655 IHTMLMetaElement
*meta
;
4659 meta
= _get_metaelem_iface(line
, unk
);
4660 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4661 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4662 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4664 IHTMLMetaElement_Release(meta
);
4667 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4668 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4670 IHTMLMetaElement
*meta
;
4674 meta
= _get_metaelem_iface(line
, unk
);
4675 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4676 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4678 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4680 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4682 IHTMLMetaElement_Release(meta
);
4685 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4686 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4688 BSTR val
= a2bstr(vala
);
4689 IHTMLMetaElement
*meta
;
4692 meta
= _get_metaelem_iface(line
, unk
);
4693 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4694 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4696 IHTMLMetaElement_Release(meta
);
4698 _test_meta_charset(line
, unk
, vala
);
4701 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4702 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4704 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4708 str
= a2bstr(exval
);
4709 hres
= IHTMLLinkElement_put_media(link
, str
);
4710 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4713 hres
= IHTMLLinkElement_get_media(link
, &str
);
4714 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4715 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4717 IHTMLLinkElement_Release(link
);
4720 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4721 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4723 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4724 VARIANT_BOOL b
= 10;
4727 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4728 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4729 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4731 IHTMLLinkElement_Release(link
);
4734 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4735 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4737 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4740 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4741 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4742 IHTMLLinkElement_Release(link
);
4743 _test_link_disabled(line
, elem
, v
);
4746 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4747 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4749 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4753 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4754 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4756 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4758 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4761 IHTMLLinkElement_Release(link
);
4764 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4765 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4767 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4768 BSTR str
= a2bstr(v
);
4771 hres
= IHTMLLinkElement_put_rel(link
, str
);
4772 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4774 IHTMLLinkElement_Release(link
);
4775 _test_link_rel(line
, elem
, v
);
4778 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4779 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4781 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4785 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4786 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4788 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4790 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4793 IHTMLLinkElement_Release(link
);
4796 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4797 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4799 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4800 BSTR str
= a2bstr(v
);
4803 hres
= IHTMLLinkElement_put_rev(link
, str
);
4804 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4806 IHTMLLinkElement_Release(link
);
4807 _test_link_rev(line
, elem
, v
);
4810 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4811 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4813 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4817 hres
= IHTMLLinkElement_get_type(link
, &type
);
4818 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4820 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4822 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4823 SysFreeString(type
);
4825 IHTMLLinkElement_Release(link
);
4828 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4829 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4834 str
= (void*)0xdeadbeef;
4835 hres
= IHTMLScriptElement_get_text(script
, &str
);
4836 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4837 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4841 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4842 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4844 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4845 BSTR str
= a2bstr(v
);
4848 hres
= IHTMLLinkElement_put_type(link
, str
);
4849 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4851 IHTMLLinkElement_Release(link
);
4852 _test_link_type(line
, elem
, v
);
4855 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4856 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4858 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4862 hres
= IHTMLLinkElement_get_href(link
, &href
);
4863 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4865 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4867 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4868 SysFreeString(href
);
4870 IHTMLLinkElement_Release(link
);
4873 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4874 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4876 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4877 BSTR str
= a2bstr(v
);
4880 hres
= IHTMLLinkElement_put_href(link
, str
);
4881 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4883 IHTMLLinkElement_Release(link
);
4884 _test_link_href(line
, elem
, v
);
4887 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4888 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4890 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4891 IHTMLDocument2
*doc
;
4896 hres
= IHTMLElement_get_document(elem
, &disp
);
4897 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4898 ok(disp
!= NULL
, "disp == NULL\n");
4900 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4901 IDispatch_Release(disp
);
4902 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4907 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4908 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4910 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4911 BSTR str
= a2bstr(attr_name
);
4912 IHTMLDOMAttribute
*attr
;
4915 attr
= (void*)0xdeadbeef;
4916 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4917 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4919 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4921 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4923 IHTMLElement4_Release(elem
);
4928 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4929 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4934 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4935 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4936 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4939 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4940 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4944 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4945 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4948 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4949 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4951 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4952 BSTR str
= a2bstr(value
);
4955 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4956 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4958 IHTMLDOMAttribute2_Release(attr2
);
4962 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4963 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4965 IHTMLDocument2
*doc
;
4969 hres
= IHTMLWindow2_get_document(window
, &doc
);
4970 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4971 ok(doc
!= NULL
, "disp == NULL\n");
4976 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4977 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4982 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4983 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4984 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4989 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4990 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4992 IHTMLElement
*elem
= NULL
;
4997 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4998 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4999 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
5005 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
5006 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
5008 IHTMLDocument3
*doc3
;
5009 IHTMLDOMNode
*node
= NULL
;
5013 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5014 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
5017 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
5018 IHTMLDocument3_Release(doc3
);
5020 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
5021 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
5026 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
5027 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5029 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5030 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
5031 IHTMLDOMNode
*new_child
= NULL
;
5034 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
5035 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
5036 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5037 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5039 IHTMLDOMNode_Release(node
);
5040 IHTMLDOMNode_Release(child
);
5045 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
5046 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
5048 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5049 IHTMLDOMNode
*new_child
= NULL
;
5052 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
5053 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
5054 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5055 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5057 IHTMLDOMNode_Release(node
);
5062 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
5063 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
5065 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5066 IHTMLDOMNode
*new_node
= NULL
;
5069 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5070 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
5071 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5072 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5074 IHTMLDOMNode_Release(node
);
5075 IHTMLDOMNode_Release(new_node
);
5078 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5079 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
5084 hres
= IHTMLDocument2_get_title(doc
, &title
);
5085 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5086 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5087 SysFreeString(title
);
5090 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5091 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
5096 tmp
= a2bstr(title
);
5097 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5098 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5102 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5104 IHTMLRect
*rect
, *rect2
;
5105 IHTMLElement2
*elem2
;
5109 elem2
= get_elem2_iface(unk
);
5110 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5111 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5112 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5113 IHTMLElement2_Release(elem2
);
5114 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5115 ok(rect
!= NULL
, "rect == NULL\n");
5116 ok(rect
!= rect2
, "rect == rect2\n");
5117 IHTMLRect_Release(rect2
);
5119 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, NULL
, "[object]");
5122 hres
= IHTMLRect_get_top(rect
, &l
);
5123 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
5124 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5127 hres
= IHTMLRect_get_left(rect
, &l
);
5128 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
5129 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5132 hres
= IHTMLRect_get_bottom(rect
, &l
);
5133 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
5134 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5137 hres
= IHTMLRect_get_right(rect
, &l
);
5138 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
5139 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5141 IHTMLRect_Release(rect
);
5144 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5145 const elem_type_t
*elem_types
, LONG len
)
5148 VARIANT name
, index
;
5152 V_VT(&index
) = VT_EMPTY
;
5153 V_VT(&name
) = VT_BSTR
;
5154 V_BSTR(&name
) = a2bstr(n
);
5156 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5157 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5159 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5160 IDispatch_Release(disp
);
5162 V_VT(&index
) = VT_I4
;
5164 for(i
=0; i
<len
; i
++) {
5166 disp
= (void*)0xdeadbeef;
5167 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5168 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5169 ok(disp
!= NULL
, "disp == NULL\n");
5170 if(FAILED(hres
) || !disp
)
5173 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5175 IDispatch_Release(disp
);
5179 disp
= (void*)0xdeadbeef;
5180 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5181 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5182 ok(disp
== NULL
, "disp != NULL\n");
5185 disp
= (void*)0xdeadbeef;
5186 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5187 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5188 ok(disp
== NULL
, "disp != NULL\n");
5190 SysFreeString(V_BSTR(&name
));
5193 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5195 IHTMLElementCollection
*col
;
5197 IDispatch
*disp
= (void*)0xdeadbeef;
5198 VARIANT name
, index
;
5201 hres
= IHTMLDocument2_get_all(doc
, &col
);
5202 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5203 ok(col
!= NULL
, "col == NULL\n");
5204 if(FAILED(hres
) || !col
)
5207 V_VT(&index
) = VT_EMPTY
;
5208 V_VT(&name
) = VT_BSTR
;
5209 V_BSTR(&name
) = a2bstr(id
);
5211 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5212 IHTMLElementCollection_Release(col
);
5213 SysFreeString(V_BSTR(&name
));
5214 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5215 if(!expect_success
) {
5216 ok(disp
== NULL
, "disp != NULL\n");
5220 ok(disp
!= NULL
, "disp == NULL\n");
5224 elem
= get_elem_iface((IUnknown
*)disp
);
5225 IDispatch_Release(disp
);
5230 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5232 IHTMLDocument3
*doc3
;
5237 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5238 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5241 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5243 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5245 IHTMLDocument3_Release(doc3
);
5250 static void test_select_elem(IHTMLSelectElement
*select
)
5252 IDispatch
*disp
, *disp2
;
5253 VARIANT name
, index
;
5256 test_select_type(select
, "select-one");
5257 test_select_length(select
, 2);
5258 test_select_selidx(select
, 0);
5259 test_select_put_selidx(select
, 1);
5261 test_select_set_value(select
, "val1");
5262 test_select_value(select
, "val1");
5264 test_select_size(select
, 0);
5265 test_select_set_size(select
, 1, S_OK
);
5266 test_select_size(select
, 1);
5268 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5269 test_select_size(select
, 1);
5270 test_select_set_size(select
, 3, S_OK
);
5271 test_select_size(select
, 3);
5273 test_select_name(select
, NULL
);
5274 test_select_set_name(select
, "select-name");
5275 test_select_name(select
, "select-name");
5276 test_select_form_notfound(select
);
5278 test_select_get_disabled(select
, VARIANT_FALSE
);
5279 test_select_set_disabled(select
, VARIANT_TRUE
);
5280 test_select_set_disabled(select
, VARIANT_FALSE
);
5283 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5284 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5285 ok(disp
!= NULL
, "options == NULL\n");
5286 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5287 IDispatch_Release(disp
);
5289 V_VT(&index
) = VT_EMPTY
;
5290 V_VT(&name
) = VT_I4
;
5292 disp
= (void*)0xdeadbeef;
5293 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5294 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5295 ok(!disp
, "disp = %p\n", disp
);
5298 disp
= (void*)0xdeadbeef;
5299 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5300 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5301 ok(!disp
, "disp = %p\n", disp
);
5304 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5305 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5308 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5309 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5310 ok(disp
!= NULL
, "disp = NULL\n");
5311 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5313 V_VT(&index
) = VT_I4
;
5316 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5317 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5318 ok(disp2
!= NULL
, "disp = NULL\n");
5319 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5320 IDispatch_Release(disp2
);
5321 IDispatch_Release(disp
);
5323 test_select_multiple(select
, VARIANT_FALSE
);
5324 test_select_set_multiple(select
, VARIANT_TRUE
);
5325 test_select_remove(select
);
5328 static void test_form_item(IHTMLElement
*elem
)
5330 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5331 IDispatch
*disp
, *disp2
;
5332 VARIANT name
, index
;
5335 V_VT(&index
) = VT_EMPTY
;
5336 V_VT(&name
) = VT_I4
;
5338 disp
= (void*)0xdeadbeef;
5339 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5340 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5341 ok(!disp
, "disp = %p\n", disp
);
5344 disp
= (void*)0xdeadbeef;
5345 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5346 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5347 ok(!disp
, "disp = %p\n", disp
);
5350 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5351 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5354 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5355 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5356 ok(disp
!= NULL
, "disp = NULL\n");
5357 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5359 V_VT(&index
) = VT_I4
;
5362 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5363 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5364 ok(disp2
!= NULL
, "disp = NULL\n");
5365 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5366 IDispatch_Release(disp2
);
5367 IDispatch_Release(disp
);
5370 static void test_create_option_elem(IHTMLDocument2
*doc
)
5372 IHTMLOptionElement
*option
;
5374 option
= create_option_elem(doc
, "test text", "test value");
5376 test_option_put_text(option
, "new text");
5377 test_option_put_value(option
, "new value");
5378 test_option_get_index(option
, 0);
5379 test_option_defaultSelected_property(option
);
5380 test_option_put_selected(option
, VARIANT_TRUE
);
5381 test_option_put_selected(option
, VARIANT_FALSE
);
5383 IHTMLOptionElement_Release(option
);
5386 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5388 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5389 IHTMLFormElement
*form
;
5392 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5393 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5395 hres
= IHTMLOptionElement_get_form(option
, &form
);
5396 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5397 ok(form
!= NULL
, "form == NULL\n");
5399 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5401 IHTMLOptionElement_Release(option
);
5402 IHTMLFormElement_Release(form
);
5405 static void test_create_img_elem(IHTMLDocument2
*doc
)
5407 IHTMLImgElement
*img
;
5409 img
= create_img_elem(doc
, 10, 15);
5412 test_img_put_width(img
, 5);
5413 test_img_put_height(img
, 20);
5415 IHTMLImgElement_Release(img
);
5419 img
= create_img_elem(doc
, -1, -1);
5422 test_img_put_width(img
, 5);
5423 test_img_put_height(img
, 20);
5425 IHTMLImgElement_Release(img
);
5429 #define test_doc_selection_type(a,b) _test_doc_selection_type(__LINE__,a,b)
5430 static void _test_doc_selection_type(unsigned line
, IHTMLDocument2
*doc
, const char *type
)
5432 IHTMLSelectionObject2
*selection2
;
5433 IHTMLSelectionObject
*selection
;
5437 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5438 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5440 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5441 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5442 ok_(__FILE__
,line
)(!strcmp_wa(str
, type
), "type = %s, expected %s\n", wine_dbgstr_w(str
), type
);
5445 hres
= IHTMLSelectionObject_QueryInterface(selection
, &IID_IHTMLSelectionObject2
, (void**)&selection2
);
5446 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLSelectionObject2 iface: %08x\n", hres
);
5448 IHTMLSelectionObject_Release(selection
);
5450 hres
= IHTMLSelectionObject2_get_typeDetail(selection2
, &str
);
5451 ok_(__FILE__
,line
)(hres
== S_OK
, "get_typeDetail failed: %08x\n", hres
);
5452 ok_(__FILE__
,line
)(!strcmp_wa(str
, "undefined"), "typeDetail = %s\n", wine_dbgstr_w(str
));
5455 IHTMLSelectionObject2_Release(selection2
);
5458 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5459 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5461 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5462 IHTMLElement
*ret_elem
= NULL
;
5463 BSTR str
= a2bstr(where
);
5466 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5467 IHTMLElement2_Release(elem2
);
5469 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5470 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5471 IHTMLElement_Release(ret_elem
);
5474 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5476 IHTMLElement
*elem
, *elem2
;
5478 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5479 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5481 elem
= test_create_elem(doc
, "BR");
5482 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5483 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5484 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5485 IHTMLElement_Release(elem
);
5487 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5489 elem
= test_create_elem(doc
, "BR");
5490 insert_adjacent_elem(parent
, "beforeend", elem
);
5492 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5494 elem2
= test_create_elem(doc
, "DIV");
5495 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5496 IHTMLElement_Release(elem2
);
5497 IHTMLElement_Release(elem
);
5499 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5502 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5504 IHTMLBodyElement
*body
;
5505 IHTMLTxtRange
*range
;
5509 elem
= doc_get_body(doc
);
5510 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5511 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5512 IHTMLElement_Release(elem
);
5514 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5515 IHTMLBodyElement_Release(body
);
5516 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5521 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5522 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5527 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5528 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5533 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5534 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5535 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5537 BSTR str
= a2bstr(how
);
5540 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5541 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5545 static void test_txtrange(IHTMLDocument2
*doc
)
5547 IHTMLTxtRange
*body_range
, *range
, *range2
;
5548 IHTMLSelectionObject
*selection
;
5549 IDispatch
*disp_range
;
5553 body_range
= test_create_body_range(doc
);
5555 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, NULL
, "[object]");
5557 test_range_text(body_range
, "test abc 123\r\nit's text");
5559 range
= range_duplicate(body_range
);
5560 range2
= range_duplicate(body_range
);
5562 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5564 test_range_text(range
, "test abc 123\r\nit's text");
5565 test_range_text(body_range
, "test abc 123\r\nit's text");
5567 test_range_collapse(range
, TRUE
);
5568 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5569 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5570 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5571 IHTMLTxtRange_Release(range2
);
5573 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5574 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5575 test_range_move(range
, characterW
, 2, 2);
5576 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5578 test_range_collapse(range
, FALSE
);
5579 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5581 test_range_collapse(range
, FALSE
);
5582 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5583 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5584 test_range_move(range
, characterW
, 2, 2);
5585 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5586 test_range_moveend(range
, characterW
, -5, -5);
5587 test_range_text(range
, NULL
);
5588 test_range_moveend(range
, characterW
, 3, 3);
5589 test_range_text(range
, "c 1");
5590 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5591 test_range_collapse(range
, TRUE
);
5592 test_range_move(range
, characterW
, 4, 4);
5593 test_range_moveend(range
, characterW
, 1, 1);
5594 test_range_text(range
, " ");
5595 test_range_move(range
, wordW
, 1, 1);
5596 test_range_moveend(range
, characterW
, 2, 2);
5597 test_range_text(range
, "ab");
5599 IHTMLTxtRange_Release(range
);
5601 range
= range_duplicate(body_range
);
5603 test_range_text(range
, "test abc 123\r\nit's text");
5604 test_range_move(range
, characterW
, 3, 3);
5605 test_range_moveend(range
, characterW
, 1, 1);
5606 test_range_text(range
, "t");
5607 test_range_moveend(range
, characterW
, 3, 3);
5608 test_range_text(range
, "t ab");
5609 test_range_moveend(range
, characterW
, -2, -2);
5610 test_range_text(range
, "t ");
5611 test_range_move(range
, characterW
, 6, 6);
5612 test_range_moveend(range
, characterW
, 3, 3);
5613 test_range_text(range
, "123");
5614 test_range_moveend(range
, characterW
, 2, 2);
5615 test_range_text(range
, "123\r\ni");
5617 IHTMLTxtRange_Release(range
);
5619 range
= range_duplicate(body_range
);
5621 test_range_move(range
, wordW
, 1, 1);
5622 test_range_moveend(range
, characterW
, 2, 2);
5623 test_range_text(range
, "ab");
5625 test_range_move(range
, characterW
, -2, -2);
5626 test_range_moveend(range
, characterW
, 2, 2);
5627 test_range_text(range
, "t ");
5629 test_range_move(range
, wordW
, 3, 3);
5630 test_range_move(range
, wordW
, -2, -2);
5631 test_range_moveend(range
, characterW
, 2, 2);
5632 test_range_text(range
, "ab");
5634 test_range_move(range
, characterW
, -6, -5);
5635 test_range_moveend(range
, characterW
, -1, 0);
5636 test_range_moveend(range
, characterW
, -6, 0);
5637 test_range_move(range
, characterW
, 2, 2);
5638 test_range_moveend(range
, characterW
, 2, 2);
5639 test_range_text(range
, "st");
5640 test_range_moveend(range
, characterW
, -6, -4);
5641 test_range_moveend(range
, characterW
, 2, 2);
5643 IHTMLTxtRange_Release(range
);
5645 range
= range_duplicate(body_range
);
5647 test_range_move(range
, wordW
, 2, 2);
5648 test_range_moveend(range
, characterW
, 2, 2);
5649 test_range_text(range
, "12");
5651 test_range_move(range
, characterW
, 15, 14);
5652 test_range_move(range
, characterW
, -2, -2);
5653 test_range_moveend(range
, characterW
, 3, 2);
5654 test_range_text(range
, "t");
5655 test_range_moveend(range
, characterW
, -1, -1);
5656 test_range_text(range
, "t");
5657 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5658 test_range_move(range
, characterW
, -2, -2);
5659 test_range_moveend(range
, characterW
, 2, 2);
5660 test_range_text(range
, "s ");
5661 test_range_move(range
, characterW
, 100, 7);
5662 test_range_move(range
, wordW
, 1, 0);
5663 test_range_move(range
, characterW
, -2, -2);
5664 test_range_moveend(range
, characterW
, 3, 2);
5665 test_range_text(range
, "t");
5667 IHTMLTxtRange_Release(range
);
5669 range
= range_duplicate(body_range
);
5671 test_range_collapse(range
, TRUE
);
5672 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5673 test_range_put_text(range
, "word");
5674 test_range_text(body_range
, "wordabc 123\r\nit's text");
5675 test_range_text(range
, NULL
);
5676 test_range_moveend(range
, characterW
, 3, 3);
5677 test_range_text(range
, "abc");
5678 test_range_movestart(range
, characterW
, -2, -2);
5679 test_range_text(range
, "rdabc");
5680 test_range_movestart(range
, characterW
, 3, 3);
5681 test_range_text(range
, "bc");
5682 test_range_movestart(range
, characterW
, 4, 4);
5683 test_range_text(range
, NULL
);
5684 test_range_movestart(range
, characterW
, -3, -3);
5685 test_range_text(range
, "c 1");
5686 test_range_movestart(range
, characterW
, -7, -6);
5687 test_range_text(range
, "wordabc 1");
5688 test_range_movestart(range
, characterW
, 100, 22);
5689 test_range_text(range
, NULL
);
5691 IHTMLTxtRange_Release(range
);
5693 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5694 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5696 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, NULL
, "[object]");
5697 test_ifaces((IUnknown
*)selection
, selection_iids
);
5699 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5700 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5701 IHTMLSelectionObject_Release(selection
);
5703 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5704 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5705 IDispatch_Release(disp_range
);
5707 test_range_text(range
, NULL
);
5708 test_range_moveend(range
, characterW
, 3, 3);
5709 test_range_text(range
, "wor");
5710 test_range_parent(range
, ET_BODY
);
5711 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5712 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5713 test_range_move(range
, characterW
, 3, 3);
5714 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5715 test_range_moveend(range
, characterW
, -4, -4);
5716 test_range_put_text(range
, "abc def ");
5717 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5718 test_range_move(range
, wordW
, 1, 1);
5719 test_range_movestart(range
, characterW
, -1, -1);
5720 test_range_text(range
, " ");
5721 test_range_move(range
, wordW
, 1, 1);
5722 test_range_moveend(range
, characterW
, 3, 3);
5723 test_range_text(range
, "def");
5724 test_range_put_text(range
, "xyz");
5725 test_range_moveend(range
, characterW
, 1, 1);
5726 test_range_move(range
, wordW
, 1, 1);
5727 test_range_moveend(range
, characterW
, 2, 2);
5728 test_range_text(range
, "ab");
5730 body
= doc_get_body(doc
);
5732 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5733 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5735 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5736 test_range_parent(range
, ET_BODY
);
5738 test_range_move(range
, wordW
, 1, 1);
5739 test_range_moveend(range
, characterW
, 12, 12);
5740 test_range_text(range
, "xyz abc 123");
5742 test_range_collapse(range
, VARIANT_TRUE
);
5743 test_range_paste_html(range
, "<br>paste<br>");
5744 test_range_text(range
, NULL
);
5746 test_range_moveend(range
, characterW
, 3, 3);
5747 test_range_text(range
, "xyz");
5749 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5750 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5752 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5754 test_range_move(range
, wordW
, 2, 2);
5755 test_range_collapse(range
, VARIANT_TRUE
);
5756 test_range_moveend(range
, characterW
, 5, 5);
5757 test_range_text(range
, "paste");
5759 range2
= range_duplicate(range
);
5761 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5762 test_range_text(range
, "abc \r\npaste");
5764 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5765 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5767 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5768 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5770 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5771 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5772 test_range_text(range
, "abc ");
5774 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5775 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5777 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5778 test_range_text(range
, "abc ");
5780 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5782 hres
= IHTMLTxtRange_select(range
);
5783 ok(hres
== S_OK
, "select failed: %08x\n", hres
);
5785 test_doc_selection_type(doc
, "Text");
5787 IHTMLTxtRange_Release(range
);
5788 IHTMLTxtRange_Release(range2
);
5789 IHTMLTxtRange_Release(body_range
);
5790 IHTMLElement_Release(body
);
5794 static void test_txtrange2(IHTMLDocument2
*doc
)
5796 IHTMLTxtRange
*range
;
5798 range
= test_create_body_range(doc
);
5800 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5801 test_range_move(range
, characterW
, 5, 5);
5802 test_range_moveend(range
, characterW
, 1, 1);
5803 test_range_text(range
, "2");
5804 test_range_move(range
, characterW
, -3, -3);
5805 test_range_moveend(range
, characterW
, 3, 3);
5806 test_range_text(range
, "c\r\n\r\n1");
5807 test_range_collapse(range
, VARIANT_FALSE
);
5808 test_range_moveend(range
, characterW
, 4, 4);
5809 test_range_text(range
, "23");
5810 test_range_moveend(range
, characterW
, 1, 1);
5811 test_range_text(range
, "23\r\n\r\n\r\nd");
5812 test_range_moveend(range
, characterW
, -1, -1);
5813 test_range_text(range
, "23");
5814 test_range_moveend(range
, characterW
, -1, -1);
5815 test_range_text(range
, "23");
5816 test_range_moveend(range
, characterW
, -2, -2);
5817 test_range_text(range
, "2");
5819 IHTMLTxtRange_Release(range
);
5822 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5823 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5825 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5829 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5830 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5831 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5834 IHTMLDocument5_Release(doc
);
5837 static void test_location(IHTMLDocument2
*doc
)
5839 IHTMLLocation
*location
, *location2
;
5840 IHTMLWindow2
*window
;
5845 hres
= IHTMLDocument2_get_location(doc
, &location
);
5846 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5848 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5849 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5851 ok(location
== location2
, "location != location2\n");
5852 IHTMLLocation_Release(location2
);
5854 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5855 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5857 hres
= IHTMLWindow2_get_location(window
, &location2
);
5858 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5859 ok(location
== location2
, "location != location2\n");
5860 IHTMLLocation_Release(location2
);
5862 test_ifaces((IUnknown
*)location
, location_iids
);
5863 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, NULL
, "about:blank");
5865 hres
= IHTMLLocation_get_pathname(location
, &str
);
5866 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5867 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5870 hres
= IHTMLLocation_get_href(location
, NULL
);
5871 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5873 hres
= IHTMLLocation_get_href(location
, &str
);
5874 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5875 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5878 ref
= IHTMLLocation_Release(location
);
5879 ok(!ref
, "location should be destroyed here\n");
5882 static void test_plugins_col(IHTMLDocument2
*doc
)
5884 IHTMLPluginsCollection
*col
, *col2
;
5885 IHTMLWindow2
*window
;
5891 window
= get_doc_window(doc
);
5892 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5893 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5894 IHTMLWindow2_Release(window
);
5896 hres
= IOmNavigator_get_plugins(nav
, &col
);
5897 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5899 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5900 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5901 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5902 IHTMLPluginsCollection_Release(col2
);
5904 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, NULL
, "[object]");
5907 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5908 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5909 ok(!len
, "length = %d\n", len
);
5911 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5912 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5914 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5915 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5917 ref
= IHTMLPluginsCollection_Release(col
);
5918 ok(!ref
, "ref=%d\n", ref
);
5920 IOmNavigator_Release(nav
);
5923 static void test_mime_types_col(IOmNavigator
*nav
)
5925 IHTMLMimeTypesCollection
*col
, *col2
;
5930 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5931 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5933 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5934 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5935 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5936 IHTMLMimeTypesCollection_Release(col2
);
5938 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, NULL
, "[object]");
5940 length
= 0xdeadbeef;
5941 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5942 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5943 ok(!length
, "length = %d\n", length
);
5945 ref
= IHTMLMimeTypesCollection_Release(col
);
5946 ok(!ref
, "ref=%d\n", ref
);
5949 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5950 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5952 BSTR str
= (void*)0xdeadbeef;
5953 IHTMLFrameBase
*fbase
;
5956 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5957 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5959 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5960 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5962 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5964 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5967 IHTMLFrameBase_Release(fbase
);
5970 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5971 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5973 IHTMLFrameBase
*fbase
;
5977 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5978 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5980 str
= name
? a2bstr(name
) : NULL
;
5981 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5982 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5985 _test_framebase_name(line
, elem
, name
);
5986 IHTMLFrameBase_Release(fbase
);
5989 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
5990 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
5992 BSTR str
= (void*)0xdeadbeef;
5993 IHTMLFrameBase
*fbase
;
5996 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5997 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5999 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
6000 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
6002 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
6004 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
6007 IHTMLFrameBase_Release(fbase
);
6010 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
6011 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6016 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
6017 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
6018 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
6020 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6022 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6026 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
6027 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6033 V_BSTR(&v
) = a2bstr(val
);
6034 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
6035 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
6039 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
6040 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
6045 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
6046 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
6047 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
6049 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6051 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6055 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
6056 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
6062 V_BSTR(&v
) = a2bstr(val
);
6063 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
6064 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
6068 static void test_framebase(IUnknown
*unk
)
6070 IHTMLFrameBase
*fbase
;
6074 /* get/put scrolling */
6075 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6076 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
6078 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6079 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6080 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6084 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6085 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
6088 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6089 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6090 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6093 str
= a2bstr("junk");
6094 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6095 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6096 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
6099 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6100 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6101 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6104 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6105 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6106 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6109 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6110 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
6113 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6114 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6115 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6118 test_framebase_marginheight(fbase
, NULL
);
6119 set_framebase_marginheight(fbase
, "1px");
6120 test_framebase_marginheight(fbase
, "1");
6122 test_framebase_marginwidth(fbase
, NULL
);
6123 set_framebase_marginwidth(fbase
, "2px");
6124 test_framebase_marginwidth(fbase
, "2");
6126 IHTMLFrameBase_Release(fbase
);
6129 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6130 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6135 if(pLCIDToLocaleName
) {
6136 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
6137 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
6138 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6140 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6141 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6145 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6146 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6148 IHTMLElementCollection
*col
;
6152 hres
= IHTMLTable_get_rows(table
, &col
);
6153 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6154 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6155 if (hres
!= S_OK
|| col
== NULL
)
6157 hres
= IHTMLElementCollection_get_length(col
, &len
);
6158 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6159 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
6161 IHTMLElementCollection_Release(col
);
6164 static void test_navigator(IHTMLDocument2
*doc
)
6166 IHTMLWindow2
*window
;
6167 IOmNavigator
*navigator
, *navigator2
;
6175 static const WCHAR v40
[] = {'4','.','0'};
6177 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6178 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6180 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6181 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6182 ok(navigator
!= NULL
, "navigator == NULL\n");
6183 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, NULL
, "[object]");
6185 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6186 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6187 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6188 IOmNavigator_Release(navigator2
);
6190 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6191 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6192 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6193 IOmNavigator_Release(navigator2
);
6195 IHTMLWindow2_Release(window
);
6197 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6198 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6199 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6200 SysFreeString(bstr
);
6203 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6204 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6205 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6206 SysFreeString(bstr
);
6209 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6210 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6211 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6212 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6213 SysFreeString(bstr
);
6216 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6217 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6218 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6219 SysFreeString(bstr
);
6222 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6223 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6224 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6225 SysFreeString(bstr
);
6228 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6229 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6230 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6231 SysFreeString(bstr
);
6233 if (pGetUserDefaultUILanguage
)
6236 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6237 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6238 test_language_string(bstr
, pGetUserDefaultUILanguage());
6239 SysFreeString(bstr
);
6242 win_skip("GetUserDefaultUILanguage not available\n");
6245 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6246 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6247 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6248 SysFreeString(bstr
);
6250 hres
= IOmNavigator_toString(navigator
, NULL
);
6251 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6254 hres
= IOmNavigator_toString(navigator
, &bstr
);
6255 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6256 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6257 SysFreeString(bstr
);
6260 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6261 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6262 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6265 hres
= ObtainUserAgentString(0, buf
, &size
);
6266 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6269 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6270 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6271 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6272 SysFreeString(bstr
);
6274 if(!strncmp(buf
, "Mozilla/", 8)) {
6276 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6277 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6278 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6279 SysFreeString(bstr
);
6281 skip("nonstandard user agent\n");
6285 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6286 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6287 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6288 SysFreeString(bstr
);
6290 test_mime_types_col(navigator
);
6292 ref
= IOmNavigator_Release(navigator
);
6293 ok(!ref
, "navigator should be destroyed here\n");
6296 static void test_screen(IHTMLWindow2
*window
)
6298 IHTMLScreen
*screen
, *screen2
;
6299 IDispatchEx
*dispex
;
6306 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6307 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6308 ok(screen
!= NULL
, "screen == NULL\n");
6311 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6312 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6313 ok(screen2
!= NULL
, "screen == NULL\n");
6314 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6315 IHTMLScreen_Release(screen2
);
6317 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6318 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6319 if(SUCCEEDED(hres
)) {
6320 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, NULL
, "[object]");
6321 IDispatchEx_Release(dispex
);
6324 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6326 exl
= GetDeviceCaps(hdc
, HORZRES
);
6328 hres
= IHTMLScreen_get_width(screen
, &l
);
6329 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6330 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6332 exl
= GetDeviceCaps(hdc
, VERTRES
);
6334 hres
= IHTMLScreen_get_height(screen
, &l
);
6335 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6336 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6338 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6340 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6341 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6342 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6346 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6349 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6350 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6351 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6354 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6355 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6356 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6358 IHTMLScreen_Release(screen
);
6361 static void test_default_selection(IHTMLDocument2
*doc
)
6363 IHTMLSelectionObject
*selection
;
6364 IHTMLTxtRange
*range
;
6368 test_doc_selection_type(doc
, "None");
6370 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6371 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6373 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6374 IHTMLSelectionObject_Release(selection
);
6375 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6377 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6378 IDispatch_Release(disp
);
6379 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6381 test_range_text(range
, NULL
);
6382 IHTMLTxtRange_Release(range
);
6385 static void test_doc_dir(IHTMLDocument2
*doc2
)
6387 IHTMLDocument3
*doc
= get_doc3_iface(doc2
);
6391 dir
= (BSTR
)0xdeadbeef;
6392 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6393 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6394 ok(!dir
, "dir = %s\n", wine_dbgstr_w(dir
));
6396 dir
= a2bstr("rtl");
6397 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6398 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6402 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6403 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6404 ok(!strcmp_wa(dir
, "rtl"), "dir = %s\n", wine_dbgstr_w(dir
));
6407 dir
= a2bstr("ltr");
6408 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6409 ok(hres
== S_OK
, "put_dir failed: %08x\n", hres
);
6413 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6414 ok(hres
== S_OK
, "get_dir failed: %08x\n", hres
);
6415 ok(!strcmp_wa(dir
, "ltr"), "dir = %s\n", wine_dbgstr_w(dir
));
6418 IHTMLDocument3_Release(doc
);
6421 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6423 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6424 IHTMLUniqueName
*unique_name
;
6430 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6432 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6433 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6434 ok(SysStringLen(id
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6436 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6437 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6438 ok(SysStringLen(id2
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6440 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6442 id
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6443 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6444 id2
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6445 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6450 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6451 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6453 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6454 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6456 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6457 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6458 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6460 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6461 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6462 ok(num
, "num = 0\n");
6464 sprintf(buf
, "ms__id%u", num
);
6465 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6470 IHTMLUniqueName_Release(unique_name
);
6471 IHTMLDocument3_Release(doc3
);
6474 static void test_doc_elem(IHTMLDocument2
*doc
)
6476 IHTMLDocument2
*doc_node
, *owner_doc
;
6478 IHTMLDocument3
*doc3
;
6482 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6483 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6485 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6486 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6487 ok(!strcmp_wa(bstr
, "[object]"),
6488 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6489 SysFreeString(bstr
);
6491 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6492 IHTMLDocument3_Release(doc3
);
6493 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6495 test_node_name((IUnknown
*)elem
, "HTML");
6496 test_elem_tag((IUnknown
*)elem
, "HTML");
6497 test_elem_set_outertext_fail(elem
);
6499 doc_node
= get_doc_node(doc
);
6500 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6501 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6502 IHTMLDocument2_Release(owner_doc
);
6504 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6505 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6506 IHTMLDocument2_Release(doc_node
);
6508 test_elem_client_rect((IUnknown
*)elem
);
6509 test_unique_id(doc
, elem
);
6512 IHTMLElement_Release(elem
);
6515 static void test_default_body(IHTMLBodyElement
*body
)
6522 bstr
= (void*)0xdeadbeef;
6523 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6524 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6525 ok(bstr
== NULL
, "bstr != NULL\n");
6527 l
= elem_get_scroll_height((IUnknown
*)body
);
6528 ok(l
!= -1, "scrollHeight == -1\n");
6529 l
= elem_get_scroll_width((IUnknown
*)body
);
6530 ok(l
!= -1, "scrollWidth == -1\n");
6531 l
= elem_get_scroll_top((IUnknown
*)body
);
6532 ok(!l
, "scrollTop = %d\n", l
);
6533 elem_get_scroll_left((IUnknown
*)body
);
6535 test_elem_dir((IUnknown
*)body
, NULL
);
6536 set_elem_dir((IUnknown
*)body
, "ltr");
6538 /* get_text tests */
6539 hres
= IHTMLBodyElement_get_text(body
, &v
);
6540 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6541 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6542 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6544 /* get_text - Invalid Text */
6546 V_BSTR(&v
) = a2bstr("Invalid");
6547 hres
= IHTMLBodyElement_put_text(body
, v
);
6548 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6552 hres
= IHTMLBodyElement_get_text(body
, &v
);
6553 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6554 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6555 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6558 /* get_text - Valid Text */
6560 V_BSTR(&v
) = a2bstr("#FF0000");
6561 hres
= IHTMLBodyElement_put_text(body
, v
);
6562 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6566 hres
= IHTMLBodyElement_get_text(body
, &v
);
6567 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6568 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6569 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6573 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6574 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6579 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6580 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6581 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6585 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6586 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6588 BSTR str
= a2bstr(val
);
6591 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6592 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6595 _test_body_scroll(line
, body
, val
);
6598 static void test_body_funs(IHTMLBodyElement
*body
)
6600 VARIANT vbg
, vDefaultbg
;
6603 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6604 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6605 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6606 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6608 V_VT(&vbg
) = VT_BSTR
;
6609 V_BSTR(&vbg
) = a2bstr("red");
6610 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6611 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6614 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6615 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6616 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6617 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6620 /* Restore Original */
6621 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6622 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6623 VariantClear(&vDefaultbg
);
6625 test_body_scroll(body
, NULL
);
6626 set_body_scroll(body
, "yes");
6627 set_body_scroll(body
, "no");
6628 set_body_scroll(body
, "auto");
6631 static void test_history(IHTMLWindow2
*window
)
6633 IOmHistory
*history
, *history2
;
6637 hres
= IHTMLWindow2_get_history(window
, &history
);
6638 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6639 ok(history
!= NULL
, "history = NULL\n");
6641 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, NULL
, "[object]");
6644 hres
= IHTMLWindow2_get_history(window
, &history2
);
6645 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6646 ok(history2
!= NULL
, "history2 = NULL\n");
6647 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6649 IOmHistory_Release(history2
);
6650 IOmHistory_Release(history
);
6653 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6657 IHTMLXMLHttpRequestFactory
*factory
;
6658 IHTMLXMLHttpRequest
*xml
;
6660 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6661 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6662 ok(V_VT(&var
) == VT_DISPATCH
, "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6665 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6666 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6667 ok(factory
!= NULL
, "factory == NULL\n");
6670 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6671 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6672 ok(xml
!= NULL
, "xml == NULL\n");
6673 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, &CLSID_HTMLXMLHttpRequest
, "[object]");
6675 IHTMLXMLHttpRequest_Release(xml
);
6676 IHTMLXMLHttpRequestFactory_Release(factory
);
6680 static void test_window(IHTMLDocument2
*doc
)
6682 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6683 IHTMLWindow5
*window5
;
6684 IHTMLDocument2
*doc2
= NULL
;
6691 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6692 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6693 test_ifaces((IUnknown
*)window
, window_iids
);
6694 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6696 IUnknown_Release(unk
);
6698 win_skip("IID_ITravelLogClient not supported\n");
6700 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, &CLSID_HTMLWindow2
, "[object]");
6702 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6703 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6704 ok(doc2
!= NULL
, "doc2 == NULL\n");
6706 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6707 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6709 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6710 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
6712 unk
= (void*)0xdeadbeef;
6713 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6714 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6715 ok(!unk
, "unk = %p\n", unk
);
6717 IHTMLDocument2_Release(doc2
);
6719 hres
= IHTMLWindow2_get_window(window
, &window2
);
6720 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6721 ok(window2
!= NULL
, "window2 == NULL\n");
6723 hres
= IHTMLWindow2_get_self(window
, &self
);
6724 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6725 ok(window2
!= NULL
, "self == NULL\n");
6727 ok(self
== window2
, "self != window2\n");
6729 IHTMLWindow2_Release(window2
);
6732 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6733 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6734 ok(disp
== (void*)window
, "disp != window\n");
6735 IDispatch_Release(disp
);
6737 hres
= IHTMLWindow2_toString(window
, NULL
);
6738 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6741 hres
= IHTMLWindow2_toString(window
, &str
);
6742 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6743 ok(!strcmp_wa(str
, "[object]") ||
6744 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6747 V_VT(&v
) = VT_ERROR
;
6748 hres
= IHTMLWindow2_get_opener(window
, &v
);
6749 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6750 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6753 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6754 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6755 ok(parent
!= NULL
, "parent == NULL\n");
6756 ok(parent
== self
, "parent != window\n");
6757 IHTMLWindow2_Release(parent
);
6758 IHTMLWindow2_Release(self
);
6760 test_window_name(window
, NULL
);
6761 set_window_name(window
, "test");
6762 test_window_length(window
, 0);
6763 test_screen(window
);
6764 test_window_status(window
);
6765 set_window_status(window
, "Test!");
6766 test_history(window
);
6768 hres
= IHTMLWindow2_moveBy(window
, 0, 0);
6769 ok(hres
== S_FALSE
, "moveBy failed: %08x\n", hres
);
6771 hres
= IHTMLWindow2_resizeBy(window
, 0, 0);
6772 ok(hres
== S_FALSE
, "resizeBy failed: %08x\n", hres
);
6774 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6775 if(SUCCEEDED(hres
)) {
6776 ok(window5
!= NULL
, "window5 == NULL\n");
6777 test_xmlhttprequest(window5
);
6778 IHTMLWindow5_Release(window5
);
6780 win_skip("IHTMLWindow5 not supported!\n");
6783 IHTMLWindow2_Release(window
);
6786 static void test_dom_implementation(IHTMLDocument2
*doc
)
6788 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6789 IHTMLDOMImplementation
*dom_implementation
;
6795 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6796 IHTMLDocument5_Release(doc5
);
6797 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6798 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6800 str
= a2bstr("test");
6802 V_BSTR(&v
) = a2bstr("1.0");
6804 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6807 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6808 ok(!b
, "hasFeature returned %x\n", b
);
6810 IHTMLDOMImplementation_Release(dom_implementation
);
6813 static void test_xhr(IHTMLDocument2
*doc
)
6815 IHTMLWindow2
*window
;
6816 IDispatchEx
*dispex
;
6821 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6822 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6824 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6825 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6827 str
= a2bstr("XMLHttpRequest");
6828 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6829 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6832 IHTMLWindow2_Release(window
);
6835 static void test_defaults(IHTMLDocument2
*doc
)
6837 IHTMLStyleSheetsCollection
*stylesheetcol
;
6838 IHTMLCurrentStyle
*cstyle
;
6839 IHTMLBodyElement
*body
;
6840 IHTMLElement2
*elem2
;
6848 IHTMLElementCollection
*collection
;
6850 elem
= doc_get_body(doc
);
6852 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6853 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6855 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6856 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6859 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6860 IHTMLElementCollection_Release(collection
);
6863 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6864 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6866 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6867 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6870 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6871 IHTMLElementCollection_Release(collection
);
6874 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6875 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6877 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6878 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6881 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6882 IHTMLElementCollection_Release(collection
);
6885 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6886 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6888 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6889 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6892 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6893 IHTMLElementCollection_Release(collection
);
6896 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6897 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6899 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6900 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6903 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6904 IHTMLElementCollection_Release(collection
);
6909 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6910 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6911 test_default_body(body
);
6912 test_body_funs(body
);
6913 IHTMLBodyElement_Release(body
);
6915 test_elem_set_outertext_fail(elem
);
6917 test_elem_istextedit(elem
, VARIANT_TRUE
);
6919 hres
= IHTMLElement_get_style(elem
, &style
);
6920 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6922 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, NULL
, "[object]");
6923 test_ifaces((IUnknown
*)style
, style_iids
);
6924 IHTMLStyle_Release(style
);
6927 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6928 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6929 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6933 test_compatmode(doc
, "BackCompat");
6935 test_navigator(doc
);
6936 test_plugins_col(doc
);
6938 elem2
= get_elem2_iface((IUnknown
*)elem
);
6939 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6940 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6941 if(SUCCEEDED(hres
)) {
6944 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, NULL
, "[object]");
6945 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6947 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6949 IUnknown_Release(unk
);
6952 /*IE6 doesn't have interface */
6953 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6956 IHTMLCurrentStyle_Release(cstyle
);
6958 IHTMLElement2_Release(elem2
);
6960 IHTMLElement_Release(elem
);
6962 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6963 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6966 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6967 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6968 ok(l
== 0, "length = %d\n", l
);
6970 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6972 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6973 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6975 str
= a2bstr("xxx");
6977 V_VT(&v
) = VT_EMPTY
;
6978 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6979 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
6980 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
6983 str
= a2bstr("respectvisibilityindesign");
6986 V_BOOL(&v
) = VARIANT_TRUE
;
6987 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6988 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
6991 test_default_selection(doc
);
6992 test_doc_title(doc
, "");
6993 test_dom_implementation(doc
);
6996 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6997 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6999 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7003 str
= (void*)0xdeadbeef;
7004 hres
= IHTMLButtonElement_get_name(button
, &str
);
7005 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7007 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
7009 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
7011 IHTMLButtonElement_Release(button
);
7014 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
7015 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
7017 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7018 BSTR str
= a2bstr(name
);
7021 hres
= IHTMLButtonElement_put_name(button
, str
);
7022 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
7024 IHTMLButtonElement_Release(button
);
7026 _test_button_name(line
, elem
, name
);
7029 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
7030 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
7032 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7033 VARIANT_BOOL disabled
= 100;
7036 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
7037 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
7038 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
7039 IHTMLButtonElement_Release(button
);
7041 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
7044 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
7045 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
7047 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7050 hres
= IHTMLButtonElement_put_disabled(button
, b
);
7051 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
7052 IHTMLButtonElement_Release(button
);
7054 _test_button_get_disabled(line
, elem
, b
);
7057 #define test_button_type(a,b) _test_button_type(__LINE__,a,b)
7058 static void _test_button_type(unsigned line
, IHTMLElement
*elem
, const char *extype
)
7060 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7064 hres
= IHTMLButtonElement_get_type(button
, &str
);
7065 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7066 ok_(__FILE__
,line
)(!strcmp_wa(str
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(str
), extype
);
7069 IHTMLButtonElement_Release(button
);
7072 #define test_button_value(a,b) _test_button_value(__LINE__,a,b)
7073 static void _test_button_value(unsigned line
, IHTMLElement
*elem
, const char *exvalue
)
7075 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7079 hres
= IHTMLButtonElement_get_value(button
, &str
);
7080 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
7082 ok_(__FILE__
,line
)(!strcmp_wa(str
, exvalue
), "value = %s, expected %s\n", wine_dbgstr_w(str
), exvalue
);
7084 ok_(__FILE__
,line
)(!str
, "value = %s, expected NULL\n", wine_dbgstr_w(str
));
7087 IHTMLButtonElement_Release(button
);
7090 #define set_button_value(a,b) _set_button_value(__LINE__,a,b)
7091 static void _set_button_value(unsigned line
, IHTMLElement
*elem
, const char *value
)
7093 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7094 BSTR str
= a2bstr(value
);
7097 hres
= IHTMLButtonElement_put_value(button
, str
);
7098 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
7099 IHTMLButtonElement_Release(button
);
7102 _test_button_value(line
, elem
, value
);
7105 #define get_button_form(a) _get_button_form(__LINE__,a)
7106 static IHTMLFormElement
*_get_button_form(unsigned line
, IHTMLElement
*elem
)
7108 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7109 IHTMLFormElement
*form
;
7112 hres
= IHTMLButtonElement_get_form(button
, &form
);
7113 ok_(__FILE__
,line
)(hres
== S_OK
, "get_form failed: %08x\n", hres
);
7114 IHTMLButtonElement_Release(button
);
7119 static void test_button_elem(IHTMLElement
*elem
)
7121 IHTMLFormElement
*form
;
7123 test_button_name(elem
, NULL
);
7124 set_button_name(elem
, "button name");
7125 test_button_type(elem
, "submit");
7126 test_button_value(elem
, NULL
);
7127 set_button_value(elem
, "val");
7129 form
= get_button_form(elem
);
7130 ok(!form
, "form != NULL\n");
7132 test_elem_istextedit(elem
, VARIANT_TRUE
);
7135 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
7136 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
7137 IHTMLTableRow
*row
, LONG len
, const char *id
)
7139 IHTMLElementCollection
*col
;
7145 hres
= IHTMLTableRow_get_cells(row
, &col
);
7146 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7147 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
7149 hres
= IHTMLElementCollection_get_length(col
, &lval
);
7150 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
7151 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
7153 V_VT(&var
) = VT_BSTR
;
7154 V_BSTR(&var
) = a2bstr(id
);
7155 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
7156 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
7157 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
7160 IDispatch_Release(disp
);
7161 IHTMLElementCollection_Release(col
);
7164 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
7168 IHTMLTableCell
*cell
;
7170 hres
= IHTMLTableRow_deleteCell(row
, 0);
7171 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
7172 test_tr_possess(elem
, row
, 1, "td2");
7174 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
7175 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
7176 ok(disp
!= NULL
, "disp == NULL\n");
7177 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
7178 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
7179 ok(cell
!= NULL
, "cell == NULL\n");
7180 if (SUCCEEDED(hres
))
7181 IHTMLTableCell_Release(cell
);
7182 test_tr_possess(elem
, row
, 2, "td2");
7183 IDispatch_Release(disp
);
7186 static void test_tr_elem(IHTMLElement
*elem
)
7188 IHTMLElementCollection
*col
;
7193 VARIANT vbg
, vDefaultbg
;
7195 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
7197 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
7198 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7203 hres
= IHTMLTableRow_get_cells(row
, &col
);
7204 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
7205 ok(col
!= NULL
, "get_cells returned NULL\n");
7207 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
7208 IHTMLElementCollection_Release(col
);
7210 bstr
= a2bstr("left");
7211 hres
= IHTMLTableRow_put_align(row
, bstr
);
7212 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7213 SysFreeString(bstr
);
7216 hres
= IHTMLTableRow_get_align(row
, &bstr
);
7217 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7218 ok(bstr
!= NULL
, "get_align returned NULL\n");
7219 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7220 SysFreeString(bstr
);
7222 bstr
= a2bstr("top");
7223 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
7224 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
7225 SysFreeString(bstr
);
7228 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
7229 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
7230 ok(bstr
!= NULL
, "get_valign returned NULL\n");
7231 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
7232 SysFreeString(bstr
);
7235 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
7236 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7237 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
7240 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
7241 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
7242 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
7244 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
7245 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7246 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7247 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7249 V_VT(&vbg
) = VT_BSTR
;
7250 V_BSTR(&vbg
) = a2bstr("red");
7251 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7252 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7255 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7256 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7257 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7258 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7262 V_I4(&vbg
) = 0xff0000;
7263 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7264 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7267 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7268 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7269 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7270 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7273 /* Restore Original */
7274 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
7275 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7276 VariantClear(&vDefaultbg
);
7278 test_tr_modify(elem
, row
);
7280 IHTMLTableRow_Release(row
);
7283 static void test_td_elem(IHTMLDocument2
*doc
, IHTMLElement
*div
)
7285 IHTMLTableCell
*cell
;
7290 VARIANT vbg
, vDefaultbg
;
7292 test_elem_set_innerhtml((IUnknown
*)div
,
7293 "<table id=\"tbl\"><tbody>"
7295 " <tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td><td></td></tr>"
7297 "</tbody></table>");
7299 elem
= get_doc_elem_by_id(doc
, "td1");
7300 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7301 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7302 IHTMLElement_Release(elem
);
7305 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7306 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7307 ok(!lval
, "Expected 0, got %d\n", lval
);
7309 str
= a2bstr("left");
7310 hres
= IHTMLTableCell_put_align(cell
, str
);
7311 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7315 hres
= IHTMLTableCell_get_align(cell
, &str
);
7316 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7317 ok(str
!= NULL
, "str is NULL\n");
7318 if (str
!= NULL
&& hres
== S_OK
) {
7319 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7323 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7324 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7325 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7326 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7328 V_VT(&vbg
) = VT_BSTR
;
7329 V_BSTR(&vbg
) = a2bstr("red");
7330 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7331 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7334 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7335 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7336 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7337 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7341 V_I4(&vbg
) = 0xff0000;
7342 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7343 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7346 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7347 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7348 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7349 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7352 /* Restore Original */
7353 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7354 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7355 VariantClear(&vDefaultbg
);
7357 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7358 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7359 ok(lval
== 1, "rowSpan = %d\n", lval
);
7361 hres
= IHTMLTableCell_put_rowSpan(cell
, -1);
7362 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7364 hres
= IHTMLTableCell_put_rowSpan(cell
, 0);
7365 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7367 hres
= IHTMLTableCell_put_rowSpan(cell
, 2);
7368 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7370 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
7371 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7372 ok(lval
== 2, "rowSpan = %d\n", lval
);
7374 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7375 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7376 ok(lval
== 1, "rowSpan = %d\n", lval
);
7378 hres
= IHTMLTableCell_put_colSpan(cell
, -1);
7379 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7381 hres
= IHTMLTableCell_put_colSpan(cell
, 0);
7382 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08x\n", hres
);
7384 hres
= IHTMLTableCell_put_colSpan(cell
, 2);
7385 ok(hres
== S_OK
, "put_rowSpan failed: %08x\n", hres
);
7387 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
7388 ok(hres
== S_OK
, "get_rowSpan failed: %08x\n", hres
);
7389 ok(lval
== 2, "rowSpan = %d\n", lval
);
7391 IHTMLTableCell_Release(cell
);
7394 static void test_label_elem(IHTMLElement
*elem
)
7396 IHTMLLabelElement
*label
;
7400 label
= get_label_iface((IUnknown
*)elem
);
7403 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7404 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7405 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7409 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7410 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7413 str
= (void*)0xdeadbeef;
7414 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7415 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7416 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7419 str
= a2bstr("abc");
7420 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7421 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7425 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7426 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7427 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7430 IHTMLLabelElement_Release(label
);
7433 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7434 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7439 V_VT(&v
) = VT_ERROR
;
7440 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7441 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7442 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7444 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7446 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7450 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7451 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7456 V_VT(&v
) = VT_ERROR
;
7457 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7458 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7459 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7461 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7463 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7467 static void test_table_modify(IHTMLTable
*table
)
7474 test_table_length(table
, 2);
7476 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7477 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7478 ok(disp
!= NULL
, "disp == NULL\n");
7479 test_table_length(table
, 3);
7480 if (hres
!= S_OK
|| disp
== NULL
)
7483 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7484 IDispatch_Release(disp
);
7486 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7487 ok(row
!= NULL
, "row == NULL\n");
7490 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7491 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7492 ok(index
== 0, "index = %d, expected 0\n", index
);
7494 IHTMLTableRow_Release(row
);
7496 hres
= IHTMLTable_deleteRow(table
, 0);
7497 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7498 test_table_length(table
, 2);
7501 static void test_table_elem(IHTMLElement
*elem
)
7503 IHTMLElementCollection
*col
;
7505 IHTMLTable3
*table3
;
7510 VARIANT vbg
, vDefaultbg
;
7512 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7513 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7514 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7516 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7517 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7521 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7522 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7527 hres
= IHTMLTable_get_rows(table
, &col
);
7528 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7529 ok(col
!= NULL
, "get_rows returned NULL\n");
7531 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7532 IHTMLElementCollection_Release(col
);
7534 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7536 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7537 test_elem_tag((IUnknown
*)node
, "TABLE");
7538 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7539 IHTMLDOMNode_Release(node
);
7541 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7542 test_elem_tag((IUnknown
*)node
, "TABLE");
7543 test_elem_all((IUnknown
*)node
, NULL
, 0);
7544 IHTMLDOMNode_Release(node
);
7547 hres
= IHTMLTable_get_tBodies(table
, &col
);
7548 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7549 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7551 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7552 IHTMLElementCollection_Release(col
);
7554 test_table_cell_spacing(table
, NULL
);
7558 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7559 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7560 test_table_cell_spacing(table
, "10");
7563 V_BSTR(&v
) = a2bstr("11");
7564 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7565 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7566 test_table_cell_spacing(table
, "11");
7569 test_table_cell_padding(table
, NULL
);
7573 hres
= IHTMLTable_put_cellPadding(table
, v
);
7574 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7575 test_table_cell_padding(table
, "10");
7578 V_BSTR(&v
) = a2bstr("11");
7579 hres
= IHTMLTable_put_cellPadding(table
, v
);
7580 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7581 test_table_cell_padding(table
, "11");
7586 hres
= IHTMLTable_put_cellPadding(table
, v
);
7587 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7588 test_table_cell_padding(table
, "5");
7590 bstr
= a2bstr("left");
7591 hres
= IHTMLTable_put_align(table
, bstr
);
7592 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7593 SysFreeString(bstr
);
7596 hres
= IHTMLTable_get_align(table
, &bstr
);
7597 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7598 ok(bstr
!= NULL
, "get_align returned NULL\n");
7599 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7600 SysFreeString(bstr
);
7602 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7603 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7604 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7605 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7607 V_VT(&vbg
) = VT_BSTR
;
7608 V_BSTR(&vbg
) = a2bstr("red");
7609 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7610 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7613 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7614 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7615 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7616 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7620 V_I4(&vbg
) = 0xff0000;
7621 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7622 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7625 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7626 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7627 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7628 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7631 /* Restore Original */
7632 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7633 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7634 VariantClear(&vDefaultbg
);
7637 V_BSTR(&v
) = a2bstr("11");
7638 hres
= IHTMLTable_put_width(table
, v
);
7639 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7641 hres
= IHTMLTable_get_width(table
, &v
);
7642 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7643 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7647 V_BSTR(&v
) = a2bstr("11.9");
7648 hres
= IHTMLTable_put_width(table
, v
);
7649 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7651 hres
= IHTMLTable_get_width(table
, &v
);
7652 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7653 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7657 V_BSTR(&v
) = a2bstr("40.2%");
7658 hres
= IHTMLTable_put_width(table
, v
);
7659 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7661 hres
= IHTMLTable_get_width(table
, &v
);
7662 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7663 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7668 hres
= IHTMLTable_put_width(table
, v
);
7669 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7670 hres
= IHTMLTable_get_width(table
, &v
);
7671 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7672 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7677 hres
= IHTMLTable_put_width(table
, v
);
7678 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7679 hres
= IHTMLTable_get_width(table
, &v
);
7680 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7681 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7684 bstr
= a2bstr("box");
7685 hres
= IHTMLTable_put_frame(table
, bstr
);
7686 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7687 SysFreeString(bstr
);
7688 hres
= IHTMLTable_get_frame(table
, &bstr
);
7689 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7690 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7691 SysFreeString(bstr
);
7693 test_table_modify(table
);
7694 bstr
= a2bstr("summary");
7695 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7696 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7697 SysFreeString(bstr
);
7699 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7700 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7701 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7702 SysFreeString(bstr
);
7704 IHTMLTable3_Release(table3
);
7705 IHTMLTable_Release(table
);
7708 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7717 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7718 SafeArrayAccessData(sa
, (void**)&var
);
7719 V_VT(var
) = VT_BSTR
;
7720 V_BSTR(var
) = a2bstr(text
);
7721 SafeArrayUnaccessData(sa
);
7724 hres
= IHTMLDocument2_writeln(doc
, sa
);
7726 hres
= IHTMLDocument2_write(doc
, sa
);
7727 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7729 SafeArrayDestroy(sa
);
7732 static void doc_complex_write(IHTMLDocument2
*doc
)
7734 SAFEARRAYBOUND dim
= {5, 0};
7739 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7740 SafeArrayAccessData(sa
, (void**)&args
);
7742 V_VT(args
) = VT_BSTR
;
7743 V_BSTR(args
) = a2bstr("<body i4val=\"");
7744 V_VT(args
+1) = VT_I4
;
7746 V_VT(args
+2) = VT_BSTR
;
7747 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7748 V_VT(args
+3) = VT_R8
;
7749 V_R8(args
+3) = 3.14;
7750 V_VT(args
+4) = VT_BSTR
;
7751 V_BSTR(args
+4) = a2bstr("\">");
7752 SafeArrayUnaccessData(sa
);
7754 hres
= IHTMLDocument2_write(doc
, sa
);
7755 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7757 SafeArrayDestroy(sa
);
7760 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7762 IHTMLDocument2
*window_doc
, *elem_doc
;
7763 IHTMLFrameElement3
*frame_elem3
;
7764 IHTMLWindow2
*content_window
;
7767 content_window
= get_frame_content_window(frame_elem
);
7768 test_ifaces((IUnknown
*)content_window
, window_iids
);
7769 window_doc
= get_window_doc(content_window
);
7770 IHTMLWindow2_Release(content_window
);
7772 elem_doc
= get_elem_doc(frame_elem
);
7773 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7776 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7777 if(SUCCEEDED(hres
)) {
7778 IDispatch
*disp
= NULL
;
7780 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7781 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7782 ok(disp
!= NULL
, "contentDocument == NULL\n");
7783 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7785 IDispatch_Release(disp
);
7786 IHTMLFrameElement3_Release(frame_elem3
);
7788 win_skip("IHTMLFrameElement3 not supported\n");
7792 IHTMLDocument2_Release(elem_doc
);
7793 IHTMLDocument2_Release(window_doc
);
7796 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7797 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7799 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7803 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7804 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7805 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7807 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7809 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7811 IHTMLIFrameElement2_Release(iframe
);
7814 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7815 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7817 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7822 V_BSTR(&v
) = a2bstr(val
);
7823 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7824 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7826 IHTMLIFrameElement2_Release(iframe
);
7829 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7830 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7832 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7836 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7837 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7838 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7840 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7842 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7844 IHTMLIFrameElement2_Release(iframe
);
7847 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7848 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7850 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7855 V_BSTR(&v
) = a2bstr(val
);
7856 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7857 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7859 IHTMLIFrameElement2_Release(iframe
);
7862 static void test_iframe_elem(IHTMLElement
*elem
)
7864 IHTMLDocument2
*content_doc
, *owner_doc
;
7865 IHTMLIFrameElement3
*iframe3
;
7866 IHTMLElementCollection
*col
;
7867 IHTMLWindow2
*content_window
;
7874 static const elem_type_t all_types
[] = {
7882 test_frame_doc((IUnknown
*)elem
, TRUE
);
7883 test_framebase((IUnknown
*)elem
);
7885 content_window
= get_frame_content_window((IUnknown
*)elem
);
7886 test_ifaces((IUnknown
*)content_window
, window_iids
);
7887 test_window_length(content_window
, 0);
7889 content_doc
= get_window_doc(content_window
);
7890 IHTMLWindow2_Release(content_window
);
7892 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7893 if(SUCCEEDED(hres
)) {
7894 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7895 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7896 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7897 IDispatch_Release(disp
);
7899 IHTMLIFrameElement3_Release(iframe3
);
7901 win_skip("IHTMLIFrameElement3 not supported\n");
7904 test_iframe_height(elem
, NULL
);
7905 set_iframe_height(elem
, "100px");
7906 set_iframe_height(elem
, "50%");
7907 test_iframe_height(elem
, "50%");
7909 test_iframe_width(elem
, NULL
);
7910 set_iframe_width(elem
, "150px");
7911 set_iframe_width(elem
, "70%");
7912 test_iframe_width(elem
, "70%");
7913 test_framebase_src(elem
, "about:blank");
7915 str
= a2bstr("text/html");
7916 V_VT(&errv
) = VT_ERROR
;
7918 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7920 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7921 ok(disp
!= NULL
, "disp == NULL\n");
7922 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7923 IDispatch_Release(disp
);
7925 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7926 doc_complex_write(content_doc
);
7927 doc_write(content_doc
, TRUE
, "<br />");
7928 doc_write(content_doc
, TRUE
, "</html>");
7930 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7931 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7932 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7933 IHTMLElementCollection_Release(col
);
7935 body
= doc_get_body(content_doc
);
7936 test_elem_attr(body
, "i4val", "4");
7937 test_elem_attr(body
, "r8val", "3.14");
7938 IHTMLElement_Release(body
);
7940 hres
= IHTMLDocument2_close(content_doc
);
7941 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7943 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7944 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7946 IHTMLDocument2_Release(content_doc
);
7949 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7950 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7955 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7956 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7957 todo_wine_if(is_todo
) {
7959 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7961 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7967 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
7968 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7970 BSTR str
= a2bstr(csstext
);
7973 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7974 todo_wine_if(is_todo
)
7975 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7979 static void test_stylesheet(IDispatch
*disp
)
7981 IHTMLStyleSheetRulesCollection
*col
= NULL
;
7982 IHTMLStyleSheet
*stylesheet
;
7986 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, "[object]");
7988 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
7989 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
7991 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
7992 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
7993 ok(col
!= NULL
, "col == NULL\n");
7995 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, NULL
, "[object]");
7996 IHTMLStyleSheetRulesCollection_Release(col
);
7998 href
= (void*)0xdeadbeef;
7999 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
8000 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
8001 ok(href
== NULL
, "got href != NULL\n");
8002 SysFreeString(href
);
8004 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
8005 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
8006 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
8007 set_stylesheet_csstext(stylesheet
, "", FALSE
);
8008 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
8009 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
8010 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
8012 IHTMLStyleSheet_Release(stylesheet
);
8015 static void test_stylesheets(IHTMLDocument2
*doc
)
8017 IHTMLStyleSheetsCollection
*col
= NULL
;
8022 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
8023 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
8024 ok(col
!= NULL
, "col == NULL\n");
8026 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, NULL
, "[object]");
8028 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
8029 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8030 ok(len
== 1, "len=%d\n", len
);
8036 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8037 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
8038 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8039 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8040 test_stylesheet(V_DISPATCH(&res
));
8047 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8048 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8049 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
8052 IHTMLStyleSheetsCollection_Release(col
);
8055 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
8057 IDispatchEx
*dispex
;
8059 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
8067 static const WCHAR w0
[] = {'0',0};
8068 static const WCHAR w100
[] = {'1','0','0',0};
8070 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
8071 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
8073 bstr
= SysAllocString(w0
);
8074 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8075 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8076 SysFreeString(bstr
);
8079 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
8080 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
8081 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
8082 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
8083 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
8084 type
= get_node_type((IUnknown
*)node
);
8085 ok(type
== 3, "type=%d\n", type
);
8086 IHTMLDOMNode_Release(node
);
8089 bstr
= SysAllocString(w100
);
8090 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
8091 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
8092 SysFreeString(bstr
);
8094 IDispatchEx_Release(dispex
);
8097 static void test_enum_children(IUnknown
*unk
, unsigned len
)
8099 IEnumVARIANT
*enum_var
;
8104 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
8105 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
8107 for(i
=0; i
<len
; i
++) {
8109 V_VT(&v
) = VT_ERROR
;
8110 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
8111 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
8113 ok(fetched
== 1, "fetched = %d\n", fetched
);
8114 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
8115 IDispatch_Release(V_DISPATCH(&v
));
8118 fetched
= 0xdeadbeef;
8120 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
8121 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
8122 ok(fetched
== 0, "fetched = %d\n", fetched
);
8123 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8125 hres
= IEnumVARIANT_Reset(enum_var
);
8126 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8128 fetched
= 0xdeadbeef;
8130 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
8131 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
8132 ok(fetched
== 0, "fetched = %d\n", fetched
);
8133 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
8135 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
8136 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
8138 hres
= IEnumVARIANT_Reset(enum_var
);
8139 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
8141 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
8142 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
8144 IEnumVARIANT_Release(enum_var
);
8147 static void test_selectors(IHTMLDocument2
*doc
, IHTMLElement
*div
)
8149 IHTMLDOMChildrenCollection
*collection
;
8150 IDocumentSelector
*doc_selector
;
8151 IElementSelector
*elem_selector
;
8155 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8157 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentSelector
, (void**)&doc_selector
);
8158 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDocumentSelector iface: %08x\n", hres
);
8160 win_skip("IDocumentSelector tests skipped.\n");
8165 str
= a2bstr("nomatch");
8166 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8167 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8168 ok(collection
!= NULL
, "collection == NULL\n");
8169 test_children_collection_length(collection
, 0);
8170 IHTMLDOMChildrenCollection_Release(collection
);
8174 str
= a2bstr(".cl1");
8175 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
8176 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8177 ok(collection
!= NULL
, "collection == NULL\n");
8178 test_children_collection_length(collection
, 2);
8179 IHTMLDOMChildrenCollection_Release(collection
);
8182 IDocumentSelector_Release(doc_selector
);
8184 hres
= IHTMLElement_QueryInterface(div
, &IID_IElementSelector
, (void**)&elem_selector
);
8185 ok(hres
== S_OK
, "Could not get IElementSelector iface: %08x\n", hres
);
8188 str
= a2bstr("nomatch");
8189 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8190 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8191 ok(collection
!= NULL
, "collection == NULL\n");
8192 test_children_collection_length(collection
, 0);
8193 IHTMLDOMChildrenCollection_Release(collection
);
8197 str
= a2bstr(".cl1");
8198 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
8199 ok(hres
== S_OK
, "querySelectorAll failed: %08x\n", hres
);
8200 ok(collection
!= NULL
, "collection == NULL\n");
8201 test_children_collection_length(collection
, 2);
8202 IHTMLDOMChildrenCollection_Release(collection
);
8205 IElementSelector_Release(elem_selector
);
8208 static void test_elemsbyclass(IHTMLElement
*div
)
8210 IHTMLElementCollection
*collection
;
8211 IHTMLElement6
*elem
;
8215 static const elem_type_t types
[] = {ET_DIV
, ET_FORM
};
8217 test_elem_set_innerhtml((IUnknown
*)div
, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
8219 hres
= IHTMLElement_QueryInterface(div
, &IID_IHTMLElement6
, (void**)&elem
);
8220 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IHTMLElement6 iface: %08x\n", hres
);
8222 win_skip("IHTMLElement6 tests skipped.\n");
8227 str
= a2bstr("nomatch");
8228 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8229 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8230 ok(collection
!= NULL
, "collection == NULL\n");
8231 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
8232 IHTMLElementCollection_Release(collection
);
8236 str
= a2bstr("cl1");
8237 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
8238 ok(hres
== S_OK
, "getElementsByClassName failed: %08x\n", hres
);
8239 ok(collection
!= NULL
, "collection == NULL\n");
8240 test_elem_collection((IUnknown
*)collection
, types
, sizeof(types
)/sizeof(*types
));
8241 IHTMLElementCollection_Release(collection
);
8244 IHTMLElement6_Release(elem
);
8247 static void test_elems(IHTMLDocument2
*doc
)
8249 IHTMLElementCollection
*col
;
8250 IHTMLDOMChildrenCollection
*child_col
;
8251 IHTMLElement
*elem
, *elem2
, *elem3
;
8252 IHTMLDOMNode
*node
, *node2
;
8253 IHTMLWindow2
*window
;
8257 IHTMLElementCollection
*collection
;
8258 IHTMLDocument3
*doc3
;
8261 static const elem_type_t all_types
[] = {
8294 static const elem_type_t item_types
[] = {
8300 hres
= IHTMLDocument2_get_all(doc
, &col
);
8301 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8302 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8303 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
8305 elem
= get_elem_col_item_idx(col
, 0);
8306 test_elem_source_index(elem
, 0);
8307 IHTMLElement_Release(elem
);
8309 elem
= get_elem_col_item_idx(col
, 3);
8310 test_elem_source_index(elem
, 3);
8311 IHTMLElement_Release(elem
);
8313 IHTMLElementCollection_Release(col
);
8315 hres
= IHTMLDocument2_get_images(doc
, &collection
);
8316 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
8319 static const elem_type_t images_types
[] = {ET_IMG
};
8320 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8322 IHTMLElementCollection_Release(collection
);
8325 hres
= IHTMLDocument2_get_links(doc
, &collection
);
8326 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
8329 static const elem_type_t images_types
[] = {ET_A
};
8330 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
8332 IHTMLElementCollection_Release(collection
);
8335 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
8336 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
8339 static const elem_type_t anchor_types
[] = {ET_A
};
8340 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
8342 IHTMLElementCollection_Release(collection
);
8345 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
8346 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
8348 static const elem_type_t script_types
[] = {ET_SCRIPT
};
8349 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
8350 IHTMLElementCollection_Release(collection
);
8353 test_plugins_col(doc
);
8355 elem
= get_doc_elem(doc
);
8356 test_elem_istextedit(elem
, VARIANT_FALSE
);
8357 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
8358 IHTMLElement_Release(elem
);
8360 get_elem_by_id(doc
, "xxx", FALSE
);
8361 elem
= get_doc_elem_by_id(doc
, "xxx");
8362 ok(!elem
, "elem != NULL\n");
8364 elem
= get_doc_elem_by_id(doc
, "s");
8365 ok(elem
!= NULL
, "elem == NULL\n");
8367 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
8368 test_elem_attr(elem
, "xxx", NULL
);
8369 test_elem_attr(elem
, "id", "s");
8370 test_elem_class((IUnknown
*)elem
, NULL
);
8371 test_elem_set_class((IUnknown
*)elem
, "cl");
8372 test_elem_set_class((IUnknown
*)elem
, NULL
);
8373 test_elem_tabindex((IUnknown
*)elem
, 0);
8374 test_elem_set_tabindex((IUnknown
*)elem
, 1);
8375 test_elem_filters((IUnknown
*)elem
);
8376 test_elem_istextedit(elem
, VARIANT_FALSE
);
8378 node
= test_node_get_parent((IUnknown
*)elem
);
8379 ok(node
!= NULL
, "node == NULL\n");
8380 test_node_name((IUnknown
*)node
, "BODY");
8381 node2
= test_node_get_parent((IUnknown
*)node
);
8382 IHTMLDOMNode_Release(node
);
8383 ok(node2
!= NULL
, "node == NULL\n");
8384 test_node_name((IUnknown
*)node2
, "HTML");
8385 node
= test_node_get_parent((IUnknown
*)node2
);
8386 IHTMLDOMNode_Release(node2
);
8387 ok(node
!= NULL
, "node == NULL\n");
8390 test_node_name((IUnknown
*)node
, "#document");
8391 type
= get_node_type((IUnknown
*)node
);
8392 ok(type
== 9, "type=%d, expected 9\n", type
);
8393 node2
= test_node_get_parent((IUnknown
*)node
);
8394 IHTMLDOMNode_Release(node
);
8395 ok(node2
== NULL
, "node != NULL\n");
8398 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8399 ok(elem2
!= NULL
, "elem2 == NULL\n");
8400 test_node_name((IUnknown
*)elem2
, "BODY");
8402 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
8403 ok(elem3
!= NULL
, "elem3 == NULL\n");
8404 test_node_name((IUnknown
*)elem3
, "HTML");
8406 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
8407 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
8408 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
8409 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
8410 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
8411 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
8412 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
8413 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
8414 IHTMLElement_Release(elem2
);
8416 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
8417 ok(elem2
== NULL
, "elem2 != NULL\n");
8418 test_elem_source_index(elem3
, 0);
8419 IHTMLElement_Release(elem3
);
8421 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
8422 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
8423 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
8425 test_elem_innertext(elem
, "opt1opt2");
8427 IHTMLElement_Release(elem
);
8430 elem
= get_elem_by_id(doc
, "s", TRUE
);
8432 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8433 IHTMLDocument2
*doc_node
, *elem_doc
;
8435 test_select_elem(select
);
8437 test_elem_istextedit(elem
, VARIANT_FALSE
);
8438 test_elem_title((IUnknown
*)select
, NULL
);
8439 test_elem_set_title((IUnknown
*)select
, "Title");
8440 test_elem_title((IUnknown
*)select
, "Title");
8441 test_elem_offset((IUnknown
*)select
, "BODY");
8442 test_elem_bounding_client_rect((IUnknown
*)select
);
8444 node
= get_first_child((IUnknown
*)select
);
8445 ok(node
!= NULL
, "node == NULL\n");
8447 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8448 IHTMLDOMNode_Release(node
);
8451 type
= get_node_type((IUnknown
*)select
);
8452 ok(type
== 1, "type=%d\n", type
);
8454 IHTMLSelectElement_Release(select
);
8456 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8458 doc_node
= get_doc_node(doc
);
8459 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8460 IHTMLDocument2_Release(doc_node
);
8461 IHTMLDocument2_Release(elem_doc
);
8463 IHTMLElement_Release(elem
);
8466 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8468 IHTMLScriptElement
*script
;
8471 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8472 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8474 test_elem_language(elem
, NULL
);
8475 test_elem_istextedit(elem
, VARIANT_FALSE
);
8481 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8482 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8483 hres
= IHTMLScriptElement_get_type(script
, &type
);
8484 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8485 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8487 type
= a2bstr("text/javascript");
8488 hres
= IHTMLScriptElement_put_type (script
, type
);
8489 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8490 SysFreeString(type
);
8491 hres
= IHTMLScriptElement_get_type(script
, &type
);
8492 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8493 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8494 SysFreeString(type
);
8496 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8499 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8500 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8502 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8503 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8504 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8506 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8507 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8509 str
= (BSTR
)0xdeadbeef;
8510 hres
= IHTMLScriptElement_get_src(script
, &str
);
8511 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8512 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8515 IHTMLScriptElement_Release(script
);
8517 set_elem_language(elem
, "vbscript");
8518 set_elem_language(elem
, "xxx");
8521 elem
= get_elem_by_id(doc
, "in", TRUE
);
8523 IHTMLInputElement
*input
;
8525 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8526 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8528 test_elem_id((IUnknown
*)elem
, "in");
8529 test_elem_put_id((IUnknown
*)elem
, "newin");
8530 test_input_get_disabled(input
, VARIANT_FALSE
);
8531 test_input_set_disabled(input
, VARIANT_TRUE
);
8532 test_input_set_disabled(input
, VARIANT_FALSE
);
8533 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8534 test_input_get_disabled(input
, VARIANT_TRUE
);
8535 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8536 test_input_get_disabled(input
, VARIANT_FALSE
);
8537 test_elem_client_size((IUnknown
*)elem
);
8538 test_input_type(input
, "text");
8539 test_elem_istextedit(elem
, VARIANT_TRUE
);
8541 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8542 test_node_put_value_str((IUnknown
*)elem
, "test");
8543 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8544 test_input_value((IUnknown
*)elem
, NULL
);
8545 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8546 test_input_put_value((IUnknown
*)elem
, "test");
8547 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8548 test_elem_class((IUnknown
*)elem
, "testclass");
8549 test_elem_tabindex((IUnknown
*)elem
, 2);
8550 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8551 test_elem_title((IUnknown
*)elem
, "test title");
8553 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8554 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8555 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8557 test_input_get_checked(input
, VARIANT_FALSE
);
8558 test_input_set_checked(input
, VARIANT_TRUE
);
8559 test_input_set_checked(input
, VARIANT_FALSE
);
8561 test_input_maxlength(input
, 0x7fffffff);
8562 test_input_set_maxlength(input
, 30);
8564 test_input_name(input
, NULL
);
8565 test_input_set_name(input
, "test");
8567 test_input_src(input
, NULL
);
8568 test_input_set_src(input
, "about:blank");
8570 test_input_set_size(input
, 15, S_OK
);
8571 test_input_get_size(input
, 15);
8572 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8573 test_input_get_size(input
, 15);
8574 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8575 test_input_get_size(input
, 15);
8577 test_input_readOnly(input
, VARIANT_TRUE
);
8578 test_input_readOnly(input
, VARIANT_FALSE
);
8580 test_elem_lang(elem
, NULL
);
8581 set_elem_lang(elem
, "en-us");
8583 IHTMLInputElement_Release(input
);
8584 IHTMLElement_Release(elem
);
8587 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8589 test_img_align((IUnknown
*)elem
, "left");
8590 test_img_name((IUnknown
*)elem
, "WineImg");
8591 test_img_src((IUnknown
*)elem
, "", NULL
);
8592 test_img_set_src((IUnknown
*)elem
, "about:blank");
8593 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8594 test_img_alt((IUnknown
*)elem
, NULL
);
8595 test_img_set_alt((IUnknown
*)elem
, "alt test");
8596 test_img_name((IUnknown
*)elem
, "WineImg");
8597 test_img_complete(elem
, VARIANT_FALSE
);
8598 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8599 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8600 IHTMLElement_Release(elem
);
8603 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8605 test_dynamic_properties(elem
);
8606 test_attr_collection(elem
);
8607 test_contenteditable((IUnknown
*)elem
);
8608 IHTMLElement_Release(elem
);
8611 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8613 test_style_media((IUnknown
*)elem
, NULL
);
8614 test_style_put_media((IUnknown
*)elem
, "screen");
8615 test_style_type((IUnknown
*)elem
, NULL
);
8616 test_style_put_type((IUnknown
*)elem
, "text/css");
8617 IHTMLElement_Release(elem
);
8620 elem
= get_doc_elem_by_id(doc
, "tbl");
8621 ok(elem
!= NULL
, "elem == NULL\n");
8623 test_table_elem(elem
);
8624 IHTMLElement_Release(elem
);
8627 elem
= get_doc_elem_by_id(doc
, "labelid");
8628 ok(elem
!= NULL
, "elem == NULL\n");
8630 test_label_elem(elem
);
8631 IHTMLElement_Release(elem
);
8634 elem
= get_doc_elem_by_id(doc
, "row2");
8635 ok(elem
!= NULL
, "elem == NULL\n");
8638 IHTMLElement_Release(elem
);
8641 elem
= get_doc_elem_by_id(doc
, "ifr");
8642 ok(elem
!= NULL
, "elem == NULL\n");
8644 test_iframe_elem(elem
);
8645 IHTMLElement_Release(elem
);
8648 elem
= get_doc_elem_by_id(doc
, "btnid");
8649 ok(elem
!= NULL
, "elem == NULL\n");
8651 test_button_elem(elem
);
8652 test_button_get_disabled(elem
, VARIANT_FALSE
);
8653 test_button_set_disabled(elem
, VARIANT_TRUE
);
8654 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8655 test_button_get_disabled(elem
, VARIANT_FALSE
);
8656 IHTMLElement_Release(elem
);
8659 elem
= get_doc_elem_by_id(doc
, "objid");
8660 ok(elem
!= NULL
, "elem == NULL\n");
8662 test_object_vspace((IUnknown
*)elem
, 100);
8663 test_object_name(elem
, "objname");
8664 set_object_name(elem
, "test");
8665 set_object_name(elem
, NULL
);
8666 IHTMLElement_Release(elem
);
8669 elem
= get_elem_by_id(doc
, "a", TRUE
);
8671 test_anchor_href((IUnknown
*)elem
, "http://test/");
8673 /* Change the href */
8674 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8675 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8676 test_anchor_hostname((IUnknown
*)elem
, "test1");
8678 /* Restore the href */
8679 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8680 test_anchor_href((IUnknown
*)elem
, "http://test/");
8681 test_anchor_hostname((IUnknown
*)elem
, "test");
8682 test_anchor_hash(elem
, NULL
);
8685 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8687 test_anchor_rel((IUnknown
*)elem
, NULL
);
8688 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8689 test_anchor_rel((IUnknown
*)elem
, "Next");
8691 /* Change the target */
8692 test_anchor_put_target((IUnknown
*)elem
, "wine");
8693 test_anchor_get_target((IUnknown
*)elem
, "wine");
8695 /* Restore the target */
8696 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8697 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8699 test_anchor_name((IUnknown
*)elem
, "x");
8700 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8701 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8702 test_anchor_put_name((IUnknown
*)elem
, "x");
8704 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8705 test_anchor_hash(elem
, "#hash");
8706 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8708 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8709 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8710 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8711 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8713 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8714 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8716 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8717 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8719 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8720 as part of the pathname, and cannot be accessed by get_search. */
8721 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8722 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8724 IHTMLElement_Release(elem
);
8727 elem
= get_doc_elem_by_id(doc
, "metaid");
8729 test_meta_name((IUnknown
*)elem
, "meta name");
8730 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8731 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8732 test_meta_charset((IUnknown
*)elem
, NULL
);
8733 set_meta_charset((IUnknown
*)elem
, "utf-8");
8734 IHTMLElement_Release(elem
);
8737 elem
= doc_get_body(doc
);
8739 node
= get_first_child((IUnknown
*)elem
);
8740 ok(node
!= NULL
, "node == NULL\n");
8742 test_ifaces((IUnknown
*)node
, text_iids
);
8743 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
8745 node2
= get_first_child((IUnknown
*)node
);
8746 ok(!node2
, "node2 != NULL\n");
8748 type
= get_node_type((IUnknown
*)node
);
8749 ok(type
== 3, "type=%d\n", type
);
8751 test_node_get_value_str((IUnknown
*)node
, "text test");
8752 test_node_put_value_str((IUnknown
*)elem
, "test text");
8753 test_node_get_value_str((IUnknown
*)node
, "text test");
8755 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8756 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8757 ok(!disp
, "disp != NULL\n");
8759 IHTMLDOMNode_Release(node
);
8762 child_col
= get_child_nodes((IUnknown
*)elem
);
8763 ok(child_col
!= NULL
, "child_coll == NULL\n");
8768 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, NULL
, "[object]");
8769 length
= test_children_collection_length(child_col
, -1);
8772 node
= get_child_item(child_col
, 0);
8773 ok(node
!= NULL
, "node == NULL\n");
8777 type
= get_node_type((IUnknown
*)node
);
8778 ok(type
== 3, "type=%d\n", type
);
8779 node2
= node_get_next((IUnknown
*)node
);
8781 prev
= node_get_prev((IUnknown
*)node2
);
8782 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8783 IHTMLDOMNode_Release(prev
);
8785 IHTMLDOMNode_Release(node
);
8788 node
= get_child_item(child_col
, 1);
8789 ok(node
!= NULL
, "node == NULL\n");
8791 type
= get_node_type((IUnknown
*)node
);
8792 ok(type
== 8, "type=%d\n", type
);
8794 test_elem_id((IUnknown
*)node
, NULL
);
8795 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8796 IHTMLDOMNode_Release(node2
);
8797 IHTMLDOMNode_Release(node
);
8800 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8801 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8803 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8804 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8806 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8807 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8809 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8810 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8812 test_child_col_disp(child_col
);
8814 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8815 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8817 test_enum_children(enum_unk
, length
);
8819 IUnknown_Release(enum_unk
);
8821 IHTMLDOMChildrenCollection_Release(child_col
);
8824 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8825 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8826 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8828 IHTMLElement_Release(elem
);
8830 elem
= get_doc_elem_by_id(doc
, "frm");
8831 ok(elem
!= NULL
, "elem == NULL\n");
8833 test_form_length((IUnknown
*)elem
, 0);
8834 test_form_elements((IUnknown
*)elem
);
8835 IHTMLElement_Release(elem
);
8838 test_stylesheets(doc
);
8839 test_create_option_elem(doc
);
8840 test_create_img_elem(doc
);
8842 elem
= get_doc_elem_by_id(doc
, "tbl");
8843 ok(elem
!= NULL
, "elem = NULL\n");
8844 test_elem_set_innertext(elem
, "inner text");
8845 IHTMLElement_Release(elem
);
8847 test_doc_title(doc
, "test");
8848 test_doc_set_title(doc
, "test title");
8849 test_doc_title(doc
, "test title");
8852 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8853 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8856 IDispatchEx
*dispex
;
8857 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8858 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8862 BSTR str
= a2bstr("Testing");
8863 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8864 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8865 ok(pid
!= -1, "pid == -1\n");
8867 IDispatchEx_Release(dispex
);
8870 IDispatch_Release(disp
);
8872 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8874 elem
= get_doc_elem_by_id(doc
, "y");
8875 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8876 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8877 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8878 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8879 node
= node_get_next((IUnknown
*)elem
);
8880 ok(!node
, "node = %p\n", node
);
8882 elem2
= get_doc_elem_by_id(doc
, "x");
8883 test_elem_tag((IUnknown
*)elem2
, "A");
8884 node
= node_get_next((IUnknown
*)elem2
);
8885 IHTMLDOMNode_Release(node
);
8886 IHTMLElement_Release(elem2
);
8887 IHTMLElement_Release(elem
);
8889 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8890 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8892 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8893 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8895 IHTMLDocument3_Release(doc3
);
8897 elem
= get_elem_by_id(doc
, "s", TRUE
);
8899 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8901 test_select_put_length((IUnknown
*)elem
, 3);
8902 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8903 test_select_put_length((IUnknown
*)elem
, 1);
8904 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8905 IHTMLElement_Release(elem
);
8908 window
= get_doc_window(doc
);
8909 test_window_name(window
, NULL
);
8910 set_window_name(window
, "test name");
8911 test_window_length(window
, 1);
8912 IHTMLWindow2_Release(window
);
8915 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
8917 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
8918 IHTMLElement4
*elem4
;
8922 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8924 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8926 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
8927 test_ifaces((IUnknown
*)attr
, attr_iids
);
8928 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8929 test_attr_specified(attr
, VARIANT_TRUE
);
8930 test_attr_parent(attr
);
8932 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8933 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8934 IHTMLDOMAttribute_Release(attr2
);
8936 get_attr_node_value(attr
, &v
, VT_BSTR
);
8937 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8941 V_BSTR(&v
) = a2bstr("divid2");
8942 put_attr_node_value(attr
, v
);
8945 get_attr_node_value(attr
, &v
, VT_BSTR
);
8946 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8949 put_attr_value(attr
, "divid3");
8951 get_attr_node_value(attr
, &v
, VT_BSTR
);
8952 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8955 IHTMLDOMAttribute_Release(attr
);
8957 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8958 get_attr_node_value(attr
, &v
, VT_BSTR
);
8959 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8963 V_BSTR(&v
) = a2bstr("newvalue");
8964 put_attr_node_value(attr
, v
);
8967 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8968 get_attr_node_value(attr
, &v
, VT_BSTR
);
8969 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8972 test_attr_specified(attr
, VARIANT_TRUE
);
8973 IHTMLDOMAttribute_Release(attr
);
8977 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
8978 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
8979 get_attr_node_value(attr
, &v
, VT_I4
);
8980 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
8981 test_attr_specified(attr
, VARIANT_TRUE
);
8985 put_attr_node_value(attr
, v
);
8987 get_attr_node_value(attr
, &v
, VT_I4
);
8988 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
8990 put_attr_value(attr
, "160");
8991 get_attr_node_value(attr
, &v
, VT_BSTR
);
8992 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8995 IHTMLDOMAttribute_Release(attr
);
8997 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
8998 test_attr_specified(attr
, VARIANT_FALSE
);
8999 test_attr_expando(attr
, VARIANT_FALSE
);
9000 IHTMLDOMAttribute_Release(attr
);
9002 /* Test created, detached attribute. */
9003 attr
= create_attr((IUnknown
*)doc
, "Test");
9005 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, "[object]");
9006 test_ifaces((IUnknown
*)attr
, attr_iids
);
9007 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9009 test_attr_node_name(attr
, "Test");
9010 test_attr_expando(attr
, VARIANT_FALSE
);
9012 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9016 put_attr_node_value(attr
, v
);
9018 get_attr_node_value(attr
, &v
, VT_I4
);
9019 ok(V_I4(&v
) == 1, "nodeValue = %d\n", V_I4(&v
));
9020 test_attr_value(attr
, "1");
9022 V_VT(&v
) = VT_EMPTY
;
9023 put_attr_node_value(attr
, v
);
9024 get_attr_node_value(attr
, &v
, VT_EMPTY
);
9027 V_BSTR(&v
) = a2bstr("testing");
9028 put_attr_node_value(attr
, v
);
9029 SysFreeString(V_BSTR(&v
));
9030 test_attr_value(attr
, "testing");
9032 elem4
= get_elem4_iface((IUnknown
*)elem
);
9034 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
9035 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9036 ok(!attr2
, "attr2 != NULL\n");
9038 test_elem_attr(elem
, "Test", "testing");
9039 put_attr_value(attr
, "new value");
9040 test_elem_attr(elem
, "Test", "new value");
9042 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9043 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9044 IHTMLDOMAttribute_Release(attr2
);
9046 attr3
= create_attr((IUnknown
*)doc
, "Test");
9047 put_attr_value(attr3
, "replace test");
9049 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9050 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
9051 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
9052 IHTMLDOMAttribute_Release(attr2
);
9054 test_elem_attr(elem
, "Test", "replace test");
9055 test_attr_value(attr
, "new value");
9056 test_attr_value(attr3
, "replace test");
9058 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
9059 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
9060 IHTMLDOMAttribute_Release(attr2
);
9062 put_attr_value(attr
, "new value2");
9063 test_elem_attr(elem
, "Test", "replace test");
9064 test_attr_value(attr
, "new value2");
9065 test_attr_value(attr3
, "replace test");
9067 put_attr_value(attr3
, "new replace value");
9068 test_elem_attr(elem
, "Test", "new replace value");
9069 test_attr_value(attr
, "new value2");
9070 test_attr_value(attr3
, "new replace value");
9072 /* Attached attributes cause errors. */
9073 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
9074 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9075 IHTMLDOMAttribute_Release(attr3
);
9077 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
9078 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
9079 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
9080 IHTMLDOMAttribute_Release(attr2
);
9082 IHTMLElement4_Release(elem4
);
9083 IHTMLDOMAttribute_Release(attr
);
9086 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
9090 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9091 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
9092 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9094 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9095 IHTMLElement_Release(elem
);
9098 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
9099 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
9100 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
9102 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
9103 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
9104 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
9105 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
9106 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
9107 IHTMLElement_Release(elem
);
9111 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
9112 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
9114 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
9115 IHTMLElementCollection
*col
;
9116 BSTR str
= a2bstr(name
);
9119 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
9120 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
9121 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
9123 IHTMLDocument3_Release(doc3
);
9128 static void test_elem_names(IHTMLDocument2
*doc
)
9130 IHTMLElementCollection
*col
;
9135 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
9137 body
= doc_get_body(doc
);
9139 test_elem_set_innerhtml((IUnknown
*)body
,
9140 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
9141 col
= doc_get_elems_by_name(doc
, "test");
9142 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
9143 IHTMLElementCollection_Release(col
);
9145 col
= doc_get_elems_by_name(doc
, "yyy");
9146 test_elem_collection((IUnknown
*)col
, NULL
, 0);
9147 IHTMLElementCollection_Release(col
);
9149 /* case insensivity test */
9150 col
= doc_get_elems_by_name(doc
, "Xxx");
9151 hres
= IHTMLElementCollection_get_length(col
, &len
);
9152 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
9153 todo_wine
ok(len
== 1, "len = %d\n", len
);
9154 IHTMLElementCollection_Release(col
);
9156 IHTMLElement_Release(body
);
9159 static void test_elems2(IHTMLDocument2
*doc
)
9161 IHTMLElement
*elem
, *elem2
, *div
;
9163 static const elem_type_t outer_types
[] = {
9168 div
= get_doc_elem_by_id(doc
, "divid");
9170 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
9172 test_link_disabled(elem
, VARIANT_FALSE
);
9173 test_link_rel(elem
, "stylesheet");
9174 test_link_rev(elem
, NULL
);
9175 test_link_type(elem
, "text/css");
9176 test_link_href(elem
, "about:blank");
9177 test_link_media(elem
, "all");
9178 link_put_disabled(elem
, VARIANT_TRUE
);
9179 link_put_rel(elem
, "prev");
9180 link_put_rev(elem
, "next");
9181 link_put_type(elem
, "text/plain");
9182 link_put_href(elem
, "about:prev");
9183 IHTMLElement_Release(elem
);
9186 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
9187 elem2
= get_doc_elem_by_id(doc
, "innerid");
9188 ok(elem2
!= NULL
, "elem2 == NULL\n");
9189 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
9190 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
9191 IHTMLElement_Release(elem2
);
9193 elem2
= get_doc_elem_by_id(doc
, "aid");
9194 ok(elem2
!= NULL
, "elem2 == NULL\n");
9195 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
9196 test_elem_all((IUnknown
*)div
, outer_types
, 1);
9197 IHTMLElement_Release(elem2
);
9199 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
9200 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9202 IHTMLFormElement
*form
;
9204 test_textarea_value((IUnknown
*)elem
, NULL
);
9205 test_textarea_put_value((IUnknown
*)elem
, "test");
9206 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
9207 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
9208 test_textarea_put_value((IUnknown
*)elem
, "test");
9209 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9210 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
9211 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
9212 test_textarea_type((IUnknown
*)elem
);
9214 form
= get_textarea_form((IUnknown
*)elem
);
9215 ok(!form
, "form = %p\n", form
);
9217 test_elem_istextedit(elem
, VARIANT_TRUE
);
9219 IHTMLElement_Release(elem
);
9222 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
9223 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9225 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
9226 IHTMLElement_Release(elem
);
9229 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
9230 elem
= get_elem_by_id(doc
, "ta", TRUE
);
9232 IHTMLFormElement
*form
;
9234 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
9235 ok(elem2
!= NULL
, "elem2 == NULL\n");
9237 form
= get_textarea_form((IUnknown
*)elem
);
9238 ok(form
!= NULL
, "form = NULL\n");
9239 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9241 IHTMLFormElement_Release(form
);
9242 IHTMLElement_Release(elem2
);
9243 IHTMLElement_Release(elem
);
9246 test_elem_set_innerhtml((IUnknown
*)div
,
9247 "<input value=\"val\" id =\"inputid\" />");
9248 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9250 test_input_defaultValue((IUnknown
*)elem
, "val");
9251 test_input_put_value((IUnknown
*)elem
, "test");
9252 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
9253 test_input_value((IUnknown
*)elem
, "test");
9254 IHTMLElement_Release(elem
);
9257 test_elem_set_innerhtml((IUnknown
*)div
, "");
9258 test_insert_adjacent_elems(doc
, div
);
9260 test_elem_set_innerhtml((IUnknown
*)div
,
9261 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
9262 elem
= get_elem_by_id(doc
, "form", TRUE
);
9264 test_form_length((IUnknown
*)elem
, 2);
9265 test_form_item(elem
);
9266 test_form_action((IUnknown
*)elem
, NULL
);
9267 test_form_put_action((IUnknown
*)elem
, "about:blank");
9268 test_form_method((IUnknown
*)elem
, "get");
9269 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
9270 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
9271 test_form_method((IUnknown
*)elem
, "post");
9272 test_form_name((IUnknown
*)elem
, NULL
);
9273 test_form_put_name((IUnknown
*)elem
, "Name");
9274 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
9275 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
9276 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
9277 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
9278 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
9279 test_form_elements((IUnknown
*)elem
);
9280 test_form_reset((IUnknown
*)elem
);
9281 test_form_target((IUnknown
*)elem
);
9282 IHTMLElement_Release(elem
);
9284 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
9285 test_input_get_form((IUnknown
*)elem
, "form");
9286 IHTMLElement_Release(elem
);
9289 test_elem_set_innerhtml((IUnknown
*)div
,
9290 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select><button id=\"btnid\"></button></form>");
9291 elem
= get_elem_by_id(doc
, "sform", TRUE
);
9292 elem2
= get_elem_by_id(doc
, "form", TRUE
);
9294 IHTMLFormElement
*form
;
9296 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9297 IHTMLElement_Release(elem
);
9299 elem
= get_elem_by_id(doc
, "oform", TRUE
);
9301 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
9302 IHTMLElement_Release(elem
);
9305 elem
= get_elem_by_id(doc
, "btnid", TRUE
);
9307 form
= get_button_form(elem
);
9308 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
9309 IHTMLFormElement_Release(form
);
9311 IHTMLElement_Release(elem
);
9312 IHTMLElement_Release(elem2
);
9315 test_selectors(doc
, div
);
9316 test_elemsbyclass(div
);
9318 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"elemid\">test</div>");
9319 elem
= get_elem_by_id(doc
, "elemid", TRUE
);
9321 test_elem_outertext(elem
, "test");
9322 test_elem_set_outertext(elem
, "outer text");
9323 test_elem_outertext(elem
, NULL
);
9324 test_elem_all((IUnknown
*)div
, NULL
, 0);
9325 elem2
= test_elem_get_parent((IUnknown
*)elem
);
9326 ok(!elem2
, "parent != NULL\n");
9327 IHTMLElement_Release(elem
);
9330 test_elem_set_innerhtml((IUnknown
*)div
, "<map><area id=\"areaid\"></area></map>");
9331 elem
= get_elem_by_id(doc
, "areaid", TRUE
);
9333 test_elem_type((IUnknown
*)elem
, ET_AREA
);
9334 IHTMLElement_Release(elem
);
9337 test_td_elem(doc
, div
);
9338 test_attr(doc
, div
);
9339 test_blocked(doc
, div
);
9340 test_elem_names(doc
);
9342 IHTMLElement_Release(div
);
9345 static void test_create_elems(IHTMLDocument2
*doc
)
9347 IHTMLElement
*elem
, *body
, *elem2
;
9348 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
9349 IHTMLDocument5
*doc5
;
9356 static const elem_type_t types1
[] = { ET_TESTG
};
9358 elem
= test_create_elem(doc
, "TEST");
9359 test_elem_tag((IUnknown
*)elem
, "TEST");
9360 type
= get_node_type((IUnknown
*)elem
);
9361 ok(type
== 1, "type=%d\n", type
);
9362 test_ifaces((IUnknown
*)elem
, elem_iids
);
9363 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
, "[object]");
9364 test_elem_source_index(elem
, -1);
9366 body
= doc_get_body(doc
);
9367 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9369 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
9370 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
9371 elem2
= get_elem_iface((IUnknown
*)node
);
9372 IHTMLElement_Release(elem2
);
9374 hres
= IHTMLElement_get_all(body
, &disp
);
9375 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9376 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
9377 IDispatch_Release(disp
);
9379 test_node_remove_child((IUnknown
*)body
, node
);
9381 hres
= IHTMLElement_get_all(body
, &disp
);
9382 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9383 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
9384 IDispatch_Release(disp
);
9385 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9387 IHTMLElement_Release(elem
);
9388 IHTMLDOMNode_Release(node
);
9390 node
= test_create_text(doc
, "abc");
9391 test_ifaces((IUnknown
*)node
, text_iids
);
9392 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, "[object]");
9393 test_text_length((IUnknown
*)node
, 3);
9394 test_text_data((IUnknown
*)node
, "abc");
9395 set_text_data((IUnknown
*)node
, "test");
9396 test_text_data((IUnknown
*)node
, "test");
9397 text_append_data((IUnknown
*)node
, " append");
9398 test_text_data((IUnknown
*)node
, "test append");
9399 text_append_data((IUnknown
*)node
, NULL
);
9400 test_text_data((IUnknown
*)node
, "test append");
9401 set_text_data((IUnknown
*)node
, "test");
9403 V_VT(&var
) = VT_NULL
;
9404 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9405 IHTMLDOMNode_Release(node
);
9407 node
= test_create_text(doc
, "insert ");
9409 V_VT(&var
) = VT_DISPATCH
;
9410 V_DISPATCH(&var
) = (IDispatch
*)node2
;
9411 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9412 IHTMLDOMNode_Release(node
);
9413 IHTMLDOMNode_Release(node2
);
9414 IHTMLDOMNode_Release(node3
);
9416 test_elem_innertext(body
, "insert test");
9417 test_elem_innerhtml((IUnknown
*)body
, "insert test");
9419 node
= test_create_text(doc
, " Test");
9420 V_VT(&var
) = VT_DISPATCH
;
9421 V_DISPATCH(&var
) = NULL
;
9422 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9423 test_elem_innertext(body
, "insert test Test");
9424 IHTMLDOMNode_Release(node
);
9426 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
9428 str
= a2bstr("testing");
9429 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
9431 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
9434 type
= get_node_type((IUnknown
*)comment
);
9435 ok(type
== 8, "type=%d, expected 8\n", type
);
9437 test_node_get_value_str((IUnknown
*)comment
, "testing");
9438 test_elem_title((IUnknown
*)comment
, NULL
);
9439 test_elem_set_title((IUnknown
*)comment
, "comment title");
9440 test_elem_title((IUnknown
*)comment
, "comment title");
9441 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
9442 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
9443 test_comment_attrs((IUnknown
*)comment
);
9445 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
9446 test_comment_text((IUnknown
*)node2
, "<!--testing-->");
9447 IHTMLDOMNode_Release(node2
);
9449 IHTMLDOMNode_Release(comment
);
9452 IHTMLDocument5_Release(doc5
);
9455 IHTMLElement_Release(body
);
9458 static void test_replacechild_elems(IHTMLDocument2
*doc
)
9461 IHTMLDOMNode
*node
, *node2
, *node3
;
9462 IHTMLDOMNode
*nodeBody
, *nodeNew
;
9466 body
= doc_get_body(doc
);
9468 node
= test_create_text(doc
, "insert");
9470 V_VT(&var
) = VT_NULL
;
9471 V_DISPATCH(&var
) = NULL
;
9472 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9473 IHTMLDOMNode_Release(node
);
9475 test_elem_innertext(body
, "insert");
9477 node3
= test_create_text(doc
, "replaced");
9479 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
9481 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
9482 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
9484 test_elem_innertext(body
, "replaced");
9486 IHTMLDOMNode_Release(node2
);
9487 IHTMLDOMNode_Release(node3
);
9488 IHTMLDOMNode_Release(nodeBody
);
9490 IHTMLElement_Release(body
);
9493 static void test_noscript(IHTMLDocument2
*doc
)
9495 IHTMLElementCollection
*col
;
9499 static const elem_type_t all_types
[] = {
9508 static const elem_type_t body_all_types
[] = {
9513 hres
= IHTMLDocument2_get_all(doc
, &col
);
9514 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9515 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9516 IHTMLElementCollection_Release(col
);
9518 body
= doc_get_body(doc
);
9519 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
9520 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
9521 IHTMLElement_Release(body
);
9524 static void test_doctype(IHTMLDocument2
*doc
)
9526 IHTMLDocument2
*doc_node
;
9527 IHTMLDOMNode
*doctype
;
9530 doc_node
= get_doc_node(doc
);
9531 doctype
= get_first_child((IUnknown
*)doc_node
);
9532 IHTMLDocument2_Release(doc_node
);
9534 type
= get_node_type((IUnknown
*)doctype
);
9535 ok(type
== 8, "type = %d\n", type
);
9537 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9538 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9539 IHTMLDOMNode_Release(doctype
);
9542 static void test_null_write(IHTMLDocument2
*doc
)
9546 doc_write(doc
, FALSE
, NULL
);
9547 doc_write(doc
, TRUE
, NULL
);
9549 hres
= IHTMLDocument2_write(doc
, NULL
);
9551 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9553 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9555 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9558 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9560 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9561 IHTMLStyleElement
*style_elem
;
9562 IHTMLElement
*doc_elem
, *elem
;
9565 static const elem_type_t all_types
[] = {
9573 static const elem_type_t all_types2
[] = {
9582 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
9584 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9585 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9587 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
9589 doc_elem
= get_doc_elem(doc
);
9591 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9592 IHTMLElement_Release(doc_elem
);
9594 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9595 IHTMLElement_Release(elem
);
9596 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9599 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9600 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9601 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9602 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9604 IHTMLStyleSheet_Release(stylesheet2
);
9605 IHTMLStyleSheet_Release(stylesheet
);
9607 IHTMLStyleElement_Release(style_elem
);
9610 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9612 IOleCommandTarget
*cmdtrg
;
9615 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9616 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9618 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9619 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9621 IOleCommandTarget_Release(cmdtrg
);
9624 static void test_indent(IHTMLDocument2
*doc
)
9626 IHTMLElementCollection
*col
;
9627 IHTMLTxtRange
*range
;
9630 static const elem_type_t all_types
[] = {
9639 static const elem_type_t indent_types
[] = {
9650 hres
= IHTMLDocument2_get_all(doc
, &col
);
9651 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9652 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9653 IHTMLElementCollection_Release(col
);
9655 range
= test_create_body_range(doc
);
9656 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9657 IHTMLTxtRange_Release(range
);
9659 hres
= IHTMLDocument2_get_all(doc
, &col
);
9660 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9661 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9662 IHTMLElementCollection_Release(col
);
9665 static void test_cond_comment(IHTMLDocument2
*doc
)
9667 IHTMLElementCollection
*col
;
9670 static const elem_type_t all_types
[] = {
9678 hres
= IHTMLDocument2_get_all(doc
, &col
);
9679 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9680 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9681 IHTMLElementCollection_Release(col
);
9684 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9686 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9687 return E_NOINTERFACE
;
9690 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9695 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9700 static const IUnknownVtbl UnknownVtbl
= {
9701 Unknown_QueryInterface
,
9705 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9707 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9709 IHTMLWindow2
*frame2
, *parent
, *top
;
9710 IHTMLDocument2
*parent_doc
, *top_doc
;
9711 IHTMLWindow4
*frame
;
9712 IHTMLFrameBase
*frame_elem
;
9713 IObjectIdentity
*obj_ident
;
9714 ITravelLogClient
*tlc
;
9717 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9718 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9722 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9723 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9724 IHTMLWindow4_Release(frame
);
9728 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9729 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9730 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9731 IHTMLFrameBase_Release(frame_elem
);
9733 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9734 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9738 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9739 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9741 IHTMLWindow2_Release(frame2
);
9745 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9746 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9747 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9748 if(hres
== E_NOINTERFACE
) {
9749 win_skip("IID_ITravelLogClient not available\n");
9752 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9754 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9755 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9756 ITravelLogClient_Release(tlc
);
9759 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9760 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9761 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9762 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9763 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9764 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9766 IObjectIdentity_Release(obj_ident
);
9768 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9769 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9770 IHTMLWindow2_Release(parent
);
9772 IHTMLWindow2_Release(frame2
);
9776 test_doc_title(parent_doc
, "frameset test");
9777 IHTMLDocument2_Release(parent_doc
);
9780 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9781 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9782 IHTMLWindow2_Release(frame2
);
9786 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9787 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9788 IHTMLWindow2_Release(top
);
9792 test_doc_title(top_doc
, "frameset test");
9793 IHTMLDocument2_Release(top_doc
);
9796 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9798 VARIANT index_var
, result_var
;
9802 /* test result length */
9803 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9804 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9805 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9807 /* test first frame */
9808 V_VT(&index_var
) = VT_I4
;
9809 V_I4(&index_var
) = 0;
9810 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9811 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9812 if(SUCCEEDED(hres
)) {
9813 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9814 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9816 VariantClear(&result_var
);
9818 /* test second frame */
9819 V_I4(&index_var
) = 1;
9820 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9821 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9822 if(SUCCEEDED(hres
)) {
9823 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9824 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9826 VariantClear(&result_var
);
9828 /* fail on next frame */
9829 V_I4(&index_var
) = 3;
9830 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9831 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9832 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9833 VariantClear(&result_var
);
9835 /* string argument (element id lookup) */
9836 V_VT(&index_var
) = VT_BSTR
;
9837 V_BSTR(&index_var
) = a2bstr(frid
);
9838 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9839 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9840 if(SUCCEEDED(hres
)) {
9841 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9842 test_frame(V_DISPATCH(&result_var
), frid
);
9844 VariantClear(&result_var
);
9845 VariantClear(&index_var
);
9847 /* invalid argument */
9848 V_VT(&index_var
) = VT_BOOL
;
9849 V_BOOL(&index_var
) = VARIANT_TRUE
;
9850 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9851 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9852 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9853 VariantClear(&result_var
);
9856 static void test_frameset(IHTMLDocument2
*doc
)
9858 IHTMLWindow2
*window
;
9859 IHTMLFramesCollection2
*frames
;
9860 IHTMLDocument6
*doc6
;
9864 window
= get_doc_window(doc
);
9866 /* test using IHTMLFramesCollection object */
9868 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9869 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9873 test_frames_collection(frames
, "fr1");
9874 IHTMLFramesCollection2_Release(frames
);
9876 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9877 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9881 test_frames_collection(frames
, "fr1");
9882 IHTMLFramesCollection2_Release(frames
);
9884 /* test using IHTMLWindow2 inheritance */
9885 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9887 /* getElementById with node name attributes */
9888 elem
= get_doc_elem_by_id(doc
, "nm1");
9889 test_elem_id((IUnknown
*)elem
, "fr1");
9891 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
9892 if(SUCCEEDED(hres
)) {
9893 IHTMLElement2
*elem2
;
9896 str
= a2bstr("nm1");
9897 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9898 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9899 ok(!elem2
, "elem = %p\n", elem2
);
9902 str
= a2bstr("fr1");
9903 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
9904 ok(hres
== S_OK
, "getElementById failed: %08x\n", hres
);
9905 ok(elem2
!= NULL
, "elem2 is NULL\n");
9906 test_elem_id((IUnknown
*)elem2
, "fr1");
9909 IHTMLDocument6_Release(doc6
);
9911 win_skip("IHTMLDocument6 not supported\n");
9914 test_framebase((IUnknown
*)elem
);
9915 test_framebase_name(elem
, "nm1");
9916 test_framebase_put_name(elem
, "frame name");
9917 test_framebase_put_name(elem
, NULL
);
9918 test_framebase_put_name(elem
, "nm1");
9919 test_framebase_src(elem
, "about:blank");
9920 IHTMLElement_Release(elem
);
9922 /* get_name with no name attr */
9923 elem
= get_doc_elem_by_id(doc
, "fr3");
9924 test_framebase_name(elem
, NULL
);
9925 test_framebase_put_name(elem
, "frame name");
9926 test_framebase_put_name(elem
, NULL
);
9927 IHTMLElement_Release(elem
);
9929 IHTMLWindow2_Release(window
);
9932 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9934 IHTMLDocument2
*frag
;
9935 IHTMLDocument3
*doc3
;
9938 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9939 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9941 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9942 IHTMLDocument3_Release(doc3
);
9943 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9944 ok(frag
!= NULL
, "frag == NULL\n");
9949 static void test_docfrag(IHTMLDocument2
*doc
)
9951 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9952 IHTMLElement
*div
, *body
, *br
;
9953 IHTMLElementCollection
*col
;
9954 IHTMLLocation
*location
;
9957 static const elem_type_t all_types
[] = {
9966 frag
= create_docfrag(doc
);
9968 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, "[object]");
9970 body
= (void*)0xdeadbeef;
9971 hres
= IHTMLDocument2_get_body(frag
, &body
);
9972 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
9973 ok(!body
, "body != NULL\n");
9975 location
= (void*)0xdeadbeef;
9976 hres
= IHTMLDocument2_get_location(frag
, &location
);
9977 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
9978 ok(location
== (void*)0xdeadbeef, "location changed\n");
9980 br
= test_create_elem(doc
, "BR");
9981 test_elem_source_index(br
, -1);
9982 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
9983 test_elem_source_index(br
, 0);
9984 IHTMLElement_Release(br
);
9986 test_doc_getelembytag(frag
, "a", ET_A
, 0);
9987 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
9989 div
= get_elem_by_id(doc
, "divid", TRUE
);
9990 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
9991 IHTMLElement_Release(div
);
9993 hres
= IHTMLDocument2_get_all(doc
, &col
);
9994 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9995 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9996 IHTMLElementCollection_Release(col
);
9998 div
= test_create_elem(frag
, "div");
9999 owner_doc
= get_owner_doc((IUnknown
*)div
);
10000 doc_node
= get_doc_node(doc
);
10001 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
10002 IHTMLDocument2_Release(doc_node
);
10003 IHTMLDocument2_Release(owner_doc
);
10004 IHTMLElement_Release(div
);
10006 IHTMLDocument2_Release(frag
);
10009 static void check_quirks_mode(IHTMLDocument2
*doc
)
10011 test_compatmode(doc
, "BackCompat");
10014 static void check_strict_mode(IHTMLDocument2
*doc
)
10016 test_compatmode(doc
, "CSS1Compat");
10019 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
10021 IHTMLElement
*elem
;
10025 hres
= IHTMLDocument2_get_body(doc
, &elem
);
10026 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
10028 /* body.offsetHeight value depends on window size in quirks mode */
10029 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
10030 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
10031 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
10032 IHTMLElement_Release(elem
);
10035 static IHTMLDocument2
*notif_doc
;
10036 static BOOL doc_complete
;
10038 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
10039 REFIID riid
, void**ppv
)
10041 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
10046 ok(0, "unexpected call\n");
10047 return E_NOINTERFACE
;
10050 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
10055 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
10060 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
10062 if(dispID
== DISPID_READYSTATE
){
10066 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
10067 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
10069 if(!strcmp_wa(state
, "complete"))
10070 doc_complete
= TRUE
;
10072 SysFreeString(state
);
10078 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
10080 ok(0, "unexpected call\n");
10084 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
10085 PropertyNotifySink_QueryInterface
,
10086 PropertyNotifySink_AddRef
,
10087 PropertyNotifySink_Release
,
10088 PropertyNotifySink_OnChanged
,
10089 PropertyNotifySink_OnRequestEdit
10092 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
10094 static HRESULT
cs_qi(REFIID
,void **);
10095 static IOleDocumentView
*view
;
10096 static HWND container_hwnd
;
10098 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
10100 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
10102 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
10103 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
10106 return E_NOINTERFACE
;
10109 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
10114 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
10119 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
10124 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
10129 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
10134 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
10135 LPCBORDERWIDTHS pborderwidths
)
10140 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
10141 LPCBORDERWIDTHS pborderwidths
)
10146 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
10147 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
10152 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10153 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
10158 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
10159 HOLEMENU holemenu
, HWND hwndActiveObject
)
10161 ok(0, "unexpected call\n");
10165 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
10167 ok(0, "unexpected call\n");
10171 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
10176 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
10181 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
10183 ok(0, "unexpected call\n");
10187 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
10188 InPlaceFrame_QueryInterface
,
10189 InPlaceFrame_AddRef
,
10190 InPlaceFrame_Release
,
10191 InPlaceFrame_GetWindow
,
10192 InPlaceFrame_ContextSensitiveHelp
,
10193 InPlaceFrame_GetBorder
,
10194 InPlaceFrame_RequestBorderSpace
,
10195 InPlaceFrame_SetBorderSpace
,
10196 InPlaceFrame_SetActiveObject
,
10197 InPlaceFrame_InsertMenus
,
10198 InPlaceFrame_SetMenu
,
10199 InPlaceFrame_RemoveMenus
,
10200 InPlaceFrame_SetStatusText
,
10201 InPlaceFrame_EnableModeless
,
10202 InPlaceFrame_TranslateAccelerator
10205 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
10207 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
10209 return cs_qi(riid
, ppv
);
10212 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
10217 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
10222 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
10224 *phwnd
= container_hwnd
;
10228 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
10230 ok(0, "unexpected call\n");
10234 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
10239 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
10244 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
10249 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
10250 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
10251 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
10253 static const RECT rect
= {0,0,500,500};
10255 *ppFrame
= &InPlaceFrame
;
10257 *lprcPosRect
= rect
;
10258 *lprcClipRect
= rect
;
10260 lpFrameInfo
->fMDIApp
= FALSE
;
10261 lpFrameInfo
->hwndFrame
= container_hwnd
;
10262 lpFrameInfo
->haccel
= NULL
;
10263 lpFrameInfo
->cAccelEntries
= 0;
10268 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
10273 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
10278 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
10283 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
10288 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
10293 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
10298 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
10299 InPlaceSite_QueryInterface
,
10300 InPlaceSite_AddRef
,
10301 InPlaceSite_Release
,
10302 InPlaceSite_GetWindow
,
10303 InPlaceSite_ContextSensitiveHelp
,
10304 InPlaceSite_CanInPlaceActivate
,
10305 InPlaceSite_OnInPlaceActivate
,
10306 InPlaceSite_OnUIActivate
,
10307 InPlaceSite_GetWindowContext
,
10308 InPlaceSite_Scroll
,
10309 InPlaceSite_OnUIDeactivate
,
10310 InPlaceSite_OnInPlaceDeactivate
,
10311 InPlaceSite_DiscardUndoState
,
10312 InPlaceSite_DeactivateAndUndo
,
10313 InPlaceSite_OnPosRectChange
,
10316 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
10318 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
10320 return cs_qi(riid
, ppv
);
10323 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
10328 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
10333 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
10335 ok(0, "unexpected call\n");
10339 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
10342 ok(0, "unexpected call\n");
10346 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
10351 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
10353 ok(0, "unexpected call\n");
10357 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
10359 ok(0, "unexpected call\n");
10363 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
10365 ok(0, "unexpected call\n");
10369 static const IOleClientSiteVtbl ClientSiteVtbl
= {
10370 ClientSite_QueryInterface
,
10372 ClientSite_Release
,
10373 ClientSite_SaveObject
,
10374 ClientSite_GetMoniker
,
10375 ClientSite_GetContainer
,
10376 ClientSite_ShowObject
,
10377 ClientSite_OnShowWindow
,
10378 ClientSite_RequestNewObjectLayout
10381 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
10383 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
10385 return cs_qi(riid
, ppv
);
10388 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
10393 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
10398 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
10400 RECT rect
= {0,0,500,500};
10401 IOleDocument
*document
;
10404 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
10405 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
10407 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
10408 IOleDocument_Release(document
);
10409 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
10411 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
10412 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
10414 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
10415 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
10417 hres
= IOleDocumentView_SetRect(view
, &rect
);
10418 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
10420 hres
= IOleDocumentView_Show(view
, TRUE
);
10421 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
10426 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
10427 DocumentSite_QueryInterface
,
10428 DocumentSite_AddRef
,
10429 DocumentSite_Release
,
10430 DocumentSite_ActivateMe
10433 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
10435 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
10439 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
10440 *ppv
= &ClientSite
;
10441 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
10442 *ppv
= &DocumentSite
;
10443 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
10444 *ppv
= &InPlaceSite
;
10446 return *ppv
? S_OK
: E_NOINTERFACE
;
10449 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
10451 IOleObject
*oleobj
;
10455 IOleDocumentView_Show(view
, FALSE
);
10456 IOleDocumentView_CloseView(view
, 0);
10457 IOleDocumentView_SetInPlaceSite(view
, NULL
);
10458 IOleDocumentView_Release(view
);
10462 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
10463 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
10465 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
10466 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
10469 IHlinkTarget
*hlink
;
10471 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
10472 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
10474 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
10475 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
10477 IHlinkTarget_Release(hlink
);
10480 IOleObject_Release(oleobj
);
10483 static IHTMLDocument2
*create_doc_with_string(const char *str
)
10485 IPersistStreamInit
*init
;
10487 IHTMLDocument2
*doc
;
10491 notif_doc
= doc
= create_document();
10495 doc_complete
= FALSE
;
10497 mem
= GlobalAlloc(0, len
);
10498 memcpy(mem
, str
, len
);
10499 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
10501 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
10503 IPersistStreamInit_Load(init
, stream
);
10504 IPersistStreamInit_Release(init
);
10505 IStream_Release(stream
);
10510 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
10512 IConnectionPointContainer
*container
;
10513 IConnectionPoint
*cp
;
10517 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
10518 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
10520 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
10521 IConnectionPointContainer_Release(container
);
10522 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
10524 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
10525 IConnectionPoint_Release(cp
);
10526 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
10529 typedef void (*domtest_t
)(IHTMLDocument2
*);
10531 static void run_domtest(const char *str
, domtest_t test
)
10533 IHTMLDocument2
*doc
;
10537 doc
= create_doc_with_string(str
);
10541 set_client_site(doc
, TRUE
);
10542 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
10544 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
10545 TranslateMessage(&msg
);
10546 DispatchMessageW(&msg
);
10551 set_client_site(doc
, FALSE
);
10552 ref
= IHTMLDocument2_Release(doc
);
10553 ok(!ref
|| broken(ref
== 1), /* Vista */
10554 "ref = %d\n", ref
);
10557 static float expected_document_mode
;
10559 static void test_document_mode(IHTMLDocument2
*doc2
)
10561 IHTMLDocument6
*doc
;
10565 if(expected_document_mode
>= 9) {
10566 IHTMLDocument7
*doc7
;
10567 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument7
, (void**)&doc7
);
10569 win_skip("IHTMLDocument7 interface not supported: %08x\n", hres
);
10572 IHTMLDocument7_Release(doc7
);
10575 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument6
, (void**)&doc
);
10576 ok(hres
== S_OK
, "Could not get IHTMLDocument6 interface: %08x\n", hres
);
10578 V_VT(&v
) = VT_EMPTY
;
10579 hres
= IHTMLDocument6_get_documentMode(doc
, &v
);
10580 ok(hres
== S_OK
, "get_documentMode failed: %08x\n", hres
);
10581 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
10582 ok(V_R4(&v
) == expected_document_mode
, "documentMode = %f\n", V_R4(&v
));
10583 IHTMLDocument6_Release(doc
);
10586 static void test_quirks_mode(void)
10588 run_domtest("<html></html>", check_quirks_mode
);
10589 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10590 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10591 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10593 expected_document_mode
= 5;
10594 run_domtest("<html><body></body></html>", test_document_mode
);
10596 expected_document_mode
= 9;
10597 run_domtest("<!DOCTYPE html>\n"
10600 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10604 "</html>", test_document_mode
);
10606 expected_document_mode
= 8;
10607 run_domtest("<!DOCTYPE html>\n"
10610 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
10611 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
10615 "</html>", test_document_mode
);
10620 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10621 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10622 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10624 CoInitialize(NULL
);
10625 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10626 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10628 run_domtest(doc_str1
, test_doc_elem
);
10629 run_domtest(doc_str1
, test_get_set_attr
);
10630 run_domtest(range_test_str
, test_txtrange
);
10631 run_domtest(range_test2_str
, test_txtrange2
);
10632 if (winetest_interactive
|| ! is_ie_hardened()) {
10633 run_domtest(elem_test_str
, test_elems
);
10634 run_domtest(elem_test2_str
, test_elems2
);
10635 run_domtest(noscript_str
, test_noscript
);
10637 skip("IE running in Enhanced Security Configuration\n");
10639 run_domtest(doc_blank
, test_create_elems
);
10640 run_domtest(doc_blank
, test_defaults
);
10641 run_domtest(doc_blank
, test_null_write
);
10642 run_domtest(emptydiv_str
, test_create_stylesheet
);
10643 run_domtest(indent_test_str
, test_indent
);
10644 run_domtest(cond_comment_str
, test_cond_comment
);
10645 run_domtest(frameset_str
, test_frameset
);
10646 run_domtest(emptydiv_str
, test_docfrag
);
10647 run_domtest(doc_blank
, test_replacechild_elems
);
10648 run_domtest(doctype_str
, test_doctype
);
10650 test_quirks_mode();
10652 DestroyWindow(container_hwnd
);