2 * Copyright 2007-2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
35 #include "mshtml_test.h"
40 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
41 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
43 static const char doc_blank
[] = "<html></html>";
44 static const char doc_str1
[] = "<html><body>test</body></html>";
45 static const char range_test_str
[] =
46 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
47 static const char range_test2_str
[] =
48 "<html><body>abc<hr />123<br /><hr />def</body></html>";
49 static const char elem_test_str
[] =
50 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
51 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
52 "<link id=\"linkid\"></head>"
53 "<body onload=\"Testing()\">text test<!-- a comment -->"
54 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
55 "<label for=\"in\" id=\"labelid\">Label:</label>"
56 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
57 "<button id=\"btnid\"></button>"
58 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
59 "<textarea id=\"X\">text text</textarea>"
60 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
61 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
62 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
63 "<img id=\"imgid\" name=\"WineImg\"/>"
64 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
65 "<form id=\"frm\"></form>"
66 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
68 static const char elem_test2_str
[] =
69 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
70 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
71 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
74 static const char indent_test_str
[] =
75 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
76 static const char cond_comment_str
[] =
77 "<html><head><title>test</title></head><body>"
78 "<!--[if gte IE 4]> <br> <![endif]-->"
80 static const char frameset_str
[] =
81 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
82 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
83 "<frame src=\"about:blank\" id=\"fr3\">"
85 static const char emptydiv_str
[] =
86 "<html><head><title>emptydiv test</title></head>"
87 "<body><div id=\"divid\"></div></body></html>";
88 static const char noscript_str
[] =
89 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
90 "<body><noscript><div>test</div></noscript></body></html>";
91 static const char doctype_str
[] =
93 "<html><head><title>emptydiv test</title></head>"
94 "<body><div id=\"divid\"></div></body></html>";
96 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
97 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
98 static WCHAR wordW
[] = {'w','o','r','d',0};
137 static const IID
* const none_iids
[] = {
142 static const IID
* const doc_node_iids
[] = {
151 &IID_IConnectionPointContainer
,
152 &IID_IInternetHostSecurityManager
,
155 &IID_IProvideClassInfo
,
159 static const IID
* const doc_obj_iids
[] = {
166 &IID_IConnectionPointContainer
,
170 &IID_IProvideClassInfo
,
171 &IID_ITargetContainer
,
175 #define ELEM_IFACES \
177 &IID_IHTMLDOMNode2, \
179 &IID_IHTMLElement2, \
180 &IID_IHTMLElement3, \
181 &IID_IHTMLElement4, \
182 &IID_IHTMLUniqueName, \
185 static const IID
* const elem_iids
[] = {
187 &IID_IConnectionPointContainer
,
191 static const IID
* const body_iids
[] = {
193 &IID_IHTMLTextContainer
,
194 &IID_IHTMLBodyElement
,
195 &IID_IConnectionPointContainer
,
199 static const IID
* const anchor_iids
[] = {
201 &IID_IHTMLAnchorElement
,
202 &IID_IConnectionPointContainer
,
206 static const IID
* const input_iids
[] = {
208 &IID_IHTMLInputElement
,
209 &IID_IHTMLInputTextElement
,
210 &IID_IConnectionPointContainer
,
214 static const IID
*const button_iids
[] = {
216 &IID_IHTMLButtonElement
,
217 &IID_IConnectionPointContainer
,
221 static const IID
* const label_iids
[] = {
223 &IID_IHTMLLabelElement
,
224 &IID_IConnectionPointContainer
,
228 static const IID
* const select_iids
[] = {
230 &IID_IHTMLSelectElement
,
231 &IID_IConnectionPointContainer
,
235 static const IID
* const textarea_iids
[] = {
237 &IID_IHTMLTextAreaElement
,
238 &IID_IConnectionPointContainer
,
242 static const IID
* const option_iids
[] = {
244 &IID_IHTMLOptionElement
,
245 &IID_IConnectionPointContainer
,
249 static const IID
* const table_iids
[] = {
254 &IID_IConnectionPointContainer
,
258 static const IID
* const script_iids
[] = {
260 &IID_IHTMLScriptElement
,
261 &IID_IConnectionPointContainer
,
265 static const IID
* const text_iids
[] = {
268 &IID_IHTMLDOMTextNode
,
269 &IID_IHTMLDOMTextNode2
,
273 static const IID
* const attr_iids
[] = {
274 &IID_IHTMLDOMAttribute
,
275 &IID_IHTMLDOMAttribute2
,
280 static const IID
* const location_iids
[] = {
286 static const IID
* const window_iids
[] = {
291 &IID_IServiceProvider
,
295 static const IID
* const comment_iids
[] = {
297 &IID_IHTMLCommentElement
,
298 &IID_IConnectionPointContainer
,
302 static const IID
* const img_iids
[] = {
304 &IID_IHTMLImgElement
,
305 &IID_IConnectionPointContainer
,
309 static const IID
* const tr_iids
[] = {
312 &IID_IConnectionPointContainer
,
316 static const IID
* const td_iids
[] = {
319 &IID_IConnectionPointContainer
,
323 static const IID
* const frame_iids
[] = {
326 &IID_IHTMLFrameBase2
,
327 &IID_IConnectionPointContainer
,
331 static const IID
* const html_iids
[] = {
333 &IID_IHTMLHtmlElement
,
334 &IID_IConnectionPointContainer
,
338 static const IID
* const head_iids
[] = {
340 &IID_IHTMLHeadElement
,
341 &IID_IConnectionPointContainer
,
345 static const IID
* const title_iids
[] = {
347 &IID_IHTMLTitleElement
,
348 &IID_IConnectionPointContainer
,
352 static const IID
* const meta_iids
[] = {
354 &IID_IHTMLMetaElement
,
355 &IID_IConnectionPointContainer
,
359 static const IID
* const link_iids
[] = {
361 &IID_IHTMLLinkElement
,
362 &IID_IConnectionPointContainer
,
366 static const IID
* const object_iids
[] = {
368 &IID_IHTMLObjectElement
,
369 &IID_IHTMLObjectElement2
,
370 /* FIXME: No IConnectionPointContainer */
374 static const IID
* const embed_iids
[] = {
376 &IID_IHTMLEmbedElement
,
377 /* FIXME: No IConnectionPointContainer */
381 static const IID
* const iframe_iids
[] = {
384 &IID_IHTMLFrameBase2
,
385 &IID_IHTMLIFrameElement
,
386 &IID_IHTMLIFrameElement2
,
387 &IID_IConnectionPointContainer
,
391 static const IID
* const form_iids
[] = {
393 &IID_IHTMLFormElement
,
394 &IID_IConnectionPointContainer
,
395 &DIID_DispHTMLFormElement
,
399 static const IID
* const styleelem_iids
[] = {
401 &IID_IHTMLStyleElement
,
402 &IID_IConnectionPointContainer
,
406 static const IID
* const generic_iids
[] = {
408 &IID_IHTMLGenericElement
,
409 &IID_IConnectionPointContainer
,
413 static const IID
* const style_iids
[] = {
424 static const IID
* const cstyle_iids
[] = {
428 &IID_IHTMLCurrentStyle
,
429 &IID_IHTMLCurrentStyle2
,
430 &IID_IHTMLCurrentStyle3
,
434 static const IID
* const img_factory_iids
[] = {
438 &IID_IHTMLImageElementFactory
,
442 static const IID
* const selection_iids
[] = {
446 &IID_IHTMLSelectionObject
,
447 &IID_IHTMLSelectionObject2
,
457 static const elem_type_info_t elem_type_infos
[] = {
458 {"", none_iids
, NULL
},
459 {"HTML", html_iids
, &DIID_DispHTMLHtmlElement
},
460 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
461 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
462 {"BODY", body_iids
, &DIID_DispHTMLBody
},
463 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
464 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
465 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
466 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
467 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
468 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
469 {"BLOCKQUOTE",elem_iids
, NULL
},
470 {"P", elem_iids
, NULL
},
471 {"BR", elem_iids
, NULL
},
472 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
473 {"TBODY", elem_iids
, NULL
},
474 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
475 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
476 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
477 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
478 {"IMG", img_iids
, &DIID_DispHTMLImg
},
479 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
480 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
481 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
482 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
483 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
484 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
485 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
486 {"DIV", elem_iids
, NULL
},
487 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
488 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
489 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
490 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
491 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
494 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
497 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
498 return lstrcmpA(stra
, buf
);
501 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
506 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
507 prefix_len
= lstrlenA(prefix
);
512 return !lstrcmpA(buf
, prefix
);
515 static BSTR
a2bstr(const char *str
)
523 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
524 ret
= SysAllocStringLen(NULL
, len
);
525 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
530 static const char *debugstr_variant(const VARIANT
*var
)
532 static char buf
[400];
542 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
545 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
548 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
551 sprintf(buf
, "{vt %d}", V_VT(var
));
558 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
560 IUnknown
*unk1
, *unk2
;
565 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
566 IUnknown_Release(unk1
);
567 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
568 IUnknown_Release(unk2
);
573 static IHTMLDocument2
*create_document(void)
576 IHTMLDocument5
*doc5
;
579 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
580 &IID_IHTMLDocument2
, (void**)&doc
);
581 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
585 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
587 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
588 IHTMLDocument2_Release(doc
);
592 IHTMLDocument5_Release(doc5
);
596 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
597 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
602 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
603 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
607 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
608 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
610 const IID
* const *piid
;
614 for(piid
= iids
; *piid
; piid
++) {
615 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
616 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
618 IUnknown_Release(unk
);
622 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
623 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
628 unk
= (void*)0xdeadbeef;
629 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
630 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
631 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
634 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
635 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
637 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
644 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
645 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
646 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
648 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
649 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
651 if(SUCCEEDED(hres
)) {
654 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
655 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
657 *iid
= type_attr
->guid
;
661 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
662 ITypeInfo_Release(typeinfo
);
665 IDispatchEx_Release(dispex
);
669 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
670 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
672 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
673 DISPPARAMS dp
= {NULL
,NULL
,0,0};
678 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
679 IDispatchEx_Release(dispex
);
680 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
682 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
683 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
687 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
688 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
692 if(_test_get_dispid(line
, unk
, &iid
))
693 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
696 _test_disp_value(line
, unk
, val
);
699 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
700 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
704 if(_test_get_dispid(line
, unk
, &iid
))
705 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
706 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
709 _test_disp_value(line
, unk
, val
);
712 #define test_class_info(u) _test_class_info(__LINE__,u)
713 static void _test_class_info(unsigned line
, IUnknown
*unk
)
715 IProvideClassInfo
*classinfo
;
720 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
721 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
725 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
726 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
729 IProvideClassInfo_Release(classinfo
);
733 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
734 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
737 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
738 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
739 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
740 "unexpected typekind %d\n", type_attr
->typekind
);
741 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
744 ITypeInfo_Release(typeinfo
);
745 IProvideClassInfo_Release(classinfo
);
748 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
749 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
751 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
752 DISPPARAMS dp
= {val
, NULL
, 1, 0};
759 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
761 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
763 memset(&ei
, 0, sizeof(ei
));
764 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
765 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
769 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
770 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
775 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
776 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
780 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
781 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
786 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
787 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
791 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
792 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
797 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
798 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
802 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
803 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
808 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
809 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
813 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
814 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
816 IHTMLDocument3
*doc3
;
819 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
820 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
825 #define get_node_iface(u) _get_node_iface(__LINE__,u)
826 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
831 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
832 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
836 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
837 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
842 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
843 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
847 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
848 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
853 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
854 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
858 #define get_img_iface(u) _get_img_iface(__LINE__,u)
859 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
861 IHTMLImgElement
*img
;
864 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
865 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
869 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
870 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
872 IHTMLAnchorElement
*anchor
;
875 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
876 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
880 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
881 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
883 IHTMLTextAreaElement
*textarea
;
886 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
887 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
891 #define get_select_iface(u) _get_select_iface(__LINE__,u)
892 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
894 IHTMLSelectElement
*select
;
897 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
898 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
902 #define get_option_iface(u) _get_option_iface(__LINE__,u)
903 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
905 IHTMLOptionElement
*option
;
908 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
909 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
913 #define get_form_iface(u) _get_form_iface(__LINE__,u)
914 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
916 IHTMLFormElement
*form
;
919 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
920 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
924 #define get_text_iface(u) _get_text_iface(__LINE__,u)
925 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
927 IHTMLDOMTextNode
*text
;
930 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
931 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
935 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
936 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
938 IHTMLDOMTextNode2
*text2
;
941 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
942 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
946 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
947 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
949 IHTMLCommentElement
*comment
;
952 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
953 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
957 #define get_object_iface(u) _get_object_iface(__LINE__,u)
958 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
960 IHTMLObjectElement
*obj
;
963 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
964 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
968 #define get_style_iface(u) _get_style_iface(__LINE__,u)
969 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
971 IHTMLStyleElement
*obj
;
974 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
975 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
979 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
980 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
982 IHTMLMetaElement
*ret
;
985 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
986 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
990 #define get_link_iface(u) _get_link_iface(__LINE__,u)
991 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
993 IHTMLLinkElement
*ret
;
996 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
997 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
1001 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
1002 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
1004 IHTMLIFrameElement2
*ret
;
1007 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1008 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1012 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1013 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1015 IHTMLButtonElement
*ret
;
1018 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1019 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1023 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1024 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1026 IHTMLLabelElement
*ret
;
1029 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1030 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1034 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1035 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1037 IHTMLDOMAttribute2
*ret
;
1040 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1041 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1045 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1046 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1048 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1052 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1053 IHTMLDOMNode_Release(node
);
1054 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1055 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1057 SysFreeString(name
);
1060 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1061 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1063 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1064 IDispatch
*disp
= (void*)0xdeadbeef;
1065 IHTMLDocument2
*doc
= NULL
;
1068 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1069 IHTMLDOMNode2_Release(node
);
1070 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1073 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1074 IDispatch_Release(disp
);
1075 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1081 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1082 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1084 IHTMLWindow2
*window
;
1088 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1089 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1090 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1095 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1096 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1098 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1099 IHTMLDOMNode
*ret
= NULL
;
1102 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1103 IHTMLDOMNode_Release(node
);
1104 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1105 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1111 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1112 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1114 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1118 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1119 IHTMLElement_Release(elem
);
1120 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1121 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1126 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1127 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1129 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1130 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1132 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1133 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1136 #define get_node_type(n) _get_node_type(__LINE__,n)
1137 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1139 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1143 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1144 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1146 IHTMLDOMNode_Release(node
);
1151 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1152 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1154 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1155 IHTMLDOMChildrenCollection
*col
= NULL
;
1159 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1160 IHTMLDOMNode_Release(node
);
1161 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1165 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1166 IDispatch_Release(disp
);
1167 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1172 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1173 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1175 IHTMLDOMNode
*node
= NULL
;
1179 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1180 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1182 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1183 IDispatch_Release(disp
);
1188 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1189 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1195 VariantInit(&value
);
1198 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1200 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1203 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1204 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1206 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1209 VariantClear(&value
);
1212 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1213 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1215 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1216 IHTMLElement
*off_parent
;
1220 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1221 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1223 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1224 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1226 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1227 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1229 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1230 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1232 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1235 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1236 IHTMLElement_Release(off_parent
);
1238 IHTMLElement_Release(elem
);
1241 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1242 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1244 LONG l
= 0xdeadbeef;
1247 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1248 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1249 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1252 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1253 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1255 IHTMLWindow2
*window
;
1256 IHTMLDocument2
*ret
;
1259 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1260 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1262 hres
= IHTMLWindow2_get_document(window
, &ret
);
1263 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1264 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1269 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1270 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1275 hres
= IHTMLWindow2_get_name(window
, &name
);
1276 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1278 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1280 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1281 SysFreeString(name
);
1284 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1285 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1291 hres
= IHTMLWindow2_put_name(window
, str
);
1293 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1295 _test_window_name(line
, window
, name
);
1298 #define test_window_status(d) _test_window_status(__LINE__,d)
1299 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1304 status
= (void*)0xdeadbeef;
1305 hres
= IHTMLWindow2_get_status(window
, &status
);
1306 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1307 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1308 SysFreeString(status
);
1311 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1312 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1317 str
= a2bstr(status
);
1318 hres
= IHTMLWindow2_put_status(window
, str
);
1320 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1323 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1324 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1329 hres
= IHTMLWindow2_get_length(window
, &length
);
1330 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1331 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1334 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1335 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1337 IHTMLFrameBase2
*base2
;
1338 IHTMLWindow2
*window
;
1341 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1342 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1345 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1346 IHTMLFrameBase2_Release(base2
);
1347 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1348 ok(window
!= NULL
, "contentWindow = NULL\n");
1353 static void test_get_set_attr(IHTMLDocument2
*doc
)
1356 IHTMLDocument3
*doc3
;
1361 /* grab an element to test with */
1362 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1363 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1365 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1366 IHTMLDocument3_Release(doc3
);
1367 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1369 /* get a non-present attribute */
1370 bstr
= a2bstr("notAnAttribute");
1371 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1372 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1373 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1375 SysFreeString(bstr
);
1377 /* get a present attribute */
1378 bstr
= a2bstr("scrollHeight");
1379 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1380 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1381 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1383 SysFreeString(bstr
);
1385 /* create a new BSTR attribute */
1386 bstr
= a2bstr("newAttribute");
1388 V_VT(&val
) = VT_BSTR
;
1389 V_BSTR(&val
) = a2bstr("the value");
1390 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1391 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1394 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1395 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1396 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1397 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
)));
1400 /* overwrite the attribute with a BOOL */
1401 V_VT(&val
) = VT_BOOL
;
1402 V_BOOL(&val
) = VARIANT_TRUE
;
1403 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1404 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1407 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1408 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1409 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1410 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1413 SysFreeString(bstr
);
1415 /* case-insensitive */
1416 bstr
= a2bstr("newattribute");
1417 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1418 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1419 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1420 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1423 /* overwrite the attribute with null */
1424 V_VT(&val
) = VT_NULL
;
1425 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1426 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1428 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1429 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1430 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1431 ok(!strcmp_wa(V_BSTR(&val
), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1434 SysFreeString(bstr
);
1435 IHTMLElement_Release(elem
);
1438 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1439 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1442 IHTMLDocument3
*doc3
;
1445 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1446 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1447 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1448 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1449 IHTMLDocument3_Release(doc3
);
1454 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1455 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1457 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1461 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1462 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1463 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1466 _test_disp_value(line
, unk
, exhref
);
1469 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1470 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1472 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1476 str
= a2bstr(exhref
);
1477 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1478 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1481 _test_disp_value(line
, unk
, exhref
);
1484 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1485 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1487 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1491 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1492 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1494 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1496 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1500 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1501 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1503 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1507 str
= a2bstr(exrel
);
1508 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1509 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1513 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1514 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1516 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1520 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1521 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1523 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1525 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1529 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1530 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1532 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1536 str
= target
? a2bstr(target
) : NULL
;
1537 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1538 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1542 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1543 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1545 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1549 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1550 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1552 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1554 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1558 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1559 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1561 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1565 str
= name
? a2bstr(name
) : NULL
;
1566 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1567 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1570 _test_anchor_name(line
, unk
, name
);
1573 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1574 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1576 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1580 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1581 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1583 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1585 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1589 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1590 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1592 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1596 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1597 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1598 if ( ! str
&& allowbroken
)
1599 win_skip("skip ie6 incorrect behavior\n");
1601 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1603 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1607 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1608 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1610 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1614 str
= search
? a2bstr(search
) : NULL
;
1615 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1616 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1620 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1621 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1623 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1627 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1628 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1630 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1632 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1636 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1637 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1642 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1643 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1644 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1645 SysFreeString(bstr
);
1648 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1649 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1654 bstr
= a2bstr(text
);
1655 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1656 SysFreeString(bstr
);
1657 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1659 _test_option_text(line
, option
, text
);
1662 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1663 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1668 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1669 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1670 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1671 SysFreeString(bstr
);
1674 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1675 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1680 bstr
= a2bstr(value
);
1681 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1682 SysFreeString(bstr
);
1683 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1685 _test_option_value(line
, option
, value
);
1688 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1689 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1691 VARIANT_BOOL b
= 0x100;
1694 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1695 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1696 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1699 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1700 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1704 hres
= IHTMLOptionElement_put_selected(option
, b
);
1705 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1706 _test_option_selected(line
, option
, b
);
1709 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1710 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1715 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1716 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1719 hres
= IHTMLOptionElement_get_index(option
, &val
);
1720 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1721 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1722 "value = %d, expected = %d\n", val
, exval
);
1725 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1726 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1730 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1731 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1734 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1735 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1740 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1741 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1744 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1745 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1746 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1749 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1751 test_option_defaultSelected(option
, VARIANT_FALSE
);
1752 test_option_selected(option
, VARIANT_FALSE
);
1754 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1755 test_option_defaultSelected(option
, VARIANT_FALSE
);
1756 test_option_selected(option
, VARIANT_FALSE
);
1758 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1759 test_option_defaultSelected(option
, VARIANT_TRUE
);
1760 test_option_selected(option
, VARIANT_FALSE
);
1762 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1763 test_option_defaultSelected(option
, VARIANT_FALSE
);
1764 test_option_selected(option
, VARIANT_FALSE
);
1766 test_option_put_selected(option
, VARIANT_TRUE
);
1767 test_option_selected(option
, VARIANT_TRUE
);
1768 test_option_defaultSelected(option
, VARIANT_FALSE
);
1770 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1771 test_option_defaultSelected(option
, VARIANT_TRUE
);
1772 test_option_selected(option
, VARIANT_TRUE
);
1774 /* Restore defaultSelected */
1775 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1776 test_option_put_selected(option
, VARIANT_FALSE
);
1779 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1780 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1782 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1783 BSTR value
= (void*)0xdeadbeef;
1786 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1787 IHTMLTextAreaElement_Release(textarea
);
1788 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1790 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1792 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1793 SysFreeString(value
);
1796 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1797 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1799 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1800 BSTR tmp
= a2bstr(value
);
1803 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1804 IHTMLTextAreaElement_Release(textarea
);
1805 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1808 _test_textarea_value(line
, unk
, value
);
1811 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1812 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1814 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1815 BSTR value
= (void*)0xdeadbeef;
1818 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1819 IHTMLTextAreaElement_Release(textarea
);
1820 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1822 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1824 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1825 SysFreeString(value
);
1828 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1829 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1831 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1832 BSTR tmp
= a2bstr(value
);
1835 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1836 IHTMLTextAreaElement_Release(textarea
);
1837 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1840 _test_textarea_defaultvalue(line
, unk
, value
);
1843 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1844 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1846 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1847 VARIANT_BOOL b
= 0x100;
1850 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1851 IHTMLTextAreaElement_Release(textarea
);
1852 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1853 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1856 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1857 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1859 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1862 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1863 IHTMLTextAreaElement_Release(textarea
);
1864 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1866 _test_textarea_readonly(line
, unk
, b
);
1869 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1870 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1872 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1873 BSTR type
= (void*)0xdeadbeef;
1876 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1877 IHTMLTextAreaElement_Release(textarea
);
1878 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1879 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1880 SysFreeString(type
);
1883 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1884 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1886 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1887 IHTMLFormElement
*form
;
1890 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1891 IHTMLTextAreaElement_Release(textarea
);
1892 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1897 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1898 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1900 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1904 text
= a2bstr(extext
);
1905 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1906 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1907 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1909 IHTMLCommentElement_Release(comment
);
1910 SysFreeString(text
);
1913 #define create_attr(a,b) _create_attr(__LINE__,a,b)
1914 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
1916 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
1917 BSTR str
= a2bstr("Test");
1918 IHTMLDOMAttribute
*attr
;
1921 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
1922 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
1924 IHTMLDocument5_Release(doc
);
1929 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
1930 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1932 VARIANT_BOOL specified
;
1935 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
1936 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
1937 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
1940 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
1941 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1943 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1944 VARIANT_BOOL expando
;
1947 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
1948 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
1949 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
1951 IHTMLDOMAttribute2_Release(attr2
);
1954 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
1955 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
1957 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1961 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
1962 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1964 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
1966 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
1968 IHTMLDOMAttribute2_Release(attr2
);
1972 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1973 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1975 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1976 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1977 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1978 IHTMLDOMAttribute
*attr
;
1979 BSTR name
= a2bstr("test");
1983 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1984 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1985 ok(attr
== NULL
, "attr != NULL\n");
1989 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1990 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1992 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1993 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1994 ok(attr
!= NULL
, "attr == NULL\n");
1996 test_attr_expando(attr
, VARIANT_TRUE
);
1998 IHTMLDOMAttribute_Release(attr
);
1999 IHTMLCommentElement_Release(comment
);
2000 IHTMLElement_Release(elem
);
2001 IHTMLElement4_Release(elem4
);
2002 SysFreeString(name
);
2005 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2006 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2008 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2013 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2014 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
2015 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
2016 IHTMLObjectElement_Release(object
);
2019 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2020 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
2022 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2026 str
= (void*)0xdeadbeef;
2027 hres
= IHTMLObjectElement_get_name(object
, &str
);
2028 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
2030 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
2032 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2034 IHTMLObjectElement_Release(object
);
2037 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2038 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2040 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2045 hres
= IHTMLObjectElement_put_name(object
, str
);
2046 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2048 IHTMLObjectElement_Release(object
);
2050 _test_object_name(line
, elem
, name
);
2053 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2054 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2055 const char *txt
, const char *val
)
2057 IHTMLOptionElementFactory
*factory
;
2058 IHTMLOptionElement
*option
;
2059 IHTMLWindow2
*window
;
2060 VARIANT text
, value
, empty
;
2063 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2064 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2066 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2067 IHTMLWindow2_Release(window
);
2068 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2070 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
2072 V_VT(&text
) = VT_BSTR
;
2073 V_BSTR(&text
) = a2bstr(txt
);
2074 V_VT(&value
) = VT_BSTR
;
2075 V_BSTR(&value
) = a2bstr(val
);
2076 V_VT(&empty
) = VT_EMPTY
;
2078 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2079 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2081 IHTMLOptionElementFactory_Release(factory
);
2082 VariantClear(&text
);
2083 VariantClear(&value
);
2085 _test_option_text(line
, option
, txt
);
2086 _test_option_value(line
, option
, val
);
2087 _test_option_selected(line
, option
, VARIANT_FALSE
);
2092 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2093 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2098 hres
= IHTMLImgElement_get_width(img
, &found
);
2099 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2100 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2103 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2104 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2108 hres
= IHTMLImgElement_put_width(img
, width
);
2109 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2111 _test_img_width(line
, img
, width
);
2114 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2115 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2120 hres
= IHTMLImgElement_get_height(img
, &found
);
2121 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2122 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2125 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2126 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2130 hres
= IHTMLImgElement_put_height(img
, height
);
2131 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2133 _test_img_height(line
, img
, height
);
2136 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2137 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2138 LONG wdth
, LONG hght
)
2140 IHTMLImageElementFactory
*factory
;
2141 IHTMLImgElement
*img
;
2142 IHTMLWindow2
*window
;
2143 VARIANT width
, height
;
2147 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2148 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2150 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2151 IHTMLWindow2_Release(window
);
2152 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2154 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2155 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
2158 snprintf(buf
, 16, "%d", wdth
);
2159 V_VT(&width
) = VT_BSTR
;
2160 V_BSTR(&width
) = a2bstr(buf
);
2162 V_VT(&width
) = VT_EMPTY
;
2167 snprintf(buf
, 16, "%d", hght
);
2168 V_VT(&height
) = VT_BSTR
;
2169 V_BSTR(&height
) = a2bstr(buf
);
2171 V_VT(&height
) = VT_EMPTY
;
2175 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2176 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2178 IHTMLImageElementFactory_Release(factory
);
2179 VariantClear(&width
);
2180 VariantClear(&height
);
2182 if(SUCCEEDED(hres
)) {
2183 _test_img_width(line
, img
, wdth
);
2184 _test_img_height(line
, img
, hght
);
2191 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2192 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2194 LONG len
= 0xdeadbeef;
2197 hres
= IHTMLSelectElement_get_length(select
, &len
);
2198 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2199 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2202 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2203 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2205 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2208 hres
= IHTMLSelectElement_put_length(select
, length
);
2209 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2210 _test_select_length(line
, select
, length
);
2211 IHTMLSelectElement_Release(select
);
2214 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2215 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2217 LONG idx
= 0xdeadbeef;
2220 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2221 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2222 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2225 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2226 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2230 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2231 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2232 _test_select_selidx(line
, select
, index
);
2235 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2236 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2241 hres
= IHTMLSelectElement_get_value(select
, &val
);
2242 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2244 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2246 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2250 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2251 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2257 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2258 SysFreeString(bstr
);
2259 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2262 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2263 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2268 hres
= IHTMLSelectElement_get_type(select
, &type
);
2269 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2270 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2271 SysFreeString(type
);
2274 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2275 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2277 VARIANT_BOOL b
= 100;
2280 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2281 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2282 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2285 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2286 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2290 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2291 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2293 _test_select_multiple(line
, select
, val
);
2296 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2297 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2302 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2303 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2306 hres
= IHTMLSelectElement_get_size(select
, &val
);
2307 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2308 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2311 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2312 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2316 hres
= IHTMLSelectElement_put_size(select
, val
);
2317 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2320 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2321 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2327 hres
= IHTMLSelectElement_get_name(select
, &text
);
2328 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2330 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2331 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2332 wine_dbgstr_w(text
), extext
);
2333 SysFreeString(text
);
2335 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2338 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2339 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2344 bstr
= a2bstr(text
);
2346 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2347 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2348 SysFreeString(bstr
);
2351 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2352 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2357 hres
= IHTMLTxtRange_get_text(range
, &text
);
2358 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2361 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2362 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2364 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2367 SysFreeString(text
);
2371 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2372 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2376 hres
= IHTMLTxtRange_collapse(range
, b
);
2377 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2378 _test_range_text(line
, range
, NULL
);
2381 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2382 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2383 VARIANT_BOOL exb
, const char *extext
)
2385 VARIANT_BOOL b
= 0xe0e0;
2388 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2389 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2390 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2391 _test_range_text(line
, range
, extext
);
2394 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2395 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2397 LONG c
= 0xdeadbeef;
2400 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2401 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2402 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2403 _test_range_text(line
, range
, NULL
);
2406 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2407 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2408 LPWSTR unit
, LONG cnt
, LONG excnt
)
2410 LONG c
= 0xdeadbeef;
2413 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2414 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2415 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2418 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2419 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2421 LONG c
= 0xdeadbeef;
2424 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2425 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2426 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2429 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2430 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2433 BSTR bstr
= a2bstr(text
);
2435 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2436 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2437 SysFreeString(bstr
);
2438 _test_range_text(line
, range
, NULL
);
2441 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2442 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2448 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2449 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2450 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2453 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2454 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2460 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2461 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2462 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2465 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2466 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2467 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2470 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2471 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2475 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2476 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2478 BSTR str
= a2bstr(html
);
2481 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2482 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2486 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2487 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2492 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2493 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2495 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2497 IHTMLElement_Release(elem
);
2500 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2501 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2503 VARIANT name
, index
;
2508 V_VT(&index
) = VT_EMPTY
;
2509 V_VT(&name
) = VT_I4
;
2511 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2512 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2513 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2515 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2516 IDispatch_Release(disp
);
2520 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2521 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2522 const elem_type_t
*elem_types
, LONG exlen
)
2524 IHTMLElementCollection
*col
;
2525 IEnumVARIANT
*enum_var
;
2530 VARIANT name
, index
, v
, vs
[5];
2531 IDispatch
*disp
, *disp2
;
2534 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2535 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2537 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2539 hres
= IHTMLElementCollection_get_length(col
, &len
);
2540 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2541 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2546 V_VT(&index
) = VT_EMPTY
;
2548 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2549 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2551 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2552 IUnknown_Release(enum_unk
);
2553 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2555 for(i
=0; i
<len
; i
++) {
2556 V_VT(&name
) = VT_I4
;
2558 disp
= (void*)0xdeadbeef;
2559 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2560 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2561 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2562 if(FAILED(hres
) || !disp
)
2565 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2568 V_VT(&name
) = VT_UINT
;
2570 disp2
= (void*)0xdeadbeef;
2571 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2572 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2573 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2575 IDispatch_Release(disp2
);
2579 V_VT(&v
) = VT_ERROR
;
2580 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2581 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2583 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2584 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2585 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2586 IDispatch_Release(V_DISPATCH(&v
));
2588 IDispatch_Release(disp
);
2591 fetched
= 0xdeadbeef;
2593 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2594 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2595 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2596 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2598 hres
= IEnumVARIANT_Reset(enum_var
);
2599 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2601 fetched
= 0xdeadbeef;
2603 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2604 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2605 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2606 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2608 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2609 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2611 memset(vs
, 0, sizeof(vs
));
2613 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2614 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2615 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2617 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2618 IDispatch_Release(V_DISPATCH(vs
));
2621 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2622 IDispatch_Release(V_DISPATCH(vs
+1));
2625 hres
= IEnumVARIANT_Reset(enum_var
);
2626 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2628 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2629 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2631 IEnumVARIANT_Release(enum_var
);
2633 V_VT(&name
) = VT_I4
;
2635 disp
= (void*)0xdeadbeef;
2636 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2637 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2638 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2640 V_VT(&name
) = VT_UI4
;
2642 disp
= (void*)0xdeadbeef;
2643 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2644 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2645 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2647 V_VT(&name
) = VT_INT
;
2649 disp
= (void*)0xdeadbeef;
2650 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2651 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2652 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2654 V_VT(&name
) = VT_UINT
;
2656 disp
= (void*)0xdeadbeef;
2657 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2658 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2659 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2661 V_VT(&name
) = VT_I4
;
2663 disp
= (void*)0xdeadbeef;
2664 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2665 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2666 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2668 IHTMLElementCollection_Release(col
);
2671 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2672 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2674 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2678 hres
= IHTMLElement_get_all(elem
, &disp
);
2679 IHTMLElement_Release(elem
);
2680 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2682 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2683 IDispatch_Release(disp
);
2686 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2687 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2689 IHTMLElementCollection
*col
;
2692 hres
= IHTMLDocument2_get_all(doc
, &col
);
2693 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2695 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2696 IHTMLElementCollection_Release(col
);
2699 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2700 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2702 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2703 IHTMLElementCollection
*col
= NULL
;
2704 elem_type_t
*types
= NULL
;
2709 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2710 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2712 IHTMLElement2_Release(elem
);
2713 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2714 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2717 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2718 for(i
=0; i
<exlen
; i
++)
2722 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2724 HeapFree(GetProcessHeap(), 0, types
);
2727 *ret
= get_elem_col_item_idx(col
, 0);
2728 IHTMLElementCollection_Release(col
);
2731 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2732 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2734 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2735 IHTMLElementCollection
*col
= NULL
;
2736 elem_type_t
*types
= NULL
;
2741 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2742 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2744 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2745 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2748 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2749 for(i
=0; i
<exlen
; i
++)
2753 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2755 HeapFree(GetProcessHeap(), 0, types
);
2756 IHTMLElementCollection_Release(col
);
2757 IHTMLDocument3_Release(doc
);
2760 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2761 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2766 hres
= IHTMLElement_get_innerText(elem
, &text
);
2767 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2769 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2770 wine_dbgstr_w(text
), extext
);
2772 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2773 SysFreeString(text
);
2776 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2777 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2779 IHTMLDOMChildrenCollection
*col
;
2784 hres
= IHTMLElement_put_innerText(elem
, str
);
2785 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2788 _test_elem_innertext(line
, elem
, text
);
2791 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2792 ok(col
!= NULL
, "col == NULL\n");
2794 LONG length
= 0, type
;
2797 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2798 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2799 ok(length
== 1, "length = %d\n", length
);
2801 node
= _get_child_item(line
, col
, 0);
2802 ok(node
!= NULL
, "node == NULL\n");
2804 type
= _get_node_type(line
, (IUnknown
*)node
);
2805 ok(type
== 3, "type=%d\n", type
);
2806 IHTMLDOMNode_Release(node
);
2809 IHTMLDOMChildrenCollection_Release(col
);
2814 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
2815 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2820 hres
= IHTMLElement_get_outerText(elem
, &text
);
2821 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08x\n", hres
);
2823 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_outerText returned %s expected %s\n",
2824 wine_dbgstr_w(text
), extext
);
2826 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2827 SysFreeString(text
);
2830 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
2831 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2833 BSTR str
= a2bstr(text
);
2836 hres
= IHTMLElement_put_outerText(elem
, str
);
2837 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08x\n", hres
);
2841 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
2842 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
2844 BSTR str
= a2bstr("test");
2847 hres
= IHTMLElement_put_outerText(elem
, str
);
2848 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08x\n", hres
);
2852 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2853 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2855 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2859 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2860 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2862 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2864 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2866 IHTMLElement_Release(elem
);
2867 SysFreeString(html
);
2870 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2871 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2873 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2877 html
= a2bstr(inner_html
);
2878 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2879 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2881 IHTMLElement_Release(elem
);
2882 SysFreeString(html
);
2885 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2886 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2888 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2892 html
= a2bstr(outer_html
);
2893 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2894 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2896 IHTMLElement_Release(elem
);
2897 SysFreeString(html
);
2900 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2901 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2903 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2907 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2908 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2909 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2911 IHTMLElement_Release(elem
);
2912 SysFreeString(html
);
2915 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2916 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2922 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2923 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2924 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2927 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
2928 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
2934 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
2935 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
2936 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
2939 #define get_first_child(n) _get_first_child(__LINE__,n)
2940 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2942 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2943 IHTMLDOMNode
*child
= NULL
;
2946 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2947 IHTMLDOMNode_Release(node
);
2948 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2953 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2954 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2956 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2957 VARIANT_BOOL b
= 0xdead;
2960 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2961 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2962 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2964 IHTMLDOMNode_Release(node
);
2967 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2968 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2970 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2971 IHTMLDOMNode
*parent
;
2974 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2975 IHTMLDOMNode_Release(node
);
2976 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2981 #define node_get_next(u) _node_get_next(__LINE__,u)
2982 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2984 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2988 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2989 IHTMLDOMNode_Release(node
);
2990 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2995 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2996 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2998 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3002 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3003 IHTMLDOMNode_Release(node
);
3004 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
3009 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3010 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3012 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3013 IHTMLElement
*parent
;
3016 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3017 IHTMLElement_Release(elem
);
3018 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
3023 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3024 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3026 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3027 VARIANT_BOOL disabled
= 100;
3031 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3032 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3033 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3034 IHTMLElement3_Release(elem3
);
3037 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3038 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3040 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3044 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3045 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3047 IHTMLElement3_Release(elem3
);
3048 _test_elem3_get_disabled(line
, unk
, b
);
3051 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3052 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3054 VARIANT_BOOL disabled
= 100;
3057 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3058 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3059 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3061 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3064 static void test_select_remove(IHTMLSelectElement
*select
)
3068 hres
= IHTMLSelectElement_remove(select
, 3);
3069 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
3070 test_select_length(select
, 2);
3072 hres
= IHTMLSelectElement_remove(select
, -1);
3073 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3074 test_select_length(select
, 2);
3076 hres
= IHTMLSelectElement_remove(select
, 0);
3077 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3078 test_select_length(select
, 1);
3081 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3082 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3084 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3088 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3089 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3090 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3091 IHTMLDOMTextNode_Release(text
);
3094 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3095 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3097 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3101 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3102 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3103 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3104 IHTMLDOMTextNode_Release(text
);
3108 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3109 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3111 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3112 BSTR str
= a2bstr(data
);
3115 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3116 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3117 IHTMLDOMTextNode_Release(text
);
3121 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3122 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3124 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3125 BSTR str
= a2bstr(data
);
3128 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3129 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3130 IHTMLDOMTextNode2_Release(text
);
3134 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3135 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3139 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3140 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3142 _test_select_get_disabled(line
, select
, b
);
3145 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3146 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3148 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3152 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3153 IHTMLElement2_Release(elem
);
3154 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3156 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3158 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3163 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3164 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3166 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3167 BSTR dir
= a2bstr(dira
);
3170 hres
= IHTMLElement2_put_dir(elem
, dir
);
3171 IHTMLElement2_Release(elem
);
3172 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3175 _test_elem_dir(line
, unk
, dira
);
3178 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3179 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3181 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3182 IHTMLTextContainer
*txtcont
;
3183 LONG l
= -1, l2
= -1;
3186 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3187 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3188 IHTMLElement2_Release(elem
);
3190 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3191 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3193 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3194 IHTMLTextContainer_Release(txtcont
);
3195 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3196 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3201 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3202 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3204 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3205 IHTMLTextContainer
*txtcont
;
3206 LONG l
= -1, l2
= -1;
3209 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3210 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3211 IHTMLElement2_Release(elem
);
3213 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3214 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3216 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3217 IHTMLTextContainer_Release(txtcont
);
3218 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3219 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3224 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3225 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3227 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3228 IHTMLTextContainer
*txtcont
;
3229 LONG l
= -1, l2
= -1;
3232 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3234 IHTMLElement2_Release(elem
);
3236 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3237 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3239 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3240 IHTMLTextContainer_Release(txtcont
);
3241 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3242 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3247 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3248 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3250 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3251 IHTMLTextContainer
*txtcont
;
3252 LONG l
= -1, l2
= -1;
3255 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3256 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3258 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3259 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3260 IHTMLElement2_Release(elem
);
3262 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3263 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3265 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3266 IHTMLTextContainer_Release(txtcont
);
3267 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3268 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3271 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3272 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3274 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3278 hres
= IHTMLImgElement_get_src(img
, &src
);
3279 IHTMLImgElement_Release(img
);
3280 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3281 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3282 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3286 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3287 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3289 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3294 hres
= IHTMLImgElement_put_src(img
, tmp
);
3295 IHTMLImgElement_Release(img
);
3297 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3300 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3301 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3303 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3307 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3308 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3310 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3312 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3316 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3317 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3319 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3324 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3325 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3328 _test_img_alt(line
, unk
, alt
);
3331 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3332 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3334 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3338 tmp
= a2bstr(align
);
3339 hres
= IHTMLImgElement_put_align(img
, tmp
);
3340 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3343 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3344 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3345 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3349 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3350 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3352 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3356 hres
= IHTMLImgElement_get_name(img
, &sName
);
3357 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3358 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3359 IHTMLImgElement_Release(img
);
3360 SysFreeString(sName
);
3363 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3364 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3366 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3367 VARIANT_BOOL b
= 100;
3370 hres
= IHTMLImgElement_get_complete(img
, &b
);
3371 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3372 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3373 IHTMLImgElement_Release(img
);
3376 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3377 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3379 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3380 VARIANT_BOOL b
= 100;
3383 hres
= IHTMLImgElement_put_isMap(img
, v
);
3384 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3386 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3387 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3388 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3390 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3391 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3392 IHTMLImgElement_Release(img
);
3395 static void test_dynamic_properties(IHTMLElement
*elem
)
3397 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3398 IDispatchEx
*dispex
;
3399 BSTR name
, attr1
= SysAllocString(attr1W
);
3403 DISPID id
= DISPID_STARTENUM
;
3406 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3407 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3409 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3410 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3411 ok(succ
, "removeAttribute set succ to FALSE\n");
3414 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3415 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3419 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3420 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3422 if(!strcmp_wa(name
, "attr1"))
3423 ok(0, "attr1 should be removed\n");
3424 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3426 SysFreeString(name
);
3428 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3429 IDispatchEx_Release(dispex
);
3431 V_VT(&val
) = VT_BSTR
;
3432 V_BSTR(&val
) = attr1
;
3433 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3434 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3435 SysFreeString(attr1
);
3438 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3439 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3444 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3445 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3446 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3450 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3451 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3453 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3454 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3457 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3458 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
3459 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3460 IHTMLDOMAttribute2_Release(attr2
);
3463 static void test_attr_collection_disp(IDispatch
*disp
)
3465 IDispatchEx
*dispex
;
3466 IHTMLDOMAttribute
*attr
;
3467 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3474 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3475 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3478 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3479 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3480 SysFreeString(bstr
);
3483 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3484 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3485 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3486 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3489 bstr
= a2bstr("attr1");
3490 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3491 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3492 SysFreeString(bstr
);
3495 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3496 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3497 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3498 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3499 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3500 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3502 test_attr_node_name(attr
, "attr1");
3504 IHTMLDOMAttribute_Release(attr
);
3507 IDispatchEx_Release(dispex
);
3510 static void test_attr_collection(IHTMLElement
*elem
)
3512 static const WCHAR testW
[] = {'t','e','s','t',0};
3515 IDispatch
*disp
, *attr
;
3516 IHTMLDOMAttribute
*dom_attr
;
3517 IHTMLAttributeCollection
*attr_col
;
3518 BSTR name
= SysAllocString(testW
);
3520 LONG i
, len
, checked
;
3523 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3524 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3526 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3527 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3529 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3530 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3531 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3532 IDispatch_Release(attr
);
3533 IHTMLDOMNode_Release(node
);
3535 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3536 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3538 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3539 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3543 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3544 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3545 SysFreeString(name
);
3547 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3548 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3549 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3552 for(i
=0; i
<len
; i
++) {
3555 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3556 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3558 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3559 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3560 IDispatch_Release(attr
);
3562 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3563 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3565 if(!strcmp_wa(name
, "id")) {
3567 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3568 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3569 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3570 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3571 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3572 test_attr_value(dom_attr
, "attr");
3573 } else if(!strcmp_wa(name
, "attr1")) {
3575 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3576 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3577 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3578 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3579 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3580 test_attr_value(dom_attr
, "attr1");
3581 } else if(!strcmp_wa(name
, "attr2")) {
3583 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3584 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3585 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3586 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3587 test_attr_value(dom_attr
, "");
3588 } else if(!strcmp_wa(name
, "attr3")) {
3590 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3591 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3592 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3593 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3594 test_attr_value(dom_attr
, "attr3");
3595 } else if(!strcmp_wa(name
, "test")) {
3597 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3598 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3599 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3600 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3601 test_attr_value(dom_attr
, "1");
3604 IHTMLDOMAttribute_Release(dom_attr
);
3605 SysFreeString(name
);
3608 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3611 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3612 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3614 V_VT(&id
) = VT_BSTR
;
3615 V_BSTR(&id
) = a2bstr("nonexisting");
3616 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3617 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3620 test_attr_collection_disp(disp
);
3622 IDispatch_Release(disp
);
3623 IHTMLAttributeCollection_Release(attr_col
);
3626 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3627 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3629 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3630 BSTR id
= (void*)0xdeadbeef;
3633 hres
= IHTMLElement_get_id(elem
, &id
);
3634 IHTMLElement_Release(elem
);
3635 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3638 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3640 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3645 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3646 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3648 BSTR lang
= (void*)0xdeadbeef;
3651 hres
= IHTMLElement_get_language(elem
, &lang
);
3652 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3655 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3657 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3659 SysFreeString(lang
);
3662 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3663 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3665 BSTR str
= a2bstr(lang
);
3668 hres
= IHTMLElement_put_language(elem
, str
);
3669 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3672 _test_elem_language(line
, elem
, lang
);
3675 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3676 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3678 BSTR lang
= (void*)0xdeadbeef;
3681 hres
= IHTMLElement_get_lang(elem
, &lang
);
3682 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3685 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3687 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3689 SysFreeString(lang
);
3692 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3693 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3695 BSTR str
= a2bstr(lang
);
3698 hres
= IHTMLElement_put_lang(elem
, str
);
3699 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08x\n", hres
);
3702 _test_elem_lang(line
, elem
, lang
);
3705 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3706 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3708 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3709 BSTR tmp
= a2bstr(new_id
);
3712 hres
= IHTMLElement_put_id(elem
, tmp
);
3713 IHTMLElement_Release(elem
);
3715 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3717 _test_elem_id(line
, unk
, new_id
);
3720 static void test_contenteditable(IUnknown
*unk
)
3722 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3724 BSTR str
, strDefault
;
3726 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3727 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3729 str
= a2bstr("true");
3730 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3731 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3733 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3734 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3735 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3737 /* Restore origin contentEditable */
3738 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3739 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3740 SysFreeString(strDefault
);
3742 IHTMLElement3_Release(elem3
);
3745 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3746 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3751 hres
= IHTMLInputElement_get_type(input
, &type
);
3752 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3753 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3754 SysFreeString(type
);
3757 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3758 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3760 BSTR name
= (BSTR
)0xdeadbeef;
3763 hres
= IHTMLInputElement_get_name(input
, &name
);
3764 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3766 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3768 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3769 SysFreeString(name
);
3772 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3773 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3775 BSTR tmp
= a2bstr(name
);
3778 hres
= IHTMLInputElement_put_name(input
, tmp
);
3779 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3782 _test_input_name(line
, input
, name
);
3785 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3786 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3788 VARIANT_BOOL disabled
= 100;
3791 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3792 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3793 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3795 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3798 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3799 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3803 hres
= IHTMLInputElement_put_disabled(input
, b
);
3804 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3806 _test_input_get_disabled(line
, input
, b
);
3809 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3810 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3812 VARIANT_BOOL checked
= 100;
3815 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3816 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3817 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3820 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3821 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3825 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3826 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3828 _test_input_get_defaultchecked(line
, input
, b
);
3831 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3832 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3834 VARIANT_BOOL checked
= 100;
3837 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3838 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3839 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3842 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3843 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3847 hres
= IHTMLInputElement_put_checked(input
, b
);
3848 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3850 _test_input_get_checked(line
, input
, b
);
3853 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3854 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3856 LONG maxlength
= 0xdeadbeef;
3859 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3860 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3861 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3864 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3865 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3869 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3870 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3872 _test_input_maxlength(line
, input
, l
);
3875 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3876 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3878 IHTMLInputElement
*input
;
3882 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3883 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3887 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3888 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3890 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3892 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3893 SysFreeString(bstr
);
3894 IHTMLInputElement_Release(input
);
3897 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3898 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3900 IHTMLInputElement
*input
;
3901 IHTMLFormElement
*form
;
3905 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3906 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3907 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3908 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3909 if(FAILED(hres
) || input
== NULL
)
3912 hres
= IHTMLInputElement_get_form(input
, &form
);
3913 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3914 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3915 if(FAILED(hres
) || form
== NULL
){
3916 IHTMLInputElement_Release(input
);
3920 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3921 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3922 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3923 if(FAILED(hres
) || elem
== NULL
){
3924 IHTMLInputElement_Release(input
);
3925 IHTMLFormElement_Release(form
);
3929 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3931 IHTMLInputElement_Release(input
);
3932 IHTMLFormElement_Release(form
);
3933 IHTMLElement_Release(elem
);
3936 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3937 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3939 IHTMLInputElement
*input
;
3943 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3944 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3949 hres
= IHTMLInputElement_put_value(input
, bstr
);
3950 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3951 SysFreeString(bstr
);
3952 IHTMLInputElement_Release(input
);
3954 _test_input_value(line
, unk
, val
);
3957 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3958 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3960 IHTMLInputElement
*input
;
3964 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3965 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3969 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3970 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3972 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3974 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3976 IHTMLInputElement_Release(input
);
3979 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3980 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3982 IHTMLInputElement
*input
;
3986 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3987 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3992 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3993 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3995 IHTMLInputElement_Release(input
);
3997 _test_input_defaultValue(line
, unk
, val
);
4000 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4001 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
4006 hres
= IHTMLInputElement_get_src(input
, &src
);
4007 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
4009 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
4011 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4015 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4016 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
4022 hres
= IHTMLInputElement_put_src(input
, tmp
);
4024 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
4026 _test_input_src(line
, input
, src
);
4029 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4030 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4034 hres
= IHTMLInputElement_put_size(input
, size
);
4035 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
4038 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4039 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4044 hres
= IHTMLInputElement_get_size(input
, &size
);
4045 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
4046 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
4048 hres
= IHTMLInputElement_get_size(input
, NULL
);
4049 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
4052 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4053 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4056 VARIANT_BOOL b
= 100;
4058 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4059 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
4061 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4062 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
4063 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4066 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4067 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
4069 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4070 BSTR
class = (void*)0xdeadbeef;
4073 hres
= IHTMLElement_get_className(elem
, &class);
4074 IHTMLElement_Release(elem
);
4075 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
4077 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4079 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4080 SysFreeString(class);
4083 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4084 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4086 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4090 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4091 IHTMLElement2_Release(elem2
);
4092 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4093 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4096 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4097 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4099 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4102 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4103 IHTMLElement2_Release(elem2
);
4104 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
4106 _test_elem_tabindex(line
, unk
, index
);
4109 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4110 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
4112 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4116 hres
= IHTMLStyleElement_get_media(style
, &media
);
4117 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4119 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4121 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4123 IHTMLStyleElement_Release(style
);
4124 SysFreeString(media
);
4127 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4128 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4130 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4134 str
= a2bstr(media
);
4135 hres
= IHTMLStyleElement_put_media(style
, str
);
4136 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4137 IHTMLStyleElement_Release(style
);
4140 _test_style_media(line
, unk
, media
);
4143 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4144 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4146 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4150 hres
= IHTMLStyleElement_get_type(style
, &type
);
4151 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4153 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4155 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4157 IHTMLStyleElement_Release(style
);
4158 SysFreeString(type
);
4161 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4162 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4164 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4169 hres
= IHTMLStyleElement_put_type(style
, str
);
4170 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4171 IHTMLStyleElement_Release(style
);
4174 _test_style_type(line
, unk
, type
);
4177 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4178 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4180 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4182 IHTMLFiltersCollection
*filters
;
4184 hres
= IHTMLElement_get_filters(elem
, &filters
);
4185 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4186 "get_filters failed: %08x\n", hres
);
4190 IDispatchEx
*dispex
;
4192 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4193 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4194 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4196 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4197 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4198 "Could not get IDispatchEx interface: %08x\n", hres
);
4199 if(SUCCEEDED(hres
)) {
4200 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
4201 IDispatchEx_Release(dispex
);
4204 IHTMLFiltersCollection_Release(filters
);
4207 IHTMLElement_Release(elem
);
4210 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4211 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4213 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4217 tmp
= class ? a2bstr(class) : NULL
;
4218 hres
= IHTMLElement_put_className(elem
, tmp
);
4219 IHTMLElement_Release(elem
);
4220 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4223 _test_elem_class(line
, unk
, class);
4226 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4227 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4229 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4233 hres
= IHTMLElement_get_title(elem
, &title
);
4234 IHTMLElement_Release(elem
);
4235 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4237 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4239 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4241 SysFreeString(title
);
4244 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4245 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4247 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4251 tmp
= a2bstr(title
);
4252 hres
= IHTMLElement_put_title(elem
, tmp
);
4253 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4255 IHTMLElement_Release(elem
);
4259 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4260 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4262 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4266 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4267 IHTMLDOMNode_Release(node
);
4268 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4271 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4272 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4274 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4280 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4281 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4283 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4287 V_VT(&var
) = VT_BSTR
;
4288 V_BSTR(&var
) = a2bstr(val
);
4290 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4291 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4292 IHTMLDOMNode_Release(node
);
4296 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4297 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4299 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4303 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4304 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4305 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4306 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4308 IHTMLElement2_Release(elem
);
4311 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4312 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4314 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4318 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4320 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4322 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4323 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4324 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4326 IHTMLElement2_Release(elem
);
4329 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4330 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4332 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4333 LONG len
= 0xdeadbeef;
4336 hres
= IHTMLFormElement_get_length(form
, &len
);
4337 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4338 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4340 IHTMLFormElement_Release(form
);
4343 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4344 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4346 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4347 BSTR action
= (void*)0xdeadbeef;
4350 hres
= IHTMLFormElement_get_action(form
, &action
);
4351 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4353 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4355 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4357 SysFreeString(action
);
4358 IHTMLFormElement_Release(form
);
4361 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4362 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4364 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4365 BSTR tmp
= a2bstr(action
);
4368 hres
= IHTMLFormElement_put_action(form
, tmp
);
4369 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4371 IHTMLFormElement_Release(form
);
4373 _test_form_action(line
, unk
, action
);
4376 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4377 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4379 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4380 BSTR method
= (void*)0xdeadbeef;
4383 hres
= IHTMLFormElement_get_method(form
, &method
);
4384 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4386 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4388 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4390 SysFreeString(method
);
4391 IHTMLFormElement_Release(form
);
4394 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4395 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4397 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4398 BSTR tmp
= a2bstr(method
);
4401 hres
= IHTMLFormElement_put_method(form
, tmp
);
4402 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4404 IHTMLFormElement_Release(form
);
4406 if(exp_hres
== S_OK
)
4407 _test_form_method(line
, unk
, method
);
4410 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4411 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4413 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4414 BSTR name
= (void*)0xdeadbeef;
4417 hres
= IHTMLFormElement_get_name(form
, &name
);
4418 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4420 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4422 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4424 SysFreeString(name
);
4425 IHTMLFormElement_Release(form
);
4428 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4429 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4431 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4432 BSTR tmp
= a2bstr(name
);
4435 hres
= IHTMLFormElement_put_name(form
, tmp
);
4436 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4438 IHTMLFormElement_Release(form
);
4440 _test_form_name(line
, unk
, name
);
4443 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4444 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4446 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4447 BSTR encoding
= (void*)0xdeadbeef;
4450 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4451 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4453 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4455 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4457 SysFreeString(encoding
);
4458 IHTMLFormElement_Release(form
);
4461 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4462 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4464 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4465 BSTR tmp
= a2bstr(encoding
);
4468 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4469 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4471 IHTMLFormElement_Release(form
);
4473 if(exp_hres
== S_OK
)
4474 _test_form_encoding(line
, unk
, encoding
);
4477 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4478 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4480 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4485 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4486 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4487 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4488 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4490 IDispatch_Release(disp
);
4491 IHTMLFormElement_Release(form
);
4494 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4495 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4497 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4500 hres
= IHTMLFormElement_reset(form
);
4501 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4503 IHTMLFormElement_Release(form
);
4506 static void test_form_target(IUnknown
*unk
)
4508 IHTMLFormElement
*form
= get_form_iface(unk
);
4511 static const char target
[] = "_blank";
4513 str
= a2bstr(target
);
4514 hres
= IHTMLFormElement_put_target(form
, str
);
4515 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4518 hres
= IHTMLFormElement_get_target(form
, &str
);
4519 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4520 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4523 IHTMLFormElement_Release(form
);
4526 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4528 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4529 IHTMLFormElement
*form
;
4532 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4533 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4535 hres
= IHTMLSelectElement_get_form(select
, &form
);
4536 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4537 ok(form
!= NULL
, "form == NULL\n");
4539 test_form_length((IUnknown
*)form
, 1);
4540 test_form_elements((IUnknown
*)form
);
4541 test_form_name((IUnknown
*)form
, "form_name");
4543 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4545 IHTMLSelectElement_Release(select
);
4546 IHTMLFormElement_Release(form
);
4549 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4551 IHTMLFormElement
*form
;
4554 form
= (IHTMLFormElement
*)0xdeadbeef;
4555 hres
= IHTMLSelectElement_get_form(select
, &form
);
4556 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4557 ok(form
== NULL
, "got %p\n", form
);
4560 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4561 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4563 IHTMLMetaElement
*meta
;
4567 meta
= _get_metaelem_iface(line
, unk
);
4568 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4569 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4570 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4571 SysFreeString(name
);
4572 IHTMLMetaElement_Release(meta
);
4575 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4576 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4578 IHTMLMetaElement
*meta
;
4579 BSTR content
= NULL
;
4582 meta
= _get_metaelem_iface(line
, unk
);
4583 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4584 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4585 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4586 SysFreeString(content
);
4587 IHTMLMetaElement_Release(meta
);
4590 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4591 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4593 IHTMLMetaElement
*meta
;
4597 meta
= _get_metaelem_iface(line
, unk
);
4598 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4599 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4600 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4602 IHTMLMetaElement_Release(meta
);
4605 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4606 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4608 IHTMLMetaElement
*meta
;
4612 meta
= _get_metaelem_iface(line
, unk
);
4613 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4614 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4616 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4618 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4620 IHTMLMetaElement_Release(meta
);
4623 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4624 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4626 BSTR val
= a2bstr(vala
);
4627 IHTMLMetaElement
*meta
;
4630 meta
= _get_metaelem_iface(line
, unk
);
4631 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4632 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4634 IHTMLMetaElement_Release(meta
);
4636 _test_meta_charset(line
, unk
, vala
);
4639 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4640 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4642 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4646 str
= a2bstr(exval
);
4647 hres
= IHTMLLinkElement_put_media(link
, str
);
4648 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4651 hres
= IHTMLLinkElement_get_media(link
, &str
);
4652 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4653 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4655 IHTMLLinkElement_Release(link
);
4658 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4659 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4661 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4662 VARIANT_BOOL b
= 10;
4665 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4666 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4667 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4669 IHTMLLinkElement_Release(link
);
4672 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4673 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4675 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4678 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4679 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4680 IHTMLLinkElement_Release(link
);
4681 _test_link_disabled(line
, elem
, v
);
4684 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4685 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4687 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4691 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4692 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4694 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4696 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4698 IHTMLLinkElement_Release(link
);
4701 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4702 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4704 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4705 BSTR str
= a2bstr(v
);
4708 hres
= IHTMLLinkElement_put_rel(link
, str
);
4709 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4711 IHTMLLinkElement_Release(link
);
4712 _test_link_rel(line
, elem
, v
);
4715 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4716 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4718 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4722 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4723 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4725 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4727 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4729 IHTMLLinkElement_Release(link
);
4732 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4733 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4735 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4736 BSTR str
= a2bstr(v
);
4739 hres
= IHTMLLinkElement_put_rev(link
, str
);
4740 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4742 IHTMLLinkElement_Release(link
);
4743 _test_link_rev(line
, elem
, v
);
4746 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4747 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4749 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4753 hres
= IHTMLLinkElement_get_type(link
, &type
);
4754 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4756 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4758 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4760 IHTMLLinkElement_Release(link
);
4763 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4764 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4769 str
= (void*)0xdeadbeef;
4770 hres
= IHTMLScriptElement_get_text(script
, &str
);
4771 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4772 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4776 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4777 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4779 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4780 BSTR str
= a2bstr(v
);
4783 hres
= IHTMLLinkElement_put_type(link
, str
);
4784 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4786 IHTMLLinkElement_Release(link
);
4787 _test_link_type(line
, elem
, v
);
4790 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4791 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4793 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4797 hres
= IHTMLLinkElement_get_href(link
, &href
);
4798 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4800 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4802 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4804 IHTMLLinkElement_Release(link
);
4807 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4808 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4810 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4811 BSTR str
= a2bstr(v
);
4814 hres
= IHTMLLinkElement_put_href(link
, str
);
4815 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4817 IHTMLLinkElement_Release(link
);
4818 _test_link_href(line
, elem
, v
);
4821 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4822 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4824 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4825 IHTMLDocument2
*doc
;
4830 hres
= IHTMLElement_get_document(elem
, &disp
);
4831 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4832 ok(disp
!= NULL
, "disp == NULL\n");
4834 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4835 IDispatch_Release(disp
);
4836 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4841 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4842 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4844 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4845 BSTR str
= a2bstr(attr_name
);
4846 IHTMLDOMAttribute
*attr
;
4849 attr
= (void*)0xdeadbeef;
4850 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4851 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4853 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4855 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4857 IHTMLElement4_Release(elem
);
4862 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4863 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4868 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4869 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4870 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4873 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4874 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4878 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4879 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4882 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4883 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4885 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4886 BSTR str
= a2bstr(value
);
4889 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4890 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4892 IHTMLDOMAttribute2_Release(attr2
);
4896 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4897 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4899 IHTMLDocument2
*doc
;
4903 hres
= IHTMLWindow2_get_document(window
, &doc
);
4904 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4905 ok(doc
!= NULL
, "disp == NULL\n");
4910 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4911 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4916 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4917 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4918 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4923 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4924 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4926 IHTMLElement
*elem
= NULL
;
4931 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4932 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4933 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4939 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4940 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4942 IHTMLDocument3
*doc3
;
4943 IHTMLDOMNode
*node
= NULL
;
4947 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4948 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4951 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4952 IHTMLDocument3_Release(doc3
);
4954 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4955 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4960 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4961 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4963 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4964 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4965 IHTMLDOMNode
*new_child
= NULL
;
4968 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4969 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4970 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4971 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4973 IHTMLDOMNode_Release(node
);
4974 IHTMLDOMNode_Release(child
);
4979 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4980 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4982 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4983 IHTMLDOMNode
*new_child
= NULL
;
4986 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4987 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4988 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4989 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4991 IHTMLDOMNode_Release(node
);
4996 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4997 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4999 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5000 IHTMLDOMNode
*new_node
= NULL
;
5003 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5004 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
5005 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5006 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5008 IHTMLDOMNode_Release(node
);
5009 IHTMLDOMNode_Release(new_node
);
5012 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5013 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
5018 hres
= IHTMLDocument2_get_title(doc
, &title
);
5019 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5020 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5021 SysFreeString(title
);
5024 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5025 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
5030 tmp
= a2bstr(title
);
5031 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5032 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
5036 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5038 IHTMLRect
*rect
, *rect2
;
5039 IHTMLElement2
*elem2
;
5043 elem2
= get_elem2_iface(unk
);
5044 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5045 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5046 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5047 IHTMLElement2_Release(elem2
);
5048 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
5049 ok(rect
!= NULL
, "rect == NULL\n");
5050 ok(rect
!= rect2
, "rect == rect2\n");
5051 IHTMLRect_Release(rect2
);
5053 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
5056 hres
= IHTMLRect_get_top(rect
, &l
);
5057 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
5058 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5061 hres
= IHTMLRect_get_left(rect
, &l
);
5062 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
5063 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5066 hres
= IHTMLRect_get_bottom(rect
, &l
);
5067 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
5068 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5071 hres
= IHTMLRect_get_right(rect
, &l
);
5072 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
5073 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5075 IHTMLRect_Release(rect
);
5078 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
5079 const elem_type_t
*elem_types
, LONG len
)
5082 VARIANT name
, index
;
5086 V_VT(&index
) = VT_EMPTY
;
5087 V_VT(&name
) = VT_BSTR
;
5088 V_BSTR(&name
) = a2bstr(n
);
5090 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5091 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5093 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5094 IDispatch_Release(disp
);
5096 V_VT(&index
) = VT_I4
;
5098 for(i
=0; i
<len
; i
++) {
5100 disp
= (void*)0xdeadbeef;
5101 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5102 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5103 ok(disp
!= NULL
, "disp == NULL\n");
5104 if(FAILED(hres
) || !disp
)
5107 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5109 IDispatch_Release(disp
);
5113 disp
= (void*)0xdeadbeef;
5114 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5115 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5116 ok(disp
== NULL
, "disp != NULL\n");
5119 disp
= (void*)0xdeadbeef;
5120 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5121 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5122 ok(disp
== NULL
, "disp != NULL\n");
5124 SysFreeString(V_BSTR(&name
));
5127 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5129 IHTMLElementCollection
*col
;
5131 IDispatch
*disp
= (void*)0xdeadbeef;
5132 VARIANT name
, index
;
5135 hres
= IHTMLDocument2_get_all(doc
, &col
);
5136 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5137 ok(col
!= NULL
, "col == NULL\n");
5138 if(FAILED(hres
) || !col
)
5141 V_VT(&index
) = VT_EMPTY
;
5142 V_VT(&name
) = VT_BSTR
;
5143 V_BSTR(&name
) = a2bstr(id
);
5145 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5146 IHTMLElementCollection_Release(col
);
5147 SysFreeString(V_BSTR(&name
));
5148 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5149 if(!expect_success
) {
5150 ok(disp
== NULL
, "disp != NULL\n");
5154 ok(disp
!= NULL
, "disp == NULL\n");
5158 elem
= get_elem_iface((IUnknown
*)disp
);
5159 IDispatch_Release(disp
);
5164 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5166 IHTMLDocument3
*doc3
;
5171 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5172 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5175 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5177 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5179 IHTMLDocument3_Release(doc3
);
5184 static void test_select_elem(IHTMLSelectElement
*select
)
5186 IDispatch
*disp
, *disp2
;
5187 VARIANT name
, index
;
5190 test_select_type(select
, "select-one");
5191 test_select_length(select
, 2);
5192 test_select_selidx(select
, 0);
5193 test_select_put_selidx(select
, 1);
5195 test_select_set_value(select
, "val1");
5196 test_select_value(select
, "val1");
5198 test_select_size(select
, 0);
5199 test_select_set_size(select
, 1, S_OK
);
5200 test_select_size(select
, 1);
5202 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5203 test_select_size(select
, 1);
5204 test_select_set_size(select
, 3, S_OK
);
5205 test_select_size(select
, 3);
5207 test_select_name(select
, NULL
);
5208 test_select_set_name(select
, "select-name");
5209 test_select_name(select
, "select-name");
5210 test_select_form_notfound(select
);
5212 test_select_get_disabled(select
, VARIANT_FALSE
);
5213 test_select_set_disabled(select
, VARIANT_TRUE
);
5214 test_select_set_disabled(select
, VARIANT_FALSE
);
5217 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5218 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5219 ok(disp
!= NULL
, "options == NULL\n");
5220 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5221 IDispatch_Release(disp
);
5223 V_VT(&index
) = VT_EMPTY
;
5224 V_VT(&name
) = VT_I4
;
5226 disp
= (void*)0xdeadbeef;
5227 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5228 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5229 ok(!disp
, "disp = %p\n", disp
);
5232 disp
= (void*)0xdeadbeef;
5233 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5234 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5235 ok(!disp
, "disp = %p\n", disp
);
5238 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5239 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5242 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5243 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5244 ok(disp
!= NULL
, "disp = NULL\n");
5245 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
5247 V_VT(&index
) = VT_I4
;
5250 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5251 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5252 ok(disp2
!= NULL
, "disp = NULL\n");
5253 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5254 IDispatch_Release(disp2
);
5255 IDispatch_Release(disp
);
5257 test_select_multiple(select
, VARIANT_FALSE
);
5258 test_select_set_multiple(select
, VARIANT_TRUE
);
5259 test_select_remove(select
);
5262 static void test_form_item(IHTMLElement
*elem
)
5264 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5265 IDispatch
*disp
, *disp2
;
5266 VARIANT name
, index
;
5269 V_VT(&index
) = VT_EMPTY
;
5270 V_VT(&name
) = VT_I4
;
5272 disp
= (void*)0xdeadbeef;
5273 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5274 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5275 ok(!disp
, "disp = %p\n", disp
);
5278 disp
= (void*)0xdeadbeef;
5279 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5280 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5281 ok(!disp
, "disp = %p\n", disp
);
5284 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5285 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5288 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5289 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5290 ok(disp
!= NULL
, "disp = NULL\n");
5291 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
5293 V_VT(&index
) = VT_I4
;
5296 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5297 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5298 ok(disp2
!= NULL
, "disp = NULL\n");
5299 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5300 IDispatch_Release(disp2
);
5301 IDispatch_Release(disp
);
5304 static void test_create_option_elem(IHTMLDocument2
*doc
)
5306 IHTMLOptionElement
*option
;
5308 option
= create_option_elem(doc
, "test text", "test value");
5310 test_option_put_text(option
, "new text");
5311 test_option_put_value(option
, "new value");
5312 test_option_get_index(option
, 0);
5313 test_option_defaultSelected_property(option
);
5314 test_option_put_selected(option
, VARIANT_TRUE
);
5315 test_option_put_selected(option
, VARIANT_FALSE
);
5317 IHTMLOptionElement_Release(option
);
5320 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5322 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5323 IHTMLFormElement
*form
;
5326 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5327 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5329 hres
= IHTMLOptionElement_get_form(option
, &form
);
5330 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5331 ok(form
!= NULL
, "form == NULL\n");
5333 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5335 IHTMLOptionElement_Release(option
);
5336 IHTMLFormElement_Release(form
);
5339 static void test_create_img_elem(IHTMLDocument2
*doc
)
5341 IHTMLImgElement
*img
;
5343 img
= create_img_elem(doc
, 10, 15);
5346 test_img_put_width(img
, 5);
5347 test_img_put_height(img
, 20);
5349 IHTMLImgElement_Release(img
);
5353 img
= create_img_elem(doc
, -1, -1);
5356 test_img_put_width(img
, 5);
5357 test_img_put_height(img
, 20);
5359 IHTMLImgElement_Release(img
);
5363 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5364 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5366 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5367 IHTMLElement
*ret_elem
= NULL
;
5368 BSTR str
= a2bstr(where
);
5371 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5372 IHTMLElement2_Release(elem2
);
5374 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5375 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5376 IHTMLElement_Release(ret_elem
);
5379 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5381 IHTMLElement
*elem
, *elem2
;
5383 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5384 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5386 elem
= test_create_elem(doc
, "BR");
5387 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5388 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5389 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5390 IHTMLElement_Release(elem
);
5392 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5394 elem
= test_create_elem(doc
, "BR");
5395 insert_adjacent_elem(parent
, "beforeend", elem
);
5397 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5399 elem2
= test_create_elem(doc
, "DIV");
5400 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5401 IHTMLElement_Release(elem2
);
5402 IHTMLElement_Release(elem
);
5404 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5407 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5409 IHTMLBodyElement
*body
;
5410 IHTMLTxtRange
*range
;
5414 elem
= doc_get_body(doc
);
5415 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5416 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5417 IHTMLElement_Release(elem
);
5419 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5420 IHTMLBodyElement_Release(body
);
5421 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5426 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5427 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5432 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5433 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5438 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5439 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5440 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5442 BSTR str
= a2bstr(how
);
5445 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5446 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5450 static void test_txtrange(IHTMLDocument2
*doc
)
5452 IHTMLTxtRange
*body_range
, *range
, *range2
;
5453 IHTMLSelectionObject
*selection
;
5454 IDispatch
*disp_range
;
5458 body_range
= test_create_body_range(doc
);
5460 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, "[object]");
5462 test_range_text(body_range
, "test abc 123\r\nit's text");
5464 range
= range_duplicate(body_range
);
5465 range2
= range_duplicate(body_range
);
5467 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5469 test_range_text(range
, "test abc 123\r\nit's text");
5470 test_range_text(body_range
, "test abc 123\r\nit's text");
5472 test_range_collapse(range
, TRUE
);
5473 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5474 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5475 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5476 IHTMLTxtRange_Release(range2
);
5478 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5479 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5480 test_range_move(range
, characterW
, 2, 2);
5481 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5483 test_range_collapse(range
, FALSE
);
5484 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5486 test_range_collapse(range
, FALSE
);
5487 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5488 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5489 test_range_move(range
, characterW
, 2, 2);
5490 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5491 test_range_moveend(range
, characterW
, -5, -5);
5492 test_range_text(range
, NULL
);
5493 test_range_moveend(range
, characterW
, 3, 3);
5494 test_range_text(range
, "c 1");
5495 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5496 test_range_collapse(range
, TRUE
);
5497 test_range_move(range
, characterW
, 4, 4);
5498 test_range_moveend(range
, characterW
, 1, 1);
5499 test_range_text(range
, " ");
5500 test_range_move(range
, wordW
, 1, 1);
5501 test_range_moveend(range
, characterW
, 2, 2);
5502 test_range_text(range
, "ab");
5504 IHTMLTxtRange_Release(range
);
5506 range
= range_duplicate(body_range
);
5508 test_range_text(range
, "test abc 123\r\nit's text");
5509 test_range_move(range
, characterW
, 3, 3);
5510 test_range_moveend(range
, characterW
, 1, 1);
5511 test_range_text(range
, "t");
5512 test_range_moveend(range
, characterW
, 3, 3);
5513 test_range_text(range
, "t ab");
5514 test_range_moveend(range
, characterW
, -2, -2);
5515 test_range_text(range
, "t ");
5516 test_range_move(range
, characterW
, 6, 6);
5517 test_range_moveend(range
, characterW
, 3, 3);
5518 test_range_text(range
, "123");
5519 test_range_moveend(range
, characterW
, 2, 2);
5520 test_range_text(range
, "123\r\ni");
5522 IHTMLTxtRange_Release(range
);
5524 range
= range_duplicate(body_range
);
5526 test_range_move(range
, wordW
, 1, 1);
5527 test_range_moveend(range
, characterW
, 2, 2);
5528 test_range_text(range
, "ab");
5530 test_range_move(range
, characterW
, -2, -2);
5531 test_range_moveend(range
, characterW
, 2, 2);
5532 test_range_text(range
, "t ");
5534 test_range_move(range
, wordW
, 3, 3);
5535 test_range_move(range
, wordW
, -2, -2);
5536 test_range_moveend(range
, characterW
, 2, 2);
5537 test_range_text(range
, "ab");
5539 test_range_move(range
, characterW
, -6, -5);
5540 test_range_moveend(range
, characterW
, -1, 0);
5541 test_range_moveend(range
, characterW
, -6, 0);
5542 test_range_move(range
, characterW
, 2, 2);
5543 test_range_moveend(range
, characterW
, 2, 2);
5544 test_range_text(range
, "st");
5545 test_range_moveend(range
, characterW
, -6, -4);
5546 test_range_moveend(range
, characterW
, 2, 2);
5548 IHTMLTxtRange_Release(range
);
5550 range
= range_duplicate(body_range
);
5552 test_range_move(range
, wordW
, 2, 2);
5553 test_range_moveend(range
, characterW
, 2, 2);
5554 test_range_text(range
, "12");
5556 test_range_move(range
, characterW
, 15, 14);
5557 test_range_move(range
, characterW
, -2, -2);
5558 test_range_moveend(range
, characterW
, 3, 2);
5559 test_range_text(range
, "t");
5560 test_range_moveend(range
, characterW
, -1, -1);
5561 test_range_text(range
, "t");
5562 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5563 test_range_move(range
, characterW
, -2, -2);
5564 test_range_moveend(range
, characterW
, 2, 2);
5565 test_range_text(range
, "s ");
5566 test_range_move(range
, characterW
, 100, 7);
5567 test_range_move(range
, wordW
, 1, 0);
5568 test_range_move(range
, characterW
, -2, -2);
5569 test_range_moveend(range
, characterW
, 3, 2);
5570 test_range_text(range
, "t");
5572 IHTMLTxtRange_Release(range
);
5574 range
= range_duplicate(body_range
);
5576 test_range_collapse(range
, TRUE
);
5577 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5578 test_range_put_text(range
, "word");
5579 test_range_text(body_range
, "wordabc 123\r\nit's text");
5580 test_range_text(range
, NULL
);
5581 test_range_moveend(range
, characterW
, 3, 3);
5582 test_range_text(range
, "abc");
5583 test_range_movestart(range
, characterW
, -2, -2);
5584 test_range_text(range
, "rdabc");
5585 test_range_movestart(range
, characterW
, 3, 3);
5586 test_range_text(range
, "bc");
5587 test_range_movestart(range
, characterW
, 4, 4);
5588 test_range_text(range
, NULL
);
5589 test_range_movestart(range
, characterW
, -3, -3);
5590 test_range_text(range
, "c 1");
5591 test_range_movestart(range
, characterW
, -7, -6);
5592 test_range_text(range
, "wordabc 1");
5593 test_range_movestart(range
, characterW
, 100, 22);
5594 test_range_text(range
, NULL
);
5596 IHTMLTxtRange_Release(range
);
5598 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5599 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5601 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, "[object]");
5602 test_ifaces((IUnknown
*)selection
, selection_iids
);
5604 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5605 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5606 IHTMLSelectionObject_Release(selection
);
5608 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5609 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5610 IDispatch_Release(disp_range
);
5612 test_range_text(range
, NULL
);
5613 test_range_moveend(range
, characterW
, 3, 3);
5614 test_range_text(range
, "wor");
5615 test_range_parent(range
, ET_BODY
);
5616 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5617 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5618 test_range_move(range
, characterW
, 3, 3);
5619 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5620 test_range_moveend(range
, characterW
, -4, -4);
5621 test_range_put_text(range
, "abc def ");
5622 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5623 test_range_move(range
, wordW
, 1, 1);
5624 test_range_movestart(range
, characterW
, -1, -1);
5625 test_range_text(range
, " ");
5626 test_range_move(range
, wordW
, 1, 1);
5627 test_range_moveend(range
, characterW
, 3, 3);
5628 test_range_text(range
, "def");
5629 test_range_put_text(range
, "xyz");
5630 test_range_moveend(range
, characterW
, 1, 1);
5631 test_range_move(range
, wordW
, 1, 1);
5632 test_range_moveend(range
, characterW
, 2, 2);
5633 test_range_text(range
, "ab");
5635 body
= doc_get_body(doc
);
5637 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5638 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5640 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5641 test_range_parent(range
, ET_BODY
);
5643 test_range_move(range
, wordW
, 1, 1);
5644 test_range_moveend(range
, characterW
, 12, 12);
5645 test_range_text(range
, "xyz abc 123");
5647 test_range_collapse(range
, VARIANT_TRUE
);
5648 test_range_paste_html(range
, "<br>paste<br>");
5649 test_range_text(range
, NULL
);
5651 test_range_moveend(range
, characterW
, 3, 3);
5652 test_range_text(range
, "xyz");
5654 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5655 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5657 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5659 test_range_move(range
, wordW
, 2, 2);
5660 test_range_collapse(range
, VARIANT_TRUE
);
5661 test_range_moveend(range
, characterW
, 5, 5);
5662 test_range_text(range
, "paste");
5664 range2
= range_duplicate(range
);
5666 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5667 test_range_text(range
, "abc \r\npaste");
5669 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5670 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5672 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5673 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5675 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5676 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5677 test_range_text(range
, "abc ");
5679 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5680 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5682 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5683 test_range_text(range
, "abc ");
5685 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5687 IHTMLTxtRange_Release(range
);
5688 IHTMLTxtRange_Release(range2
);
5689 IHTMLTxtRange_Release(body_range
);
5690 IHTMLElement_Release(body
);
5694 static void test_txtrange2(IHTMLDocument2
*doc
)
5696 IHTMLTxtRange
*range
;
5698 range
= test_create_body_range(doc
);
5700 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5701 test_range_move(range
, characterW
, 5, 5);
5702 test_range_moveend(range
, characterW
, 1, 1);
5703 test_range_text(range
, "2");
5704 test_range_move(range
, characterW
, -3, -3);
5705 test_range_moveend(range
, characterW
, 3, 3);
5706 test_range_text(range
, "c\r\n\r\n1");
5707 test_range_collapse(range
, VARIANT_FALSE
);
5708 test_range_moveend(range
, characterW
, 4, 4);
5709 test_range_text(range
, "23");
5710 test_range_moveend(range
, characterW
, 1, 1);
5711 test_range_text(range
, "23\r\n\r\n\r\nd");
5712 test_range_moveend(range
, characterW
, -1, -1);
5713 test_range_text(range
, "23");
5714 test_range_moveend(range
, characterW
, -1, -1);
5715 test_range_text(range
, "23");
5716 test_range_moveend(range
, characterW
, -2, -2);
5717 test_range_text(range
, "2");
5719 IHTMLTxtRange_Release(range
);
5722 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5723 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5725 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5729 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5730 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5731 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5733 IHTMLDocument5_Release(doc
);
5736 static void test_location(IHTMLDocument2
*doc
)
5738 IHTMLLocation
*location
, *location2
;
5739 IHTMLWindow2
*window
;
5744 hres
= IHTMLDocument2_get_location(doc
, &location
);
5745 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5747 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5748 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5750 ok(location
== location2
, "location != location2\n");
5751 IHTMLLocation_Release(location2
);
5753 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5754 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5756 hres
= IHTMLWindow2_get_location(window
, &location2
);
5757 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5758 ok(location
== location2
, "location != location2\n");
5759 IHTMLLocation_Release(location2
);
5761 test_ifaces((IUnknown
*)location
, location_iids
);
5762 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5764 hres
= IHTMLLocation_get_pathname(location
, &str
);
5765 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5766 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5769 hres
= IHTMLLocation_get_href(location
, NULL
);
5770 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5772 hres
= IHTMLLocation_get_href(location
, &str
);
5773 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5774 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5777 ref
= IHTMLLocation_Release(location
);
5778 ok(!ref
, "location should be destroyed here\n");
5781 static void test_plugins_col(IHTMLDocument2
*doc
)
5783 IHTMLPluginsCollection
*col
, *col2
;
5784 IHTMLWindow2
*window
;
5790 window
= get_doc_window(doc
);
5791 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5792 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5793 IHTMLWindow2_Release(window
);
5795 hres
= IOmNavigator_get_plugins(nav
, &col
);
5796 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5798 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5799 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5800 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5801 IHTMLPluginsCollection_Release(col2
);
5803 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5806 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5807 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5808 ok(!len
, "length = %d\n", len
);
5810 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5811 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5813 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5814 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5816 ref
= IHTMLPluginsCollection_Release(col
);
5817 ok(!ref
, "ref=%d\n", ref
);
5819 IOmNavigator_Release(nav
);
5822 static void test_mime_types_col(IOmNavigator
*nav
)
5824 IHTMLMimeTypesCollection
*col
, *col2
;
5829 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5830 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5832 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5833 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5834 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5835 IHTMLMimeTypesCollection_Release(col2
);
5837 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5839 length
= 0xdeadbeef;
5840 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5841 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5842 ok(!length
, "length = %d\n", length
);
5844 ref
= IHTMLMimeTypesCollection_Release(col
);
5845 ok(!ref
, "ref=%d\n", ref
);
5848 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5849 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5851 BSTR str
= (void*)0xdeadbeef;
5852 IHTMLFrameBase
*fbase
;
5855 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5856 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5858 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5859 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5861 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5863 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5866 IHTMLFrameBase_Release(fbase
);
5869 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5870 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5872 IHTMLFrameBase
*fbase
;
5876 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5877 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5879 str
= name
? a2bstr(name
) : NULL
;
5880 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5881 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5884 _test_framebase_name(line
, elem
, name
);
5885 IHTMLFrameBase_Release(fbase
);
5888 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
5889 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
5891 BSTR str
= (void*)0xdeadbeef;
5892 IHTMLFrameBase
*fbase
;
5895 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5896 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5898 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
5899 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
5901 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
5903 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
5906 IHTMLFrameBase_Release(fbase
);
5909 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5910 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5915 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5916 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5917 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5919 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5921 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5925 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5926 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5932 V_BSTR(&v
) = a2bstr(val
);
5933 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5934 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5938 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5939 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5944 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5945 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5946 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5948 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5950 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5954 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5955 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5961 V_BSTR(&v
) = a2bstr(val
);
5962 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5963 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5967 static void test_framebase(IUnknown
*unk
)
5969 IHTMLFrameBase
*fbase
;
5973 /* get/put scrolling */
5974 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5975 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5977 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5978 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5979 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5983 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5984 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5987 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5988 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5989 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5992 str
= a2bstr("junk");
5993 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5994 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5995 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5998 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5999 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
6000 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6003 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6004 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6005 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6008 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6009 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
6012 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6013 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
6014 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6016 test_framebase_marginheight(fbase
, NULL
);
6017 set_framebase_marginheight(fbase
, "1px");
6018 test_framebase_marginheight(fbase
, "1");
6020 test_framebase_marginwidth(fbase
, NULL
);
6021 set_framebase_marginwidth(fbase
, "2px");
6022 test_framebase_marginwidth(fbase
, "2");
6024 IHTMLFrameBase_Release(fbase
);
6027 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6028 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6033 if(pLCIDToLocaleName
) {
6034 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
6035 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
6036 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6038 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6039 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6043 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6044 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6046 IHTMLElementCollection
*col
;
6050 hres
= IHTMLTable_get_rows(table
, &col
);
6051 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6052 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6053 if (hres
!= S_OK
|| col
== NULL
)
6055 hres
= IHTMLElementCollection_get_length(col
, &len
);
6056 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6057 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
6059 IHTMLElementCollection_Release(col
);
6062 static void test_navigator(IHTMLDocument2
*doc
)
6064 IHTMLWindow2
*window
;
6065 IOmNavigator
*navigator
, *navigator2
;
6073 static const WCHAR v40
[] = {'4','.','0'};
6075 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6076 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
6078 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6079 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6080 ok(navigator
!= NULL
, "navigator == NULL\n");
6081 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
6083 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6084 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
6085 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6086 IOmNavigator_Release(navigator2
);
6088 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6089 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
6090 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6091 IOmNavigator_Release(navigator2
);
6093 IHTMLWindow2_Release(window
);
6095 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6096 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
6097 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6098 SysFreeString(bstr
);
6101 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6102 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
6103 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6104 SysFreeString(bstr
);
6107 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6108 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
6109 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
6110 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6111 SysFreeString(bstr
);
6114 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6115 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
6116 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6117 SysFreeString(bstr
);
6120 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6121 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6122 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6123 SysFreeString(bstr
);
6126 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6127 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6128 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6129 SysFreeString(bstr
);
6131 if (pGetUserDefaultUILanguage
)
6134 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6135 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6136 test_language_string(bstr
, pGetUserDefaultUILanguage());
6137 SysFreeString(bstr
);
6140 win_skip("GetUserDefaultUILanguage not available\n");
6143 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6144 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6145 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6146 SysFreeString(bstr
);
6148 hres
= IOmNavigator_toString(navigator
, NULL
);
6149 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6152 hres
= IOmNavigator_toString(navigator
, &bstr
);
6153 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6154 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6155 SysFreeString(bstr
);
6158 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6159 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6160 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6163 hres
= ObtainUserAgentString(0, buf
, &size
);
6164 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6167 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6168 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6169 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6170 SysFreeString(bstr
);
6172 if(!strncmp(buf
, "Mozilla/", 8)) {
6174 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6175 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6176 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6177 SysFreeString(bstr
);
6179 skip("nonstandard user agent\n");
6183 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6184 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6185 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6186 SysFreeString(bstr
);
6188 test_mime_types_col(navigator
);
6190 ref
= IOmNavigator_Release(navigator
);
6191 ok(!ref
, "navigator should be destroyed here\n");
6194 static void test_screen(IHTMLWindow2
*window
)
6196 IHTMLScreen
*screen
, *screen2
;
6197 IDispatchEx
*dispex
;
6204 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6205 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6206 ok(screen
!= NULL
, "screen == NULL\n");
6209 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6210 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6211 ok(screen2
!= NULL
, "screen == NULL\n");
6212 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6213 IHTMLScreen_Release(screen2
);
6215 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6216 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6217 if(SUCCEEDED(hres
)) {
6218 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
6219 IDispatchEx_Release(dispex
);
6222 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6224 exl
= GetDeviceCaps(hdc
, HORZRES
);
6226 hres
= IHTMLScreen_get_width(screen
, &l
);
6227 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6228 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6230 exl
= GetDeviceCaps(hdc
, VERTRES
);
6232 hres
= IHTMLScreen_get_height(screen
, &l
);
6233 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6234 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6236 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6238 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6239 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6240 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6244 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6247 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6248 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6249 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6252 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6253 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6254 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6256 IHTMLScreen_Release(screen
);
6259 static void test_default_selection(IHTMLDocument2
*doc
)
6261 IHTMLSelectionObject
*selection
;
6262 IHTMLTxtRange
*range
;
6267 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6268 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6270 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
6271 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
6272 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
6275 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6276 IHTMLSelectionObject_Release(selection
);
6277 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6279 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6280 IDispatch_Release(disp
);
6281 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6283 test_range_text(range
, NULL
);
6284 IHTMLTxtRange_Release(range
);
6287 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6289 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6290 IHTMLUniqueName
*unique_name
;
6296 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6298 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6299 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6300 ok(SysStringLen(id
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6302 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6303 ok(hres
== S_OK
, "get_uniqueID failed: %08x\n", hres
);
6304 ok(SysStringLen(id2
) >= sizeof(prefixW
)/sizeof(*prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6306 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6308 id
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6309 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6310 id2
[sizeof(prefixW
)/sizeof(*prefixW
)-1] = 0;
6311 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6316 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6317 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08x\n", hres
);
6319 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6320 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6322 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6323 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6324 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6326 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6327 ok(hres
== S_OK
, "get_uniqueName failed: %08x\n", hres
);
6328 ok(num
, "num = 0\n");
6330 sprintf(buf
, "ms__id%u", num
);
6331 ok(!strcmp_wa(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6336 IHTMLUniqueName_Release(unique_name
);
6337 IHTMLDocument3_Release(doc3
);
6340 static void test_doc_elem(IHTMLDocument2
*doc
)
6342 IHTMLDocument2
*doc_node
, *owner_doc
;
6344 IHTMLDocument3
*doc3
;
6348 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6349 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6351 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6352 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6353 ok(!strcmp_wa(bstr
, "[object]"),
6354 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6355 SysFreeString(bstr
);
6357 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6358 IHTMLDocument3_Release(doc3
);
6359 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6361 test_node_name((IUnknown
*)elem
, "HTML");
6362 test_elem_tag((IUnknown
*)elem
, "HTML");
6363 test_elem_set_outertext_fail(elem
);
6365 doc_node
= get_doc_node(doc
);
6366 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6367 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6368 IHTMLDocument2_Release(owner_doc
);
6370 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6371 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6372 IHTMLDocument2_Release(doc_node
);
6374 test_elem_client_rect((IUnknown
*)elem
);
6375 test_unique_id(doc
, elem
);
6377 IHTMLElement_Release(elem
);
6380 static void test_default_body(IHTMLBodyElement
*body
)
6387 bstr
= (void*)0xdeadbeef;
6388 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6389 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6390 ok(bstr
== NULL
, "bstr != NULL\n");
6392 l
= elem_get_scroll_height((IUnknown
*)body
);
6393 ok(l
!= -1, "scrollHeight == -1\n");
6394 l
= elem_get_scroll_width((IUnknown
*)body
);
6395 ok(l
!= -1, "scrollWidth == -1\n");
6396 l
= elem_get_scroll_top((IUnknown
*)body
);
6397 ok(!l
, "scrollTop = %d\n", l
);
6398 elem_get_scroll_left((IUnknown
*)body
);
6400 test_elem_dir((IUnknown
*)body
, NULL
);
6401 set_elem_dir((IUnknown
*)body
, "ltr");
6403 /* get_text tests */
6404 hres
= IHTMLBodyElement_get_text(body
, &v
);
6405 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6406 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6407 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6409 /* get_text - Invalid Text */
6411 V_BSTR(&v
) = a2bstr("Invalid");
6412 hres
= IHTMLBodyElement_put_text(body
, v
);
6413 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6417 hres
= IHTMLBodyElement_get_text(body
, &v
);
6418 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6419 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6420 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6423 /* get_text - Valid Text */
6425 V_BSTR(&v
) = a2bstr("#FF0000");
6426 hres
= IHTMLBodyElement_put_text(body
, v
);
6427 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6431 hres
= IHTMLBodyElement_get_text(body
, &v
);
6432 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6433 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6434 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6438 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6439 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6444 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6445 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6446 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6450 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6451 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6453 BSTR str
= a2bstr(val
);
6456 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6457 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6460 _test_body_scroll(line
, body
, val
);
6463 static void test_body_funs(IHTMLBodyElement
*body
)
6465 VARIANT vbg
, vDefaultbg
;
6468 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6469 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6470 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6471 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6473 V_VT(&vbg
) = VT_BSTR
;
6474 V_BSTR(&vbg
) = a2bstr("red");
6475 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6476 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6479 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6480 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6481 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6482 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6485 /* Restore Originial */
6486 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6487 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6488 VariantClear(&vDefaultbg
);
6490 test_body_scroll(body
, NULL
);
6491 set_body_scroll(body
, "yes");
6492 set_body_scroll(body
, "no");
6493 set_body_scroll(body
, "auto");
6496 static void test_history(IHTMLWindow2
*window
)
6498 IOmHistory
*history
, *history2
;
6502 hres
= IHTMLWindow2_get_history(window
, &history
);
6503 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6504 ok(history
!= NULL
, "history = NULL\n");
6506 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
6509 hres
= IHTMLWindow2_get_history(window
, &history2
);
6510 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6511 ok(history2
!= NULL
, "history2 = NULL\n");
6512 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6514 IOmHistory_Release(history2
);
6515 IOmHistory_Release(history
);
6518 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6522 IHTMLXMLHttpRequestFactory
*factory
;
6523 IHTMLXMLHttpRequest
*xml
;
6525 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6526 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6527 ok(V_VT(&var
) == VT_DISPATCH
, "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6530 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6531 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6532 ok(factory
!= NULL
, "factory == NULL\n");
6535 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6536 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6537 ok(xml
!= NULL
, "xml == NULL\n");
6538 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, "[object]");
6540 IHTMLXMLHttpRequest_Release(xml
);
6541 IHTMLXMLHttpRequestFactory_Release(factory
);
6545 static void test_window(IHTMLDocument2
*doc
)
6547 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6548 IHTMLWindow5
*window5
;
6549 IHTMLDocument2
*doc2
= NULL
;
6556 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6557 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6558 test_ifaces((IUnknown
*)window
, window_iids
);
6559 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6561 IUnknown_Release(unk
);
6563 win_skip("IID_ITravelLogClient not supported\n");
6565 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
6567 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6568 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6569 ok(doc2
!= NULL
, "doc2 == NULL\n");
6571 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6572 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
6573 test_class_info((IUnknown
*)doc2
);
6575 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6576 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
6577 test_class_info((IUnknown
*)doc
);
6579 unk
= (void*)0xdeadbeef;
6580 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6581 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6582 ok(!unk
, "unk = %p\n", unk
);
6584 IHTMLDocument2_Release(doc2
);
6586 hres
= IHTMLWindow2_get_window(window
, &window2
);
6587 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6588 ok(window2
!= NULL
, "window2 == NULL\n");
6590 hres
= IHTMLWindow2_get_self(window
, &self
);
6591 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6592 ok(window2
!= NULL
, "self == NULL\n");
6594 ok(self
== window2
, "self != window2\n");
6596 IHTMLWindow2_Release(window2
);
6599 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6600 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6601 ok(disp
== (void*)window
, "disp != window\n");
6602 IDispatch_Release(disp
);
6604 hres
= IHTMLWindow2_toString(window
, NULL
);
6605 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6608 hres
= IHTMLWindow2_toString(window
, &str
);
6609 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6610 ok(!strcmp_wa(str
, "[object]") ||
6611 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6614 V_VT(&v
) = VT_ERROR
;
6615 hres
= IHTMLWindow2_get_opener(window
, &v
);
6616 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6617 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6620 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6621 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6622 ok(parent
!= NULL
, "parent == NULL\n");
6623 ok(parent
== self
, "parent != window\n");
6624 IHTMLWindow2_Release(parent
);
6625 IHTMLWindow2_Release(self
);
6627 test_window_name(window
, NULL
);
6628 set_window_name(window
, "test");
6629 test_window_length(window
, 0);
6630 test_screen(window
);
6631 test_window_status(window
);
6632 set_window_status(window
, "Test!");
6633 test_history(window
);
6635 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6636 if(SUCCEEDED(hres
)) {
6637 ok(window5
!= NULL
, "window5 == NULL\n");
6638 test_xmlhttprequest(window5
);
6639 IHTMLWindow5_Release(window5
);
6641 win_skip("IHTMLWindow5 not supported!\n");
6644 IHTMLWindow2_Release(window
);
6647 static void test_dom_implementation(IHTMLDocument2
*doc
)
6649 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6650 IHTMLDOMImplementation
*dom_implementation
;
6656 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6657 IHTMLDocument5_Release(doc5
);
6658 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6659 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6661 str
= a2bstr("test");
6663 V_BSTR(&v
) = a2bstr("1.0");
6665 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6668 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6669 ok(!b
, "hasFeature returned %x\n", b
);
6671 IHTMLDOMImplementation_Release(dom_implementation
);
6674 static void test_xhr(IHTMLDocument2
*doc
)
6676 IHTMLWindow2
*window
;
6677 IDispatchEx
*dispex
;
6682 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6683 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6685 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
6686 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
6688 str
= a2bstr("XMLHttpRequest");
6689 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
6690 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6693 IHTMLWindow2_Release(window
);
6696 static void test_defaults(IHTMLDocument2
*doc
)
6698 IHTMLStyleSheetsCollection
*stylesheetcol
;
6699 IHTMLCurrentStyle
*cstyle
;
6700 IHTMLBodyElement
*body
;
6701 IHTMLElement2
*elem2
;
6709 IHTMLElementCollection
*collection
;
6711 elem
= doc_get_body(doc
);
6713 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6714 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6716 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6717 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6720 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6721 IHTMLElementCollection_Release(collection
);
6724 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6725 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6727 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6728 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6731 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6732 IHTMLElementCollection_Release(collection
);
6735 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6736 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6738 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6739 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6742 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6743 IHTMLElementCollection_Release(collection
);
6746 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6747 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6749 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6750 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6753 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6754 IHTMLElementCollection_Release(collection
);
6757 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6758 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6760 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6761 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6764 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6765 IHTMLElementCollection_Release(collection
);
6770 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6771 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6772 test_default_body(body
);
6773 test_body_funs(body
);
6774 IHTMLBodyElement_Release(body
);
6776 test_elem_set_outertext_fail(elem
);
6778 test_elem_istextedit(elem
, VARIANT_TRUE
);
6780 hres
= IHTMLElement_get_style(elem
, &style
);
6781 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6783 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
6784 test_ifaces((IUnknown
*)style
, style_iids
);
6785 IHTMLStyle_Release(style
);
6788 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6789 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6790 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6794 test_compatmode(doc
, "BackCompat");
6796 test_navigator(doc
);
6797 test_plugins_col(doc
);
6799 elem2
= get_elem2_iface((IUnknown
*)elem
);
6800 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6801 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6802 if(SUCCEEDED(hres
)) {
6805 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
6806 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6808 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6810 IUnknown_Release(unk
);
6813 /*IE6 doesn't have interface */
6814 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6817 IHTMLCurrentStyle_Release(cstyle
);
6819 IHTMLElement2_Release(elem2
);
6821 IHTMLElement_Release(elem
);
6823 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6824 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6827 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6828 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6829 ok(l
== 0, "length = %d\n", l
);
6831 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6833 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6834 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6836 str
= a2bstr("xxx");
6838 V_VT(&v
) = VT_EMPTY
;
6839 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6840 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
6841 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
6844 str
= a2bstr("respectvisibilityindesign");
6847 V_BOOL(&v
) = VARIANT_TRUE
;
6848 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6849 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
6852 test_default_selection(doc
);
6853 test_doc_title(doc
, "");
6854 test_dom_implementation(doc
);
6857 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6858 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6860 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6864 str
= (void*)0xdeadbeef;
6865 hres
= IHTMLButtonElement_get_name(button
, &str
);
6866 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6868 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
6870 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6872 IHTMLButtonElement_Release(button
);
6875 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
6876 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6878 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6879 BSTR str
= a2bstr(name
);
6882 hres
= IHTMLButtonElement_put_name(button
, str
);
6883 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6885 IHTMLButtonElement_Release(button
);
6887 _test_button_name(line
, elem
, name
);
6890 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
6891 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
6893 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6894 VARIANT_BOOL disabled
= 100;
6897 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
6898 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
6899 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
6900 IHTMLButtonElement_Release(button
);
6902 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6905 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6906 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6908 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6911 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6912 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6913 IHTMLButtonElement_Release(button
);
6915 _test_button_get_disabled(line
, elem
, b
);
6918 static void test_button_elem(IHTMLElement
*elem
)
6920 test_button_name(elem
, NULL
);
6921 set_button_name(elem
, "button name");
6923 test_elem_istextedit(elem
, VARIANT_TRUE
);
6926 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6927 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6928 IHTMLTableRow
*row
, LONG len
, const char *id
)
6930 IHTMLElementCollection
*col
;
6936 hres
= IHTMLTableRow_get_cells(row
, &col
);
6937 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6938 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6940 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6941 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6942 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6944 V_VT(&var
) = VT_BSTR
;
6945 V_BSTR(&var
) = a2bstr(id
);
6946 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6947 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6948 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6951 IDispatch_Release(disp
);
6952 IHTMLElementCollection_Release(col
);
6955 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6959 IHTMLTableCell
*cell
;
6961 hres
= IHTMLTableRow_deleteCell(row
, 0);
6962 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6963 test_tr_possess(elem
, row
, 1, "td2");
6965 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6966 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6967 ok(disp
!= NULL
, "disp == NULL\n");
6968 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6969 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6970 ok(cell
!= NULL
, "cell == NULL\n");
6971 if (SUCCEEDED(hres
))
6972 IHTMLTableCell_Release(cell
);
6973 test_tr_possess(elem
, row
, 2, "td2");
6974 IDispatch_Release(disp
);
6977 static void test_tr_elem(IHTMLElement
*elem
)
6979 IHTMLElementCollection
*col
;
6984 VARIANT vbg
, vDefaultbg
;
6986 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6988 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6989 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6994 hres
= IHTMLTableRow_get_cells(row
, &col
);
6995 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6996 ok(col
!= NULL
, "get_cells returned NULL\n");
6998 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6999 IHTMLElementCollection_Release(col
);
7001 bstr
= a2bstr("left");
7002 hres
= IHTMLTableRow_put_align(row
, bstr
);
7003 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7004 SysFreeString(bstr
);
7007 hres
= IHTMLTableRow_get_align(row
, &bstr
);
7008 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7009 ok(bstr
!= NULL
, "get_align returned NULL\n");
7010 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7011 SysFreeString(bstr
);
7013 bstr
= a2bstr("top");
7014 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
7015 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
7016 SysFreeString(bstr
);
7019 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
7020 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
7021 ok(bstr
!= NULL
, "get_valign returned NULL\n");
7022 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
7023 SysFreeString(bstr
);
7026 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
7027 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7028 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
7031 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
7032 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
7033 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
7035 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
7036 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7037 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7038 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7040 V_VT(&vbg
) = VT_BSTR
;
7041 V_BSTR(&vbg
) = a2bstr("red");
7042 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7043 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7046 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7047 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7048 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7049 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7053 V_I4(&vbg
) = 0xff0000;
7054 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
7055 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7058 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
7059 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7060 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7061 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7064 /* Restore Originial */
7065 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
7066 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7067 VariantClear(&vDefaultbg
);
7069 test_tr_modify(elem
, row
);
7071 IHTMLTableRow_Release(row
);
7074 static void test_td_elem(IHTMLElement
*elem
)
7076 IHTMLTableCell
*cell
;
7080 VARIANT vbg
, vDefaultbg
;
7082 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
7083 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
7088 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
7089 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
7090 ok(lval
== 1, "Expected 1, got %d\n", lval
);
7092 str
= a2bstr("left");
7093 hres
= IHTMLTableCell_put_align(cell
, str
);
7094 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
7098 hres
= IHTMLTableCell_get_align(cell
, &str
);
7099 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7100 ok(str
!= NULL
, "str is NULL\n");
7101 if (str
!= NULL
&& hres
== S_OK
) {
7102 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
7106 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
7107 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7108 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7109 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7111 V_VT(&vbg
) = VT_BSTR
;
7112 V_BSTR(&vbg
) = a2bstr("red");
7113 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7114 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7117 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7118 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7119 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7120 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7124 V_I4(&vbg
) = 0xff0000;
7125 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
7126 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7129 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
7130 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7131 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7132 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7135 /* Restore Originial */
7136 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
7137 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7138 VariantClear(&vDefaultbg
);
7140 IHTMLTableCell_Release(cell
);
7143 static void test_label_elem(IHTMLElement
*elem
)
7145 IHTMLLabelElement
*label
;
7149 label
= get_label_iface((IUnknown
*)elem
);
7152 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7153 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7154 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7158 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7159 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7162 str
= (void*)0xdeadbeef;
7163 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7164 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7165 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
7167 str
= a2bstr("abc");
7168 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
7169 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
7173 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
7174 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
7175 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
7178 IHTMLLabelElement_Release(label
);
7181 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
7182 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7187 V_VT(&v
) = VT_ERROR
;
7188 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
7189 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
7190 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7192 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7194 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7198 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7199 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7204 V_VT(&v
) = VT_ERROR
;
7205 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7206 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7207 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7209 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7211 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7215 static void test_table_modify(IHTMLTable
*table
)
7222 test_table_length(table
, 2);
7224 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7225 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7226 ok(disp
!= NULL
, "disp == NULL\n");
7227 test_table_length(table
, 3);
7228 if (hres
!= S_OK
|| disp
== NULL
)
7231 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7232 IDispatch_Release(disp
);
7234 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7235 ok(row
!= NULL
, "row == NULL\n");
7238 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7239 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7240 ok(index
== 0, "index = %d, expected 0\n", index
);
7242 IHTMLTableRow_Release(row
);
7244 hres
= IHTMLTable_deleteRow(table
, 0);
7245 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7246 test_table_length(table
, 2);
7249 static void test_table_elem(IHTMLElement
*elem
)
7251 IHTMLElementCollection
*col
;
7253 IHTMLTable3
*table3
;
7258 VARIANT vbg
, vDefaultbg
;
7260 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7261 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7262 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7264 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7265 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7269 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7270 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7275 hres
= IHTMLTable_get_rows(table
, &col
);
7276 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7277 ok(col
!= NULL
, "get_rows returned NULL\n");
7279 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7280 IHTMLElementCollection_Release(col
);
7282 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7284 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7285 test_elem_tag((IUnknown
*)node
, "TABLE");
7286 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7287 IHTMLDOMNode_Release(node
);
7289 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7290 test_elem_tag((IUnknown
*)node
, "TABLE");
7291 test_elem_all((IUnknown
*)node
, NULL
, 0);
7292 IHTMLDOMNode_Release(node
);
7295 hres
= IHTMLTable_get_tBodies(table
, &col
);
7296 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7297 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7299 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7300 IHTMLElementCollection_Release(col
);
7302 test_table_cell_spacing(table
, NULL
);
7306 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7307 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7308 test_table_cell_spacing(table
, "10");
7311 V_BSTR(&v
) = a2bstr("11");
7312 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7313 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7314 test_table_cell_spacing(table
, "11");
7317 test_table_cell_padding(table
, NULL
);
7321 hres
= IHTMLTable_put_cellPadding(table
, v
);
7322 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7323 test_table_cell_padding(table
, "10");
7326 V_BSTR(&v
) = a2bstr("11");
7327 hres
= IHTMLTable_put_cellPadding(table
, v
);
7328 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7329 test_table_cell_padding(table
, "11");
7334 hres
= IHTMLTable_put_cellPadding(table
, v
);
7335 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7336 test_table_cell_padding(table
, "5");
7338 bstr
= a2bstr("left");
7339 hres
= IHTMLTable_put_align(table
, bstr
);
7340 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7341 SysFreeString(bstr
);
7344 hres
= IHTMLTable_get_align(table
, &bstr
);
7345 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7346 ok(bstr
!= NULL
, "get_align returned NULL\n");
7347 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7348 SysFreeString(bstr
);
7350 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7351 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7352 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7353 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7355 V_VT(&vbg
) = VT_BSTR
;
7356 V_BSTR(&vbg
) = a2bstr("red");
7357 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7358 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7361 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7362 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7363 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7364 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7368 V_I4(&vbg
) = 0xff0000;
7369 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7370 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7373 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7374 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7375 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7376 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7379 /* Restore Originial */
7380 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7381 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7382 VariantClear(&vDefaultbg
);
7385 V_BSTR(&v
) = a2bstr("11");
7386 hres
= IHTMLTable_put_width(table
, v
);
7387 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7389 hres
= IHTMLTable_get_width(table
, &v
);
7390 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7391 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7395 V_BSTR(&v
) = a2bstr("11.9");
7396 hres
= IHTMLTable_put_width(table
, v
);
7397 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7399 hres
= IHTMLTable_get_width(table
, &v
);
7400 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7401 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7405 V_BSTR(&v
) = a2bstr("40.2%");
7406 hres
= IHTMLTable_put_width(table
, v
);
7407 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7409 hres
= IHTMLTable_get_width(table
, &v
);
7410 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7411 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7416 hres
= IHTMLTable_put_width(table
, v
);
7417 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7418 hres
= IHTMLTable_get_width(table
, &v
);
7419 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7420 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7425 hres
= IHTMLTable_put_width(table
, v
);
7426 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7427 hres
= IHTMLTable_get_width(table
, &v
);
7428 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7429 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7432 bstr
= a2bstr("box");
7433 hres
= IHTMLTable_put_frame(table
, bstr
);
7434 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7435 SysFreeString(bstr
);
7436 hres
= IHTMLTable_get_frame(table
, &bstr
);
7437 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7438 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7439 SysFreeString(bstr
);
7441 test_table_modify(table
);
7442 bstr
= a2bstr("summary");
7443 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7444 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7445 SysFreeString(bstr
);
7447 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7448 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7449 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7450 SysFreeString(bstr
);
7452 IHTMLTable3_Release(table3
);
7453 IHTMLTable_Release(table
);
7456 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7465 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7466 SafeArrayAccessData(sa
, (void**)&var
);
7467 V_VT(var
) = VT_BSTR
;
7468 V_BSTR(var
) = a2bstr(text
);
7469 SafeArrayUnaccessData(sa
);
7472 hres
= IHTMLDocument2_writeln(doc
, sa
);
7474 hres
= IHTMLDocument2_write(doc
, sa
);
7475 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7477 SafeArrayDestroy(sa
);
7480 static void doc_complex_write(IHTMLDocument2
*doc
)
7482 SAFEARRAYBOUND dim
= {5, 0};
7487 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7488 SafeArrayAccessData(sa
, (void**)&args
);
7490 V_VT(args
) = VT_BSTR
;
7491 V_BSTR(args
) = a2bstr("<body i4val=\"");
7492 V_VT(args
+1) = VT_I4
;
7494 V_VT(args
+2) = VT_BSTR
;
7495 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7496 V_VT(args
+3) = VT_R8
;
7497 V_R8(args
+3) = 3.14;
7498 V_VT(args
+4) = VT_BSTR
;
7499 V_BSTR(args
+4) = a2bstr("\">");
7500 SafeArrayUnaccessData(sa
);
7502 hres
= IHTMLDocument2_write(doc
, sa
);
7503 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7505 SafeArrayDestroy(sa
);
7508 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7510 IHTMLDocument2
*window_doc
, *elem_doc
;
7511 IHTMLFrameElement3
*frame_elem3
;
7512 IHTMLWindow2
*content_window
;
7515 content_window
= get_frame_content_window(frame_elem
);
7516 test_ifaces((IUnknown
*)content_window
, window_iids
);
7517 window_doc
= get_window_doc(content_window
);
7518 IHTMLWindow2_Release(content_window
);
7520 elem_doc
= get_elem_doc(frame_elem
);
7521 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7524 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7525 if(SUCCEEDED(hres
)) {
7526 IDispatch
*disp
= NULL
;
7528 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7529 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7530 ok(disp
!= NULL
, "contentDocument == NULL\n");
7531 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7533 IDispatch_Release(disp
);
7534 IHTMLFrameElement3_Release(frame_elem3
);
7536 win_skip("IHTMLFrameElement3 not supported\n");
7540 IHTMLDocument2_Release(elem_doc
);
7541 IHTMLDocument2_Release(window_doc
);
7544 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7545 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7547 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7551 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7552 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7553 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7555 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7557 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7559 IHTMLIFrameElement2_Release(iframe
);
7562 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7563 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7565 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7570 V_BSTR(&v
) = a2bstr(val
);
7571 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7572 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7574 IHTMLIFrameElement2_Release(iframe
);
7577 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7578 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7580 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7584 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7585 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7586 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7588 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7590 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7592 IHTMLIFrameElement2_Release(iframe
);
7595 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7596 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7598 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7603 V_BSTR(&v
) = a2bstr(val
);
7604 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7605 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7607 IHTMLIFrameElement2_Release(iframe
);
7610 static void test_iframe_elem(IHTMLElement
*elem
)
7612 IHTMLDocument2
*content_doc
, *owner_doc
;
7613 IHTMLIFrameElement3
*iframe3
;
7614 IHTMLElementCollection
*col
;
7615 IHTMLWindow2
*content_window
;
7622 static const elem_type_t all_types
[] = {
7630 test_frame_doc((IUnknown
*)elem
, TRUE
);
7631 test_framebase((IUnknown
*)elem
);
7633 content_window
= get_frame_content_window((IUnknown
*)elem
);
7634 test_ifaces((IUnknown
*)content_window
, window_iids
);
7635 test_window_length(content_window
, 0);
7637 content_doc
= get_window_doc(content_window
);
7638 IHTMLWindow2_Release(content_window
);
7640 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7641 if(SUCCEEDED(hres
)) {
7642 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7643 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7644 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7645 IDispatch_Release(disp
);
7647 IHTMLIFrameElement3_Release(iframe3
);
7649 win_skip("IHTMLIFrameElement3 not supported\n");
7652 test_iframe_height(elem
, NULL
);
7653 set_iframe_height(elem
, "100px");
7654 set_iframe_height(elem
, "50%");
7655 test_iframe_height(elem
, "50%");
7657 test_iframe_width(elem
, NULL
);
7658 set_iframe_width(elem
, "150px");
7659 set_iframe_width(elem
, "70%");
7660 test_iframe_width(elem
, "70%");
7661 test_framebase_src(elem
, "about:blank");
7663 str
= a2bstr("text/html");
7664 V_VT(&errv
) = VT_ERROR
;
7666 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7668 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7669 ok(disp
!= NULL
, "disp == NULL\n");
7670 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7671 IDispatch_Release(disp
);
7673 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7674 doc_complex_write(content_doc
);
7675 doc_write(content_doc
, TRUE
, "<br />");
7676 doc_write(content_doc
, TRUE
, "</html>");
7678 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7679 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7680 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7681 IHTMLElementCollection_Release(col
);
7683 body
= doc_get_body(content_doc
);
7684 test_elem_attr(body
, "i4val", "4");
7685 test_elem_attr(body
, "r8val", "3.14");
7686 IHTMLElement_Release(body
);
7688 hres
= IHTMLDocument2_close(content_doc
);
7689 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7691 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7692 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7694 IHTMLDocument2_Release(content_doc
);
7697 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7698 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7703 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7704 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7705 todo_wine_if(is_todo
) {
7707 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7709 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7715 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
7716 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7718 BSTR str
= a2bstr(csstext
);
7721 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7722 todo_wine_if(is_todo
)
7723 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7727 static void test_stylesheet(IDispatch
*disp
)
7729 IHTMLStyleSheetRulesCollection
*col
= NULL
;
7730 IHTMLStyleSheet
*stylesheet
;
7734 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
7736 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
7737 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
7739 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
7740 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
7741 ok(col
!= NULL
, "col == NULL\n");
7743 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
7744 IHTMLStyleSheetRulesCollection_Release(col
);
7746 href
= (void*)0xdeadbeef;
7747 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
7748 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
7749 ok(href
== NULL
, "got href != NULL\n");
7750 SysFreeString(href
);
7752 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
7753 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
7754 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
7755 set_stylesheet_csstext(stylesheet
, "", FALSE
);
7756 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
7757 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
7758 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
7760 IHTMLStyleSheet_Release(stylesheet
);
7763 static void test_stylesheets(IHTMLDocument2
*doc
)
7765 IHTMLStyleSheetsCollection
*col
= NULL
;
7770 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
7771 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
7772 ok(col
!= NULL
, "col == NULL\n");
7774 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
7776 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
7777 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7778 ok(len
== 1, "len=%d\n", len
);
7784 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7785 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
7786 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
7787 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
7788 test_stylesheet(V_DISPATCH(&res
));
7795 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7796 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7797 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
7800 IHTMLStyleSheetsCollection_Release(col
);
7803 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
7805 IDispatchEx
*dispex
;
7807 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
7815 static const WCHAR w0
[] = {'0',0};
7816 static const WCHAR w100
[] = {'1','0','0',0};
7818 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
7819 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
7821 bstr
= SysAllocString(w0
);
7822 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7823 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7824 SysFreeString(bstr
);
7827 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
7828 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
7829 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
7830 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
7831 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
7832 type
= get_node_type((IUnknown
*)node
);
7833 ok(type
== 3, "type=%d\n", type
);
7834 IHTMLDOMNode_Release(node
);
7837 bstr
= SysAllocString(w100
);
7838 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7839 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
7840 SysFreeString(bstr
);
7842 IDispatchEx_Release(dispex
);
7845 static void test_enum_children(IUnknown
*unk
, unsigned len
)
7847 IEnumVARIANT
*enum_var
;
7852 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
7853 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
7855 for(i
=0; i
<len
; i
++) {
7857 V_VT(&v
) = VT_ERROR
;
7858 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
7859 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
7861 ok(fetched
== 1, "fetched = %d\n", fetched
);
7862 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
7863 IDispatch_Release(V_DISPATCH(&v
));
7866 fetched
= 0xdeadbeef;
7868 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
7869 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
7870 ok(fetched
== 0, "fetched = %d\n", fetched
);
7871 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7873 hres
= IEnumVARIANT_Reset(enum_var
);
7874 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7876 fetched
= 0xdeadbeef;
7878 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
7879 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
7880 ok(fetched
== 0, "fetched = %d\n", fetched
);
7881 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7883 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
7884 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
7886 hres
= IEnumVARIANT_Reset(enum_var
);
7887 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7889 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
7890 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
7892 IEnumVARIANT_Release(enum_var
);
7895 static void test_elems(IHTMLDocument2
*doc
)
7897 IHTMLElementCollection
*col
;
7898 IHTMLDOMChildrenCollection
*child_col
;
7899 IHTMLElement
*elem
, *elem2
, *elem3
;
7900 IHTMLDOMNode
*node
, *node2
;
7901 IHTMLWindow2
*window
;
7905 IHTMLElementCollection
*collection
;
7906 IHTMLDocument3
*doc3
;
7909 static const elem_type_t all_types
[] = {
7942 static const elem_type_t item_types
[] = {
7948 hres
= IHTMLDocument2_get_all(doc
, &col
);
7949 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7950 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7951 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
7953 elem
= get_elem_col_item_idx(col
, 0);
7954 test_elem_source_index(elem
, 0);
7955 IHTMLElement_Release(elem
);
7957 elem
= get_elem_col_item_idx(col
, 3);
7958 test_elem_source_index(elem
, 3);
7959 IHTMLElement_Release(elem
);
7961 IHTMLElementCollection_Release(col
);
7963 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7964 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
7967 static const elem_type_t images_types
[] = {ET_IMG
};
7968 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7970 IHTMLElementCollection_Release(collection
);
7973 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7974 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
7977 static const elem_type_t images_types
[] = {ET_A
};
7978 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7980 IHTMLElementCollection_Release(collection
);
7983 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7984 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7987 static const elem_type_t anchor_types
[] = {ET_A
};
7988 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7990 IHTMLElementCollection_Release(collection
);
7993 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7994 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7996 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7997 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7998 IHTMLElementCollection_Release(collection
);
8001 test_plugins_col(doc
);
8003 elem
= get_doc_elem(doc
);
8004 test_elem_istextedit(elem
, VARIANT_FALSE
);
8005 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
8006 IHTMLElement_Release(elem
);
8008 get_elem_by_id(doc
, "xxx", FALSE
);
8009 elem
= get_doc_elem_by_id(doc
, "xxx");
8010 ok(!elem
, "elem != NULL\n");
8012 elem
= get_doc_elem_by_id(doc
, "s");
8013 ok(elem
!= NULL
, "elem == NULL\n");
8015 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
8016 test_elem_attr(elem
, "xxx", NULL
);
8017 test_elem_attr(elem
, "id", "s");
8018 test_elem_class((IUnknown
*)elem
, NULL
);
8019 test_elem_set_class((IUnknown
*)elem
, "cl");
8020 test_elem_set_class((IUnknown
*)elem
, NULL
);
8021 test_elem_tabindex((IUnknown
*)elem
, 0);
8022 test_elem_set_tabindex((IUnknown
*)elem
, 1);
8023 test_elem_filters((IUnknown
*)elem
);
8024 test_elem_istextedit(elem
, VARIANT_FALSE
);
8026 node
= test_node_get_parent((IUnknown
*)elem
);
8027 ok(node
!= NULL
, "node == NULL\n");
8028 test_node_name((IUnknown
*)node
, "BODY");
8029 node2
= test_node_get_parent((IUnknown
*)node
);
8030 IHTMLDOMNode_Release(node
);
8031 ok(node2
!= NULL
, "node == NULL\n");
8032 test_node_name((IUnknown
*)node2
, "HTML");
8033 node
= test_node_get_parent((IUnknown
*)node2
);
8034 IHTMLDOMNode_Release(node2
);
8035 ok(node
!= NULL
, "node == NULL\n");
8038 test_node_name((IUnknown
*)node
, "#document");
8039 type
= get_node_type((IUnknown
*)node
);
8040 ok(type
== 9, "type=%d, expected 9\n", type
);
8041 node2
= test_node_get_parent((IUnknown
*)node
);
8042 IHTMLDOMNode_Release(node
);
8043 ok(node2
== NULL
, "node != NULL\n");
8046 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8047 ok(elem2
!= NULL
, "elem2 == NULL\n");
8048 test_node_name((IUnknown
*)elem2
, "BODY");
8050 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
8051 ok(elem3
!= NULL
, "elem3 == NULL\n");
8052 test_node_name((IUnknown
*)elem3
, "HTML");
8054 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
8055 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
8056 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
8057 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
8058 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
8059 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
8060 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
8061 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
8062 IHTMLElement_Release(elem2
);
8064 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
8065 ok(elem2
== NULL
, "elem2 != NULL\n");
8066 test_elem_source_index(elem3
, 0);
8067 IHTMLElement_Release(elem3
);
8069 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
8070 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
8071 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
8073 test_elem_innertext(elem
, "opt1opt2");
8075 IHTMLElement_Release(elem
);
8078 elem
= get_elem_by_id(doc
, "s", TRUE
);
8080 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
8081 IHTMLDocument2
*doc_node
, *elem_doc
;
8083 test_select_elem(select
);
8085 test_elem_istextedit(elem
, VARIANT_FALSE
);
8086 test_elem_title((IUnknown
*)select
, NULL
);
8087 test_elem_set_title((IUnknown
*)select
, "Title");
8088 test_elem_title((IUnknown
*)select
, "Title");
8089 test_elem_offset((IUnknown
*)select
, "BODY");
8090 test_elem_bounding_client_rect((IUnknown
*)select
);
8092 node
= get_first_child((IUnknown
*)select
);
8093 ok(node
!= NULL
, "node == NULL\n");
8095 test_elem_type((IUnknown
*)node
, ET_OPTION
);
8096 IHTMLDOMNode_Release(node
);
8099 type
= get_node_type((IUnknown
*)select
);
8100 ok(type
== 1, "type=%d\n", type
);
8102 IHTMLSelectElement_Release(select
);
8104 elem_doc
= get_elem_doc((IUnknown
*)elem
);
8106 doc_node
= get_doc_node(doc
);
8107 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
8108 IHTMLDocument2_Release(doc_node
);
8109 IHTMLDocument2_Release(elem_doc
);
8111 IHTMLElement_Release(elem
);
8114 elem
= get_elem_by_id(doc
, "sc", TRUE
);
8116 IHTMLScriptElement
*script
;
8119 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
8120 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
8122 test_elem_language(elem
, NULL
);
8123 test_elem_istextedit(elem
, VARIANT_FALSE
);
8129 hres
= IHTMLScriptElement_put_type (script
, NULL
);
8130 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8131 hres
= IHTMLScriptElement_get_type(script
, &type
);
8132 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8133 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
8135 type
= a2bstr("text/javascript");
8136 hres
= IHTMLScriptElement_put_type (script
, type
);
8137 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
8138 SysFreeString(type
);
8139 hres
= IHTMLScriptElement_get_type(script
, &type
);
8140 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
8141 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
8142 SysFreeString(type
);
8144 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
8147 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
8148 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8150 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
8151 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
8152 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
8154 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
8155 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
8157 str
= (BSTR
)0xdeadbeef;
8158 hres
= IHTMLScriptElement_get_src(script
, &str
);
8159 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
8160 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
8163 IHTMLScriptElement_Release(script
);
8165 set_elem_language(elem
, "vbscript");
8166 set_elem_language(elem
, "xxx");
8169 elem
= get_elem_by_id(doc
, "in", TRUE
);
8171 IHTMLInputElement
*input
;
8173 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
8174 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
8176 test_elem_id((IUnknown
*)elem
, "in");
8177 test_elem_put_id((IUnknown
*)elem
, "newin");
8178 test_input_get_disabled(input
, VARIANT_FALSE
);
8179 test_input_set_disabled(input
, VARIANT_TRUE
);
8180 test_input_set_disabled(input
, VARIANT_FALSE
);
8181 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
8182 test_input_get_disabled(input
, VARIANT_TRUE
);
8183 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
8184 test_input_get_disabled(input
, VARIANT_FALSE
);
8185 test_elem_client_size((IUnknown
*)elem
);
8186 test_input_type(input
, "text");
8187 test_elem_istextedit(elem
, VARIANT_TRUE
);
8189 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8190 test_node_put_value_str((IUnknown
*)elem
, "test");
8191 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8192 test_input_value((IUnknown
*)elem
, NULL
);
8193 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8194 test_input_put_value((IUnknown
*)elem
, "test");
8195 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8196 test_elem_class((IUnknown
*)elem
, "testclass");
8197 test_elem_tabindex((IUnknown
*)elem
, 2);
8198 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8199 test_elem_title((IUnknown
*)elem
, "test title");
8201 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8202 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8203 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8205 test_input_get_checked(input
, VARIANT_FALSE
);
8206 test_input_set_checked(input
, VARIANT_TRUE
);
8207 test_input_set_checked(input
, VARIANT_FALSE
);
8209 test_input_maxlength(input
, 0x7fffffff);
8210 test_input_set_maxlength(input
, 30);
8212 test_input_name(input
, NULL
);
8213 test_input_set_name(input
, "test");
8215 test_input_src(input
, NULL
);
8216 test_input_set_src(input
, "about:blank");
8218 test_input_set_size(input
, 15, S_OK
);
8219 test_input_get_size(input
, 15);
8220 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8221 test_input_get_size(input
, 15);
8222 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8223 test_input_get_size(input
, 15);
8225 test_input_readOnly(input
, VARIANT_TRUE
);
8226 test_input_readOnly(input
, VARIANT_FALSE
);
8228 test_elem_lang(elem
, NULL
);
8229 set_elem_lang(elem
, "en-us");
8231 IHTMLInputElement_Release(input
);
8232 IHTMLElement_Release(elem
);
8235 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8237 test_img_align((IUnknown
*)elem
, "left");
8238 test_img_name((IUnknown
*)elem
, "WineImg");
8239 test_img_src((IUnknown
*)elem
, "", NULL
);
8240 test_img_set_src((IUnknown
*)elem
, "about:blank");
8241 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8242 test_img_alt((IUnknown
*)elem
, NULL
);
8243 test_img_set_alt((IUnknown
*)elem
, "alt test");
8244 test_img_name((IUnknown
*)elem
, "WineImg");
8245 test_img_complete(elem
, VARIANT_FALSE
);
8246 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8247 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8248 IHTMLElement_Release(elem
);
8251 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8253 test_dynamic_properties(elem
);
8254 test_attr_collection(elem
);
8255 test_contenteditable((IUnknown
*)elem
);
8256 IHTMLElement_Release(elem
);
8259 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8261 test_style_media((IUnknown
*)elem
, NULL
);
8262 test_style_put_media((IUnknown
*)elem
, "screen");
8263 test_style_type((IUnknown
*)elem
, NULL
);
8264 test_style_put_type((IUnknown
*)elem
, "text/css");
8265 IHTMLElement_Release(elem
);
8268 elem
= get_doc_elem_by_id(doc
, "tbl");
8269 ok(elem
!= NULL
, "elem == NULL\n");
8271 test_table_elem(elem
);
8272 IHTMLElement_Release(elem
);
8275 elem
= get_doc_elem_by_id(doc
, "labelid");
8276 ok(elem
!= NULL
, "elem == NULL\n");
8278 test_label_elem(elem
);
8279 IHTMLElement_Release(elem
);
8282 elem
= get_doc_elem_by_id(doc
, "td2");
8283 ok(elem
!= NULL
, "elem == NULL\n");
8286 IHTMLElement_Release(elem
);
8289 elem
= get_doc_elem_by_id(doc
, "row2");
8290 ok(elem
!= NULL
, "elem == NULL\n");
8293 IHTMLElement_Release(elem
);
8296 elem
= get_doc_elem_by_id(doc
, "ifr");
8297 ok(elem
!= NULL
, "elem == NULL\n");
8299 test_iframe_elem(elem
);
8300 IHTMLElement_Release(elem
);
8303 elem
= get_doc_elem_by_id(doc
, "btnid");
8304 ok(elem
!= NULL
, "elem == NULL\n");
8306 test_button_elem(elem
);
8307 test_button_get_disabled(elem
, VARIANT_FALSE
);
8308 test_button_set_disabled(elem
, VARIANT_TRUE
);
8309 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8310 test_button_get_disabled(elem
, VARIANT_FALSE
);
8311 IHTMLElement_Release(elem
);
8314 elem
= get_doc_elem_by_id(doc
, "objid");
8315 ok(elem
!= NULL
, "elem == NULL\n");
8317 test_object_vspace((IUnknown
*)elem
, 100);
8318 test_object_name(elem
, "objname");
8319 set_object_name(elem
, "test");
8320 set_object_name(elem
, NULL
);
8321 IHTMLElement_Release(elem
);
8324 elem
= get_elem_by_id(doc
, "a", TRUE
);
8326 test_anchor_href((IUnknown
*)elem
, "http://test/");
8328 /* Change the href */
8329 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8330 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8331 test_anchor_hostname((IUnknown
*)elem
, "test1");
8333 /* Restore the href */
8334 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8335 test_anchor_href((IUnknown
*)elem
, "http://test/");
8336 test_anchor_hostname((IUnknown
*)elem
, "test");
8337 test_anchor_hash(elem
, NULL
);
8340 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8342 test_anchor_rel((IUnknown
*)elem
, NULL
);
8343 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8344 test_anchor_rel((IUnknown
*)elem
, "Next");
8346 /* Change the target */
8347 test_anchor_put_target((IUnknown
*)elem
, "wine");
8348 test_anchor_get_target((IUnknown
*)elem
, "wine");
8350 /* Restore the target */
8351 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8352 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8354 test_anchor_name((IUnknown
*)elem
, "x");
8355 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8356 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8357 test_anchor_put_name((IUnknown
*)elem
, "x");
8359 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8360 test_anchor_hash(elem
, "#hash");
8361 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8363 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8364 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8365 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8366 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8368 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8369 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8371 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8372 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8374 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8375 as part of the pathname, and cannot be accessed by get_search. */
8376 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8377 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8379 IHTMLElement_Release(elem
);
8382 elem
= get_doc_elem_by_id(doc
, "metaid");
8384 test_meta_name((IUnknown
*)elem
, "meta name");
8385 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8386 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8387 test_meta_charset((IUnknown
*)elem
, NULL
);
8388 set_meta_charset((IUnknown
*)elem
, "utf-8");
8389 IHTMLElement_Release(elem
);
8392 elem
= doc_get_body(doc
);
8394 node
= get_first_child((IUnknown
*)elem
);
8395 ok(node
!= NULL
, "node == NULL\n");
8397 test_ifaces((IUnknown
*)node
, text_iids
);
8398 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8400 node2
= get_first_child((IUnknown
*)node
);
8401 ok(!node2
, "node2 != NULL\n");
8403 type
= get_node_type((IUnknown
*)node
);
8404 ok(type
== 3, "type=%d\n", type
);
8406 test_node_get_value_str((IUnknown
*)node
, "text test");
8407 test_node_put_value_str((IUnknown
*)elem
, "test text");
8408 test_node_get_value_str((IUnknown
*)node
, "text test");
8410 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8411 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8412 ok(!disp
, "disp != NULL\n");
8414 IHTMLDOMNode_Release(node
);
8417 child_col
= get_child_nodes((IUnknown
*)elem
);
8418 ok(child_col
!= NULL
, "child_coll == NULL\n");
8423 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
8425 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
8426 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8427 ok(length
, "length=0\n");
8430 node
= get_child_item(child_col
, 0);
8431 ok(node
!= NULL
, "node == NULL\n");
8435 type
= get_node_type((IUnknown
*)node
);
8436 ok(type
== 3, "type=%d\n", type
);
8437 node2
= node_get_next((IUnknown
*)node
);
8439 prev
= node_get_prev((IUnknown
*)node2
);
8440 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8441 IHTMLDOMNode_Release(prev
);
8443 IHTMLDOMNode_Release(node
);
8446 node
= get_child_item(child_col
, 1);
8447 ok(node
!= NULL
, "node == NULL\n");
8449 type
= get_node_type((IUnknown
*)node
);
8450 ok(type
== 8, "type=%d\n", type
);
8452 test_elem_id((IUnknown
*)node
, NULL
);
8453 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8454 IHTMLDOMNode_Release(node2
);
8455 IHTMLDOMNode_Release(node
);
8458 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8459 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8461 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8462 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8464 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8465 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8467 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8468 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8470 test_child_col_disp(child_col
);
8472 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8473 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8475 test_enum_children(enum_unk
, length
);
8477 IUnknown_Release(enum_unk
);
8479 IHTMLDOMChildrenCollection_Release(child_col
);
8482 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8483 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8484 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8486 IHTMLElement_Release(elem
);
8488 elem
= get_doc_elem_by_id(doc
, "frm");
8489 ok(elem
!= NULL
, "elem == NULL\n");
8491 test_form_length((IUnknown
*)elem
, 0);
8492 test_form_elements((IUnknown
*)elem
);
8493 IHTMLElement_Release(elem
);
8496 test_stylesheets(doc
);
8497 test_create_option_elem(doc
);
8498 test_create_img_elem(doc
);
8500 elem
= get_doc_elem_by_id(doc
, "tbl");
8501 ok(elem
!= NULL
, "elem = NULL\n");
8502 test_elem_set_innertext(elem
, "inner text");
8503 IHTMLElement_Release(elem
);
8505 test_doc_title(doc
, "test");
8506 test_doc_set_title(doc
, "test title");
8507 test_doc_title(doc
, "test title");
8510 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8511 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8514 IDispatchEx
*dispex
;
8515 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8516 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8520 BSTR str
= a2bstr("Testing");
8521 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8522 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8523 ok(pid
!= -1, "pid == -1\n");
8525 IDispatchEx_Release(dispex
);
8528 IDispatch_Release(disp
);
8530 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8532 elem
= get_doc_elem_by_id(doc
, "y");
8533 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8534 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8535 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8536 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8537 node
= node_get_next((IUnknown
*)elem
);
8538 ok(!node
, "node = %p\n", node
);
8540 elem2
= get_doc_elem_by_id(doc
, "x");
8541 test_elem_tag((IUnknown
*)elem2
, "A");
8542 node
= node_get_next((IUnknown
*)elem2
);
8543 IHTMLDOMNode_Release(node
);
8544 IHTMLElement_Release(elem2
);
8545 IHTMLElement_Release(elem
);
8547 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8548 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8550 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8551 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8553 IHTMLDocument3_Release(doc3
);
8555 elem
= get_elem_by_id(doc
, "s", TRUE
);
8557 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8559 test_select_put_length((IUnknown
*)elem
, 3);
8560 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8561 test_select_put_length((IUnknown
*)elem
, 1);
8562 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8563 IHTMLElement_Release(elem
);
8566 window
= get_doc_window(doc
);
8567 test_window_name(window
, NULL
);
8568 set_window_name(window
, "test name");
8569 test_window_length(window
, 1);
8570 IHTMLWindow2_Release(window
);
8573 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
8575 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
8576 IHTMLElement4
*elem4
;
8580 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8582 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8584 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8585 test_ifaces((IUnknown
*)attr
, attr_iids
);
8586 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8587 test_attr_specified(attr
, VARIANT_TRUE
);
8588 test_attr_parent(attr
);
8590 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8591 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8592 IHTMLDOMAttribute_Release(attr2
);
8594 get_attr_node_value(attr
, &v
, VT_BSTR
);
8595 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8599 V_BSTR(&v
) = a2bstr("divid2");
8600 put_attr_node_value(attr
, v
);
8602 get_attr_node_value(attr
, &v
, VT_BSTR
);
8603 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8606 put_attr_value(attr
, "divid3");
8608 get_attr_node_value(attr
, &v
, VT_BSTR
);
8609 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8612 IHTMLDOMAttribute_Release(attr
);
8614 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8615 get_attr_node_value(attr
, &v
, VT_BSTR
);
8616 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8620 V_BSTR(&v
) = a2bstr("newvalue");
8621 put_attr_node_value(attr
, v
);
8624 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8625 get_attr_node_value(attr
, &v
, VT_BSTR
);
8626 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8629 test_attr_specified(attr
, VARIANT_TRUE
);
8630 IHTMLDOMAttribute_Release(attr
);
8634 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
8635 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
8636 get_attr_node_value(attr
, &v
, VT_I4
);
8637 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
8638 test_attr_specified(attr
, VARIANT_TRUE
);
8642 put_attr_node_value(attr
, v
);
8644 get_attr_node_value(attr
, &v
, VT_I4
);
8645 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
8647 put_attr_value(attr
, "160");
8648 get_attr_node_value(attr
, &v
, VT_BSTR
);
8649 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8652 IHTMLDOMAttribute_Release(attr
);
8654 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
8655 test_attr_specified(attr
, VARIANT_FALSE
);
8656 test_attr_expando(attr
, VARIANT_FALSE
);
8657 IHTMLDOMAttribute_Release(attr
);
8659 /* Test created, detached attribute. */
8660 attr
= create_attr((IUnknown
*)doc
, "Test");
8662 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8663 test_ifaces((IUnknown
*)attr
, attr_iids
);
8664 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8666 test_attr_node_name(attr
, "Test");
8667 test_attr_expando(attr
, VARIANT_FALSE
);
8669 get_attr_node_value(attr
, &v
, VT_EMPTY
);
8673 put_attr_node_value(attr
, v
);
8675 get_attr_node_value(attr
, &v
, VT_I4
);
8676 ok(V_I4(&v
) == 1, "nodeValue = %d\n", V_I4(&v
));
8677 test_attr_value(attr
, "1");
8679 V_VT(&v
) = VT_EMPTY
;
8680 put_attr_node_value(attr
, v
);
8681 get_attr_node_value(attr
, &v
, VT_EMPTY
);
8684 V_BSTR(&v
) = a2bstr("testing");
8685 put_attr_node_value(attr
, v
);
8686 SysFreeString(V_BSTR(&v
));
8687 test_attr_value(attr
, "testing");
8689 elem4
= get_elem4_iface((IUnknown
*)elem
);
8691 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
8692 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
8693 ok(!attr2
, "attr2 != NULL\n");
8695 test_elem_attr(elem
, "Test", "testing");
8696 put_attr_value(attr
, "new value");
8697 test_elem_attr(elem
, "Test", "new value");
8699 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
8700 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
8701 IHTMLDOMAttribute_Release(attr2
);
8703 attr3
= create_attr((IUnknown
*)doc
, "Test");
8704 put_attr_value(attr3
, "replace test");
8706 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
8707 ok(hres
== S_OK
, "setAttributeNode failed: %08x\n", hres
);
8708 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
8709 IHTMLDOMAttribute_Release(attr2
);
8711 test_elem_attr(elem
, "Test", "replace test");
8712 test_attr_value(attr
, "new value");
8713 test_attr_value(attr3
, "replace test");
8715 attr2
= get_elem_attr_node((IUnknown
*)elem
, "Test", TRUE
);
8716 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
8717 IHTMLDOMAttribute_Release(attr2
);
8719 put_attr_value(attr
, "new value2");
8720 test_elem_attr(elem
, "Test", "replace test");
8721 test_attr_value(attr
, "new value2");
8722 test_attr_value(attr3
, "replace test");
8724 put_attr_value(attr3
, "new replace value");
8725 test_elem_attr(elem
, "Test", "new replace value");
8726 test_attr_value(attr
, "new value2");
8727 test_attr_value(attr3
, "new replace value");
8729 /* Attached attributes cause errors. */
8730 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
8731 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
8732 IHTMLDOMAttribute_Release(attr3
);
8734 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8735 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
8736 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08x, expected E_INVALIDARG\n", hres
);
8737 IHTMLDOMAttribute_Release(attr2
);
8739 IHTMLElement4_Release(elem4
);
8740 IHTMLDOMAttribute_Release(attr
);
8743 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
8747 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8748 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
8749 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8751 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8752 IHTMLElement_Release(elem
);
8755 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8756 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
8757 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8759 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
8760 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
8761 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
8762 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
8763 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8764 IHTMLElement_Release(elem
);
8768 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
8769 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
8771 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
8772 IHTMLElementCollection
*col
;
8773 BSTR str
= a2bstr(name
);
8776 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
8777 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
8778 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
8780 IHTMLDocument3_Release(doc3
);
8785 static void test_elem_names(IHTMLDocument2
*doc
)
8787 IHTMLElementCollection
*col
;
8792 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
8794 body
= doc_get_body(doc
);
8796 test_elem_set_innerhtml((IUnknown
*)body
,
8797 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
8798 col
= doc_get_elems_by_name(doc
, "test");
8799 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
8800 IHTMLElementCollection_Release(col
);
8802 col
= doc_get_elems_by_name(doc
, "yyy");
8803 test_elem_collection((IUnknown
*)col
, NULL
, 0);
8804 IHTMLElementCollection_Release(col
);
8806 /* case insensivity test */
8807 col
= doc_get_elems_by_name(doc
, "Xxx");
8808 hres
= IHTMLElementCollection_get_length(col
, &len
);
8809 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8810 todo_wine
ok(len
== 1, "len = %d\n", len
);
8811 IHTMLElementCollection_Release(col
);
8813 IHTMLElement_Release(body
);
8816 static void test_elems2(IHTMLDocument2
*doc
)
8818 IHTMLElement
*elem
, *elem2
, *div
;
8820 static const elem_type_t outer_types
[] = {
8825 div
= get_doc_elem_by_id(doc
, "divid");
8827 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
8829 test_link_disabled(elem
, VARIANT_FALSE
);
8830 test_link_rel(elem
, "stylesheet");
8831 test_link_rev(elem
, NULL
);
8832 test_link_type(elem
, "text/css");
8833 test_link_href(elem
, "about:blank");
8834 test_link_media(elem
, "all");
8835 link_put_disabled(elem
, VARIANT_TRUE
);
8836 link_put_rel(elem
, "prev");
8837 link_put_rev(elem
, "next");
8838 link_put_type(elem
, "text/plain");
8839 link_put_href(elem
, "about:prev");
8840 IHTMLElement_Release(elem
);
8843 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
8844 elem2
= get_doc_elem_by_id(doc
, "innerid");
8845 ok(elem2
!= NULL
, "elem2 == NULL\n");
8846 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
8847 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
8848 IHTMLElement_Release(elem2
);
8850 elem2
= get_doc_elem_by_id(doc
, "aid");
8851 ok(elem2
!= NULL
, "elem2 == NULL\n");
8852 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
8853 test_elem_all((IUnknown
*)div
, outer_types
, 1);
8854 IHTMLElement_Release(elem2
);
8856 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
8857 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8859 IHTMLFormElement
*form
;
8861 test_textarea_value((IUnknown
*)elem
, NULL
);
8862 test_textarea_put_value((IUnknown
*)elem
, "test");
8863 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
8864 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
8865 test_textarea_put_value((IUnknown
*)elem
, "test");
8866 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8867 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
8868 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8869 test_textarea_type((IUnknown
*)elem
);
8871 form
= get_textarea_form((IUnknown
*)elem
);
8872 ok(!form
, "form = %p\n", form
);
8874 test_elem_istextedit(elem
, VARIANT_TRUE
);
8876 IHTMLElement_Release(elem
);
8879 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
8880 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8882 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
8883 IHTMLElement_Release(elem
);
8886 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
8887 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8889 IHTMLFormElement
*form
;
8891 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
8892 ok(elem2
!= NULL
, "elem2 == NULL\n");
8894 form
= get_textarea_form((IUnknown
*)elem
);
8895 ok(form
!= NULL
, "form = NULL\n");
8896 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
8898 IHTMLFormElement_Release(form
);
8899 IHTMLElement_Release(elem2
);
8900 IHTMLElement_Release(elem
);
8903 test_elem_set_innerhtml((IUnknown
*)div
,
8904 "<input value=\"val\" id =\"inputid\" />");
8905 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8907 test_input_defaultValue((IUnknown
*)elem
, "val");
8908 test_input_put_value((IUnknown
*)elem
, "test");
8909 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
8910 test_input_value((IUnknown
*)elem
, "test");
8911 IHTMLElement_Release(elem
);
8914 test_elem_set_innerhtml((IUnknown
*)div
, "");
8915 test_insert_adjacent_elems(doc
, div
);
8917 test_elem_set_innerhtml((IUnknown
*)div
,
8918 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
8919 elem
= get_elem_by_id(doc
, "form", TRUE
);
8921 test_form_length((IUnknown
*)elem
, 2);
8922 test_form_item(elem
);
8923 test_form_action((IUnknown
*)elem
, NULL
);
8924 test_form_put_action((IUnknown
*)elem
, "about:blank");
8925 test_form_method((IUnknown
*)elem
, "get");
8926 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
8927 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
8928 test_form_method((IUnknown
*)elem
, "post");
8929 test_form_name((IUnknown
*)elem
, NULL
);
8930 test_form_put_name((IUnknown
*)elem
, "Name");
8931 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
8932 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
8933 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
8934 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
8935 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
8936 test_form_elements((IUnknown
*)elem
);
8937 test_form_reset((IUnknown
*)elem
);
8938 test_form_target((IUnknown
*)elem
);
8939 IHTMLElement_Release(elem
);
8941 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8942 test_input_get_form((IUnknown
*)elem
, "form");
8943 IHTMLElement_Release(elem
);
8946 test_elem_set_innerhtml((IUnknown
*)div
,
8947 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select></form>");
8948 elem
= get_elem_by_id(doc
, "sform", TRUE
);
8949 elem2
= get_elem_by_id(doc
, "form", TRUE
);
8951 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8952 IHTMLElement_Release(elem
);
8954 elem
= get_elem_by_id(doc
, "oform", TRUE
);
8956 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8957 IHTMLElement_Release(elem
);
8959 IHTMLElement_Release(elem2
);
8962 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"elemid\">test</div>");
8963 elem
= get_elem_by_id(doc
, "elemid", TRUE
);
8965 test_elem_outertext(elem
, "test");
8966 test_elem_set_outertext(elem
, "outer text");
8967 test_elem_outertext(elem
, NULL
);
8968 test_elem_all((IUnknown
*)div
, NULL
, 0);
8969 elem2
= test_elem_get_parent((IUnknown
*)elem
);
8970 ok(!elem2
, "parent != NULL\n");
8971 IHTMLElement_Release(elem
);
8974 test_attr(doc
, div
);
8975 test_blocked(doc
, div
);
8976 test_elem_names(doc
);
8978 IHTMLElement_Release(div
);
8981 static void test_create_elems(IHTMLDocument2
*doc
)
8983 IHTMLElement
*elem
, *body
, *elem2
;
8984 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
8985 IHTMLDocument5
*doc5
;
8992 static const elem_type_t types1
[] = { ET_TESTG
};
8994 elem
= test_create_elem(doc
, "TEST");
8995 test_elem_tag((IUnknown
*)elem
, "TEST");
8996 type
= get_node_type((IUnknown
*)elem
);
8997 ok(type
== 1, "type=%d\n", type
);
8998 test_ifaces((IUnknown
*)elem
, elem_iids
);
8999 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
9000 test_elem_source_index(elem
, -1);
9002 body
= doc_get_body(doc
);
9003 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9005 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
9006 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
9007 elem2
= get_elem_iface((IUnknown
*)node
);
9008 IHTMLElement_Release(elem2
);
9010 hres
= IHTMLElement_get_all(body
, &disp
);
9011 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9012 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
9013 IDispatch_Release(disp
);
9015 test_node_remove_child((IUnknown
*)body
, node
);
9017 hres
= IHTMLElement_get_all(body
, &disp
);
9018 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9019 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
9020 IDispatch_Release(disp
);
9021 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
9023 IHTMLElement_Release(elem
);
9024 IHTMLDOMNode_Release(node
);
9026 node
= test_create_text(doc
, "abc");
9027 test_ifaces((IUnknown
*)node
, text_iids
);
9028 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
9029 test_text_length((IUnknown
*)node
, 3);
9030 test_text_data((IUnknown
*)node
, "abc");
9031 set_text_data((IUnknown
*)node
, "test");
9032 test_text_data((IUnknown
*)node
, "test");
9033 text_append_data((IUnknown
*)node
, " append");
9034 test_text_data((IUnknown
*)node
, "test append");
9035 text_append_data((IUnknown
*)node
, NULL
);
9036 test_text_data((IUnknown
*)node
, "test append");
9037 set_text_data((IUnknown
*)node
, "test");
9039 V_VT(&var
) = VT_NULL
;
9040 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9041 IHTMLDOMNode_Release(node
);
9043 node
= test_create_text(doc
, "insert ");
9045 V_VT(&var
) = VT_DISPATCH
;
9046 V_DISPATCH(&var
) = (IDispatch
*)node2
;
9047 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9048 IHTMLDOMNode_Release(node
);
9049 IHTMLDOMNode_Release(node2
);
9050 IHTMLDOMNode_Release(node3
);
9052 test_elem_innertext(body
, "insert test");
9053 test_elem_innerhtml((IUnknown
*)body
, "insert test");
9055 node
= test_create_text(doc
, " Test");
9056 V_VT(&var
) = VT_DISPATCH
;
9057 V_DISPATCH(&var
) = NULL
;
9058 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9059 test_elem_innertext(body
, "insert test Test");
9060 IHTMLDOMNode_Release(node
);
9062 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
9064 str
= a2bstr("testing");
9065 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
9067 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
9070 type
= get_node_type((IUnknown
*)comment
);
9071 ok(type
== 8, "type=%d, expected 8\n", type
);
9073 test_node_get_value_str((IUnknown
*)comment
, "testing");
9074 test_elem_title((IUnknown
*)comment
, NULL
);
9075 test_elem_set_title((IUnknown
*)comment
, "comment title");
9076 test_elem_title((IUnknown
*)comment
, "comment title");
9077 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
9078 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
9079 test_comment_attrs((IUnknown
*)comment
);
9081 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
9082 test_comment_text((IUnknown
*)node2
, "<!--testing-->");
9083 IHTMLDOMNode_Release(node2
);
9085 IHTMLDOMNode_Release(comment
);
9088 IHTMLDocument5_Release(doc5
);
9091 IHTMLElement_Release(body
);
9094 static void test_replacechild_elems(IHTMLDocument2
*doc
)
9097 IHTMLDOMNode
*node
, *node2
, *node3
;
9098 IHTMLDOMNode
*nodeBody
, *nodeNew
;
9102 body
= doc_get_body(doc
);
9104 node
= test_create_text(doc
, "insert");
9106 V_VT(&var
) = VT_NULL
;
9107 V_DISPATCH(&var
) = NULL
;
9108 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
9109 IHTMLDOMNode_Release(node
);
9111 test_elem_innertext(body
, "insert");
9113 node3
= test_create_text(doc
, "replaced");
9115 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
9117 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
9118 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
9120 test_elem_innertext(body
, "replaced");
9122 IHTMLDOMNode_Release(node2
);
9123 IHTMLDOMNode_Release(node3
);
9124 IHTMLDOMNode_Release(nodeBody
);
9126 IHTMLElement_Release(body
);
9129 static void test_noscript(IHTMLDocument2
*doc
)
9131 IHTMLElementCollection
*col
;
9135 static const elem_type_t all_types
[] = {
9144 static const elem_type_t body_all_types
[] = {
9149 hres
= IHTMLDocument2_get_all(doc
, &col
);
9150 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9151 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9152 IHTMLElementCollection_Release(col
);
9154 body
= doc_get_body(doc
);
9155 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
9156 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
9157 IHTMLElement_Release(body
);
9160 static void test_doctype(IHTMLDocument2
*doc
)
9162 IHTMLDocument2
*doc_node
;
9163 IHTMLDOMNode
*doctype
;
9166 doc_node
= get_doc_node(doc
);
9167 doctype
= get_first_child((IUnknown
*)doc_node
);
9168 IHTMLDocument2_Release(doc_node
);
9170 type
= get_node_type((IUnknown
*)doctype
);
9171 ok(type
== 8, "type = %d\n", type
);
9173 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
9174 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
9175 IHTMLDOMNode_Release(doctype
);
9178 static void test_null_write(IHTMLDocument2
*doc
)
9182 doc_write(doc
, FALSE
, NULL
);
9183 doc_write(doc
, TRUE
, NULL
);
9185 hres
= IHTMLDocument2_write(doc
, NULL
);
9187 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
9189 hres
= IHTMLDocument2_writeln(doc
, NULL
);
9191 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
9194 static void test_create_stylesheet(IHTMLDocument2
*doc
)
9196 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
9197 IHTMLStyleElement
*style_elem
;
9198 IHTMLElement
*doc_elem
, *elem
;
9201 static const elem_type_t all_types
[] = {
9209 static const elem_type_t all_types2
[] = {
9218 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
9220 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
9221 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
9223 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
9225 doc_elem
= get_doc_elem(doc
);
9227 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
9228 IHTMLElement_Release(doc_elem
);
9230 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
9231 IHTMLElement_Release(elem
);
9232 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
9235 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
9236 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
9237 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
9238 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
9240 IHTMLStyleSheet_Release(stylesheet2
);
9241 IHTMLStyleSheet_Release(stylesheet
);
9243 IHTMLStyleElement_Release(style_elem
);
9246 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
9248 IOleCommandTarget
*cmdtrg
;
9251 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
9252 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
9254 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
9255 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
9257 IOleCommandTarget_Release(cmdtrg
);
9260 static void test_indent(IHTMLDocument2
*doc
)
9262 IHTMLElementCollection
*col
;
9263 IHTMLTxtRange
*range
;
9266 static const elem_type_t all_types
[] = {
9275 static const elem_type_t indent_types
[] = {
9286 hres
= IHTMLDocument2_get_all(doc
, &col
);
9287 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9288 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9289 IHTMLElementCollection_Release(col
);
9291 range
= test_create_body_range(doc
);
9292 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9293 IHTMLTxtRange_Release(range
);
9295 hres
= IHTMLDocument2_get_all(doc
, &col
);
9296 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9297 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9298 IHTMLElementCollection_Release(col
);
9301 static void test_cond_comment(IHTMLDocument2
*doc
)
9303 IHTMLElementCollection
*col
;
9306 static const elem_type_t all_types
[] = {
9314 hres
= IHTMLDocument2_get_all(doc
, &col
);
9315 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9316 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9317 IHTMLElementCollection_Release(col
);
9320 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9322 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9323 return E_NOINTERFACE
;
9326 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9331 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9336 static const IUnknownVtbl UnknownVtbl
= {
9337 Unknown_QueryInterface
,
9341 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9343 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9345 IHTMLWindow2
*frame2
, *parent
, *top
;
9346 IHTMLDocument2
*parent_doc
, *top_doc
;
9347 IHTMLWindow4
*frame
;
9348 IHTMLFrameBase
*frame_elem
;
9349 IObjectIdentity
*obj_ident
;
9350 ITravelLogClient
*tlc
;
9353 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9354 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9358 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9359 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9360 IHTMLWindow4_Release(frame
);
9364 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9365 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9366 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9367 IHTMLFrameBase_Release(frame_elem
);
9369 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9370 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9374 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9375 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9377 IHTMLWindow2_Release(frame2
);
9381 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9382 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9383 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9384 if(hres
== E_NOINTERFACE
) {
9385 win_skip("IID_ITravelLogClient not available\n");
9388 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9390 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9391 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9392 ITravelLogClient_Release(tlc
);
9395 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9396 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9397 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9398 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9399 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9400 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9402 IObjectIdentity_Release(obj_ident
);
9404 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9405 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9406 IHTMLWindow2_Release(parent
);
9408 IHTMLWindow2_Release(frame2
);
9412 test_doc_title(parent_doc
, "frameset test");
9413 IHTMLDocument2_Release(parent_doc
);
9416 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9417 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9418 IHTMLWindow2_Release(frame2
);
9422 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9423 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9424 IHTMLWindow2_Release(top
);
9428 test_doc_title(top_doc
, "frameset test");
9429 IHTMLDocument2_Release(top_doc
);
9432 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9434 VARIANT index_var
, result_var
;
9438 /* test result length */
9439 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9440 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9441 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9443 /* test first frame */
9444 V_VT(&index_var
) = VT_I4
;
9445 V_I4(&index_var
) = 0;
9446 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9447 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9448 if(SUCCEEDED(hres
)) {
9449 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9450 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9452 VariantClear(&result_var
);
9454 /* test second frame */
9455 V_I4(&index_var
) = 1;
9456 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9457 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9458 if(SUCCEEDED(hres
)) {
9459 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9460 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9462 VariantClear(&result_var
);
9464 /* fail on next frame */
9465 V_I4(&index_var
) = 3;
9466 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9467 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9468 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9469 VariantClear(&result_var
);
9471 /* string argument (element id lookup) */
9472 V_VT(&index_var
) = VT_BSTR
;
9473 V_BSTR(&index_var
) = a2bstr(frid
);
9474 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9475 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9476 if(SUCCEEDED(hres
)) {
9477 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9478 test_frame(V_DISPATCH(&result_var
), frid
);
9480 VariantClear(&result_var
);
9481 VariantClear(&index_var
);
9483 /* invalid argument */
9484 V_VT(&index_var
) = VT_BOOL
;
9485 V_BOOL(&index_var
) = VARIANT_TRUE
;
9486 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9487 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9488 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9489 VariantClear(&result_var
);
9492 static void test_frameset(IHTMLDocument2
*doc
)
9494 IHTMLWindow2
*window
;
9495 IHTMLFramesCollection2
*frames
;
9499 window
= get_doc_window(doc
);
9501 /* test using IHTMLFramesCollection object */
9503 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9504 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9508 test_frames_collection(frames
, "fr1");
9509 IHTMLFramesCollection2_Release(frames
);
9511 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9512 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9516 test_frames_collection(frames
, "fr1");
9517 IHTMLFramesCollection2_Release(frames
);
9519 /* test using IHTMLWindow2 inheritance */
9520 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9522 /* getElementById with node name attributes */
9523 elem
= get_doc_elem_by_id(doc
, "nm1");
9524 test_elem_id((IUnknown
*)elem
, "fr1");
9526 test_framebase((IUnknown
*)elem
);
9527 test_framebase_name(elem
, "nm1");
9528 test_framebase_put_name(elem
, "frame name");
9529 test_framebase_put_name(elem
, NULL
);
9530 test_framebase_put_name(elem
, "nm1");
9531 test_framebase_src(elem
, "about:blank");
9532 IHTMLElement_Release(elem
);
9534 /* get_name with no name attr */
9535 elem
= get_doc_elem_by_id(doc
, "fr3");
9536 test_framebase_name(elem
, NULL
);
9537 test_framebase_put_name(elem
, "frame name");
9538 test_framebase_put_name(elem
, NULL
);
9539 IHTMLElement_Release(elem
);
9541 IHTMLWindow2_Release(window
);
9544 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9546 IHTMLDocument2
*frag
;
9547 IHTMLDocument3
*doc3
;
9550 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9551 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9553 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9554 IHTMLDocument3_Release(doc3
);
9555 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9556 ok(frag
!= NULL
, "frag == NULL\n");
9561 static void test_docfrag(IHTMLDocument2
*doc
)
9563 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9564 IHTMLElement
*div
, *body
, *br
;
9565 IHTMLElementCollection
*col
;
9566 IHTMLLocation
*location
;
9569 static const elem_type_t all_types
[] = {
9578 frag
= create_docfrag(doc
);
9580 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
9582 body
= (void*)0xdeadbeef;
9583 hres
= IHTMLDocument2_get_body(frag
, &body
);
9584 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
9585 ok(!body
, "body != NULL\n");
9587 location
= (void*)0xdeadbeef;
9588 hres
= IHTMLDocument2_get_location(frag
, &location
);
9589 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
9590 ok(location
== (void*)0xdeadbeef, "location changed\n");
9592 br
= test_create_elem(doc
, "BR");
9593 test_elem_source_index(br
, -1);
9594 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
9595 test_elem_source_index(br
, 0);
9596 IHTMLElement_Release(br
);
9598 test_doc_getelembytag(frag
, "a", ET_A
, 0);
9599 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
9601 div
= get_elem_by_id(doc
, "divid", TRUE
);
9602 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
9603 IHTMLElement_Release(div
);
9605 hres
= IHTMLDocument2_get_all(doc
, &col
);
9606 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9607 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9608 IHTMLElementCollection_Release(col
);
9610 div
= test_create_elem(frag
, "div");
9611 owner_doc
= get_owner_doc((IUnknown
*)div
);
9612 doc_node
= get_doc_node(doc
);
9613 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
9614 IHTMLDocument2_Release(doc_node
);
9615 IHTMLDocument2_Release(owner_doc
);
9616 IHTMLElement_Release(div
);
9618 IHTMLDocument2_Release(frag
);
9621 static void check_quirks_mode(IHTMLDocument2
*doc
)
9623 test_compatmode(doc
, "BackCompat");
9626 static void check_strict_mode(IHTMLDocument2
*doc
)
9628 test_compatmode(doc
, "CSS1Compat");
9631 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
9637 hres
= IHTMLDocument2_get_body(doc
, &elem
);
9638 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
9640 /* body.offsetHeight value depends on window size in quirks mode */
9641 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
9642 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
9643 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
9644 IHTMLElement_Release(elem
);
9647 static IHTMLDocument2
*notif_doc
;
9648 static BOOL doc_complete
;
9650 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
9651 REFIID riid
, void**ppv
)
9653 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
9658 ok(0, "unexpected call\n");
9659 return E_NOINTERFACE
;
9662 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
9667 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
9672 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
9674 if(dispID
== DISPID_READYSTATE
){
9678 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
9679 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
9681 if(!strcmp_wa(state
, "complete"))
9682 doc_complete
= TRUE
;
9684 SysFreeString(state
);
9690 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
9692 ok(0, "unexpected call\n");
9696 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
9697 PropertyNotifySink_QueryInterface
,
9698 PropertyNotifySink_AddRef
,
9699 PropertyNotifySink_Release
,
9700 PropertyNotifySink_OnChanged
,
9701 PropertyNotifySink_OnRequestEdit
9704 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
9706 static HRESULT
cs_qi(REFIID
,void **);
9707 static IOleDocumentView
*view
;
9708 static HWND container_hwnd
;
9710 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
9712 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
9714 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
9715 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
9718 return E_NOINTERFACE
;
9721 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
9726 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
9731 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
9736 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
9741 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
9746 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
9747 LPCBORDERWIDTHS pborderwidths
)
9752 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
9753 LPCBORDERWIDTHS pborderwidths
)
9758 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
9759 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
9764 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9765 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
9770 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9771 HOLEMENU holemenu
, HWND hwndActiveObject
)
9773 ok(0, "unexpected call\n");
9777 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
9779 ok(0, "unexpected call\n");
9783 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
9788 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
9793 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
9795 ok(0, "unexpected call\n");
9799 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
9800 InPlaceFrame_QueryInterface
,
9801 InPlaceFrame_AddRef
,
9802 InPlaceFrame_Release
,
9803 InPlaceFrame_GetWindow
,
9804 InPlaceFrame_ContextSensitiveHelp
,
9805 InPlaceFrame_GetBorder
,
9806 InPlaceFrame_RequestBorderSpace
,
9807 InPlaceFrame_SetBorderSpace
,
9808 InPlaceFrame_SetActiveObject
,
9809 InPlaceFrame_InsertMenus
,
9810 InPlaceFrame_SetMenu
,
9811 InPlaceFrame_RemoveMenus
,
9812 InPlaceFrame_SetStatusText
,
9813 InPlaceFrame_EnableModeless
,
9814 InPlaceFrame_TranslateAccelerator
9817 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
9819 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
9821 return cs_qi(riid
, ppv
);
9824 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
9829 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
9834 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
9836 *phwnd
= container_hwnd
;
9840 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
9842 ok(0, "unexpected call\n");
9846 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
9851 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
9856 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
9861 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
9862 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
9863 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
9865 static const RECT rect
= {0,0,500,500};
9867 *ppFrame
= &InPlaceFrame
;
9869 *lprcPosRect
= rect
;
9870 *lprcClipRect
= rect
;
9872 lpFrameInfo
->fMDIApp
= FALSE
;
9873 lpFrameInfo
->hwndFrame
= container_hwnd
;
9874 lpFrameInfo
->haccel
= NULL
;
9875 lpFrameInfo
->cAccelEntries
= 0;
9880 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
9885 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
9890 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
9895 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
9900 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
9905 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
9910 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
9911 InPlaceSite_QueryInterface
,
9913 InPlaceSite_Release
,
9914 InPlaceSite_GetWindow
,
9915 InPlaceSite_ContextSensitiveHelp
,
9916 InPlaceSite_CanInPlaceActivate
,
9917 InPlaceSite_OnInPlaceActivate
,
9918 InPlaceSite_OnUIActivate
,
9919 InPlaceSite_GetWindowContext
,
9921 InPlaceSite_OnUIDeactivate
,
9922 InPlaceSite_OnInPlaceDeactivate
,
9923 InPlaceSite_DiscardUndoState
,
9924 InPlaceSite_DeactivateAndUndo
,
9925 InPlaceSite_OnPosRectChange
,
9928 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
9930 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
9932 return cs_qi(riid
, ppv
);
9935 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
9940 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
9945 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
9947 ok(0, "unexpected call\n");
9951 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
9954 ok(0, "unexpected call\n");
9958 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
9963 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
9965 ok(0, "unexpected call\n");
9969 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
9971 ok(0, "unexpected call\n");
9975 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
9977 ok(0, "unexpected call\n");
9981 static const IOleClientSiteVtbl ClientSiteVtbl
= {
9982 ClientSite_QueryInterface
,
9985 ClientSite_SaveObject
,
9986 ClientSite_GetMoniker
,
9987 ClientSite_GetContainer
,
9988 ClientSite_ShowObject
,
9989 ClientSite_OnShowWindow
,
9990 ClientSite_RequestNewObjectLayout
9993 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
9995 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
9997 return cs_qi(riid
, ppv
);
10000 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
10005 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
10010 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
10012 RECT rect
= {0,0,500,500};
10013 IOleDocument
*document
;
10016 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
10017 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
10019 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
10020 IOleDocument_Release(document
);
10021 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
10023 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
10024 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
10026 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
10027 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
10029 hres
= IOleDocumentView_SetRect(view
, &rect
);
10030 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
10032 hres
= IOleDocumentView_Show(view
, TRUE
);
10033 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
10038 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
10039 DocumentSite_QueryInterface
,
10040 DocumentSite_AddRef
,
10041 DocumentSite_Release
,
10042 DocumentSite_ActivateMe
10045 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
10047 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
10051 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
10052 *ppv
= &ClientSite
;
10053 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
10054 *ppv
= &DocumentSite
;
10055 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
10056 *ppv
= &InPlaceSite
;
10058 return *ppv
? S_OK
: E_NOINTERFACE
;
10061 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
10063 IOleObject
*oleobj
;
10067 IOleDocumentView_Show(view
, FALSE
);
10068 IOleDocumentView_CloseView(view
, 0);
10069 IOleDocumentView_SetInPlaceSite(view
, NULL
);
10070 IOleDocumentView_Release(view
);
10074 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
10075 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
10077 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
10078 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
10081 IHlinkTarget
*hlink
;
10083 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
10084 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
10086 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
10087 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
10089 IHlinkTarget_Release(hlink
);
10092 IOleObject_Release(oleobj
);
10095 static IHTMLDocument2
*create_doc_with_string(const char *str
)
10097 IPersistStreamInit
*init
;
10099 IHTMLDocument2
*doc
;
10103 notif_doc
= doc
= create_document();
10107 doc_complete
= FALSE
;
10109 mem
= GlobalAlloc(0, len
);
10110 memcpy(mem
, str
, len
);
10111 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
10113 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
10115 IPersistStreamInit_Load(init
, stream
);
10116 IPersistStreamInit_Release(init
);
10117 IStream_Release(stream
);
10122 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
10124 IConnectionPointContainer
*container
;
10125 IConnectionPoint
*cp
;
10129 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
10130 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
10132 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
10133 IConnectionPointContainer_Release(container
);
10134 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
10136 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
10137 IConnectionPoint_Release(cp
);
10138 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
10141 typedef void (*domtest_t
)(IHTMLDocument2
*);
10143 static void run_domtest(const char *str
, domtest_t test
)
10145 IHTMLDocument2
*doc
;
10149 doc
= create_doc_with_string(str
);
10153 set_client_site(doc
, TRUE
);
10154 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
10156 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
10157 TranslateMessage(&msg
);
10158 DispatchMessageW(&msg
);
10163 set_client_site(doc
, FALSE
);
10164 ref
= IHTMLDocument2_Release(doc
);
10165 ok(!ref
|| broken(ref
== 1), /* Vista */
10166 "ref = %d\n", ref
);
10169 static void test_quirks_mode(void)
10171 run_domtest("<html></html>", check_quirks_mode
);
10172 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
10173 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
10174 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
10179 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
10180 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
10181 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
10183 CoInitialize(NULL
);
10184 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
10185 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
10187 run_domtest(doc_str1
, test_doc_elem
);
10188 run_domtest(doc_str1
, test_get_set_attr
);
10189 run_domtest(range_test_str
, test_txtrange
);
10190 run_domtest(range_test2_str
, test_txtrange2
);
10191 if (winetest_interactive
|| ! is_ie_hardened()) {
10192 run_domtest(elem_test_str
, test_elems
);
10193 run_domtest(elem_test2_str
, test_elems2
);
10194 run_domtest(noscript_str
, test_noscript
);
10196 skip("IE running in Enhanced Security Configuration\n");
10198 run_domtest(doc_blank
, test_create_elems
);
10199 run_domtest(doc_blank
, test_defaults
);
10200 run_domtest(doc_blank
, test_null_write
);
10201 run_domtest(emptydiv_str
, test_create_stylesheet
);
10202 run_domtest(indent_test_str
, test_indent
);
10203 run_domtest(cond_comment_str
, test_cond_comment
);
10204 run_domtest(frameset_str
, test_frameset
);
10205 run_domtest(emptydiv_str
, test_docfrag
);
10206 run_domtest(doc_blank
, test_replacechild_elems
);
10207 run_domtest(doctype_str
, test_doctype
);
10209 test_quirks_mode();
10211 DestroyWindow(container_hwnd
);