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, \
184 static const IID
* const elem_iids
[] = {
186 &IID_IConnectionPointContainer
,
190 static const IID
* const body_iids
[] = {
192 &IID_IHTMLTextContainer
,
193 &IID_IHTMLBodyElement
,
194 &IID_IConnectionPointContainer
,
198 static const IID
* const anchor_iids
[] = {
200 &IID_IHTMLAnchorElement
,
201 &IID_IConnectionPointContainer
,
205 static const IID
* const input_iids
[] = {
207 &IID_IHTMLInputElement
,
208 &IID_IHTMLInputTextElement
,
209 &IID_IConnectionPointContainer
,
213 static const IID
*const button_iids
[] = {
215 &IID_IHTMLButtonElement
,
216 &IID_IConnectionPointContainer
,
220 static const IID
* const label_iids
[] = {
222 &IID_IHTMLLabelElement
,
223 &IID_IConnectionPointContainer
,
227 static const IID
* const select_iids
[] = {
229 &IID_IHTMLSelectElement
,
230 &IID_IConnectionPointContainer
,
234 static const IID
* const textarea_iids
[] = {
236 &IID_IHTMLTextAreaElement
,
237 &IID_IConnectionPointContainer
,
241 static const IID
* const option_iids
[] = {
243 &IID_IHTMLOptionElement
,
244 &IID_IConnectionPointContainer
,
248 static const IID
* const table_iids
[] = {
253 &IID_IConnectionPointContainer
,
257 static const IID
* const script_iids
[] = {
259 &IID_IHTMLScriptElement
,
260 &IID_IConnectionPointContainer
,
264 static const IID
* const text_iids
[] = {
267 &IID_IHTMLDOMTextNode
,
268 &IID_IHTMLDOMTextNode2
,
272 static const IID
* const attr_iids
[] = {
273 &IID_IHTMLDOMAttribute
,
274 &IID_IHTMLDOMAttribute2
,
279 static const IID
* const location_iids
[] = {
285 static const IID
* const window_iids
[] = {
290 &IID_IServiceProvider
,
294 static const IID
* const comment_iids
[] = {
296 &IID_IHTMLCommentElement
,
297 &IID_IConnectionPointContainer
,
301 static const IID
* const img_iids
[] = {
303 &IID_IHTMLImgElement
,
304 &IID_IConnectionPointContainer
,
308 static const IID
* const tr_iids
[] = {
311 &IID_IConnectionPointContainer
,
315 static const IID
* const td_iids
[] = {
318 &IID_IConnectionPointContainer
,
322 static const IID
* const frame_iids
[] = {
325 &IID_IHTMLFrameBase2
,
326 &IID_IConnectionPointContainer
,
330 static const IID
* const head_iids
[] = {
332 &IID_IHTMLHeadElement
,
333 &IID_IConnectionPointContainer
,
337 static const IID
* const title_iids
[] = {
339 &IID_IHTMLTitleElement
,
340 &IID_IConnectionPointContainer
,
344 static const IID
* const meta_iids
[] = {
346 &IID_IHTMLMetaElement
,
347 &IID_IConnectionPointContainer
,
351 static const IID
* const link_iids
[] = {
353 &IID_IHTMLLinkElement
,
354 &IID_IConnectionPointContainer
,
358 static const IID
* const object_iids
[] = {
360 &IID_IHTMLObjectElement
,
361 &IID_IHTMLObjectElement2
,
362 /* FIXME: No IConnectionPointContainer */
366 static const IID
* const embed_iids
[] = {
368 &IID_IHTMLEmbedElement
,
369 /* FIXME: No IConnectionPointContainer */
373 static const IID
* const iframe_iids
[] = {
376 &IID_IHTMLFrameBase2
,
377 &IID_IHTMLIFrameElement
,
378 &IID_IHTMLIFrameElement2
,
379 &IID_IConnectionPointContainer
,
383 static const IID
* const form_iids
[] = {
385 &IID_IHTMLFormElement
,
386 &IID_IConnectionPointContainer
,
387 &DIID_DispHTMLFormElement
,
391 static const IID
* const styleelem_iids
[] = {
393 &IID_IHTMLStyleElement
,
394 &IID_IConnectionPointContainer
,
398 static const IID
* const generic_iids
[] = {
400 &IID_IHTMLGenericElement
,
401 &IID_IConnectionPointContainer
,
405 static const IID
* const style_iids
[] = {
416 static const IID
* const cstyle_iids
[] = {
420 &IID_IHTMLCurrentStyle
,
421 &IID_IHTMLCurrentStyle2
,
422 &IID_IHTMLCurrentStyle3
,
426 static const IID
* const img_factory_iids
[] = {
430 &IID_IHTMLImageElementFactory
,
434 static const IID
* const selection_iids
[] = {
438 &IID_IHTMLSelectionObject
,
439 &IID_IHTMLSelectionObject2
,
449 static const elem_type_info_t elem_type_infos
[] = {
450 {"", none_iids
, NULL
},
451 {"HTML", elem_iids
, NULL
},
452 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
453 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
454 {"BODY", body_iids
, &DIID_DispHTMLBody
},
455 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
456 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
457 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
458 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
459 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
460 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
461 {"BLOCKQUOTE",elem_iids
, NULL
},
462 {"P", elem_iids
, NULL
},
463 {"BR", elem_iids
, NULL
},
464 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
465 {"TBODY", elem_iids
, NULL
},
466 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
467 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
468 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
469 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
470 {"IMG", img_iids
, &DIID_DispHTMLImg
},
471 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
472 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
473 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
474 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
475 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
476 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
477 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
478 {"DIV", elem_iids
, NULL
},
479 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
480 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
481 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
482 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
483 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
486 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
489 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
490 return lstrcmpA(stra
, buf
);
493 static BOOL
is_prefix_wa(const WCHAR
*strw
, const char *prefix
)
498 len
= WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
)-1;
499 prefix_len
= lstrlenA(prefix
);
504 return !lstrcmpA(buf
, prefix
);
507 static BSTR
a2bstr(const char *str
)
515 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
516 ret
= SysAllocStringLen(NULL
, len
);
517 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
522 static const char *debugstr_variant(const VARIANT
*var
)
524 static char buf
[400];
534 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
537 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
540 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
543 sprintf(buf
, "{vt %d}", V_VT(var
));
550 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
552 IUnknown
*unk1
, *unk2
;
557 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
558 IUnknown_Release(unk1
);
559 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
560 IUnknown_Release(unk2
);
565 static IHTMLDocument2
*create_document(void)
568 IHTMLDocument5
*doc5
;
571 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
572 &IID_IHTMLDocument2
, (void**)&doc
);
573 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
577 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
579 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
580 IHTMLDocument2_Release(doc
);
584 IHTMLDocument5_Release(doc5
);
588 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
589 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
594 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
595 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
599 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
600 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
602 const IID
* const *piid
;
606 for(piid
= iids
; *piid
; piid
++) {
607 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
608 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
610 IUnknown_Release(unk
);
614 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
615 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
620 unk
= (void*)0xdeadbeef;
621 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
622 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
623 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
626 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
627 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
629 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
636 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
637 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
638 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
640 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
641 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
643 if(SUCCEEDED(hres
)) {
646 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
647 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
649 *iid
= type_attr
->guid
;
653 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
654 ITypeInfo_Release(typeinfo
);
657 IDispatchEx_Release(dispex
);
661 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
662 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
664 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
665 DISPPARAMS dp
= {NULL
,NULL
,0,0};
670 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
671 IDispatchEx_Release(dispex
);
672 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
674 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
675 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
679 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
680 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
684 if(_test_get_dispid(line
, unk
, &iid
))
685 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
688 _test_disp_value(line
, unk
, val
);
691 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
692 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
696 if(_test_get_dispid(line
, unk
, &iid
))
697 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
698 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
701 _test_disp_value(line
, unk
, val
);
704 #define test_class_info(u) _test_class_info(__LINE__,u)
705 static void _test_class_info(unsigned line
, IUnknown
*unk
)
707 IProvideClassInfo
*classinfo
;
712 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
713 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
717 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
718 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
721 IProvideClassInfo_Release(classinfo
);
725 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
726 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
729 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
730 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
731 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
732 "unexpected typekind %d\n", type_attr
->typekind
);
733 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
736 ITypeInfo_Release(typeinfo
);
737 IProvideClassInfo_Release(classinfo
);
740 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
741 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
743 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
744 DISPPARAMS dp
= {val
, NULL
, 1, 0};
751 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
753 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
755 memset(&ei
, 0, sizeof(ei
));
756 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
757 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
761 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
762 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
767 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
768 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
772 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
773 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
778 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
779 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
783 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
784 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
789 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
790 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
794 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
795 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
800 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
801 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
805 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
806 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
808 IHTMLDocument3
*doc3
;
811 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
812 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
817 #define get_node_iface(u) _get_node_iface(__LINE__,u)
818 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
823 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
824 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
828 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
829 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
834 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
835 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
839 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
840 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
845 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
846 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
850 #define get_img_iface(u) _get_img_iface(__LINE__,u)
851 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
853 IHTMLImgElement
*img
;
856 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
857 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
861 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
862 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
864 IHTMLAnchorElement
*anchor
;
867 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
868 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
872 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
873 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
875 IHTMLTextAreaElement
*textarea
;
878 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
879 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
883 #define get_select_iface(u) _get_select_iface(__LINE__,u)
884 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
886 IHTMLSelectElement
*select
;
889 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
890 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
894 #define get_option_iface(u) _get_option_iface(__LINE__,u)
895 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
897 IHTMLOptionElement
*option
;
900 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
901 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08x\n", hres
);
905 #define get_form_iface(u) _get_form_iface(__LINE__,u)
906 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
908 IHTMLFormElement
*form
;
911 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
916 #define get_text_iface(u) _get_text_iface(__LINE__,u)
917 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
919 IHTMLDOMTextNode
*text
;
922 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
927 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
928 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
930 IHTMLDOMTextNode2
*text2
;
933 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
934 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08x\n", hres
);
938 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
939 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
941 IHTMLCommentElement
*comment
;
944 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
945 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
949 #define get_object_iface(u) _get_object_iface(__LINE__,u)
950 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
952 IHTMLObjectElement
*obj
;
955 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
956 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
960 #define get_style_iface(u) _get_style_iface(__LINE__,u)
961 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
963 IHTMLStyleElement
*obj
;
966 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
967 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
971 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
972 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
974 IHTMLMetaElement
*ret
;
977 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
978 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
982 #define get_link_iface(u) _get_link_iface(__LINE__,u)
983 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
985 IHTMLLinkElement
*ret
;
988 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
989 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
993 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
994 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
996 IHTMLIFrameElement2
*ret
;
999 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1000 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
1004 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1005 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1007 IHTMLButtonElement
*ret
;
1010 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1011 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
1015 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1016 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1018 IHTMLLabelElement
*ret
;
1021 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1022 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
1026 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1027 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1029 IHTMLDOMAttribute2
*ret
;
1032 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1033 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08x\n", hres
);
1037 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1038 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
1040 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1044 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1045 IHTMLDOMNode_Release(node
);
1046 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
1047 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
1049 SysFreeString(name
);
1052 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1053 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1055 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1056 IDispatch
*disp
= (void*)0xdeadbeef;
1057 IHTMLDocument2
*doc
= NULL
;
1060 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1061 IHTMLDOMNode2_Release(node
);
1062 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
1065 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1066 IDispatch_Release(disp
);
1067 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
1073 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1074 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1076 IHTMLWindow2
*window
;
1080 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1081 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1082 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1087 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1088 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1090 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1091 IHTMLDOMNode
*ret
= NULL
;
1094 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1095 IHTMLDOMNode_Release(node
);
1096 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1097 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1103 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1104 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1106 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1110 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1111 IHTMLElement_Release(elem
);
1112 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1113 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1118 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1119 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1121 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1122 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1124 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1125 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1128 #define get_node_type(n) _get_node_type(__LINE__,n)
1129 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1131 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1135 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1136 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1138 IHTMLDOMNode_Release(node
);
1143 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1144 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1146 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1147 IHTMLDOMChildrenCollection
*col
= NULL
;
1151 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1152 IHTMLDOMNode_Release(node
);
1153 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1157 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1158 IDispatch_Release(disp
);
1159 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1164 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1165 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1167 IHTMLDOMNode
*node
= NULL
;
1171 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1172 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1174 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1175 IDispatch_Release(disp
);
1180 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1181 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1187 VariantInit(&value
);
1190 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1192 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1195 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1196 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1198 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1201 VariantClear(&value
);
1204 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1205 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1207 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1208 IHTMLElement
*off_parent
;
1212 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1213 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1215 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1216 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1218 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1221 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1222 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1224 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1225 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1227 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1228 IHTMLElement_Release(off_parent
);
1230 IHTMLElement_Release(elem
);
1233 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1234 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1236 LONG l
= 0xdeadbeef;
1239 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1240 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1241 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1244 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1245 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1247 IHTMLWindow2
*window
;
1248 IHTMLDocument2
*ret
;
1251 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1252 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1254 hres
= IHTMLWindow2_get_document(window
, &ret
);
1255 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1256 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1261 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1262 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1267 hres
= IHTMLWindow2_get_name(window
, &name
);
1268 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1270 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1272 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1273 SysFreeString(name
);
1276 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1277 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1283 hres
= IHTMLWindow2_put_name(window
, str
);
1285 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1287 _test_window_name(line
, window
, name
);
1290 #define test_window_status(d) _test_window_status(__LINE__,d)
1291 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1296 status
= (void*)0xdeadbeef;
1297 hres
= IHTMLWindow2_get_status(window
, &status
);
1298 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1299 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1300 SysFreeString(status
);
1303 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1304 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1309 str
= a2bstr(status
);
1310 hres
= IHTMLWindow2_put_status(window
, str
);
1312 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1315 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1316 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1321 hres
= IHTMLWindow2_get_length(window
, &length
);
1322 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1323 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1326 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1327 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1329 IHTMLFrameBase2
*base2
;
1330 IHTMLWindow2
*window
;
1333 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1334 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1337 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1338 IHTMLFrameBase2_Release(base2
);
1339 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1340 ok(window
!= NULL
, "contentWindow = NULL\n");
1345 static void test_get_set_attr(IHTMLDocument2
*doc
)
1348 IHTMLDocument3
*doc3
;
1353 /* grab an element to test with */
1354 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1355 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1357 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1358 IHTMLDocument3_Release(doc3
);
1359 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1361 /* get a non-present attribute */
1362 bstr
= a2bstr("notAnAttribute");
1363 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1364 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1365 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1367 SysFreeString(bstr
);
1369 /* get a present attribute */
1370 bstr
= a2bstr("scrollHeight");
1371 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1372 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1373 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1375 SysFreeString(bstr
);
1377 /* create a new BSTR attribute */
1378 bstr
= a2bstr("newAttribute");
1380 V_VT(&val
) = VT_BSTR
;
1381 V_BSTR(&val
) = a2bstr("the value");
1382 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1383 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1386 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1387 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1388 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1389 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
)));
1392 /* overwrite the attribute with a BOOL */
1393 V_VT(&val
) = VT_BOOL
;
1394 V_BOOL(&val
) = VARIANT_TRUE
;
1395 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1396 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1399 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1400 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1401 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1402 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1405 SysFreeString(bstr
);
1407 /* case-insensitive */
1408 bstr
= a2bstr("newattribute");
1409 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1410 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1411 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1412 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1414 SysFreeString(bstr
);
1416 IHTMLElement_Release(elem
);
1419 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1420 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1423 IHTMLDocument3
*doc3
;
1426 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1427 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1428 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1429 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1430 IHTMLDocument3_Release(doc3
);
1435 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1436 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1438 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1442 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1443 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1444 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1447 _test_disp_value(line
, unk
, exhref
);
1450 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1451 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1453 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1457 str
= a2bstr(exhref
);
1458 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1459 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1462 _test_disp_value(line
, unk
, exhref
);
1465 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1466 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1468 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1472 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1473 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1475 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1477 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1481 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1482 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1484 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1488 str
= a2bstr(exrel
);
1489 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1490 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1494 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1495 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1497 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1501 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1502 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1504 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1506 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1510 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1511 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1513 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1517 str
= target
? a2bstr(target
) : NULL
;
1518 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1519 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1523 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1524 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1526 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1530 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1531 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1533 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1535 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1539 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1540 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1542 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1546 str
= name
? a2bstr(name
) : NULL
;
1547 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1548 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1551 _test_anchor_name(line
, unk
, name
);
1554 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1555 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1557 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1561 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1562 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1564 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1566 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1570 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1571 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1573 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1577 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1578 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1579 if ( ! str
&& allowbroken
)
1580 win_skip("skip ie6 incorrect behavior\n");
1582 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1584 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1588 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1589 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1591 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1595 str
= search
? a2bstr(search
) : NULL
;
1596 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1597 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1601 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1602 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1604 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1608 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1609 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1611 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1613 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1617 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1618 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1623 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1624 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1625 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1626 SysFreeString(bstr
);
1629 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1630 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1635 bstr
= a2bstr(text
);
1636 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1637 SysFreeString(bstr
);
1638 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1640 _test_option_text(line
, option
, text
);
1643 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1644 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1649 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1650 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1651 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1652 SysFreeString(bstr
);
1655 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1656 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1661 bstr
= a2bstr(value
);
1662 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1663 SysFreeString(bstr
);
1664 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1666 _test_option_value(line
, option
, value
);
1669 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1670 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1672 VARIANT_BOOL b
= 0x100;
1675 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1676 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1677 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1680 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1681 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1685 hres
= IHTMLOptionElement_put_selected(option
, b
);
1686 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1687 _test_option_selected(line
, option
, b
);
1690 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1691 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1696 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1697 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08x\n", hres
);
1700 hres
= IHTMLOptionElement_get_index(option
, &val
);
1701 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08x\n", hres
);
1702 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1703 "value = %d, expected = %d\n", val
, exval
);
1706 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1707 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1711 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1712 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08x\n", hres
);
1715 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1716 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1721 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1722 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08x\n", hres
);
1725 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1726 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08x\n", hres
);
1727 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1730 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1732 test_option_defaultSelected(option
, VARIANT_FALSE
);
1733 test_option_selected(option
, VARIANT_FALSE
);
1735 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1736 test_option_defaultSelected(option
, VARIANT_FALSE
);
1737 test_option_selected(option
, VARIANT_FALSE
);
1739 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1740 test_option_defaultSelected(option
, VARIANT_TRUE
);
1741 test_option_selected(option
, VARIANT_FALSE
);
1743 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1744 test_option_defaultSelected(option
, VARIANT_FALSE
);
1745 test_option_selected(option
, VARIANT_FALSE
);
1747 test_option_put_selected(option
, VARIANT_TRUE
);
1748 test_option_selected(option
, VARIANT_TRUE
);
1749 test_option_defaultSelected(option
, VARIANT_FALSE
);
1751 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1752 test_option_defaultSelected(option
, VARIANT_TRUE
);
1753 test_option_selected(option
, VARIANT_TRUE
);
1755 /* Restore defaultSelected */
1756 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1757 test_option_put_selected(option
, VARIANT_FALSE
);
1760 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1761 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1763 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1764 BSTR value
= (void*)0xdeadbeef;
1767 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1768 IHTMLTextAreaElement_Release(textarea
);
1769 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1771 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1773 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1774 SysFreeString(value
);
1777 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1778 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1780 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1781 BSTR tmp
= a2bstr(value
);
1784 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1785 IHTMLTextAreaElement_Release(textarea
);
1786 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1789 _test_textarea_value(line
, unk
, value
);
1792 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1793 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const char *exval
)
1795 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1796 BSTR value
= (void*)0xdeadbeef;
1799 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1800 IHTMLTextAreaElement_Release(textarea
);
1801 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
1803 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1805 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1806 SysFreeString(value
);
1809 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1810 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const char *value
)
1812 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1813 BSTR tmp
= a2bstr(value
);
1816 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1817 IHTMLTextAreaElement_Release(textarea
);
1818 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08x\n", hres
);
1821 _test_textarea_defaultvalue(line
, unk
, value
);
1824 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1825 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1827 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1828 VARIANT_BOOL b
= 0x100;
1831 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1832 IHTMLTextAreaElement_Release(textarea
);
1833 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1834 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1837 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1838 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1840 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1843 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1844 IHTMLTextAreaElement_Release(textarea
);
1845 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1847 _test_textarea_readonly(line
, unk
, b
);
1850 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1851 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1853 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1854 BSTR type
= (void*)0xdeadbeef;
1857 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1858 IHTMLTextAreaElement_Release(textarea
);
1859 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1860 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1861 SysFreeString(type
);
1864 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1865 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1867 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1868 IHTMLFormElement
*form
;
1871 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1872 IHTMLTextAreaElement_Release(textarea
);
1873 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1878 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1879 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1881 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1885 text
= a2bstr(extext
);
1886 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1887 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1888 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1890 IHTMLCommentElement_Release(comment
);
1891 SysFreeString(text
);
1894 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
1895 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1897 VARIANT_BOOL specified
;
1900 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
1901 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
1902 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
1905 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
1906 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
1908 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1909 VARIANT_BOOL expando
;
1912 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
1913 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08x\n", hres
);
1914 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
1916 IHTMLDOMAttribute2_Release(attr2
);
1919 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
1920 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exval
)
1922 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
1926 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
1927 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1929 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
1931 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
1933 IHTMLDOMAttribute2_Release(attr2
);
1937 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1938 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1940 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1941 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1942 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1943 IHTMLDOMAttribute
*attr
;
1944 BSTR name
= a2bstr("test");
1948 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1949 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1950 ok(attr
== NULL
, "attr != NULL\n");
1954 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1955 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1957 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1958 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1959 ok(attr
!= NULL
, "attr == NULL\n");
1961 test_attr_expando(attr
, VARIANT_TRUE
);
1963 IHTMLDOMAttribute_Release(attr
);
1964 IHTMLCommentElement_Release(comment
);
1965 IHTMLElement_Release(elem
);
1966 IHTMLElement4_Release(elem4
);
1967 SysFreeString(name
);
1970 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1971 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1973 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1978 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1979 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1980 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1981 IHTMLObjectElement_Release(object
);
1984 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
1985 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
1987 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1991 str
= (void*)0xdeadbeef;
1992 hres
= IHTMLObjectElement_get_name(object
, &str
);
1993 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1995 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
1997 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
1999 IHTMLObjectElement_Release(object
);
2002 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2003 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
2005 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2010 hres
= IHTMLObjectElement_put_name(object
, str
);
2011 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
2013 IHTMLObjectElement_Release(object
);
2015 _test_object_name(line
, elem
, name
);
2018 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2019 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2020 const char *txt
, const char *val
)
2022 IHTMLOptionElementFactory
*factory
;
2023 IHTMLOptionElement
*option
;
2024 IHTMLWindow2
*window
;
2025 VARIANT text
, value
, empty
;
2028 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2029 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2031 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2032 IHTMLWindow2_Release(window
);
2033 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
2035 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
2037 V_VT(&text
) = VT_BSTR
;
2038 V_BSTR(&text
) = a2bstr(txt
);
2039 V_VT(&value
) = VT_BSTR
;
2040 V_BSTR(&value
) = a2bstr(val
);
2041 V_VT(&empty
) = VT_EMPTY
;
2043 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2044 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2046 IHTMLOptionElementFactory_Release(factory
);
2047 VariantClear(&text
);
2048 VariantClear(&value
);
2050 _test_option_text(line
, option
, txt
);
2051 _test_option_value(line
, option
, val
);
2052 _test_option_selected(line
, option
, VARIANT_FALSE
);
2057 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2058 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2063 hres
= IHTMLImgElement_get_width(img
, &found
);
2064 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
2065 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
2068 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2069 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2073 hres
= IHTMLImgElement_put_width(img
, width
);
2074 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2076 _test_img_width(line
, img
, width
);
2079 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2080 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2085 hres
= IHTMLImgElement_get_height(img
, &found
);
2086 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
2087 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
2090 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2091 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2095 hres
= IHTMLImgElement_put_height(img
, height
);
2096 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2098 _test_img_height(line
, img
, height
);
2101 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2102 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2103 LONG wdth
, LONG hght
)
2105 IHTMLImageElementFactory
*factory
;
2106 IHTMLImgElement
*img
;
2107 IHTMLWindow2
*window
;
2108 VARIANT width
, height
;
2112 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2113 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2115 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2116 IHTMLWindow2_Release(window
);
2117 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
2119 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2120 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
2123 snprintf(buf
, 16, "%d", wdth
);
2124 V_VT(&width
) = VT_BSTR
;
2125 V_BSTR(&width
) = a2bstr(buf
);
2127 V_VT(&width
) = VT_EMPTY
;
2132 snprintf(buf
, 16, "%d", hght
);
2133 V_VT(&height
) = VT_BSTR
;
2134 V_BSTR(&height
) = a2bstr(buf
);
2136 V_VT(&height
) = VT_EMPTY
;
2140 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2141 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
2143 IHTMLImageElementFactory_Release(factory
);
2144 VariantClear(&width
);
2145 VariantClear(&height
);
2147 if(SUCCEEDED(hres
)) {
2148 _test_img_width(line
, img
, wdth
);
2149 _test_img_height(line
, img
, hght
);
2156 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2157 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2159 LONG len
= 0xdeadbeef;
2162 hres
= IHTMLSelectElement_get_length(select
, &len
);
2163 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2164 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
2167 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2168 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2170 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2173 hres
= IHTMLSelectElement_put_length(select
, length
);
2174 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
2175 _test_select_length(line
, select
, length
);
2176 IHTMLSelectElement_Release(select
);
2179 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2180 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2182 LONG idx
= 0xdeadbeef;
2185 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2186 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2187 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
2190 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2191 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2195 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2196 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
2197 _test_select_selidx(line
, select
, index
);
2200 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2201 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
2206 hres
= IHTMLSelectElement_get_value(select
, &val
);
2207 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
2209 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2211 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2215 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2216 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
2222 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2223 SysFreeString(bstr
);
2224 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
2227 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2228 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
2233 hres
= IHTMLSelectElement_get_type(select
, &type
);
2234 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2235 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2236 SysFreeString(type
);
2239 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2240 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2242 VARIANT_BOOL b
= 100;
2245 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2247 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2250 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2251 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2255 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2256 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2258 _test_select_multiple(line
, select
, val
);
2261 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2262 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2267 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2268 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08x, expected E_INVALIDARG\n", hres
);
2271 hres
= IHTMLSelectElement_get_size(select
, &val
);
2272 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
2273 ok_(__FILE__
,line
) (val
== exval
, "size = %d, expected %d\n", val
, exval
);
2276 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2277 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2281 hres
= IHTMLSelectElement_put_size(select
, val
);
2282 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%d) got %08x, expect %08x\n", val
, hres
, exhres
);
2285 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2286 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const char *extext
)
2292 hres
= IHTMLSelectElement_get_name(select
, &text
);
2293 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
2295 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2296 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "name = %s, expected %s\n",
2297 wine_dbgstr_w(text
), extext
);
2298 SysFreeString(text
);
2300 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2303 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2304 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const char *text
)
2309 bstr
= a2bstr(text
);
2311 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2312 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08x\n", wine_dbgstr_w(bstr
), hres
);
2313 SysFreeString(bstr
);
2316 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2317 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2322 hres
= IHTMLTxtRange_get_text(range
, &text
);
2323 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2326 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2327 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2329 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2332 SysFreeString(text
);
2336 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2337 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2341 hres
= IHTMLTxtRange_collapse(range
, b
);
2342 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2343 _test_range_text(line
, range
, NULL
);
2346 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2347 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2348 VARIANT_BOOL exb
, const char *extext
)
2350 VARIANT_BOOL b
= 0xe0e0;
2353 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2354 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2355 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2356 _test_range_text(line
, range
, extext
);
2359 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2360 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2362 LONG c
= 0xdeadbeef;
2365 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2366 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2367 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2368 _test_range_text(line
, range
, NULL
);
2371 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2372 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2373 LPWSTR unit
, LONG cnt
, LONG excnt
)
2375 LONG c
= 0xdeadbeef;
2378 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2379 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2380 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2383 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2384 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2386 LONG c
= 0xdeadbeef;
2389 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2390 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2391 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2394 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2395 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2398 BSTR bstr
= a2bstr(text
);
2400 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2401 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2402 SysFreeString(bstr
);
2403 _test_range_text(line
, range
, NULL
);
2406 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2407 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2413 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2414 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2415 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2418 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2419 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2425 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2426 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2427 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2430 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2431 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2432 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2435 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2436 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2440 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2441 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const char *html
)
2443 BSTR str
= a2bstr(html
);
2446 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2447 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08x\n", hres
);
2451 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2452 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2457 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2458 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2460 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2462 IHTMLElement_Release(elem
);
2465 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2466 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2468 VARIANT name
, index
;
2473 V_VT(&index
) = VT_EMPTY
;
2474 V_VT(&name
) = VT_I4
;
2476 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2477 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2478 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2480 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2481 IDispatch_Release(disp
);
2485 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2486 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2487 const elem_type_t
*elem_types
, LONG exlen
)
2489 IHTMLElementCollection
*col
;
2490 IEnumVARIANT
*enum_var
;
2495 VARIANT name
, index
, v
, vs
[5];
2496 IDispatch
*disp
, *disp2
;
2499 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2500 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2502 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2504 hres
= IHTMLElementCollection_get_length(col
, &len
);
2505 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2506 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2511 V_VT(&index
) = VT_EMPTY
;
2513 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2514 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2516 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2517 IUnknown_Release(enum_unk
);
2518 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2520 for(i
=0; i
<len
; i
++) {
2521 V_VT(&name
) = VT_I4
;
2523 disp
= (void*)0xdeadbeef;
2524 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2525 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2526 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2527 if(FAILED(hres
) || !disp
)
2530 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2533 V_VT(&name
) = VT_UINT
;
2535 disp2
= (void*)0xdeadbeef;
2536 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2537 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2538 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2540 IDispatch_Release(disp2
);
2544 V_VT(&v
) = VT_ERROR
;
2545 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2546 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2548 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2549 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2550 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2551 IDispatch_Release(V_DISPATCH(&v
));
2553 IDispatch_Release(disp
);
2556 fetched
= 0xdeadbeef;
2558 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2559 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2560 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2561 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2563 hres
= IEnumVARIANT_Reset(enum_var
);
2564 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2566 fetched
= 0xdeadbeef;
2568 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2569 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2570 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2571 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2573 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2574 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2576 memset(vs
, 0, sizeof(vs
));
2578 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2579 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2580 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2582 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2583 IDispatch_Release(V_DISPATCH(vs
));
2586 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2587 IDispatch_Release(V_DISPATCH(vs
+1));
2590 hres
= IEnumVARIANT_Reset(enum_var
);
2591 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2593 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2594 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2596 IEnumVARIANT_Release(enum_var
);
2598 V_VT(&name
) = VT_I4
;
2600 disp
= (void*)0xdeadbeef;
2601 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2602 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2603 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2605 V_VT(&name
) = VT_UI4
;
2607 disp
= (void*)0xdeadbeef;
2608 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2609 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2610 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2612 V_VT(&name
) = VT_INT
;
2614 disp
= (void*)0xdeadbeef;
2615 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2616 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2617 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2619 V_VT(&name
) = VT_UINT
;
2621 disp
= (void*)0xdeadbeef;
2622 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2623 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2624 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2626 V_VT(&name
) = VT_I4
;
2628 disp
= (void*)0xdeadbeef;
2629 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2630 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2631 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2633 IHTMLElementCollection_Release(col
);
2636 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2637 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2639 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2643 hres
= IHTMLElement_get_all(elem
, &disp
);
2644 IHTMLElement_Release(elem
);
2645 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2647 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2648 IDispatch_Release(disp
);
2651 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2652 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2654 IHTMLElementCollection
*col
;
2657 hres
= IHTMLDocument2_get_all(doc
, &col
);
2658 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2660 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2661 IHTMLElementCollection_Release(col
);
2664 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2665 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2667 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2668 IHTMLElementCollection
*col
= NULL
;
2669 elem_type_t
*types
= NULL
;
2674 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2675 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2677 IHTMLElement2_Release(elem
);
2678 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2679 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2682 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2683 for(i
=0; i
<exlen
; i
++)
2687 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2689 HeapFree(GetProcessHeap(), 0, types
);
2692 *ret
= get_elem_col_item_idx(col
, 0);
2693 IHTMLElementCollection_Release(col
);
2696 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2697 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2699 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2700 IHTMLElementCollection
*col
= NULL
;
2701 elem_type_t
*types
= NULL
;
2706 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2707 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2709 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2710 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2713 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2714 for(i
=0; i
<exlen
; i
++)
2718 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2720 HeapFree(GetProcessHeap(), 0, types
);
2721 IHTMLElementCollection_Release(col
);
2722 IHTMLDocument3_Release(doc
);
2725 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2726 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2731 hres
= IHTMLElement_get_innerText(elem
, &text
);
2732 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2734 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2735 wine_dbgstr_w(text
), extext
);
2737 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2738 SysFreeString(text
);
2741 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2742 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2744 IHTMLDOMChildrenCollection
*col
;
2749 hres
= IHTMLElement_put_innerText(elem
, str
);
2750 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2753 _test_elem_innertext(line
, elem
, text
);
2756 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2757 ok(col
!= NULL
, "col == NULL\n");
2759 LONG length
= 0, type
;
2762 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2763 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2764 ok(length
== 1, "length = %d\n", length
);
2766 node
= _get_child_item(line
, col
, 0);
2767 ok(node
!= NULL
, "node == NULL\n");
2769 type
= _get_node_type(line
, (IUnknown
*)node
);
2770 ok(type
== 3, "type=%d\n", type
);
2771 IHTMLDOMNode_Release(node
);
2774 IHTMLDOMChildrenCollection_Release(col
);
2779 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2780 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2782 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2786 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2787 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2789 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2791 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2793 IHTMLElement_Release(elem
);
2794 SysFreeString(html
);
2797 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2798 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2800 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2804 html
= a2bstr(inner_html
);
2805 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2806 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2808 IHTMLElement_Release(elem
);
2809 SysFreeString(html
);
2812 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2813 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2815 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2819 html
= a2bstr(outer_html
);
2820 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2821 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2823 IHTMLElement_Release(elem
);
2824 SysFreeString(html
);
2827 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2828 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2830 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2834 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2835 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2836 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2838 IHTMLElement_Release(elem
);
2839 SysFreeString(html
);
2842 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2843 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2849 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2850 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2851 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2854 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
2855 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
2861 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
2862 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08x\n", hres
);
2863 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
2866 #define get_first_child(n) _get_first_child(__LINE__,n)
2867 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2869 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2870 IHTMLDOMNode
*child
= NULL
;
2873 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2874 IHTMLDOMNode_Release(node
);
2875 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2880 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2881 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2883 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2884 VARIANT_BOOL b
= 0xdead;
2887 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2888 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2889 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2891 IHTMLDOMNode_Release(node
);
2894 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2895 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2897 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2898 IHTMLDOMNode
*parent
;
2901 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2902 IHTMLDOMNode_Release(node
);
2903 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2908 #define node_get_next(u) _node_get_next(__LINE__,u)
2909 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2911 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2915 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2916 IHTMLDOMNode_Release(node
);
2917 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2922 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2923 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2925 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2929 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2930 IHTMLDOMNode_Release(node
);
2931 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2936 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2937 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2939 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2940 IHTMLElement
*parent
;
2943 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2944 IHTMLElement_Release(elem
);
2945 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2950 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2951 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2953 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2954 VARIANT_BOOL disabled
= 100;
2958 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2959 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2960 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2961 IHTMLElement3_Release(elem3
);
2964 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2965 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2967 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2971 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2972 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2974 IHTMLElement3_Release(elem3
);
2975 _test_elem3_get_disabled(line
, unk
, b
);
2978 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2979 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2981 VARIANT_BOOL disabled
= 100;
2984 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2985 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2986 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2988 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2991 static void test_select_remove(IHTMLSelectElement
*select
)
2995 hres
= IHTMLSelectElement_remove(select
, 3);
2996 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
2997 test_select_length(select
, 2);
2999 hres
= IHTMLSelectElement_remove(select
, -1);
3000 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
3001 test_select_length(select
, 2);
3003 hres
= IHTMLSelectElement_remove(select
, 0);
3004 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
3005 test_select_length(select
, 1);
3008 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3009 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3011 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3015 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3016 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3017 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
3018 IHTMLDOMTextNode_Release(text
);
3021 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3022 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
3024 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3028 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3029 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3030 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
3031 IHTMLDOMTextNode_Release(text
);
3035 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3036 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
3038 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3039 BSTR str
= a2bstr(data
);
3042 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3043 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
3044 IHTMLDOMTextNode_Release(text
);
3048 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3049 static void _text_append_data(unsigned line
, IUnknown
*unk
, const char *data
)
3051 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3052 BSTR str
= a2bstr(data
);
3055 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3056 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08x\n", hres
);
3057 IHTMLDOMTextNode2_Release(text
);
3061 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3062 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3066 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3067 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3069 _test_select_get_disabled(line
, select
, b
);
3072 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3073 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const char *exdir
)
3075 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3079 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3080 IHTMLElement2_Release(elem
);
3081 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08x\n", hres
);
3083 ok_(__FILE__
, line
) (!strcmp_wa(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), exdir
);
3085 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3090 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3091 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const char *dira
)
3093 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3094 BSTR dir
= a2bstr(dira
);
3097 hres
= IHTMLElement2_put_dir(elem
, dir
);
3098 IHTMLElement2_Release(elem
);
3099 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08x\n", hres
);
3102 _test_elem_dir(line
, unk
, dira
);
3105 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3106 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3108 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3109 IHTMLTextContainer
*txtcont
;
3110 LONG l
= -1, l2
= -1;
3113 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3114 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
3115 IHTMLElement2_Release(elem
);
3117 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3118 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3120 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3121 IHTMLTextContainer_Release(txtcont
);
3122 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
3123 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
3128 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3129 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3131 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3132 IHTMLTextContainer
*txtcont
;
3133 LONG l
= -1, l2
= -1;
3136 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
3138 IHTMLElement2_Release(elem
);
3140 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3141 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3143 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3144 IHTMLTextContainer_Release(txtcont
);
3145 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
3146 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
3151 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3152 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3154 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3155 IHTMLTextContainer
*txtcont
;
3156 LONG l
= -1, l2
= -1;
3159 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3160 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3161 IHTMLElement2_Release(elem
);
3163 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3164 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3166 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3167 IHTMLTextContainer_Release(txtcont
);
3168 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
3169 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
3174 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3175 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3177 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3178 IHTMLTextContainer
*txtcont
;
3179 LONG l
= -1, l2
= -1;
3182 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3183 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
3185 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3186 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
3187 IHTMLElement2_Release(elem
);
3189 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3190 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
3192 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3193 IHTMLTextContainer_Release(txtcont
);
3194 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
3195 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
3198 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3199 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
3201 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3205 hres
= IHTMLImgElement_get_src(img
, &src
);
3206 IHTMLImgElement_Release(img
);
3207 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3208 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
3209 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3213 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3214 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
3216 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3221 hres
= IHTMLImgElement_put_src(img
, tmp
);
3222 IHTMLImgElement_Release(img
);
3224 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3227 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3228 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
3230 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3234 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3235 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3237 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3239 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3243 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3244 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
3246 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3251 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3252 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
3255 _test_img_alt(line
, unk
, alt
);
3258 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3259 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
3261 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3265 tmp
= a2bstr(align
);
3266 hres
= IHTMLImgElement_put_align(img
, tmp
);
3267 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3270 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3271 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
3272 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
3276 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3277 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
3279 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3283 hres
= IHTMLImgElement_get_name(img
, &sName
);
3284 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
3285 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
3286 IHTMLImgElement_Release(img
);
3287 SysFreeString(sName
);
3290 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3291 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3293 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3294 VARIANT_BOOL b
= 100;
3297 hres
= IHTMLImgElement_get_complete(img
, &b
);
3298 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
3299 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3300 IHTMLImgElement_Release(img
);
3303 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3304 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3306 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3307 VARIANT_BOOL b
= 100;
3310 hres
= IHTMLImgElement_put_isMap(img
, v
);
3311 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
3313 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3314 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
3315 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3317 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3318 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
3319 IHTMLImgElement_Release(img
);
3322 static void test_dynamic_properties(IHTMLElement
*elem
)
3324 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3325 IDispatchEx
*dispex
;
3326 BSTR name
, attr1
= SysAllocString(attr1W
);
3330 DISPID id
= DISPID_STARTENUM
;
3333 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3334 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3336 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3337 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
3338 ok(succ
, "removeAttribute set succ to FALSE\n");
3341 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3342 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
3346 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3347 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
3349 if(!strcmp_wa(name
, "attr1"))
3350 ok(0, "attr1 should be removed\n");
3351 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
3353 SysFreeString(name
);
3355 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3356 IDispatchEx_Release(dispex
);
3358 V_VT(&val
) = VT_BSTR
;
3359 V_BSTR(&val
) = attr1
;
3360 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3361 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3362 SysFreeString(attr1
);
3365 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3366 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
3371 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3372 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
3373 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
3377 static void test_attr_collection_disp(IDispatch
*disp
)
3379 IDispatchEx
*dispex
;
3380 IHTMLDOMAttribute
*attr
;
3381 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3388 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3389 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3392 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3393 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3394 SysFreeString(bstr
);
3397 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3398 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3399 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3400 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3403 bstr
= a2bstr("attr1");
3404 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3405 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3406 SysFreeString(bstr
);
3409 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3410 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3411 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3412 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3413 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3414 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3416 test_attr_node_name(attr
, "attr1");
3418 IHTMLDOMAttribute_Release(attr
);
3421 IDispatchEx_Release(dispex
);
3424 static void test_attr_collection(IHTMLElement
*elem
)
3426 static const WCHAR testW
[] = {'t','e','s','t',0};
3429 IDispatch
*disp
, *attr
;
3430 IHTMLDOMAttribute
*dom_attr
;
3431 IHTMLAttributeCollection
*attr_col
;
3432 BSTR name
= SysAllocString(testW
);
3434 LONG i
, len
, checked
;
3437 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3438 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3440 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3441 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3443 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3444 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3445 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3446 IDispatch_Release(attr
);
3447 IHTMLDOMNode_Release(node
);
3449 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3450 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3452 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3453 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3457 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3458 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3459 SysFreeString(name
);
3461 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3462 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3463 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3466 for(i
=0; i
<len
; i
++) {
3469 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3470 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3472 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3473 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3474 IDispatch_Release(attr
);
3476 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3477 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3479 if(!strcmp_wa(name
, "id")) {
3481 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3482 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3483 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3484 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3485 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3486 test_attr_value(dom_attr
, "attr");
3487 } else if(!strcmp_wa(name
, "attr1")) {
3489 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3490 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3491 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3492 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3493 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3494 test_attr_value(dom_attr
, "attr1");
3495 } else if(!strcmp_wa(name
, "attr2")) {
3497 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3498 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3499 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3500 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3501 test_attr_value(dom_attr
, "");
3502 } else if(!strcmp_wa(name
, "attr3")) {
3504 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3505 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3506 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3507 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3508 test_attr_value(dom_attr
, "attr3");
3509 } else if(!strcmp_wa(name
, "test")) {
3511 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3512 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3513 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3514 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3515 test_attr_value(dom_attr
, "1");
3518 IHTMLDOMAttribute_Release(dom_attr
);
3519 SysFreeString(name
);
3522 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3525 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3526 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3528 V_VT(&id
) = VT_BSTR
;
3529 V_BSTR(&id
) = a2bstr("nonexisting");
3530 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3531 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3534 test_attr_collection_disp(disp
);
3536 IDispatch_Release(disp
);
3537 IHTMLAttributeCollection_Release(attr_col
);
3540 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3541 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3543 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3544 BSTR id
= (void*)0xdeadbeef;
3547 hres
= IHTMLElement_get_id(elem
, &id
);
3548 IHTMLElement_Release(elem
);
3549 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3552 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3554 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3559 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3560 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3562 BSTR lang
= (void*)0xdeadbeef;
3565 hres
= IHTMLElement_get_language(elem
, &lang
);
3566 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3569 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3571 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3573 SysFreeString(lang
);
3576 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3577 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3579 BSTR str
= a2bstr(lang
);
3582 hres
= IHTMLElement_put_language(elem
, str
);
3583 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3586 _test_elem_language(line
, elem
, lang
);
3589 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3590 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3592 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3593 BSTR tmp
= a2bstr(new_id
);
3596 hres
= IHTMLElement_put_id(elem
, tmp
);
3597 IHTMLElement_Release(elem
);
3599 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3601 _test_elem_id(line
, unk
, new_id
);
3604 static void test_contenteditable(IUnknown
*unk
)
3606 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3608 BSTR str
, strDefault
;
3610 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3611 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3613 str
= a2bstr("true");
3614 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3615 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3617 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3618 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3619 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3621 /* Restore origin contentEditable */
3622 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3623 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3624 SysFreeString(strDefault
);
3626 IHTMLElement3_Release(elem3
);
3629 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3630 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3635 hres
= IHTMLInputElement_get_type(input
, &type
);
3636 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3637 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3638 SysFreeString(type
);
3641 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3642 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3644 BSTR name
= (BSTR
)0xdeadbeef;
3647 hres
= IHTMLInputElement_get_name(input
, &name
);
3648 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3650 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3652 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3653 SysFreeString(name
);
3656 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3657 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3659 BSTR tmp
= a2bstr(name
);
3662 hres
= IHTMLInputElement_put_name(input
, tmp
);
3663 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3666 _test_input_name(line
, input
, name
);
3669 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3670 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3672 VARIANT_BOOL disabled
= 100;
3675 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3676 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3677 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3679 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3682 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3683 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3687 hres
= IHTMLInputElement_put_disabled(input
, b
);
3688 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3690 _test_input_get_disabled(line
, input
, b
);
3693 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3694 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3696 VARIANT_BOOL checked
= 100;
3699 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3700 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3701 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3704 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3705 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3709 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3710 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3712 _test_input_get_defaultchecked(line
, input
, b
);
3715 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3716 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3718 VARIANT_BOOL checked
= 100;
3721 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3722 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3723 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3726 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3727 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3731 hres
= IHTMLInputElement_put_checked(input
, b
);
3732 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3734 _test_input_get_checked(line
, input
, b
);
3737 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3738 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3740 LONG maxlength
= 0xdeadbeef;
3743 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3744 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3745 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3748 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3749 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3753 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3754 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3756 _test_input_maxlength(line
, input
, l
);
3759 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3760 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3762 IHTMLInputElement
*input
;
3766 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3767 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3771 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3772 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3774 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3776 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3777 SysFreeString(bstr
);
3778 IHTMLInputElement_Release(input
);
3781 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3782 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3784 IHTMLInputElement
*input
;
3785 IHTMLFormElement
*form
;
3789 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3790 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3791 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3792 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3793 if(FAILED(hres
) || input
== NULL
)
3796 hres
= IHTMLInputElement_get_form(input
, &form
);
3797 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3798 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3799 if(FAILED(hres
) || form
== NULL
){
3800 IHTMLInputElement_Release(input
);
3804 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3805 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3806 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3807 if(FAILED(hres
) || elem
== NULL
){
3808 IHTMLInputElement_Release(input
);
3809 IHTMLFormElement_Release(form
);
3813 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3815 IHTMLInputElement_Release(input
);
3816 IHTMLFormElement_Release(form
);
3817 IHTMLElement_Release(elem
);
3820 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3821 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3823 IHTMLInputElement
*input
;
3827 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3828 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3833 hres
= IHTMLInputElement_put_value(input
, bstr
);
3834 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3835 SysFreeString(bstr
);
3836 IHTMLInputElement_Release(input
);
3838 _test_input_value(line
, unk
, val
);
3841 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3842 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3844 IHTMLInputElement
*input
;
3848 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3849 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3853 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3854 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3856 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3858 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3860 IHTMLInputElement_Release(input
);
3863 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3864 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3866 IHTMLInputElement
*input
;
3870 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3871 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3876 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3877 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3879 IHTMLInputElement_Release(input
);
3881 _test_input_defaultValue(line
, unk
, val
);
3884 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
3885 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
3890 hres
= IHTMLInputElement_get_src(input
, &src
);
3891 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3893 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3895 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
3899 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
3900 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
3906 hres
= IHTMLInputElement_put_src(input
, tmp
);
3908 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3910 _test_input_src(line
, input
, src
);
3913 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
3914 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
3918 hres
= IHTMLInputElement_put_size(input
, size
);
3919 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
3922 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
3923 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
3928 hres
= IHTMLInputElement_get_size(input
, &size
);
3929 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
3930 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
3932 hres
= IHTMLInputElement_get_size(input
, NULL
);
3933 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
3936 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
3937 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
3940 VARIANT_BOOL b
= 100;
3942 hres
= IHTMLInputElement_put_readOnly(input
, v
);
3943 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
3945 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
3946 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
3947 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
3950 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
3951 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
3953 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3954 BSTR
class = (void*)0xdeadbeef;
3957 hres
= IHTMLElement_get_className(elem
, &class);
3958 IHTMLElement_Release(elem
);
3959 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
3961 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
3963 ok_(__FILE__
,line
) (!class, "class != NULL\n");
3964 SysFreeString(class);
3967 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
3968 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
3970 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3974 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
3975 IHTMLElement2_Release(elem2
);
3976 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3977 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
3980 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
3981 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
3983 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3986 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
3987 IHTMLElement2_Release(elem2
);
3988 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3990 _test_elem_tabindex(line
, unk
, index
);
3993 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
3994 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
3996 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4000 hres
= IHTMLStyleElement_get_media(style
, &media
);
4001 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4003 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
4005 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4007 IHTMLStyleElement_Release(style
);
4008 SysFreeString(media
);
4011 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4012 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
4014 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4018 str
= a2bstr(media
);
4019 hres
= IHTMLStyleElement_put_media(style
, str
);
4020 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
4021 IHTMLStyleElement_Release(style
);
4024 _test_style_media(line
, unk
, media
);
4027 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4028 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
4030 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4034 hres
= IHTMLStyleElement_get_type(style
, &type
);
4035 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4037 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
4039 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4041 IHTMLStyleElement_Release(style
);
4042 SysFreeString(type
);
4045 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4046 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
4048 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4053 hres
= IHTMLStyleElement_put_type(style
, str
);
4054 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
4055 IHTMLStyleElement_Release(style
);
4058 _test_style_type(line
, unk
, type
);
4061 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4062 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4064 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4066 IHTMLFiltersCollection
*filters
;
4068 hres
= IHTMLElement_get_filters(elem
, &filters
);
4069 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4070 "get_filters failed: %08x\n", hres
);
4074 IDispatchEx
*dispex
;
4076 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4077 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
4078 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
4080 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4081 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4082 "Could not get IDispatchEx interface: %08x\n", hres
);
4083 if(SUCCEEDED(hres
)) {
4084 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
4085 IDispatchEx_Release(dispex
);
4088 IHTMLFiltersCollection_Release(filters
);
4091 IHTMLElement_Release(elem
);
4094 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4095 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
4097 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4101 tmp
= class ? a2bstr(class) : NULL
;
4102 hres
= IHTMLElement_put_className(elem
, tmp
);
4103 IHTMLElement_Release(elem
);
4104 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
4107 _test_elem_class(line
, unk
, class);
4110 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4111 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
4113 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4117 hres
= IHTMLElement_get_title(elem
, &title
);
4118 IHTMLElement_Release(elem
);
4119 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4121 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4123 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4125 SysFreeString(title
);
4128 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4129 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
4131 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4135 tmp
= a2bstr(title
);
4136 hres
= IHTMLElement_put_title(elem
, tmp
);
4137 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4139 IHTMLElement_Release(elem
);
4143 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4144 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
4146 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4150 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4151 IHTMLDOMNode_Release(node
);
4152 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4155 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4156 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4158 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4164 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4165 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
4167 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4171 V_VT(&var
) = VT_BSTR
;
4172 V_BSTR(&var
) = a2bstr(val
);
4174 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4175 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
4176 IHTMLDOMNode_Release(node
);
4180 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4181 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4183 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4187 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4188 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
4189 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4190 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
4192 IHTMLElement2_Release(elem
);
4195 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4196 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4198 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4202 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4203 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
4204 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
4206 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4207 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
4208 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
4210 IHTMLElement2_Release(elem
);
4213 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4214 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4216 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4217 LONG len
= 0xdeadbeef;
4220 hres
= IHTMLFormElement_get_length(form
, &len
);
4221 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
4222 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
4224 IHTMLFormElement_Release(form
);
4227 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4228 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
4230 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4231 BSTR action
= (void*)0xdeadbeef;
4234 hres
= IHTMLFormElement_get_action(form
, &action
);
4235 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
4237 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
4239 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4241 SysFreeString(action
);
4242 IHTMLFormElement_Release(form
);
4245 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4246 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
4248 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4249 BSTR tmp
= a2bstr(action
);
4252 hres
= IHTMLFormElement_put_action(form
, tmp
);
4253 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
4255 IHTMLFormElement_Release(form
);
4257 _test_form_action(line
, unk
, action
);
4260 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4261 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
4263 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4264 BSTR method
= (void*)0xdeadbeef;
4267 hres
= IHTMLFormElement_get_method(form
, &method
);
4268 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
4270 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
4272 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4274 SysFreeString(method
);
4275 IHTMLFormElement_Release(form
);
4278 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4279 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
4281 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4282 BSTR tmp
= a2bstr(method
);
4285 hres
= IHTMLFormElement_put_method(form
, tmp
);
4286 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
4288 IHTMLFormElement_Release(form
);
4290 if(exp_hres
== S_OK
)
4291 _test_form_method(line
, unk
, method
);
4294 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4295 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
4297 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4298 BSTR name
= (void*)0xdeadbeef;
4301 hres
= IHTMLFormElement_get_name(form
, &name
);
4302 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4304 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
4306 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4308 SysFreeString(name
);
4309 IHTMLFormElement_Release(form
);
4312 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4313 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
4315 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4316 BSTR tmp
= a2bstr(name
);
4319 hres
= IHTMLFormElement_put_name(form
, tmp
);
4320 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
4322 IHTMLFormElement_Release(form
);
4324 _test_form_name(line
, unk
, name
);
4327 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4328 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
4330 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4331 BSTR encoding
= (void*)0xdeadbeef;
4334 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4335 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
4337 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
4339 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4341 SysFreeString(encoding
);
4342 IHTMLFormElement_Release(form
);
4345 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4346 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
4348 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4349 BSTR tmp
= a2bstr(encoding
);
4352 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4353 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
4355 IHTMLFormElement_Release(form
);
4357 if(exp_hres
== S_OK
)
4358 _test_form_encoding(line
, unk
, encoding
);
4361 #define test_form_elements(a) _test_form_elements(__LINE__,a)
4362 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
4364 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4369 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4370 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
4371 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4372 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4374 IDispatch_Release(disp
);
4375 IHTMLFormElement_Release(form
);
4378 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4379 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4381 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4384 hres
= IHTMLFormElement_reset(form
);
4385 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
4387 IHTMLFormElement_Release(form
);
4390 static void test_form_target(IUnknown
*unk
)
4392 IHTMLFormElement
*form
= get_form_iface(unk
);
4395 static const char target
[] = "_blank";
4397 str
= a2bstr(target
);
4398 hres
= IHTMLFormElement_put_target(form
, str
);
4399 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
4402 hres
= IHTMLFormElement_get_target(form
, &str
);
4403 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4404 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4407 IHTMLFormElement_Release(form
);
4410 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4412 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4413 IHTMLFormElement
*form
;
4416 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4417 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
4419 hres
= IHTMLSelectElement_get_form(select
, &form
);
4420 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4421 ok(form
!= NULL
, "form == NULL\n");
4423 test_form_length((IUnknown
*)form
, 1);
4424 test_form_elements((IUnknown
*)form
);
4425 test_form_name((IUnknown
*)form
, "form_name");
4427 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4429 IHTMLSelectElement_Release(select
);
4430 IHTMLFormElement_Release(form
);
4433 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4435 IHTMLFormElement
*form
;
4438 form
= (IHTMLFormElement
*)0xdeadbeef;
4439 hres
= IHTMLSelectElement_get_form(select
, &form
);
4440 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
4441 ok(form
== NULL
, "got %p\n", form
);
4444 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4445 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4447 IHTMLMetaElement
*meta
;
4451 meta
= _get_metaelem_iface(line
, unk
);
4452 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4453 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4454 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4455 SysFreeString(name
);
4456 IHTMLMetaElement_Release(meta
);
4459 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4460 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4462 IHTMLMetaElement
*meta
;
4463 BSTR content
= NULL
;
4466 meta
= _get_metaelem_iface(line
, unk
);
4467 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4468 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4469 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4470 SysFreeString(content
);
4471 IHTMLMetaElement_Release(meta
);
4474 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4475 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4477 IHTMLMetaElement
*meta
;
4481 meta
= _get_metaelem_iface(line
, unk
);
4482 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4483 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4484 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4486 IHTMLMetaElement_Release(meta
);
4489 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4490 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4492 IHTMLMetaElement
*meta
;
4496 meta
= _get_metaelem_iface(line
, unk
);
4497 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4498 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4500 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4502 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4504 IHTMLMetaElement_Release(meta
);
4507 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4508 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4510 BSTR val
= a2bstr(vala
);
4511 IHTMLMetaElement
*meta
;
4514 meta
= _get_metaelem_iface(line
, unk
);
4515 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4516 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4518 IHTMLMetaElement_Release(meta
);
4520 _test_meta_charset(line
, unk
, vala
);
4523 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4524 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4526 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4530 str
= a2bstr(exval
);
4531 hres
= IHTMLLinkElement_put_media(link
, str
);
4532 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4535 hres
= IHTMLLinkElement_get_media(link
, &str
);
4536 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4537 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4539 IHTMLLinkElement_Release(link
);
4542 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4543 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4545 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4546 VARIANT_BOOL b
= 10;
4549 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4550 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4551 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4553 IHTMLLinkElement_Release(link
);
4556 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4557 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4559 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4562 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4563 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4564 IHTMLLinkElement_Release(link
);
4565 _test_link_disabled(line
, elem
, v
);
4568 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4569 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4571 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4575 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4576 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4578 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4580 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4582 IHTMLLinkElement_Release(link
);
4585 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4586 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4588 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4589 BSTR str
= a2bstr(v
);
4592 hres
= IHTMLLinkElement_put_rel(link
, str
);
4593 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4595 IHTMLLinkElement_Release(link
);
4596 _test_link_rel(line
, elem
, v
);
4599 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4600 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4602 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4606 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4607 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4609 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4611 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4613 IHTMLLinkElement_Release(link
);
4616 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4617 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4619 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4620 BSTR str
= a2bstr(v
);
4623 hres
= IHTMLLinkElement_put_rev(link
, str
);
4624 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4626 IHTMLLinkElement_Release(link
);
4627 _test_link_rev(line
, elem
, v
);
4630 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4631 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4633 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4637 hres
= IHTMLLinkElement_get_type(link
, &type
);
4638 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4640 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4642 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4644 IHTMLLinkElement_Release(link
);
4647 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4648 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4653 str
= (void*)0xdeadbeef;
4654 hres
= IHTMLScriptElement_get_text(script
, &str
);
4655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4656 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4660 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4661 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4663 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4664 BSTR str
= a2bstr(v
);
4667 hres
= IHTMLLinkElement_put_type(link
, str
);
4668 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4670 IHTMLLinkElement_Release(link
);
4671 _test_link_type(line
, elem
, v
);
4674 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4675 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4677 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4681 hres
= IHTMLLinkElement_get_href(link
, &href
);
4682 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4684 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4686 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4688 IHTMLLinkElement_Release(link
);
4691 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4692 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4694 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4695 BSTR str
= a2bstr(v
);
4698 hres
= IHTMLLinkElement_put_href(link
, str
);
4699 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4701 IHTMLLinkElement_Release(link
);
4702 _test_link_href(line
, elem
, v
);
4705 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4706 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4708 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4709 IHTMLDocument2
*doc
;
4714 hres
= IHTMLElement_get_document(elem
, &disp
);
4715 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4716 ok(disp
!= NULL
, "disp == NULL\n");
4718 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4719 IDispatch_Release(disp
);
4720 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4725 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4726 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4728 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4729 BSTR str
= a2bstr(attr_name
);
4730 IHTMLDOMAttribute
*attr
;
4733 attr
= (void*)0xdeadbeef;
4734 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4735 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4737 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4739 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4741 IHTMLElement4_Release(elem
);
4746 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4747 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4751 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4752 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4753 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4756 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4757 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4761 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4762 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4765 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
4766 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const char *value
)
4768 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
4769 BSTR str
= a2bstr(value
);
4772 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
4773 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4775 IHTMLDOMAttribute2_Release(attr2
);
4779 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4780 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4782 IHTMLDocument2
*doc
;
4786 hres
= IHTMLWindow2_get_document(window
, &doc
);
4787 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4788 ok(doc
!= NULL
, "disp == NULL\n");
4793 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4794 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4799 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4800 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4801 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4806 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4807 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4809 IHTMLElement
*elem
= NULL
;
4814 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4815 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4816 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4822 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4823 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4825 IHTMLDocument3
*doc3
;
4826 IHTMLDOMNode
*node
= NULL
;
4830 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4831 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4834 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4835 IHTMLDocument3_Release(doc3
);
4837 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4838 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4843 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4844 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4846 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4847 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4848 IHTMLDOMNode
*new_child
= NULL
;
4851 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4852 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4853 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4854 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4856 IHTMLDOMNode_Release(node
);
4857 IHTMLDOMNode_Release(child
);
4862 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4863 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4865 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4866 IHTMLDOMNode
*new_child
= NULL
;
4869 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4870 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4871 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4872 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4874 IHTMLDOMNode_Release(node
);
4879 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4880 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4882 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4883 IHTMLDOMNode
*new_node
= NULL
;
4886 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
4887 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
4888 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
4889 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
4891 IHTMLDOMNode_Release(node
);
4892 IHTMLDOMNode_Release(new_node
);
4895 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
4896 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
4901 hres
= IHTMLDocument2_get_title(doc
, &title
);
4902 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4903 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4904 SysFreeString(title
);
4907 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
4908 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
4913 tmp
= a2bstr(title
);
4914 hres
= IHTMLDocument2_put_title(doc
, tmp
);
4915 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4919 static void test_elem_bounding_client_rect(IUnknown
*unk
)
4921 IHTMLRect
*rect
, *rect2
;
4922 IHTMLElement2
*elem2
;
4926 elem2
= get_elem2_iface(unk
);
4927 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
4928 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4929 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
4930 IHTMLElement2_Release(elem2
);
4931 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4932 ok(rect
!= NULL
, "rect == NULL\n");
4933 ok(rect
!= rect2
, "rect == rect2\n");
4934 IHTMLRect_Release(rect2
);
4936 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
4939 hres
= IHTMLRect_get_top(rect
, &l
);
4940 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4941 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4944 hres
= IHTMLRect_get_left(rect
, &l
);
4945 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4946 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4949 hres
= IHTMLRect_get_bottom(rect
, &l
);
4950 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4951 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4954 hres
= IHTMLRect_get_right(rect
, &l
);
4955 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4956 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4958 IHTMLRect_Release(rect
);
4961 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
4962 const elem_type_t
*elem_types
, LONG len
)
4965 VARIANT name
, index
;
4969 V_VT(&index
) = VT_EMPTY
;
4970 V_VT(&name
) = VT_BSTR
;
4971 V_BSTR(&name
) = a2bstr(n
);
4973 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4974 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4976 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
4977 IDispatch_Release(disp
);
4979 V_VT(&index
) = VT_I4
;
4981 for(i
=0; i
<len
; i
++) {
4983 disp
= (void*)0xdeadbeef;
4984 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4985 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4986 ok(disp
!= NULL
, "disp == NULL\n");
4987 if(FAILED(hres
) || !disp
)
4990 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
4992 IDispatch_Release(disp
);
4996 disp
= (void*)0xdeadbeef;
4997 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4998 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4999 ok(disp
== NULL
, "disp != NULL\n");
5002 disp
= (void*)0xdeadbeef;
5003 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5004 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5005 ok(disp
== NULL
, "disp != NULL\n");
5007 SysFreeString(V_BSTR(&name
));
5010 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
5012 IHTMLElementCollection
*col
;
5014 IDispatch
*disp
= (void*)0xdeadbeef;
5015 VARIANT name
, index
;
5018 hres
= IHTMLDocument2_get_all(doc
, &col
);
5019 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
5020 ok(col
!= NULL
, "col == NULL\n");
5021 if(FAILED(hres
) || !col
)
5024 V_VT(&index
) = VT_EMPTY
;
5025 V_VT(&name
) = VT_BSTR
;
5026 V_BSTR(&name
) = a2bstr(id
);
5028 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5029 IHTMLElementCollection_Release(col
);
5030 SysFreeString(V_BSTR(&name
));
5031 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5032 if(!expect_success
) {
5033 ok(disp
== NULL
, "disp != NULL\n");
5037 ok(disp
!= NULL
, "disp == NULL\n");
5041 elem
= get_elem_iface((IUnknown
*)disp
);
5042 IDispatch_Release(disp
);
5047 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
5049 IHTMLDocument3
*doc3
;
5054 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5055 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
5058 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5060 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
5062 IHTMLDocument3_Release(doc3
);
5067 static void test_select_elem(IHTMLSelectElement
*select
)
5069 IDispatch
*disp
, *disp2
;
5070 VARIANT name
, index
;
5073 test_select_type(select
, "select-one");
5074 test_select_length(select
, 2);
5075 test_select_selidx(select
, 0);
5076 test_select_put_selidx(select
, 1);
5078 test_select_set_value(select
, "val1");
5079 test_select_value(select
, "val1");
5081 test_select_size(select
, 0);
5082 test_select_set_size(select
, 1, S_OK
);
5083 test_select_size(select
, 1);
5085 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5086 test_select_size(select
, 1);
5087 test_select_set_size(select
, 3, S_OK
);
5088 test_select_size(select
, 3);
5090 test_select_name(select
, NULL
);
5091 test_select_set_name(select
, "select-name");
5092 test_select_name(select
, "select-name");
5093 test_select_form_notfound(select
);
5095 test_select_get_disabled(select
, VARIANT_FALSE
);
5096 test_select_set_disabled(select
, VARIANT_TRUE
);
5097 test_select_set_disabled(select
, VARIANT_FALSE
);
5100 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5101 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
5102 ok(disp
!= NULL
, "options == NULL\n");
5103 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5104 IDispatch_Release(disp
);
5106 V_VT(&index
) = VT_EMPTY
;
5107 V_VT(&name
) = VT_I4
;
5109 disp
= (void*)0xdeadbeef;
5110 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5111 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5112 ok(!disp
, "disp = %p\n", disp
);
5115 disp
= (void*)0xdeadbeef;
5116 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5117 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5118 ok(!disp
, "disp = %p\n", disp
);
5121 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5122 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
5125 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5126 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5127 ok(disp
!= NULL
, "disp = NULL\n");
5128 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
5130 V_VT(&index
) = VT_I4
;
5133 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5134 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5135 ok(disp2
!= NULL
, "disp = NULL\n");
5136 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5137 IDispatch_Release(disp2
);
5138 IDispatch_Release(disp
);
5140 test_select_multiple(select
, VARIANT_FALSE
);
5141 test_select_set_multiple(select
, VARIANT_TRUE
);
5142 test_select_remove(select
);
5145 static void test_form_item(IHTMLElement
*elem
)
5147 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5148 IDispatch
*disp
, *disp2
;
5149 VARIANT name
, index
;
5152 V_VT(&index
) = VT_EMPTY
;
5153 V_VT(&name
) = VT_I4
;
5155 disp
= (void*)0xdeadbeef;
5156 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5157 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5158 ok(!disp
, "disp = %p\n", disp
);
5161 disp
= (void*)0xdeadbeef;
5162 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5163 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5164 ok(!disp
, "disp = %p\n", disp
);
5167 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5168 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
5171 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5172 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5173 ok(disp
!= NULL
, "disp = NULL\n");
5174 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
5176 V_VT(&index
) = VT_I4
;
5179 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5180 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
5181 ok(disp2
!= NULL
, "disp = NULL\n");
5182 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5183 IDispatch_Release(disp2
);
5184 IDispatch_Release(disp
);
5187 static void test_create_option_elem(IHTMLDocument2
*doc
)
5189 IHTMLOptionElement
*option
;
5191 option
= create_option_elem(doc
, "test text", "test value");
5193 test_option_put_text(option
, "new text");
5194 test_option_put_value(option
, "new value");
5195 test_option_get_index(option
, 0);
5196 test_option_defaultSelected_property(option
);
5197 test_option_put_selected(option
, VARIANT_TRUE
);
5198 test_option_put_selected(option
, VARIANT_FALSE
);
5200 IHTMLOptionElement_Release(option
);
5203 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5205 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5206 IHTMLFormElement
*form
;
5209 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5210 ok(hres
== E_POINTER
, "got %08x\n, expected E_POINTER\n", hres
);
5212 hres
= IHTMLOptionElement_get_form(option
, &form
);
5213 ok(hres
== S_OK
, "get_form failed: %08x\n", hres
);
5214 ok(form
!= NULL
, "form == NULL\n");
5216 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5218 IHTMLOptionElement_Release(option
);
5219 IHTMLFormElement_Release(form
);
5222 static void test_create_img_elem(IHTMLDocument2
*doc
)
5224 IHTMLImgElement
*img
;
5226 img
= create_img_elem(doc
, 10, 15);
5229 test_img_put_width(img
, 5);
5230 test_img_put_height(img
, 20);
5232 IHTMLImgElement_Release(img
);
5236 img
= create_img_elem(doc
, -1, -1);
5239 test_img_put_width(img
, 5);
5240 test_img_put_height(img
, 20);
5242 IHTMLImgElement_Release(img
);
5246 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5247 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
5249 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5250 IHTMLElement
*ret_elem
= NULL
;
5251 BSTR str
= a2bstr(where
);
5254 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5255 IHTMLElement2_Release(elem2
);
5257 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
5258 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5259 IHTMLElement_Release(ret_elem
);
5262 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5264 IHTMLElement
*elem
, *elem2
;
5266 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5267 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5269 elem
= test_create_elem(doc
, "BR");
5270 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5271 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5272 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
5273 IHTMLElement_Release(elem
);
5275 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5277 elem
= test_create_elem(doc
, "BR");
5278 insert_adjacent_elem(parent
, "beforeend", elem
);
5280 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5282 elem2
= test_create_elem(doc
, "DIV");
5283 insert_adjacent_elem(elem
, "beforebegin", elem2
);
5284 IHTMLElement_Release(elem2
);
5285 IHTMLElement_Release(elem
);
5287 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5290 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5292 IHTMLBodyElement
*body
;
5293 IHTMLTxtRange
*range
;
5297 elem
= doc_get_body(doc
);
5298 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5299 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
5300 IHTMLElement_Release(elem
);
5302 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5303 IHTMLBodyElement_Release(body
);
5304 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
5309 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5310 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5315 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5316 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
5321 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5322 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const char *how
,
5323 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5325 BSTR str
= a2bstr(how
);
5328 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5329 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08x, expected %08x\n", hres
, exhres
);
5333 static void test_txtrange(IHTMLDocument2
*doc
)
5335 IHTMLTxtRange
*body_range
, *range
, *range2
;
5336 IHTMLSelectionObject
*selection
;
5337 IDispatch
*disp_range
;
5341 body_range
= test_create_body_range(doc
);
5343 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, "[object]");
5345 test_range_text(body_range
, "test abc 123\r\nit's text");
5347 range
= range_duplicate(body_range
);
5348 range2
= range_duplicate(body_range
);
5350 test_range_isequal(range
, range2
, VARIANT_TRUE
);
5352 test_range_text(range
, "test abc 123\r\nit's text");
5353 test_range_text(body_range
, "test abc 123\r\nit's text");
5355 test_range_collapse(range
, TRUE
);
5356 test_range_isequal(range
, range2
, VARIANT_FALSE
);
5357 test_range_inrange(range
, range2
, VARIANT_FALSE
);
5358 test_range_inrange(range2
, range
, VARIANT_TRUE
);
5359 IHTMLTxtRange_Release(range2
);
5361 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5362 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
5363 test_range_move(range
, characterW
, 2, 2);
5364 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5366 test_range_collapse(range
, FALSE
);
5367 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
5369 test_range_collapse(range
, FALSE
);
5370 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5371 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
5372 test_range_move(range
, characterW
, 2, 2);
5373 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
5374 test_range_moveend(range
, characterW
, -5, -5);
5375 test_range_text(range
, NULL
);
5376 test_range_moveend(range
, characterW
, 3, 3);
5377 test_range_text(range
, "c 1");
5378 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
5379 test_range_collapse(range
, TRUE
);
5380 test_range_move(range
, characterW
, 4, 4);
5381 test_range_moveend(range
, characterW
, 1, 1);
5382 test_range_text(range
, " ");
5383 test_range_move(range
, wordW
, 1, 1);
5384 test_range_moveend(range
, characterW
, 2, 2);
5385 test_range_text(range
, "ab");
5387 IHTMLTxtRange_Release(range
);
5389 range
= range_duplicate(body_range
);
5391 test_range_text(range
, "test abc 123\r\nit's text");
5392 test_range_move(range
, characterW
, 3, 3);
5393 test_range_moveend(range
, characterW
, 1, 1);
5394 test_range_text(range
, "t");
5395 test_range_moveend(range
, characterW
, 3, 3);
5396 test_range_text(range
, "t ab");
5397 test_range_moveend(range
, characterW
, -2, -2);
5398 test_range_text(range
, "t ");
5399 test_range_move(range
, characterW
, 6, 6);
5400 test_range_moveend(range
, characterW
, 3, 3);
5401 test_range_text(range
, "123");
5402 test_range_moveend(range
, characterW
, 2, 2);
5403 test_range_text(range
, "123\r\ni");
5405 IHTMLTxtRange_Release(range
);
5407 range
= range_duplicate(body_range
);
5409 test_range_move(range
, wordW
, 1, 1);
5410 test_range_moveend(range
, characterW
, 2, 2);
5411 test_range_text(range
, "ab");
5413 test_range_move(range
, characterW
, -2, -2);
5414 test_range_moveend(range
, characterW
, 2, 2);
5415 test_range_text(range
, "t ");
5417 test_range_move(range
, wordW
, 3, 3);
5418 test_range_move(range
, wordW
, -2, -2);
5419 test_range_moveend(range
, characterW
, 2, 2);
5420 test_range_text(range
, "ab");
5422 test_range_move(range
, characterW
, -6, -5);
5423 test_range_moveend(range
, characterW
, -1, 0);
5424 test_range_moveend(range
, characterW
, -6, 0);
5425 test_range_move(range
, characterW
, 2, 2);
5426 test_range_moveend(range
, characterW
, 2, 2);
5427 test_range_text(range
, "st");
5428 test_range_moveend(range
, characterW
, -6, -4);
5429 test_range_moveend(range
, characterW
, 2, 2);
5431 IHTMLTxtRange_Release(range
);
5433 range
= range_duplicate(body_range
);
5435 test_range_move(range
, wordW
, 2, 2);
5436 test_range_moveend(range
, characterW
, 2, 2);
5437 test_range_text(range
, "12");
5439 test_range_move(range
, characterW
, 15, 14);
5440 test_range_move(range
, characterW
, -2, -2);
5441 test_range_moveend(range
, characterW
, 3, 2);
5442 test_range_text(range
, "t");
5443 test_range_moveend(range
, characterW
, -1, -1);
5444 test_range_text(range
, "t");
5445 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
5446 test_range_move(range
, characterW
, -2, -2);
5447 test_range_moveend(range
, characterW
, 2, 2);
5448 test_range_text(range
, "s ");
5449 test_range_move(range
, characterW
, 100, 7);
5450 test_range_move(range
, wordW
, 1, 0);
5451 test_range_move(range
, characterW
, -2, -2);
5452 test_range_moveend(range
, characterW
, 3, 2);
5453 test_range_text(range
, "t");
5455 IHTMLTxtRange_Release(range
);
5457 range
= range_duplicate(body_range
);
5459 test_range_collapse(range
, TRUE
);
5460 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
5461 test_range_put_text(range
, "word");
5462 test_range_text(body_range
, "wordabc 123\r\nit's text");
5463 test_range_text(range
, NULL
);
5464 test_range_moveend(range
, characterW
, 3, 3);
5465 test_range_text(range
, "abc");
5466 test_range_movestart(range
, characterW
, -2, -2);
5467 test_range_text(range
, "rdabc");
5468 test_range_movestart(range
, characterW
, 3, 3);
5469 test_range_text(range
, "bc");
5470 test_range_movestart(range
, characterW
, 4, 4);
5471 test_range_text(range
, NULL
);
5472 test_range_movestart(range
, characterW
, -3, -3);
5473 test_range_text(range
, "c 1");
5474 test_range_movestart(range
, characterW
, -7, -6);
5475 test_range_text(range
, "wordabc 1");
5476 test_range_movestart(range
, characterW
, 100, 22);
5477 test_range_text(range
, NULL
);
5479 IHTMLTxtRange_Release(range
);
5481 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5482 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
5484 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, "[object]");
5485 test_ifaces((IUnknown
*)selection
, selection_iids
);
5487 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
5488 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
5489 IHTMLSelectionObject_Release(selection
);
5491 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
5492 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
5493 IDispatch_Release(disp_range
);
5495 test_range_text(range
, NULL
);
5496 test_range_moveend(range
, characterW
, 3, 3);
5497 test_range_text(range
, "wor");
5498 test_range_parent(range
, ET_BODY
);
5499 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5500 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
5501 test_range_move(range
, characterW
, 3, 3);
5502 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
5503 test_range_moveend(range
, characterW
, -4, -4);
5504 test_range_put_text(range
, "abc def ");
5505 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
5506 test_range_move(range
, wordW
, 1, 1);
5507 test_range_movestart(range
, characterW
, -1, -1);
5508 test_range_text(range
, " ");
5509 test_range_move(range
, wordW
, 1, 1);
5510 test_range_moveend(range
, characterW
, 3, 3);
5511 test_range_text(range
, "def");
5512 test_range_put_text(range
, "xyz");
5513 test_range_moveend(range
, characterW
, 1, 1);
5514 test_range_move(range
, wordW
, 1, 1);
5515 test_range_moveend(range
, characterW
, 2, 2);
5516 test_range_text(range
, "ab");
5518 body
= doc_get_body(doc
);
5520 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5521 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5523 test_range_text(range
, "abc xyz abc 123\r\nit's text");
5524 test_range_parent(range
, ET_BODY
);
5526 test_range_move(range
, wordW
, 1, 1);
5527 test_range_moveend(range
, characterW
, 12, 12);
5528 test_range_text(range
, "xyz abc 123");
5530 test_range_collapse(range
, VARIANT_TRUE
);
5531 test_range_paste_html(range
, "<br>paste<br>");
5532 test_range_text(range
, NULL
);
5534 test_range_moveend(range
, characterW
, 3, 3);
5535 test_range_text(range
, "xyz");
5537 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
5538 ok(hres
== S_OK
, "moveToElementText failed: %08x\n", hres
);
5540 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5542 test_range_move(range
, wordW
, 2, 2);
5543 test_range_collapse(range
, VARIANT_TRUE
);
5544 test_range_moveend(range
, characterW
, 5, 5);
5545 test_range_text(range
, "paste");
5547 range2
= range_duplicate(range
);
5549 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5550 test_range_text(range
, "abc \r\npaste");
5552 test_range_set_end_point(range
, "endtoend", body_range
, S_OK
);
5553 test_range_text(range
, "abc \r\npaste\r\nxyz abc 123\r\nit's text");
5555 test_range_set_end_point(range
, "starttoend", range2
, S_OK
);
5556 test_range_text(range
, "\r\nxyz abc 123\r\nit's text");
5558 test_range_set_end_point(range
, "starttostart", body_range
, S_OK
);
5559 test_range_set_end_point(range
, "endtostart", range2
, S_OK
);
5560 test_range_text(range
, "abc ");
5562 test_range_set_end_point(range
, "starttoend", body_range
, S_OK
);
5563 test_range_text(range
, "paste\r\nxyz abc 123\r\nit's text");
5565 test_range_set_end_point(range
, "EndToStart", body_range
, S_OK
);
5566 test_range_text(range
, "abc ");
5568 test_range_set_end_point(range
, "xxx", body_range
, E_INVALIDARG
);
5570 IHTMLTxtRange_Release(range
);
5571 IHTMLTxtRange_Release(range2
);
5572 IHTMLTxtRange_Release(body_range
);
5573 IHTMLElement_Release(body
);
5577 static void test_txtrange2(IHTMLDocument2
*doc
)
5579 IHTMLTxtRange
*range
;
5581 range
= test_create_body_range(doc
);
5583 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5584 test_range_move(range
, characterW
, 5, 5);
5585 test_range_moveend(range
, characterW
, 1, 1);
5586 test_range_text(range
, "2");
5587 test_range_move(range
, characterW
, -3, -3);
5588 test_range_moveend(range
, characterW
, 3, 3);
5589 test_range_text(range
, "c\r\n\r\n1");
5590 test_range_collapse(range
, VARIANT_FALSE
);
5591 test_range_moveend(range
, characterW
, 4, 4);
5592 test_range_text(range
, "23");
5593 test_range_moveend(range
, characterW
, 1, 1);
5594 test_range_text(range
, "23\r\n\r\n\r\nd");
5595 test_range_moveend(range
, characterW
, -1, -1);
5596 test_range_text(range
, "23");
5597 test_range_moveend(range
, characterW
, -1, -1);
5598 test_range_text(range
, "23");
5599 test_range_moveend(range
, characterW
, -2, -2);
5600 test_range_text(range
, "2");
5602 IHTMLTxtRange_Release(range
);
5605 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5606 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5608 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5612 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5613 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5614 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5616 IHTMLDocument5_Release(doc
);
5619 static void test_location(IHTMLDocument2
*doc
)
5621 IHTMLLocation
*location
, *location2
;
5622 IHTMLWindow2
*window
;
5627 hres
= IHTMLDocument2_get_location(doc
, &location
);
5628 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5630 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5631 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5633 ok(location
== location2
, "location != location2\n");
5634 IHTMLLocation_Release(location2
);
5636 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5637 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5639 hres
= IHTMLWindow2_get_location(window
, &location2
);
5640 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5641 ok(location
== location2
, "location != location2\n");
5642 IHTMLLocation_Release(location2
);
5644 test_ifaces((IUnknown
*)location
, location_iids
);
5645 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5647 hres
= IHTMLLocation_get_pathname(location
, &str
);
5648 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5649 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5652 hres
= IHTMLLocation_get_href(location
, NULL
);
5653 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5655 hres
= IHTMLLocation_get_href(location
, &str
);
5656 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5657 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5660 ref
= IHTMLLocation_Release(location
);
5661 ok(!ref
, "location chould be destroyed here\n");
5664 static void test_plugins_col(IHTMLDocument2
*doc
)
5666 IHTMLPluginsCollection
*col
, *col2
;
5667 IHTMLWindow2
*window
;
5673 window
= get_doc_window(doc
);
5674 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5675 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5676 IHTMLWindow2_Release(window
);
5678 hres
= IOmNavigator_get_plugins(nav
, &col
);
5679 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5681 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5682 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5683 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5684 IHTMLPluginsCollection_Release(col2
);
5686 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5689 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5690 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5691 ok(!len
, "length = %d\n", len
);
5693 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
5694 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5696 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
5697 ok(hres
== S_OK
, "refresh failed: %08x\n", hres
);
5699 ref
= IHTMLPluginsCollection_Release(col
);
5700 ok(!ref
, "ref=%d\n", ref
);
5702 IOmNavigator_Release(nav
);
5705 static void test_mime_types_col(IOmNavigator
*nav
)
5707 IHTMLMimeTypesCollection
*col
, *col2
;
5712 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5713 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5715 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5716 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5717 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5718 IHTMLMimeTypesCollection_Release(col2
);
5720 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5722 length
= 0xdeadbeef;
5723 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5724 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5725 ok(!length
, "length = %d\n", length
);
5727 ref
= IHTMLMimeTypesCollection_Release(col
);
5728 ok(!ref
, "ref=%d\n", ref
);
5731 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5732 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5734 BSTR str
= (void*)0xdeadbeef;
5735 IHTMLFrameBase
*fbase
;
5738 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5739 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5741 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5742 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5744 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5746 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5749 IHTMLFrameBase_Release(fbase
);
5752 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5753 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5755 IHTMLFrameBase
*fbase
;
5759 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5760 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5762 str
= name
? a2bstr(name
) : NULL
;
5763 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5764 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5767 _test_framebase_name(line
, elem
, name
);
5768 IHTMLFrameBase_Release(fbase
);
5771 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
5772 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const char *src
)
5774 BSTR str
= (void*)0xdeadbeef;
5775 IHTMLFrameBase
*fbase
;
5778 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5779 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5781 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
5782 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08x\n", hres
);
5784 ok_(__FILE__
,line
)(!strcmp_wa(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), src
);
5786 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
5789 IHTMLFrameBase_Release(fbase
);
5792 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5793 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5798 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5799 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5800 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5802 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5804 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5808 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5809 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5815 V_BSTR(&v
) = a2bstr(val
);
5816 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5817 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5821 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5822 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5827 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5828 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5829 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5831 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5833 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5837 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5838 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5844 V_BSTR(&v
) = a2bstr(val
);
5845 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5846 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5850 static void test_framebase(IUnknown
*unk
)
5852 IHTMLFrameBase
*fbase
;
5856 /* get/put scrolling */
5857 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5858 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5860 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5861 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5862 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5866 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5867 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5870 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5871 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5872 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5875 str
= a2bstr("junk");
5876 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5877 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5878 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5881 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5882 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5883 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5886 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5887 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5888 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
5891 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
5892 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
5895 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5896 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5897 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
5899 test_framebase_marginheight(fbase
, NULL
);
5900 set_framebase_marginheight(fbase
, "1px");
5901 test_framebase_marginheight(fbase
, "1");
5903 test_framebase_marginwidth(fbase
, NULL
);
5904 set_framebase_marginwidth(fbase
, "2px");
5905 test_framebase_marginwidth(fbase
, "2");
5907 IHTMLFrameBase_Release(fbase
);
5910 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
5911 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
5916 if(pLCIDToLocaleName
) {
5917 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
5918 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
5919 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
5921 win_skip("LCIDToLocaleName not available, unable to test language string\n");
5922 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
5926 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
5927 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
5929 IHTMLElementCollection
*col
;
5933 hres
= IHTMLTable_get_rows(table
, &col
);
5934 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5935 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
5936 if (hres
!= S_OK
|| col
== NULL
)
5938 hres
= IHTMLElementCollection_get_length(col
, &len
);
5939 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5940 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
5942 IHTMLElementCollection_Release(col
);
5945 static void test_navigator(IHTMLDocument2
*doc
)
5947 IHTMLWindow2
*window
;
5948 IOmNavigator
*navigator
, *navigator2
;
5956 static const WCHAR v40
[] = {'4','.','0'};
5958 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5959 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
5961 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
5962 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5963 ok(navigator
!= NULL
, "navigator == NULL\n");
5964 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
5966 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
5967 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5968 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
5969 IOmNavigator_Release(navigator2
);
5971 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
5972 ok(hres
== S_OK
, "get_clientInformation failed: %08x\n", hres
);
5973 todo_wine
ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
5974 IOmNavigator_Release(navigator2
);
5976 IHTMLWindow2_Release(window
);
5978 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
5979 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
5980 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5981 SysFreeString(bstr
);
5984 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
5985 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
5986 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5987 SysFreeString(bstr
);
5990 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
5991 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
5992 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
5993 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
5994 SysFreeString(bstr
);
5997 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
5998 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
5999 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6000 SysFreeString(bstr
);
6003 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6004 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6005 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6006 SysFreeString(bstr
);
6009 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6010 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
6011 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6012 SysFreeString(bstr
);
6014 if (pGetUserDefaultUILanguage
)
6017 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6018 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
6019 test_language_string(bstr
, pGetUserDefaultUILanguage());
6020 SysFreeString(bstr
);
6023 win_skip("GetUserDefaultUILanguage not available\n");
6026 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6027 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
6028 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6029 SysFreeString(bstr
);
6031 hres
= IOmNavigator_toString(navigator
, NULL
);
6032 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6035 hres
= IOmNavigator_toString(navigator
, &bstr
);
6036 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6037 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6038 SysFreeString(bstr
);
6041 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6042 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
6043 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6046 hres
= ObtainUserAgentString(0, buf
, &size
);
6047 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
6050 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6051 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
6052 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
6053 SysFreeString(bstr
);
6055 if(!strncmp(buf
, "Mozilla/", 8)) {
6057 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6058 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
6059 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
6060 SysFreeString(bstr
);
6062 skip("nonstandard user agent\n");
6066 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6067 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
6068 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6069 SysFreeString(bstr
);
6071 test_mime_types_col(navigator
);
6073 ref
= IOmNavigator_Release(navigator
);
6074 ok(!ref
, "navigator should be destroyed here\n");
6077 static void test_screen(IHTMLWindow2
*window
)
6079 IHTMLScreen
*screen
, *screen2
;
6080 IDispatchEx
*dispex
;
6087 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6088 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6089 ok(screen
!= NULL
, "screen == NULL\n");
6092 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6093 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
6094 ok(screen2
!= NULL
, "screen == NULL\n");
6095 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6096 IHTMLScreen_Release(screen2
);
6098 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6099 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
6100 if(SUCCEEDED(hres
)) {
6101 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
6102 IDispatchEx_Release(dispex
);
6105 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6107 exl
= GetDeviceCaps(hdc
, HORZRES
);
6109 hres
= IHTMLScreen_get_width(screen
, &l
);
6110 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6111 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
6113 exl
= GetDeviceCaps(hdc
, VERTRES
);
6115 hres
= IHTMLScreen_get_height(screen
, &l
);
6116 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6117 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6119 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6121 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6122 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6123 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
6127 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6130 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6131 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
6132 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
6135 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6136 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
6137 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
6139 IHTMLScreen_Release(screen
);
6142 static void test_default_selection(IHTMLDocument2
*doc
)
6144 IHTMLSelectionObject
*selection
;
6145 IHTMLTxtRange
*range
;
6150 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6151 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
6153 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
6154 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
6155 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
6158 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6159 IHTMLSelectionObject_Release(selection
);
6160 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
6162 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6163 IDispatch_Release(disp
);
6164 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
6166 test_range_text(range
, NULL
);
6167 IHTMLTxtRange_Release(range
);
6170 static void test_doc_elem(IHTMLDocument2
*doc
)
6172 IHTMLDocument2
*doc_node
, *owner_doc
;
6174 IHTMLDocument3
*doc3
;
6178 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6179 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
6181 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6182 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6183 ok(!strcmp_wa(bstr
, "[object]"),
6184 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6185 SysFreeString(bstr
);
6187 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
6188 IHTMLDocument3_Release(doc3
);
6189 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
6191 test_node_name((IUnknown
*)elem
, "HTML");
6192 test_elem_tag((IUnknown
*)elem
, "HTML");
6194 doc_node
= get_doc_node(doc
);
6195 owner_doc
= get_owner_doc((IUnknown
*)elem
);
6196 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
6197 IHTMLDocument2_Release(owner_doc
);
6199 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
6200 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6201 IHTMLDocument2_Release(doc_node
);
6203 test_elem_client_rect((IUnknown
*)elem
);
6205 IHTMLElement_Release(elem
);
6208 static void test_default_body(IHTMLBodyElement
*body
)
6215 bstr
= (void*)0xdeadbeef;
6216 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
6217 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
6218 ok(bstr
== NULL
, "bstr != NULL\n");
6220 l
= elem_get_scroll_height((IUnknown
*)body
);
6221 ok(l
!= -1, "scrollHeight == -1\n");
6222 l
= elem_get_scroll_width((IUnknown
*)body
);
6223 ok(l
!= -1, "scrollWidth == -1\n");
6224 l
= elem_get_scroll_top((IUnknown
*)body
);
6225 ok(!l
, "scrollTop = %d\n", l
);
6226 elem_get_scroll_left((IUnknown
*)body
);
6228 test_elem_dir((IUnknown
*)body
, NULL
);
6229 set_elem_dir((IUnknown
*)body
, "ltr");
6231 /* get_text tests */
6232 hres
= IHTMLBodyElement_get_text(body
, &v
);
6233 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6234 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6235 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
6237 /* get_text - Invalid Text */
6239 V_BSTR(&v
) = a2bstr("Invalid");
6240 hres
= IHTMLBodyElement_put_text(body
, v
);
6241 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6245 hres
= IHTMLBodyElement_get_text(body
, &v
);
6246 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6247 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6248 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
6251 /* get_text - Valid Text */
6253 V_BSTR(&v
) = a2bstr("#FF0000");
6254 hres
= IHTMLBodyElement_put_text(body
, v
);
6255 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6259 hres
= IHTMLBodyElement_get_text(body
, &v
);
6260 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
6261 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
6262 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
6266 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
6267 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
6272 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
6273 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
6274 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
6278 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
6279 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
6281 BSTR str
= a2bstr(val
);
6284 hres
= IHTMLBodyElement_put_scroll(body
, str
);
6285 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
6288 _test_body_scroll(line
, body
, val
);
6291 static void test_body_funs(IHTMLBodyElement
*body
)
6293 VARIANT vbg
, vDefaultbg
;
6296 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
6297 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6298 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6299 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6301 V_VT(&vbg
) = VT_BSTR
;
6302 V_BSTR(&vbg
) = a2bstr("red");
6303 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
6304 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6307 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
6308 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6309 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6310 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6313 /* Restore Originial */
6314 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
6315 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6316 VariantClear(&vDefaultbg
);
6318 test_body_scroll(body
, NULL
);
6319 set_body_scroll(body
, "yes");
6320 set_body_scroll(body
, "no");
6321 set_body_scroll(body
, "auto");
6324 static void test_history(IHTMLWindow2
*window
)
6326 IOmHistory
*history
, *history2
;
6330 hres
= IHTMLWindow2_get_history(window
, &history
);
6331 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6332 ok(history
!= NULL
, "history = NULL\n");
6334 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
6337 hres
= IHTMLWindow2_get_history(window
, &history2
);
6338 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
6339 ok(history2
!= NULL
, "history2 = NULL\n");
6340 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
6342 IOmHistory_Release(history2
);
6343 IOmHistory_Release(history
);
6346 static void test_xmlhttprequest(IHTMLWindow5
*window
)
6350 IHTMLXMLHttpRequestFactory
*factory
;
6351 IHTMLXMLHttpRequest
*xml
;
6353 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
6354 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08x\n", hres
);
6355 ok(V_VT(&var
) == VT_DISPATCH
, "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
6358 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
6359 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08x\n", hres
);
6360 ok(factory
!= NULL
, "factory == NULL\n");
6363 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
6364 ok(hres
== S_OK
, "create failed: %08x\n", hres
);
6365 ok(xml
!= NULL
, "xml == NULL\n");
6366 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, "[object]");
6368 IHTMLXMLHttpRequest_Release(xml
);
6369 IHTMLXMLHttpRequestFactory_Release(factory
);
6373 static void test_window(IHTMLDocument2
*doc
)
6375 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
6376 IHTMLWindow5
*window5
;
6377 IHTMLDocument2
*doc2
= NULL
;
6384 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6385 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
6386 test_ifaces((IUnknown
*)window
, window_iids
);
6387 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
6389 IUnknown_Release(unk
);
6391 win_skip("IID_ITravelLogClient not supported\n");
6393 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
6395 hres
= IHTMLWindow2_get_document(window
, &doc2
);
6396 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
6397 ok(doc2
!= NULL
, "doc2 == NULL\n");
6399 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
6400 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
6401 test_class_info((IUnknown
*)doc2
);
6403 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
6404 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
6405 test_class_info((IUnknown
*)doc
);
6407 unk
= (void*)0xdeadbeef;
6408 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
6409 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
6410 ok(!unk
, "unk = %p\n", unk
);
6412 IHTMLDocument2_Release(doc2
);
6414 hres
= IHTMLWindow2_get_window(window
, &window2
);
6415 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
6416 ok(window2
!= NULL
, "window2 == NULL\n");
6418 hres
= IHTMLWindow2_get_self(window
, &self
);
6419 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
6420 ok(window2
!= NULL
, "self == NULL\n");
6422 ok(self
== window2
, "self != window2\n");
6424 IHTMLWindow2_Release(window2
);
6427 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
6428 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
6429 ok(disp
== (void*)window
, "disp != window\n");
6430 IDispatch_Release(disp
);
6432 hres
= IHTMLWindow2_toString(window
, NULL
);
6433 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
6436 hres
= IHTMLWindow2_toString(window
, &str
);
6437 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
6438 ok(!strcmp_wa(str
, "[object]") ||
6439 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
6442 V_VT(&v
) = VT_ERROR
;
6443 hres
= IHTMLWindow2_get_opener(window
, &v
);
6444 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
6445 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
6448 hres
= IHTMLWindow2_get_parent(window
, &parent
);
6449 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
6450 ok(parent
!= NULL
, "parent == NULL\n");
6451 ok(parent
== self
, "parent != window\n");
6452 IHTMLWindow2_Release(parent
);
6453 IHTMLWindow2_Release(self
);
6455 test_window_name(window
, NULL
);
6456 set_window_name(window
, "test");
6457 test_window_length(window
, 0);
6458 test_screen(window
);
6459 test_window_status(window
);
6460 set_window_status(window
, "Test!");
6461 test_history(window
);
6463 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
6464 if(SUCCEEDED(hres
)) {
6465 ok(window5
!= NULL
, "window5 == NULL\n");
6466 test_xmlhttprequest(window5
);
6467 IHTMLWindow5_Release(window5
);
6469 win_skip("IHTMLWindow5 not supported!\n");
6472 IHTMLWindow2_Release(window
);
6475 static void test_dom_implementation(IHTMLDocument2
*doc
)
6477 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
6478 IHTMLDOMImplementation
*dom_implementation
;
6484 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
6485 IHTMLDocument5_Release(doc5
);
6486 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
6487 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
6489 str
= a2bstr("test");
6491 V_BSTR(&v
) = a2bstr("1.0");
6493 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
6496 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
6497 ok(!b
, "hasFeature returned %x\n", b
);
6499 IHTMLDOMImplementation_Release(dom_implementation
);
6502 static void test_defaults(IHTMLDocument2
*doc
)
6504 IHTMLStyleSheetsCollection
*stylesheetcol
;
6505 IHTMLCurrentStyle
*cstyle
;
6506 IHTMLBodyElement
*body
;
6507 IHTMLElement2
*elem2
;
6515 IHTMLElementCollection
*collection
;
6517 elem
= doc_get_body(doc
);
6519 hres
= IHTMLDocument2_get_images(doc
, NULL
);
6520 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6522 hres
= IHTMLDocument2_get_images(doc
, &collection
);
6523 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
6526 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6527 IHTMLElementCollection_Release(collection
);
6530 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
6531 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6533 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
6534 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
6537 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6538 IHTMLElementCollection_Release(collection
);
6541 hres
= IHTMLDocument2_get_links(doc
, NULL
);
6542 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6544 hres
= IHTMLDocument2_get_links(doc
, &collection
);
6545 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
6548 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6549 IHTMLElementCollection_Release(collection
);
6552 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
6553 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6555 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
6556 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
6559 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6560 IHTMLElementCollection_Release(collection
);
6563 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
6564 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
6566 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
6567 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
6570 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
6571 IHTMLElementCollection_Release(collection
);
6574 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
6575 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
6576 test_default_body(body
);
6577 test_body_funs(body
);
6578 IHTMLBodyElement_Release(body
);
6580 test_elem_istextedit(elem
, VARIANT_TRUE
);
6582 hres
= IHTMLElement_get_style(elem
, &style
);
6583 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
6585 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
6586 test_ifaces((IUnknown
*)style
, style_iids
);
6587 IHTMLStyle_Release(style
);
6590 hres
= IHTMLDocument2_get_charset(doc
, &str
);
6591 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
6592 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
6596 test_compatmode(doc
, "BackCompat");
6598 test_navigator(doc
);
6599 test_plugins_col(doc
);
6601 elem2
= get_elem2_iface((IUnknown
*)elem
);
6602 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
6603 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
6604 if(SUCCEEDED(hres
)) {
6607 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
6608 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
6610 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
6612 IUnknown_Release(unk
);
6615 /*IE6 doesn't have interface */
6616 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
6619 IHTMLCurrentStyle_Release(cstyle
);
6621 IHTMLElement2_Release(elem2
);
6623 IHTMLElement_Release(elem
);
6625 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
6626 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6629 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
6630 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6631 ok(l
== 0, "length = %d\n", l
);
6633 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
6635 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
6636 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
6638 str
= a2bstr("xxx");
6640 V_VT(&v
) = VT_EMPTY
;
6641 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6642 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
6643 "execCommand failed: %08x, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
6646 str
= a2bstr("respectvisibilityindesign");
6649 V_BOOL(&v
) = VARIANT_TRUE
;
6650 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
6651 ok(hres
== S_OK
, "execCommand failed: %08x, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
6654 test_default_selection(doc
);
6655 test_doc_title(doc
, "");
6656 test_dom_implementation(doc
);
6659 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6660 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6662 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6666 str
= (void*)0xdeadbeef;
6667 hres
= IHTMLButtonElement_get_name(button
, &str
);
6668 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6670 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
6672 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6674 IHTMLButtonElement_Release(button
);
6677 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
6678 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6680 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6681 BSTR str
= a2bstr(name
);
6684 hres
= IHTMLButtonElement_put_name(button
, str
);
6685 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6687 IHTMLButtonElement_Release(button
);
6689 _test_button_name(line
, elem
, name
);
6692 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
6693 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
6695 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6696 VARIANT_BOOL disabled
= 100;
6699 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
6700 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
6701 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
6702 IHTMLButtonElement_Release(button
);
6704 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6707 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6708 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6710 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6713 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6714 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6715 IHTMLButtonElement_Release(button
);
6717 _test_button_get_disabled(line
, elem
, b
);
6720 static void test_button_elem(IHTMLElement
*elem
)
6722 test_button_name(elem
, NULL
);
6723 set_button_name(elem
, "button name");
6725 test_elem_istextedit(elem
, VARIANT_TRUE
);
6728 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6729 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6730 IHTMLTableRow
*row
, LONG len
, const char *id
)
6732 IHTMLElementCollection
*col
;
6738 hres
= IHTMLTableRow_get_cells(row
, &col
);
6739 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6740 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6742 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6743 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6744 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6746 V_VT(&var
) = VT_BSTR
;
6747 V_BSTR(&var
) = a2bstr(id
);
6748 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6749 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6750 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6753 IDispatch_Release(disp
);
6754 IHTMLElementCollection_Release(col
);
6757 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6761 IHTMLTableCell
*cell
;
6763 hres
= IHTMLTableRow_deleteCell(row
, 0);
6764 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6765 test_tr_possess(elem
, row
, 1, "td2");
6767 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6768 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6769 ok(disp
!= NULL
, "disp == NULL\n");
6770 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6771 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6772 ok(cell
!= NULL
, "cell == NULL\n");
6773 if (SUCCEEDED(hres
))
6774 IHTMLTableCell_Release(cell
);
6775 test_tr_possess(elem
, row
, 2, "td2");
6776 IDispatch_Release(disp
);
6779 static void test_tr_elem(IHTMLElement
*elem
)
6781 IHTMLElementCollection
*col
;
6786 VARIANT vbg
, vDefaultbg
;
6788 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6790 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6791 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6796 hres
= IHTMLTableRow_get_cells(row
, &col
);
6797 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6798 ok(col
!= NULL
, "get_cells returned NULL\n");
6800 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6801 IHTMLElementCollection_Release(col
);
6803 bstr
= a2bstr("left");
6804 hres
= IHTMLTableRow_put_align(row
, bstr
);
6805 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6806 SysFreeString(bstr
);
6809 hres
= IHTMLTableRow_get_align(row
, &bstr
);
6810 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6811 ok(bstr
!= NULL
, "get_align returned NULL\n");
6812 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6813 SysFreeString(bstr
);
6815 bstr
= a2bstr("top");
6816 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
6817 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
6818 SysFreeString(bstr
);
6821 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
6822 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
6823 ok(bstr
!= NULL
, "get_valign returned NULL\n");
6824 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
6825 SysFreeString(bstr
);
6828 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
6829 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6830 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
6833 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
6834 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
6835 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
6837 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
6838 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6839 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6840 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6842 V_VT(&vbg
) = VT_BSTR
;
6843 V_BSTR(&vbg
) = a2bstr("red");
6844 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6845 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6848 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6849 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6850 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6851 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6855 V_I4(&vbg
) = 0xff0000;
6856 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6857 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6860 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6861 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6862 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6863 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6866 /* Restore Originial */
6867 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
6868 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6869 VariantClear(&vDefaultbg
);
6871 test_tr_modify(elem
, row
);
6873 IHTMLTableRow_Release(row
);
6876 static void test_td_elem(IHTMLElement
*elem
)
6878 IHTMLTableCell
*cell
;
6882 VARIANT vbg
, vDefaultbg
;
6884 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
6885 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6890 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
6891 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
6892 ok(lval
== 1, "Expected 1, got %d\n", lval
);
6894 str
= a2bstr("left");
6895 hres
= IHTMLTableCell_put_align(cell
, str
);
6896 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
6900 hres
= IHTMLTableCell_get_align(cell
, &str
);
6901 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6902 ok(str
!= NULL
, "str is NULL\n");
6903 if (str
!= NULL
&& hres
== S_OK
) {
6904 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
6908 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
6909 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6910 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6911 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6913 V_VT(&vbg
) = VT_BSTR
;
6914 V_BSTR(&vbg
) = a2bstr("red");
6915 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6916 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6919 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6920 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6921 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6922 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6926 V_I4(&vbg
) = 0xff0000;
6927 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6928 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6931 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6932 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6933 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6934 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6937 /* Restore Originial */
6938 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
6939 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6940 VariantClear(&vDefaultbg
);
6942 IHTMLTableCell_Release(cell
);
6945 static void test_label_elem(IHTMLElement
*elem
)
6947 IHTMLLabelElement
*label
;
6951 label
= get_label_iface((IUnknown
*)elem
);
6954 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6955 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6956 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6960 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6961 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6964 str
= (void*)0xdeadbeef;
6965 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6966 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6967 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
6969 str
= a2bstr("abc");
6970 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6971 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6975 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6976 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6977 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6980 IHTMLLabelElement_Release(label
);
6983 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
6984 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
6989 V_VT(&v
) = VT_ERROR
;
6990 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
6991 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
6992 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
6994 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
6996 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7000 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
7001 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const char *exstr
)
7006 V_VT(&v
) = VT_ERROR
;
7007 hres
= IHTMLTable_get_cellPadding(table
, &v
);
7008 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08x\n", hres
);
7009 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
7011 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
7013 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7017 static void test_table_modify(IHTMLTable
*table
)
7024 test_table_length(table
, 2);
7026 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
7027 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
7028 ok(disp
!= NULL
, "disp == NULL\n");
7029 test_table_length(table
, 3);
7030 if (hres
!= S_OK
|| disp
== NULL
)
7033 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
7034 IDispatch_Release(disp
);
7036 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
7037 ok(row
!= NULL
, "row == NULL\n");
7040 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
7041 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
7042 ok(index
== 0, "index = %d, expected 0\n", index
);
7044 IHTMLTableRow_Release(row
);
7046 hres
= IHTMLTable_deleteRow(table
, 0);
7047 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
7048 test_table_length(table
, 2);
7051 static void test_table_elem(IHTMLElement
*elem
)
7053 IHTMLElementCollection
*col
;
7055 IHTMLTable3
*table3
;
7060 VARIANT vbg
, vDefaultbg
;
7062 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
7063 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
7064 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
7066 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
7067 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
7071 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
7072 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
7077 hres
= IHTMLTable_get_rows(table
, &col
);
7078 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
7079 ok(col
!= NULL
, "get_rows returned NULL\n");
7081 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
7082 IHTMLElementCollection_Release(col
);
7084 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7086 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
7087 test_elem_tag((IUnknown
*)node
, "TABLE");
7088 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
7089 IHTMLDOMNode_Release(node
);
7091 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
7092 test_elem_tag((IUnknown
*)node
, "TABLE");
7093 test_elem_all((IUnknown
*)node
, NULL
, 0);
7094 IHTMLDOMNode_Release(node
);
7097 hres
= IHTMLTable_get_tBodies(table
, &col
);
7098 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
7099 ok(col
!= NULL
, "get_tBodies returned NULL\n");
7101 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
7102 IHTMLElementCollection_Release(col
);
7104 test_table_cell_spacing(table
, NULL
);
7108 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7109 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7110 test_table_cell_spacing(table
, "10");
7113 V_BSTR(&v
) = a2bstr("11");
7114 hres
= IHTMLTable_put_cellSpacing(table
, v
);
7115 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
7116 test_table_cell_spacing(table
, "11");
7119 test_table_cell_padding(table
, NULL
);
7123 hres
= IHTMLTable_put_cellPadding(table
, v
);
7124 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7125 test_table_cell_padding(table
, "10");
7128 V_BSTR(&v
) = a2bstr("11");
7129 hres
= IHTMLTable_put_cellPadding(table
, v
);
7130 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7131 test_table_cell_padding(table
, "11");
7136 hres
= IHTMLTable_put_cellPadding(table
, v
);
7137 ok(hres
== S_OK
, "put_cellPadding = %08x\n", hres
);
7138 test_table_cell_padding(table
, "5");
7140 bstr
= a2bstr("left");
7141 hres
= IHTMLTable_put_align(table
, bstr
);
7142 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
7143 SysFreeString(bstr
);
7146 hres
= IHTMLTable_get_align(table
, &bstr
);
7147 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
7148 ok(bstr
!= NULL
, "get_align returned NULL\n");
7149 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
7150 SysFreeString(bstr
);
7152 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
7153 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7154 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7155 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7157 V_VT(&vbg
) = VT_BSTR
;
7158 V_BSTR(&vbg
) = a2bstr("red");
7159 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7160 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7163 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7164 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7165 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7166 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7170 V_I4(&vbg
) = 0xff0000;
7171 hres
= IHTMLTable_put_bgColor(table
, vbg
);
7172 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7175 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
7176 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
7177 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7178 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7181 /* Restore Originial */
7182 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
7183 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
7184 VariantClear(&vDefaultbg
);
7187 V_BSTR(&v
) = a2bstr("11");
7188 hres
= IHTMLTable_put_width(table
, v
);
7189 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7191 hres
= IHTMLTable_get_width(table
, &v
);
7192 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7193 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7197 V_BSTR(&v
) = a2bstr("11.9");
7198 hres
= IHTMLTable_put_width(table
, v
);
7199 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7201 hres
= IHTMLTable_get_width(table
, &v
);
7202 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7203 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7207 V_BSTR(&v
) = a2bstr("40.2%");
7208 hres
= IHTMLTable_put_width(table
, v
);
7209 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7211 hres
= IHTMLTable_get_width(table
, &v
);
7212 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7213 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7218 hres
= IHTMLTable_put_width(table
, v
);
7219 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7220 hres
= IHTMLTable_get_width(table
, &v
);
7221 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7222 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7227 hres
= IHTMLTable_put_width(table
, v
);
7228 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
7229 hres
= IHTMLTable_get_width(table
, &v
);
7230 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
7231 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7234 bstr
= a2bstr("box");
7235 hres
= IHTMLTable_put_frame(table
, bstr
);
7236 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
7237 SysFreeString(bstr
);
7238 hres
= IHTMLTable_get_frame(table
, &bstr
);
7239 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
7240 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
7241 SysFreeString(bstr
);
7243 test_table_modify(table
);
7244 bstr
= a2bstr("summary");
7245 hres
= IHTMLTable3_put_summary(table3
, bstr
);
7246 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
7247 SysFreeString(bstr
);
7249 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
7250 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
7251 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
7252 SysFreeString(bstr
);
7254 IHTMLTable3_Release(table3
);
7255 IHTMLTable_Release(table
);
7258 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
7267 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7268 SafeArrayAccessData(sa
, (void**)&var
);
7269 V_VT(var
) = VT_BSTR
;
7270 V_BSTR(var
) = a2bstr(text
);
7271 SafeArrayUnaccessData(sa
);
7274 hres
= IHTMLDocument2_writeln(doc
, sa
);
7276 hres
= IHTMLDocument2_write(doc
, sa
);
7277 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7279 SafeArrayDestroy(sa
);
7282 static void doc_complex_write(IHTMLDocument2
*doc
)
7284 SAFEARRAYBOUND dim
= {5, 0};
7289 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
7290 SafeArrayAccessData(sa
, (void**)&args
);
7292 V_VT(args
) = VT_BSTR
;
7293 V_BSTR(args
) = a2bstr("<body i4val=\"");
7294 V_VT(args
+1) = VT_I4
;
7296 V_VT(args
+2) = VT_BSTR
;
7297 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
7298 V_VT(args
+3) = VT_R8
;
7299 V_R8(args
+3) = 3.14;
7300 V_VT(args
+4) = VT_BSTR
;
7301 V_BSTR(args
+4) = a2bstr("\">");
7302 SafeArrayUnaccessData(sa
);
7304 hres
= IHTMLDocument2_write(doc
, sa
);
7305 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
7307 SafeArrayDestroy(sa
);
7310 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
7312 IHTMLDocument2
*window_doc
, *elem_doc
;
7313 IHTMLFrameElement3
*frame_elem3
;
7314 IHTMLWindow2
*content_window
;
7317 content_window
= get_frame_content_window(frame_elem
);
7318 test_ifaces((IUnknown
*)content_window
, window_iids
);
7319 window_doc
= get_window_doc(content_window
);
7320 IHTMLWindow2_Release(content_window
);
7322 elem_doc
= get_elem_doc(frame_elem
);
7323 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
7326 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
7327 if(SUCCEEDED(hres
)) {
7328 IDispatch
*disp
= NULL
;
7330 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
7331 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7332 ok(disp
!= NULL
, "contentDocument == NULL\n");
7333 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
7335 IDispatch_Release(disp
);
7336 IHTMLFrameElement3_Release(frame_elem3
);
7338 win_skip("IHTMLFrameElement3 not supported\n");
7342 IHTMLDocument2_Release(elem_doc
);
7343 IHTMLDocument2_Release(window_doc
);
7346 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
7347 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7349 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7353 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
7354 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
7355 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
7357 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7359 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7361 IHTMLIFrameElement2_Release(iframe
);
7364 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
7365 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
7367 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7372 V_BSTR(&v
) = a2bstr(val
);
7373 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
7374 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
7376 IHTMLIFrameElement2_Release(iframe
);
7379 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
7380 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
7382 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7386 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
7387 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
7388 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
7390 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
7392 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
7394 IHTMLIFrameElement2_Release(iframe
);
7397 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
7398 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
7400 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
7405 V_BSTR(&v
) = a2bstr(val
);
7406 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
7407 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
7409 IHTMLIFrameElement2_Release(iframe
);
7412 static void test_iframe_elem(IHTMLElement
*elem
)
7414 IHTMLDocument2
*content_doc
, *owner_doc
;
7415 IHTMLIFrameElement3
*iframe3
;
7416 IHTMLElementCollection
*col
;
7417 IHTMLWindow2
*content_window
;
7424 static const elem_type_t all_types
[] = {
7432 test_frame_doc((IUnknown
*)elem
, TRUE
);
7433 test_framebase((IUnknown
*)elem
);
7435 content_window
= get_frame_content_window((IUnknown
*)elem
);
7436 test_ifaces((IUnknown
*)content_window
, window_iids
);
7437 test_window_length(content_window
, 0);
7439 content_doc
= get_window_doc(content_window
);
7440 IHTMLWindow2_Release(content_window
);
7442 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
7443 if(SUCCEEDED(hres
)) {
7444 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
7445 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
7446 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
7447 IDispatch_Release(disp
);
7449 IHTMLIFrameElement3_Release(iframe3
);
7451 win_skip("IHTMLIFrameElement3 not supported\n");
7454 test_iframe_height(elem
, NULL
);
7455 set_iframe_height(elem
, "100px");
7456 set_iframe_height(elem
, "50%");
7457 test_iframe_height(elem
, "50%");
7459 test_iframe_width(elem
, NULL
);
7460 set_iframe_width(elem
, "150px");
7461 set_iframe_width(elem
, "70%");
7462 test_iframe_width(elem
, "70%");
7463 test_framebase_src(elem
, "about:blank");
7465 str
= a2bstr("text/html");
7466 V_VT(&errv
) = VT_ERROR
;
7468 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
7470 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
7471 ok(disp
!= NULL
, "disp == NULL\n");
7472 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
7473 IDispatch_Release(disp
);
7475 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
7476 doc_complex_write(content_doc
);
7477 doc_write(content_doc
, TRUE
, "<br />");
7478 doc_write(content_doc
, TRUE
, "</html>");
7480 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
7481 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7482 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7483 IHTMLElementCollection_Release(col
);
7485 body
= doc_get_body(content_doc
);
7486 test_elem_attr(body
, "i4val", "4");
7487 test_elem_attr(body
, "r8val", "3.14");
7488 IHTMLElement_Release(body
);
7490 hres
= IHTMLDocument2_close(content_doc
);
7491 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
7493 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
7494 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7496 IHTMLDocument2_Release(content_doc
);
7499 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
7500 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *exstr
, BOOL is_todo
)
7505 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
7506 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08x\n", hres
);
7509 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7511 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7514 ok_(__FILE__
,line
)(is_prefix_wa(str
, exstr
), "cssText = %s\n", wine_dbgstr_w(str
));
7516 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
7522 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
7523 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const char *csstext
, BOOL is_todo
)
7525 BSTR str
= a2bstr(csstext
);
7528 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
7530 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7532 todo_wine
ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08x\n", hres
);
7536 static void test_stylesheet(IDispatch
*disp
)
7538 IHTMLStyleSheetRulesCollection
*col
= NULL
;
7539 IHTMLStyleSheet
*stylesheet
;
7543 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
7545 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
7546 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
7548 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
7549 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
7550 ok(col
!= NULL
, "col == NULL\n");
7552 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
7553 IHTMLStyleSheetRulesCollection_Release(col
);
7555 href
= (void*)0xdeadbeef;
7556 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
7557 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
7558 ok(href
== NULL
, "got href != NULL\n");
7559 SysFreeString(href
);
7561 test_stylesheet_csstext(stylesheet
, ".body {", FALSE
);
7562 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
7563 test_stylesheet_csstext(stylesheet
, ".div {", TRUE
);
7564 set_stylesheet_csstext(stylesheet
, "", FALSE
);
7565 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
7566 set_stylesheet_csstext(stylesheet
, ".div { margin-right: 1px; }", FALSE
);
7567 test_stylesheet_csstext(stylesheet
, ".div {", FALSE
);
7569 IHTMLStyleSheet_Release(stylesheet
);
7572 static void test_stylesheets(IHTMLDocument2
*doc
)
7574 IHTMLStyleSheetsCollection
*col
= NULL
;
7579 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
7580 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
7581 ok(col
!= NULL
, "col == NULL\n");
7583 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
7585 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
7586 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7587 ok(len
== 1, "len=%d\n", len
);
7593 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7594 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
7595 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
7596 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
7597 test_stylesheet(V_DISPATCH(&res
));
7604 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
7605 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7606 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
7609 IHTMLStyleSheetsCollection_Release(col
);
7612 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
7614 IDispatchEx
*dispex
;
7616 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
7624 static const WCHAR w0
[] = {'0',0};
7625 static const WCHAR w100
[] = {'1','0','0',0};
7627 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
7628 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
7630 bstr
= SysAllocString(w0
);
7631 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7632 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7633 SysFreeString(bstr
);
7636 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
7637 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
7638 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
7639 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
7640 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
7641 type
= get_node_type((IUnknown
*)node
);
7642 ok(type
== 3, "type=%d\n", type
);
7643 IHTMLDOMNode_Release(node
);
7646 bstr
= SysAllocString(w100
);
7647 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
7648 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
7649 SysFreeString(bstr
);
7651 IDispatchEx_Release(dispex
);
7654 static void test_enum_children(IUnknown
*unk
, unsigned len
)
7656 IEnumVARIANT
*enum_var
;
7661 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
7662 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
7664 for(i
=0; i
<len
; i
++) {
7666 V_VT(&v
) = VT_ERROR
;
7667 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
7668 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
7670 ok(fetched
== 1, "fetched = %d\n", fetched
);
7671 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
7672 IDispatch_Release(V_DISPATCH(&v
));
7675 fetched
= 0xdeadbeef;
7677 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
7678 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
7679 ok(fetched
== 0, "fetched = %d\n", fetched
);
7680 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7682 hres
= IEnumVARIANT_Reset(enum_var
);
7683 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7685 fetched
= 0xdeadbeef;
7687 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
7688 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
7689 ok(fetched
== 0, "fetched = %d\n", fetched
);
7690 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
7692 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
7693 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
7695 hres
= IEnumVARIANT_Reset(enum_var
);
7696 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
7698 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
7699 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
7701 IEnumVARIANT_Release(enum_var
);
7704 static void test_elems(IHTMLDocument2
*doc
)
7706 IHTMLElementCollection
*col
;
7707 IHTMLDOMChildrenCollection
*child_col
;
7708 IHTMLElement
*elem
, *elem2
, *elem3
;
7709 IHTMLDOMNode
*node
, *node2
;
7710 IHTMLWindow2
*window
;
7714 IHTMLElementCollection
*collection
;
7715 IHTMLDocument3
*doc3
;
7718 static const elem_type_t all_types
[] = {
7751 static const elem_type_t item_types
[] = {
7757 hres
= IHTMLDocument2_get_all(doc
, &col
);
7758 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7759 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7760 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
7762 elem
= get_elem_col_item_idx(col
, 0);
7763 test_elem_source_index(elem
, 0);
7764 IHTMLElement_Release(elem
);
7766 elem
= get_elem_col_item_idx(col
, 3);
7767 test_elem_source_index(elem
, 3);
7768 IHTMLElement_Release(elem
);
7770 IHTMLElementCollection_Release(col
);
7772 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7773 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
7776 static const elem_type_t images_types
[] = {ET_IMG
};
7777 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7779 IHTMLElementCollection_Release(collection
);
7782 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7783 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
7786 static const elem_type_t images_types
[] = {ET_A
};
7787 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7789 IHTMLElementCollection_Release(collection
);
7792 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7793 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7796 static const elem_type_t anchor_types
[] = {ET_A
};
7797 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7799 IHTMLElementCollection_Release(collection
);
7802 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7803 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7805 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7806 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7807 IHTMLElementCollection_Release(collection
);
7810 test_plugins_col(doc
);
7812 elem
= get_doc_elem(doc
);
7813 test_elem_istextedit(elem
, VARIANT_FALSE
);
7814 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
7815 IHTMLElement_Release(elem
);
7817 get_elem_by_id(doc
, "xxx", FALSE
);
7818 elem
= get_doc_elem_by_id(doc
, "xxx");
7819 ok(!elem
, "elem != NULL\n");
7821 elem
= get_doc_elem_by_id(doc
, "s");
7822 ok(elem
!= NULL
, "elem == NULL\n");
7824 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
7825 test_elem_attr(elem
, "xxx", NULL
);
7826 test_elem_attr(elem
, "id", "s");
7827 test_elem_class((IUnknown
*)elem
, NULL
);
7828 test_elem_set_class((IUnknown
*)elem
, "cl");
7829 test_elem_set_class((IUnknown
*)elem
, NULL
);
7830 test_elem_tabindex((IUnknown
*)elem
, 0);
7831 test_elem_set_tabindex((IUnknown
*)elem
, 1);
7832 test_elem_filters((IUnknown
*)elem
);
7833 test_elem_istextedit(elem
, VARIANT_FALSE
);
7835 node
= test_node_get_parent((IUnknown
*)elem
);
7836 ok(node
!= NULL
, "node == NULL\n");
7837 test_node_name((IUnknown
*)node
, "BODY");
7838 node2
= test_node_get_parent((IUnknown
*)node
);
7839 IHTMLDOMNode_Release(node
);
7840 ok(node2
!= NULL
, "node == NULL\n");
7841 test_node_name((IUnknown
*)node2
, "HTML");
7842 node
= test_node_get_parent((IUnknown
*)node2
);
7843 IHTMLDOMNode_Release(node2
);
7844 ok(node
!= NULL
, "node == NULL\n");
7847 test_node_name((IUnknown
*)node
, "#document");
7848 type
= get_node_type((IUnknown
*)node
);
7849 ok(type
== 9, "type=%d, expected 9\n", type
);
7850 node2
= test_node_get_parent((IUnknown
*)node
);
7851 IHTMLDOMNode_Release(node
);
7852 ok(node2
== NULL
, "node != NULL\n");
7855 elem2
= test_elem_get_parent((IUnknown
*)elem
);
7856 ok(elem2
!= NULL
, "elem2 == NULL\n");
7857 test_node_name((IUnknown
*)elem2
, "BODY");
7859 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
7860 ok(elem3
!= NULL
, "elem3 == NULL\n");
7861 test_node_name((IUnknown
*)elem3
, "HTML");
7863 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
7864 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
7865 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
7866 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
7867 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
7868 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
7869 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
7870 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
7871 IHTMLElement_Release(elem2
);
7873 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
7874 ok(elem2
== NULL
, "elem2 != NULL\n");
7875 test_elem_source_index(elem3
, 0);
7876 IHTMLElement_Release(elem3
);
7878 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
7879 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
7880 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
7882 test_elem_innertext(elem
, "opt1opt2");
7884 IHTMLElement_Release(elem
);
7887 elem
= get_elem_by_id(doc
, "s", TRUE
);
7889 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
7890 IHTMLDocument2
*doc_node
, *elem_doc
;
7892 test_select_elem(select
);
7894 test_elem_istextedit(elem
, VARIANT_FALSE
);
7895 test_elem_title((IUnknown
*)select
, NULL
);
7896 test_elem_set_title((IUnknown
*)select
, "Title");
7897 test_elem_title((IUnknown
*)select
, "Title");
7898 test_elem_offset((IUnknown
*)select
, "BODY");
7899 test_elem_bounding_client_rect((IUnknown
*)select
);
7901 node
= get_first_child((IUnknown
*)select
);
7902 ok(node
!= NULL
, "node == NULL\n");
7904 test_elem_type((IUnknown
*)node
, ET_OPTION
);
7905 IHTMLDOMNode_Release(node
);
7908 type
= get_node_type((IUnknown
*)select
);
7909 ok(type
== 1, "type=%d\n", type
);
7911 IHTMLSelectElement_Release(select
);
7913 elem_doc
= get_elem_doc((IUnknown
*)elem
);
7915 doc_node
= get_doc_node(doc
);
7916 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
7917 IHTMLDocument2_Release(doc_node
);
7918 IHTMLDocument2_Release(elem_doc
);
7920 IHTMLElement_Release(elem
);
7923 elem
= get_elem_by_id(doc
, "sc", TRUE
);
7925 IHTMLScriptElement
*script
;
7928 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
7929 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
7931 test_elem_language(elem
, NULL
);
7932 test_elem_istextedit(elem
, VARIANT_FALSE
);
7938 hres
= IHTMLScriptElement_put_type (script
, NULL
);
7939 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7940 hres
= IHTMLScriptElement_get_type(script
, &type
);
7941 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7942 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
7944 type
= a2bstr("text/javascript");
7945 hres
= IHTMLScriptElement_put_type (script
, type
);
7946 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7947 SysFreeString(type
);
7948 hres
= IHTMLScriptElement_get_type(script
, &type
);
7949 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7950 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
7951 SysFreeString(type
);
7953 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
7956 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
7957 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7959 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
7960 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
7961 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
7963 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
7964 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7966 str
= (BSTR
)0xdeadbeef;
7967 hres
= IHTMLScriptElement_get_src(script
, &str
);
7968 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
7969 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
7972 IHTMLScriptElement_Release(script
);
7974 set_elem_language(elem
, "vbscript");
7975 set_elem_language(elem
, "xxx");
7978 elem
= get_elem_by_id(doc
, "in", TRUE
);
7980 IHTMLInputElement
*input
;
7982 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
7983 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
7985 test_elem_id((IUnknown
*)elem
, "in");
7986 test_elem_put_id((IUnknown
*)elem
, "newin");
7987 test_input_get_disabled(input
, VARIANT_FALSE
);
7988 test_input_set_disabled(input
, VARIANT_TRUE
);
7989 test_input_set_disabled(input
, VARIANT_FALSE
);
7990 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
7991 test_input_get_disabled(input
, VARIANT_TRUE
);
7992 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
7993 test_input_get_disabled(input
, VARIANT_FALSE
);
7994 test_elem_client_size((IUnknown
*)elem
);
7995 test_input_type(input
, "text");
7996 test_elem_istextedit(elem
, VARIANT_TRUE
);
7998 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7999 test_node_put_value_str((IUnknown
*)elem
, "test");
8000 test_node_get_value_str((IUnknown
*)elem
, NULL
);
8001 test_input_value((IUnknown
*)elem
, NULL
);
8002 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8003 test_input_put_value((IUnknown
*)elem
, "test");
8004 test_input_defaultValue((IUnknown
*)elem
, NULL
);
8005 test_elem_class((IUnknown
*)elem
, "testclass");
8006 test_elem_tabindex((IUnknown
*)elem
, 2);
8007 test_elem_set_tabindex((IUnknown
*)elem
, 3);
8008 test_elem_title((IUnknown
*)elem
, "test title");
8010 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
8011 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
8012 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
8014 test_input_get_checked(input
, VARIANT_FALSE
);
8015 test_input_set_checked(input
, VARIANT_TRUE
);
8016 test_input_set_checked(input
, VARIANT_FALSE
);
8018 test_input_maxlength(input
, 0x7fffffff);
8019 test_input_set_maxlength(input
, 30);
8021 test_input_name(input
, NULL
);
8022 test_input_set_name(input
, "test");
8024 test_input_src(input
, NULL
);
8025 test_input_set_src(input
, "about:blank");
8027 test_input_set_size(input
, 15, S_OK
);
8028 test_input_get_size(input
, 15);
8029 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
8030 test_input_get_size(input
, 15);
8031 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
8032 test_input_get_size(input
, 15);
8034 test_input_readOnly(input
, VARIANT_TRUE
);
8035 test_input_readOnly(input
, VARIANT_FALSE
);
8037 IHTMLInputElement_Release(input
);
8038 IHTMLElement_Release(elem
);
8041 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8043 test_img_align((IUnknown
*)elem
, "left");
8044 test_img_name((IUnknown
*)elem
, "WineImg");
8045 test_img_src((IUnknown
*)elem
, "", NULL
);
8046 test_img_set_src((IUnknown
*)elem
, "about:blank");
8047 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
8048 test_img_alt((IUnknown
*)elem
, NULL
);
8049 test_img_set_alt((IUnknown
*)elem
, "alt test");
8050 test_img_name((IUnknown
*)elem
, "WineImg");
8051 test_img_complete(elem
, VARIANT_FALSE
);
8052 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
8053 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
8054 IHTMLElement_Release(elem
);
8057 elem
= get_elem_by_id(doc
, "attr", TRUE
);
8059 test_dynamic_properties(elem
);
8060 test_attr_collection(elem
);
8061 test_contenteditable((IUnknown
*)elem
);
8062 IHTMLElement_Release(elem
);
8065 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
8067 test_style_media((IUnknown
*)elem
, NULL
);
8068 test_style_put_media((IUnknown
*)elem
, "screen");
8069 test_style_type((IUnknown
*)elem
, NULL
);
8070 test_style_put_type((IUnknown
*)elem
, "text/css");
8071 IHTMLElement_Release(elem
);
8074 elem
= get_doc_elem_by_id(doc
, "tbl");
8075 ok(elem
!= NULL
, "elem == NULL\n");
8077 test_table_elem(elem
);
8078 IHTMLElement_Release(elem
);
8081 elem
= get_doc_elem_by_id(doc
, "labelid");
8082 ok(elem
!= NULL
, "elem == NULL\n");
8084 test_label_elem(elem
);
8085 IHTMLElement_Release(elem
);
8088 elem
= get_doc_elem_by_id(doc
, "td2");
8089 ok(elem
!= NULL
, "elem == NULL\n");
8092 IHTMLElement_Release(elem
);
8095 elem
= get_doc_elem_by_id(doc
, "row2");
8096 ok(elem
!= NULL
, "elem == NULL\n");
8099 IHTMLElement_Release(elem
);
8102 elem
= get_doc_elem_by_id(doc
, "ifr");
8103 ok(elem
!= NULL
, "elem == NULL\n");
8105 test_iframe_elem(elem
);
8106 IHTMLElement_Release(elem
);
8109 elem
= get_doc_elem_by_id(doc
, "btnid");
8110 ok(elem
!= NULL
, "elem == NULL\n");
8112 test_button_elem(elem
);
8113 test_button_get_disabled(elem
, VARIANT_FALSE
);
8114 test_button_set_disabled(elem
, VARIANT_TRUE
);
8115 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8116 test_button_get_disabled(elem
, VARIANT_FALSE
);
8117 IHTMLElement_Release(elem
);
8120 elem
= get_doc_elem_by_id(doc
, "objid");
8121 ok(elem
!= NULL
, "elem == NULL\n");
8123 test_object_vspace((IUnknown
*)elem
, 100);
8124 test_object_name(elem
, "objname");
8125 set_object_name(elem
, "test");
8126 set_object_name(elem
, NULL
);
8127 IHTMLElement_Release(elem
);
8130 elem
= get_elem_by_id(doc
, "a", TRUE
);
8132 test_anchor_href((IUnknown
*)elem
, "http://test/");
8134 /* Change the href */
8135 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
8136 test_anchor_href((IUnknown
*)elem
, "http://test1/");
8137 test_anchor_hostname((IUnknown
*)elem
, "test1");
8139 /* Restore the href */
8140 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
8141 test_anchor_href((IUnknown
*)elem
, "http://test/");
8142 test_anchor_hostname((IUnknown
*)elem
, "test");
8143 test_anchor_hash(elem
, NULL
);
8146 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8148 test_anchor_rel((IUnknown
*)elem
, NULL
);
8149 test_anchor_put_rel((IUnknown
*)elem
, "Next");
8150 test_anchor_rel((IUnknown
*)elem
, "Next");
8152 /* Change the target */
8153 test_anchor_put_target((IUnknown
*)elem
, "wine");
8154 test_anchor_get_target((IUnknown
*)elem
, "wine");
8156 /* Restore the target */
8157 test_anchor_put_target((IUnknown
*)elem
, NULL
);
8158 test_anchor_get_target((IUnknown
*)elem
, NULL
);
8160 test_anchor_name((IUnknown
*)elem
, "x");
8161 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
8162 test_anchor_put_name((IUnknown
*)elem
, NULL
);
8163 test_anchor_put_name((IUnknown
*)elem
, "x");
8165 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
8166 test_anchor_hash(elem
, "#hash");
8167 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
8169 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
8170 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
8171 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
8172 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
8174 test_anchor_put_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
8175 test_anchor_search((IUnknown
*)elem
, "?q=%E4%BD%A0%E5%A5%BD", FALSE
);
8177 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
8178 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
8180 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
8181 as part of the pathname, and cannot be accessed by get_search. */
8182 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
8183 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
8185 IHTMLElement_Release(elem
);
8188 elem
= get_doc_elem_by_id(doc
, "metaid");
8190 test_meta_name((IUnknown
*)elem
, "meta name");
8191 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
8192 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
8193 test_meta_charset((IUnknown
*)elem
, NULL
);
8194 set_meta_charset((IUnknown
*)elem
, "utf-8");
8195 IHTMLElement_Release(elem
);
8198 elem
= doc_get_body(doc
);
8200 node
= get_first_child((IUnknown
*)elem
);
8201 ok(node
!= NULL
, "node == NULL\n");
8203 test_ifaces((IUnknown
*)node
, text_iids
);
8204 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8206 node2
= get_first_child((IUnknown
*)node
);
8207 ok(!node2
, "node2 != NULL\n");
8209 type
= get_node_type((IUnknown
*)node
);
8210 ok(type
== 3, "type=%d\n", type
);
8212 test_node_get_value_str((IUnknown
*)node
, "text test");
8213 test_node_put_value_str((IUnknown
*)elem
, "test text");
8214 test_node_get_value_str((IUnknown
*)node
, "text test");
8216 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
8217 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
8218 ok(!disp
, "disp != NULL\n");
8220 IHTMLDOMNode_Release(node
);
8223 child_col
= get_child_nodes((IUnknown
*)elem
);
8224 ok(child_col
!= NULL
, "child_coll == NULL\n");
8229 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
8231 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
8232 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8233 ok(length
, "length=0\n");
8236 node
= get_child_item(child_col
, 0);
8237 ok(node
!= NULL
, "node == NULL\n");
8241 type
= get_node_type((IUnknown
*)node
);
8242 ok(type
== 3, "type=%d\n", type
);
8243 node2
= node_get_next((IUnknown
*)node
);
8245 prev
= node_get_prev((IUnknown
*)node2
);
8246 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
8247 IHTMLDOMNode_Release(prev
);
8249 IHTMLDOMNode_Release(node
);
8252 node
= get_child_item(child_col
, 1);
8253 ok(node
!= NULL
, "node == NULL\n");
8255 type
= get_node_type((IUnknown
*)node
);
8256 ok(type
== 8, "type=%d\n", type
);
8258 test_elem_id((IUnknown
*)node
, NULL
);
8259 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
8260 IHTMLDOMNode_Release(node2
);
8261 IHTMLDOMNode_Release(node
);
8264 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
8265 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8267 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
8268 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
8270 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
8271 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8273 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
8274 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
8276 test_child_col_disp(child_col
);
8278 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
8279 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
8281 test_enum_children(enum_unk
, length
);
8283 IUnknown_Release(enum_unk
);
8285 IHTMLDOMChildrenCollection_Release(child_col
);
8288 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8289 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
8290 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
8292 IHTMLElement_Release(elem
);
8294 elem
= get_doc_elem_by_id(doc
, "frm");
8295 ok(elem
!= NULL
, "elem == NULL\n");
8297 test_form_length((IUnknown
*)elem
, 0);
8298 test_form_elements((IUnknown
*)elem
);
8299 IHTMLElement_Release(elem
);
8302 test_stylesheets(doc
);
8303 test_create_option_elem(doc
);
8304 test_create_img_elem(doc
);
8306 elem
= get_doc_elem_by_id(doc
, "tbl");
8307 ok(elem
!= NULL
, "elem = NULL\n");
8308 test_elem_set_innertext(elem
, "inner text");
8309 IHTMLElement_Release(elem
);
8311 test_doc_title(doc
, "test");
8312 test_doc_set_title(doc
, "test title");
8313 test_doc_title(doc
, "test title");
8316 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
8317 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
8320 IDispatchEx
*dispex
;
8321 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
8322 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
8326 BSTR str
= a2bstr("Testing");
8327 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
8328 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
8329 ok(pid
!= -1, "pid == -1\n");
8331 IDispatchEx_Release(dispex
);
8334 IDispatch_Release(disp
);
8336 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
8338 elem
= get_doc_elem_by_id(doc
, "y");
8339 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
8340 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
8341 test_elem_set_innerhtml((IUnknown
*)elem
, "");
8342 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
8343 node
= node_get_next((IUnknown
*)elem
);
8344 ok(!node
, "node = %p\n", node
);
8346 elem2
= get_doc_elem_by_id(doc
, "x");
8347 test_elem_tag((IUnknown
*)elem2
, "A");
8348 node
= node_get_next((IUnknown
*)elem2
);
8349 IHTMLDOMNode_Release(node
);
8350 IHTMLElement_Release(elem2
);
8351 IHTMLElement_Release(elem
);
8353 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8354 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8356 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
8357 ok(hres
== S_OK
, "recalc failed: %08x\n", hres
);
8359 IHTMLDocument3_Release(doc3
);
8361 elem
= get_elem_by_id(doc
, "s", TRUE
);
8363 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
8365 test_select_put_length((IUnknown
*)elem
, 3);
8366 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
8367 test_select_put_length((IUnknown
*)elem
, 1);
8368 test_elem_all((IUnknown
*)elem
, select_types
, 1);
8369 IHTMLElement_Release(elem
);
8372 window
= get_doc_window(doc
);
8373 test_window_name(window
, NULL
);
8374 set_window_name(window
, "test name");
8375 test_window_length(window
, 1);
8376 IHTMLWindow2_Release(window
);
8379 static void test_attr(IHTMLElement
*elem
)
8381 IHTMLDOMAttribute
*attr
, *attr2
;
8384 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
8386 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8388 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8389 test_ifaces((IUnknown
*)attr
, attr_iids
);
8390 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8391 test_attr_specified(attr
, VARIANT_TRUE
);
8393 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
8394 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
8395 IHTMLDOMAttribute_Release(attr2
);
8397 get_attr_node_value(attr
, &v
, VT_BSTR
);
8398 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8402 V_BSTR(&v
) = a2bstr("divid2");
8403 put_attr_node_value(attr
, v
);
8405 get_attr_node_value(attr
, &v
, VT_BSTR
);
8406 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8409 put_attr_value(attr
, "divid3");
8411 get_attr_node_value(attr
, &v
, VT_BSTR
);
8412 ok(!strcmp_wa(V_BSTR(&v
), "divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8415 IHTMLDOMAttribute_Release(attr
);
8417 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8418 get_attr_node_value(attr
, &v
, VT_BSTR
);
8419 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8423 V_BSTR(&v
) = a2bstr("newvalue");
8424 put_attr_node_value(attr
, v
);
8427 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
8428 get_attr_node_value(attr
, &v
, VT_BSTR
);
8429 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8432 test_attr_specified(attr
, VARIANT_TRUE
);
8433 IHTMLDOMAttribute_Release(attr
);
8437 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
8438 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
8439 get_attr_node_value(attr
, &v
, VT_I4
);
8440 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
8441 test_attr_specified(attr
, VARIANT_TRUE
);
8445 put_attr_node_value(attr
, v
);
8447 get_attr_node_value(attr
, &v
, VT_I4
);
8448 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
8450 put_attr_value(attr
, "160");
8451 get_attr_node_value(attr
, &v
, VT_BSTR
);
8452 ok(!strcmp_wa(V_BSTR(&v
), "160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8455 IHTMLDOMAttribute_Release(attr
);
8457 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
8458 test_attr_specified(attr
, VARIANT_FALSE
);
8459 test_attr_expando(attr
, VARIANT_FALSE
);
8460 IHTMLDOMAttribute_Release(attr
);
8463 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
8467 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8468 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
8469 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8471 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8472 IHTMLElement_Release(elem
);
8475 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
8476 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
8477 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
8479 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
8480 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
8481 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
8482 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
8483 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
8484 IHTMLElement_Release(elem
);
8488 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
8489 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
8491 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
8492 IHTMLElementCollection
*col
;
8493 BSTR str
= a2bstr(name
);
8496 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
8497 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
8498 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
8500 IHTMLDocument3_Release(doc3
);
8505 static void test_elem_names(IHTMLDocument2
*doc
)
8507 IHTMLElementCollection
*col
;
8512 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
8514 body
= doc_get_body(doc
);
8516 test_elem_set_innerhtml((IUnknown
*)body
,
8517 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
8518 col
= doc_get_elems_by_name(doc
, "test");
8519 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
8520 IHTMLElementCollection_Release(col
);
8522 col
= doc_get_elems_by_name(doc
, "yyy");
8523 test_elem_collection((IUnknown
*)col
, NULL
, 0);
8524 IHTMLElementCollection_Release(col
);
8526 /* case insensivity test */
8527 col
= doc_get_elems_by_name(doc
, "Xxx");
8528 hres
= IHTMLElementCollection_get_length(col
, &len
);
8529 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
8530 todo_wine
ok(len
== 1, "len = %d\n", len
);
8531 IHTMLElementCollection_Release(col
);
8533 IHTMLElement_Release(body
);
8536 static void test_elems2(IHTMLDocument2
*doc
)
8538 IHTMLElement
*elem
, *elem2
, *div
;
8540 static const elem_type_t outer_types
[] = {
8545 div
= get_doc_elem_by_id(doc
, "divid");
8547 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
8549 test_link_disabled(elem
, VARIANT_FALSE
);
8550 test_link_rel(elem
, "stylesheet");
8551 test_link_rev(elem
, NULL
);
8552 test_link_type(elem
, "text/css");
8553 test_link_href(elem
, "about:blank");
8554 test_link_media(elem
, "all");
8555 link_put_disabled(elem
, VARIANT_TRUE
);
8556 link_put_rel(elem
, "prev");
8557 link_put_rev(elem
, "next");
8558 link_put_type(elem
, "text/plain");
8559 link_put_href(elem
, "about:prev");
8560 IHTMLElement_Release(elem
);
8563 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
8564 elem2
= get_doc_elem_by_id(doc
, "innerid");
8565 ok(elem2
!= NULL
, "elem2 == NULL\n");
8566 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
8567 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
8568 IHTMLElement_Release(elem2
);
8570 elem2
= get_doc_elem_by_id(doc
, "aid");
8571 ok(elem2
!= NULL
, "elem2 == NULL\n");
8572 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
8573 test_elem_all((IUnknown
*)div
, outer_types
, 1);
8574 IHTMLElement_Release(elem2
);
8576 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
8577 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8579 IHTMLFormElement
*form
;
8581 test_textarea_value((IUnknown
*)elem
, NULL
);
8582 test_textarea_put_value((IUnknown
*)elem
, "test");
8583 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
8584 test_textarea_put_defaultvalue((IUnknown
*)elem
, "defval text");
8585 test_textarea_put_value((IUnknown
*)elem
, "test");
8586 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8587 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
8588 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
8589 test_textarea_type((IUnknown
*)elem
);
8591 form
= get_textarea_form((IUnknown
*)elem
);
8592 ok(!form
, "form = %p\n", form
);
8594 test_elem_istextedit(elem
, VARIANT_TRUE
);
8596 IHTMLElement_Release(elem
);
8599 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\">default text</textarea>");
8600 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8602 test_textarea_defaultvalue((IUnknown
*)elem
, "default text");
8603 IHTMLElement_Release(elem
);
8606 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
8607 elem
= get_elem_by_id(doc
, "ta", TRUE
);
8609 IHTMLFormElement
*form
;
8611 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
8612 ok(elem2
!= NULL
, "elem2 == NULL\n");
8614 form
= get_textarea_form((IUnknown
*)elem
);
8615 ok(form
!= NULL
, "form = NULL\n");
8616 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
8618 IHTMLFormElement_Release(form
);
8619 IHTMLElement_Release(elem2
);
8620 IHTMLElement_Release(elem
);
8623 test_elem_set_innerhtml((IUnknown
*)div
,
8624 "<input value=\"val\" id =\"inputid\" />");
8625 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8627 test_input_defaultValue((IUnknown
*)elem
, "val");
8628 test_input_put_value((IUnknown
*)elem
, "test");
8629 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
8630 test_input_value((IUnknown
*)elem
, "test");
8631 IHTMLElement_Release(elem
);
8634 test_elem_set_innerhtml((IUnknown
*)div
, "");
8635 test_insert_adjacent_elems(doc
, div
);
8637 test_elem_set_innerhtml((IUnknown
*)div
,
8638 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
8639 elem
= get_elem_by_id(doc
, "form", TRUE
);
8641 test_form_length((IUnknown
*)elem
, 2);
8642 test_form_item(elem
);
8643 test_form_action((IUnknown
*)elem
, NULL
);
8644 test_form_put_action((IUnknown
*)elem
, "about:blank");
8645 test_form_method((IUnknown
*)elem
, "get");
8646 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
8647 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
8648 test_form_method((IUnknown
*)elem
, "post");
8649 test_form_name((IUnknown
*)elem
, NULL
);
8650 test_form_put_name((IUnknown
*)elem
, "Name");
8651 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
8652 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
8653 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
8654 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
8655 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
8656 test_form_elements((IUnknown
*)elem
);
8657 test_form_reset((IUnknown
*)elem
);
8658 test_form_target((IUnknown
*)elem
);
8659 IHTMLElement_Release(elem
);
8661 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
8662 test_input_get_form((IUnknown
*)elem
, "form");
8663 IHTMLElement_Release(elem
);
8666 test_elem_set_innerhtml((IUnknown
*)div
,
8667 "<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select></form>");
8668 elem
= get_elem_by_id(doc
, "sform", TRUE
);
8669 elem2
= get_elem_by_id(doc
, "form", TRUE
);
8671 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8672 IHTMLElement_Release(elem
);
8674 elem
= get_elem_by_id(doc
, "oform", TRUE
);
8676 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
8677 IHTMLElement_Release(elem
);
8679 IHTMLElement_Release(elem2
);
8683 test_blocked(doc
, div
);
8684 test_elem_names(doc
);
8686 IHTMLElement_Release(div
);
8689 static void test_create_elems(IHTMLDocument2
*doc
)
8691 IHTMLElement
*elem
, *body
, *elem2
;
8692 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
8693 IHTMLDOMAttribute
*attr
;
8694 IHTMLDocument5
*doc5
;
8701 static const elem_type_t types1
[] = { ET_TESTG
};
8703 elem
= test_create_elem(doc
, "TEST");
8704 test_elem_tag((IUnknown
*)elem
, "TEST");
8705 type
= get_node_type((IUnknown
*)elem
);
8706 ok(type
== 1, "type=%d\n", type
);
8707 test_ifaces((IUnknown
*)elem
, elem_iids
);
8708 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
8709 test_elem_source_index(elem
, -1);
8711 body
= doc_get_body(doc
);
8712 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8714 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
8715 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
8716 elem2
= get_elem_iface((IUnknown
*)node
);
8717 IHTMLElement_Release(elem2
);
8719 hres
= IHTMLElement_get_all(body
, &disp
);
8720 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8721 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
8722 IDispatch_Release(disp
);
8724 test_node_remove_child((IUnknown
*)body
, node
);
8726 hres
= IHTMLElement_get_all(body
, &disp
);
8727 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8728 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
8729 IDispatch_Release(disp
);
8730 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
8732 IHTMLElement_Release(elem
);
8733 IHTMLDOMNode_Release(node
);
8735 node
= test_create_text(doc
, "abc");
8736 test_ifaces((IUnknown
*)node
, text_iids
);
8737 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
8738 test_text_length((IUnknown
*)node
, 3);
8739 test_text_data((IUnknown
*)node
, "abc");
8740 set_text_data((IUnknown
*)node
, "test");
8741 test_text_data((IUnknown
*)node
, "test");
8742 text_append_data((IUnknown
*)node
, " append");
8743 test_text_data((IUnknown
*)node
, "test append");
8744 text_append_data((IUnknown
*)node
, NULL
);
8745 test_text_data((IUnknown
*)node
, "test append");
8746 set_text_data((IUnknown
*)node
, "test");
8748 V_VT(&var
) = VT_NULL
;
8749 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8750 IHTMLDOMNode_Release(node
);
8752 node
= test_create_text(doc
, "insert ");
8754 V_VT(&var
) = VT_DISPATCH
;
8755 V_DISPATCH(&var
) = (IDispatch
*)node2
;
8756 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8757 IHTMLDOMNode_Release(node
);
8758 IHTMLDOMNode_Release(node2
);
8759 IHTMLDOMNode_Release(node3
);
8761 test_elem_innertext(body
, "insert test");
8762 test_elem_innerhtml((IUnknown
*)body
, "insert test");
8764 node
= test_create_text(doc
, " Test");
8765 V_VT(&var
) = VT_DISPATCH
;
8766 V_DISPATCH(&var
) = NULL
;
8767 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8768 test_elem_innertext(body
, "insert test Test");
8769 IHTMLDOMNode_Release(node
);
8771 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
8773 str
= a2bstr("testing");
8774 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
8776 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
8779 type
= get_node_type((IUnknown
*)comment
);
8780 ok(type
== 8, "type=%d, expected 8\n", type
);
8782 test_node_get_value_str((IUnknown
*)comment
, "testing");
8783 test_elem_title((IUnknown
*)comment
, NULL
);
8784 test_elem_set_title((IUnknown
*)comment
, "comment title");
8785 test_elem_title((IUnknown
*)comment
, "comment title");
8786 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
8787 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
8788 test_comment_attrs((IUnknown
*)comment
);
8790 IHTMLDOMNode_Release(comment
);
8793 str
= a2bstr("Test");
8794 hres
= IHTMLDocument5_createAttribute(doc5
, str
, &attr
);
8795 ok(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
8797 if(SUCCEEDED(hres
)) {
8798 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8799 test_ifaces((IUnknown
*)attr
, attr_iids
);
8800 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8802 test_attr_node_name(attr
, "Test");
8804 IHTMLDOMAttribute_Release(attr
);
8807 IHTMLDocument5_Release(doc5
);
8810 IHTMLElement_Release(body
);
8813 static void test_replacechild_elems(IHTMLDocument2
*doc
)
8816 IHTMLDOMNode
*node
, *node2
, *node3
;
8817 IHTMLDOMNode
*nodeBody
, *nodeNew
;
8821 body
= doc_get_body(doc
);
8823 node
= test_create_text(doc
, "insert");
8825 V_VT(&var
) = VT_NULL
;
8826 V_DISPATCH(&var
) = NULL
;
8827 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8828 IHTMLDOMNode_Release(node
);
8830 test_elem_innertext(body
, "insert");
8832 node3
= test_create_text(doc
, "replaced");
8834 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
8836 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
8837 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
8839 test_elem_innertext(body
, "replaced");
8841 IHTMLDOMNode_Release(node2
);
8842 IHTMLDOMNode_Release(node3
);
8843 IHTMLDOMNode_Release(nodeBody
);
8845 IHTMLElement_Release(body
);
8848 static void test_noscript(IHTMLDocument2
*doc
)
8850 IHTMLElementCollection
*col
;
8854 static const elem_type_t all_types
[] = {
8863 static const elem_type_t body_all_types
[] = {
8868 hres
= IHTMLDocument2_get_all(doc
, &col
);
8869 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8870 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8871 IHTMLElementCollection_Release(col
);
8873 body
= doc_get_body(doc
);
8874 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
8875 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
8876 IHTMLElement_Release(body
);
8879 static void test_doctype(IHTMLDocument2
*doc
)
8881 IHTMLDocument2
*doc_node
;
8882 IHTMLDOMNode
*doctype
;
8885 doc_node
= get_doc_node(doc
);
8886 doctype
= get_first_child((IUnknown
*)doc_node
);
8887 IHTMLDocument2_Release(doc_node
);
8889 type
= get_node_type((IUnknown
*)doctype
);
8890 ok(type
== 8, "type = %d\n", type
);
8892 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
8893 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
8894 IHTMLDOMNode_Release(doctype
);
8897 static void test_null_write(IHTMLDocument2
*doc
)
8901 doc_write(doc
, FALSE
, NULL
);
8902 doc_write(doc
, TRUE
, NULL
);
8904 hres
= IHTMLDocument2_write(doc
, NULL
);
8906 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
8908 hres
= IHTMLDocument2_writeln(doc
, NULL
);
8910 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
8913 static void test_create_stylesheet(IHTMLDocument2
*doc
)
8915 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
8916 IHTMLStyleElement
*style_elem
;
8917 IHTMLElement
*doc_elem
, *elem
;
8920 static const elem_type_t all_types
[] = {
8928 static const elem_type_t all_types2
[] = {
8937 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
8939 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
8940 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
8942 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
8944 doc_elem
= get_doc_elem(doc
);
8946 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
8947 IHTMLElement_Release(doc_elem
);
8949 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
8950 IHTMLElement_Release(elem
);
8951 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
8954 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
8955 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
8956 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
8957 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
8959 IHTMLStyleSheet_Release(stylesheet2
);
8960 IHTMLStyleSheet_Release(stylesheet
);
8962 IHTMLStyleElement_Release(style_elem
);
8965 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
8967 IOleCommandTarget
*cmdtrg
;
8970 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
8971 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
8973 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
8974 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
8976 IOleCommandTarget_Release(cmdtrg
);
8979 static void test_indent(IHTMLDocument2
*doc
)
8981 IHTMLElementCollection
*col
;
8982 IHTMLTxtRange
*range
;
8985 static const elem_type_t all_types
[] = {
8994 static const elem_type_t indent_types
[] = {
9005 hres
= IHTMLDocument2_get_all(doc
, &col
);
9006 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9007 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9008 IHTMLElementCollection_Release(col
);
9010 range
= test_create_body_range(doc
);
9011 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
9012 IHTMLTxtRange_Release(range
);
9014 hres
= IHTMLDocument2_get_all(doc
, &col
);
9015 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9016 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
9017 IHTMLElementCollection_Release(col
);
9020 static void test_cond_comment(IHTMLDocument2
*doc
)
9022 IHTMLElementCollection
*col
;
9025 static const elem_type_t all_types
[] = {
9033 hres
= IHTMLDocument2_get_all(doc
, &col
);
9034 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9035 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9036 IHTMLElementCollection_Release(col
);
9039 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
9041 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
9042 return E_NOINTERFACE
;
9045 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
9050 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
9055 static const IUnknownVtbl UnknownVtbl
= {
9056 Unknown_QueryInterface
,
9060 static IUnknown obj_ident_test
= { &UnknownVtbl
};
9062 static void test_frame(IDispatch
*disp
, const char *exp_id
)
9064 IHTMLWindow2
*frame2
, *parent
, *top
;
9065 IHTMLDocument2
*parent_doc
, *top_doc
;
9066 IHTMLWindow4
*frame
;
9067 IHTMLFrameBase
*frame_elem
;
9068 IObjectIdentity
*obj_ident
;
9069 ITravelLogClient
*tlc
;
9072 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
9073 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
9077 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
9078 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
9079 IHTMLWindow4_Release(frame
);
9083 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
9084 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
9085 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
9086 IHTMLFrameBase_Release(frame_elem
);
9088 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
9089 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
9093 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
9094 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
9096 IHTMLWindow2_Release(frame2
);
9100 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
9101 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
9102 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
9103 if(hres
== E_NOINTERFACE
) {
9104 win_skip("IID_ITravelLogClient not available\n");
9107 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
9109 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
9110 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9111 ITravelLogClient_Release(tlc
);
9114 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
9115 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
9116 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
9117 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
9118 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
9119 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
9121 IObjectIdentity_Release(obj_ident
);
9123 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
9124 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9125 IHTMLWindow2_Release(parent
);
9127 IHTMLWindow2_Release(frame2
);
9131 test_doc_title(parent_doc
, "frameset test");
9132 IHTMLDocument2_Release(parent_doc
);
9135 hres
= IHTMLWindow2_get_top(frame2
, &top
);
9136 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
9137 IHTMLWindow2_Release(frame2
);
9141 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
9142 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
9143 IHTMLWindow2_Release(top
);
9147 test_doc_title(top_doc
, "frameset test");
9148 IHTMLDocument2_Release(top_doc
);
9151 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
9153 VARIANT index_var
, result_var
;
9157 /* test result length */
9158 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
9159 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
9160 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
9162 /* test first frame */
9163 V_VT(&index_var
) = VT_I4
;
9164 V_I4(&index_var
) = 0;
9165 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9166 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9167 if(SUCCEEDED(hres
)) {
9168 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9169 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
9171 VariantClear(&result_var
);
9173 /* test second frame */
9174 V_I4(&index_var
) = 1;
9175 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9176 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9177 if(SUCCEEDED(hres
)) {
9178 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9179 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
9181 VariantClear(&result_var
);
9183 /* fail on next frame */
9184 V_I4(&index_var
) = 3;
9185 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9186 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
9187 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
9188 VariantClear(&result_var
);
9190 /* string argument (element id lookup) */
9191 V_VT(&index_var
) = VT_BSTR
;
9192 V_BSTR(&index_var
) = a2bstr(frid
);
9193 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9194 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
9195 if(SUCCEEDED(hres
)) {
9196 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
9197 test_frame(V_DISPATCH(&result_var
), frid
);
9199 VariantClear(&result_var
);
9200 VariantClear(&index_var
);
9202 /* invalid argument */
9203 V_VT(&index_var
) = VT_BOOL
;
9204 V_BOOL(&index_var
) = VARIANT_TRUE
;
9205 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
9206 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
9207 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
9208 VariantClear(&result_var
);
9211 static void test_frameset(IHTMLDocument2
*doc
)
9213 IHTMLWindow2
*window
;
9214 IHTMLFramesCollection2
*frames
;
9218 window
= get_doc_window(doc
);
9220 /* test using IHTMLFramesCollection object */
9222 hres
= IHTMLWindow2_get_frames(window
, &frames
);
9223 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
9227 test_frames_collection(frames
, "fr1");
9228 IHTMLFramesCollection2_Release(frames
);
9230 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
9231 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
9235 test_frames_collection(frames
, "fr1");
9236 IHTMLFramesCollection2_Release(frames
);
9238 /* test using IHTMLWindow2 inheritance */
9239 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
9241 /* getElementById with node name attributes */
9242 elem
= get_doc_elem_by_id(doc
, "nm1");
9243 test_elem_id((IUnknown
*)elem
, "fr1");
9245 test_framebase((IUnknown
*)elem
);
9246 test_framebase_name(elem
, "nm1");
9247 test_framebase_put_name(elem
, "frame name");
9248 test_framebase_put_name(elem
, NULL
);
9249 test_framebase_put_name(elem
, "nm1");
9250 test_framebase_src(elem
, "about:blank");
9251 IHTMLElement_Release(elem
);
9253 /* get_name with no name attr */
9254 elem
= get_doc_elem_by_id(doc
, "fr3");
9255 test_framebase_name(elem
, NULL
);
9256 test_framebase_put_name(elem
, "frame name");
9257 test_framebase_put_name(elem
, NULL
);
9258 IHTMLElement_Release(elem
);
9260 IHTMLWindow2_Release(window
);
9263 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
9265 IHTMLDocument2
*frag
;
9266 IHTMLDocument3
*doc3
;
9269 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9270 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
9272 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
9273 IHTMLDocument3_Release(doc3
);
9274 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
9275 ok(frag
!= NULL
, "frag == NULL\n");
9280 static void test_docfrag(IHTMLDocument2
*doc
)
9282 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
9283 IHTMLElement
*div
, *body
, *br
;
9284 IHTMLElementCollection
*col
;
9285 IHTMLLocation
*location
;
9288 static const elem_type_t all_types
[] = {
9297 frag
= create_docfrag(doc
);
9299 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
9301 body
= (void*)0xdeadbeef;
9302 hres
= IHTMLDocument2_get_body(frag
, &body
);
9303 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
9304 ok(!body
, "body != NULL\n");
9306 location
= (void*)0xdeadbeef;
9307 hres
= IHTMLDocument2_get_location(frag
, &location
);
9308 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
9309 ok(location
== (void*)0xdeadbeef, "location changed\n");
9311 br
= test_create_elem(doc
, "BR");
9312 test_elem_source_index(br
, -1);
9313 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
9314 test_elem_source_index(br
, 0);
9315 IHTMLElement_Release(br
);
9317 test_doc_getelembytag(frag
, "a", ET_A
, 0);
9318 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
9320 div
= get_elem_by_id(doc
, "divid", TRUE
);
9321 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
9322 IHTMLElement_Release(div
);
9324 hres
= IHTMLDocument2_get_all(doc
, &col
);
9325 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
9326 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
9327 IHTMLElementCollection_Release(col
);
9329 div
= test_create_elem(frag
, "div");
9330 owner_doc
= get_owner_doc((IUnknown
*)div
);
9331 doc_node
= get_doc_node(doc
);
9332 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
9333 IHTMLDocument2_Release(doc_node
);
9334 IHTMLDocument2_Release(owner_doc
);
9335 IHTMLElement_Release(div
);
9337 IHTMLDocument2_Release(frag
);
9340 static void check_quirks_mode(IHTMLDocument2
*doc
)
9342 test_compatmode(doc
, "BackCompat");
9345 static void check_strict_mode(IHTMLDocument2
*doc
)
9347 test_compatmode(doc
, "CSS1Compat");
9350 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
9356 hres
= IHTMLDocument2_get_body(doc
, &elem
);
9357 ok(hres
== S_OK
, "get_body fauled: %08x\n", hres
);
9359 /* body.offsetHeight value depends on window size in quirks mode */
9360 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
9361 ok(hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
9362 todo_wine
ok(oh
== 500, "offsetHeight = %d\n", oh
);
9363 IHTMLElement_Release(elem
);
9366 static IHTMLDocument2
*notif_doc
;
9367 static BOOL doc_complete
;
9369 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
9370 REFIID riid
, void**ppv
)
9372 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
9377 ok(0, "unexpected call\n");
9378 return E_NOINTERFACE
;
9381 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
9386 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
9391 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
9393 if(dispID
== DISPID_READYSTATE
){
9397 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
9398 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
9400 if(!strcmp_wa(state
, "complete"))
9401 doc_complete
= TRUE
;
9403 SysFreeString(state
);
9409 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
9411 ok(0, "unexpected call\n");
9415 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
9416 PropertyNotifySink_QueryInterface
,
9417 PropertyNotifySink_AddRef
,
9418 PropertyNotifySink_Release
,
9419 PropertyNotifySink_OnChanged
,
9420 PropertyNotifySink_OnRequestEdit
9423 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
9425 static HRESULT
cs_qi(REFIID
,void **);
9426 static IOleDocumentView
*view
;
9427 static HWND container_hwnd
;
9429 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
9431 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
9433 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
9434 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
9437 return E_NOINTERFACE
;
9440 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
9445 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
9450 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
9455 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
9460 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
9465 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
9466 LPCBORDERWIDTHS pborderwidths
)
9471 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
9472 LPCBORDERWIDTHS pborderwidths
)
9477 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
9478 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
9483 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9484 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
9489 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
9490 HOLEMENU holemenu
, HWND hwndActiveObject
)
9492 ok(0, "unexpected call\n");
9496 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
9498 ok(0, "unexpected call\n");
9502 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
9507 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
9512 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
9514 ok(0, "unexpected call\n");
9518 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
9519 InPlaceFrame_QueryInterface
,
9520 InPlaceFrame_AddRef
,
9521 InPlaceFrame_Release
,
9522 InPlaceFrame_GetWindow
,
9523 InPlaceFrame_ContextSensitiveHelp
,
9524 InPlaceFrame_GetBorder
,
9525 InPlaceFrame_RequestBorderSpace
,
9526 InPlaceFrame_SetBorderSpace
,
9527 InPlaceFrame_SetActiveObject
,
9528 InPlaceFrame_InsertMenus
,
9529 InPlaceFrame_SetMenu
,
9530 InPlaceFrame_RemoveMenus
,
9531 InPlaceFrame_SetStatusText
,
9532 InPlaceFrame_EnableModeless
,
9533 InPlaceFrame_TranslateAccelerator
9536 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
9538 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
9540 return cs_qi(riid
, ppv
);
9543 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
9548 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
9553 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
9555 *phwnd
= container_hwnd
;
9559 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
9561 ok(0, "unexpected call\n");
9565 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
9570 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
9575 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
9580 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
9581 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
9582 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
9584 static const RECT rect
= {0,0,500,500};
9586 *ppFrame
= &InPlaceFrame
;
9588 *lprcPosRect
= rect
;
9589 *lprcClipRect
= rect
;
9591 lpFrameInfo
->fMDIApp
= FALSE
;
9592 lpFrameInfo
->hwndFrame
= container_hwnd
;
9593 lpFrameInfo
->haccel
= NULL
;
9594 lpFrameInfo
->cAccelEntries
= 0;
9599 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
9604 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
9609 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
9614 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
9619 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
9624 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
9629 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
9630 InPlaceSite_QueryInterface
,
9632 InPlaceSite_Release
,
9633 InPlaceSite_GetWindow
,
9634 InPlaceSite_ContextSensitiveHelp
,
9635 InPlaceSite_CanInPlaceActivate
,
9636 InPlaceSite_OnInPlaceActivate
,
9637 InPlaceSite_OnUIActivate
,
9638 InPlaceSite_GetWindowContext
,
9640 InPlaceSite_OnUIDeactivate
,
9641 InPlaceSite_OnInPlaceDeactivate
,
9642 InPlaceSite_DiscardUndoState
,
9643 InPlaceSite_DeactivateAndUndo
,
9644 InPlaceSite_OnPosRectChange
,
9647 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
9649 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
9651 return cs_qi(riid
, ppv
);
9654 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
9659 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
9664 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
9666 ok(0, "unexpected call\n");
9670 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
9673 ok(0, "unexpected call\n");
9677 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
9682 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
9684 ok(0, "unexpected call\n");
9688 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
9690 ok(0, "unexpected call\n");
9694 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
9696 ok(0, "unexpected call\n");
9700 static const IOleClientSiteVtbl ClientSiteVtbl
= {
9701 ClientSite_QueryInterface
,
9704 ClientSite_SaveObject
,
9705 ClientSite_GetMoniker
,
9706 ClientSite_GetContainer
,
9707 ClientSite_ShowObject
,
9708 ClientSite_OnShowWindow
,
9709 ClientSite_RequestNewObjectLayout
9712 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
9714 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
9716 return cs_qi(riid
, ppv
);
9719 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
9724 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
9729 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
9731 RECT rect
= {0,0,500,500};
9732 IOleDocument
*document
;
9735 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
9736 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
9738 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
9739 IOleDocument_Release(document
);
9740 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
9742 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
9743 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
9745 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
9746 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
9748 hres
= IOleDocumentView_SetRect(view
, &rect
);
9749 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
9751 hres
= IOleDocumentView_Show(view
, TRUE
);
9752 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
9757 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
9758 DocumentSite_QueryInterface
,
9759 DocumentSite_AddRef
,
9760 DocumentSite_Release
,
9761 DocumentSite_ActivateMe
9764 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
9766 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
9770 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
9772 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
9773 *ppv
= &DocumentSite
;
9774 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
9775 *ppv
= &InPlaceSite
;
9777 return *ppv
? S_OK
: E_NOINTERFACE
;
9780 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
9786 IOleDocumentView_Show(view
, FALSE
);
9787 IOleDocumentView_CloseView(view
, 0);
9788 IOleDocumentView_SetInPlaceSite(view
, NULL
);
9789 IOleDocumentView_Release(view
);
9793 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
9794 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
9796 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
9797 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
9800 IHlinkTarget
*hlink
;
9802 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
9803 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
9805 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
9806 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
9808 IHlinkTarget_Release(hlink
);
9811 IOleObject_Release(oleobj
);
9814 static IHTMLDocument2
*create_doc_with_string(const char *str
)
9816 IPersistStreamInit
*init
;
9818 IHTMLDocument2
*doc
;
9822 notif_doc
= doc
= create_document();
9826 doc_complete
= FALSE
;
9828 mem
= GlobalAlloc(0, len
);
9829 memcpy(mem
, str
, len
);
9830 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
9832 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
9834 IPersistStreamInit_Load(init
, stream
);
9835 IPersistStreamInit_Release(init
);
9836 IStream_Release(stream
);
9841 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
9843 IConnectionPointContainer
*container
;
9844 IConnectionPoint
*cp
;
9848 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
9849 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
9851 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
9852 IConnectionPointContainer_Release(container
);
9853 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
9855 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
9856 IConnectionPoint_Release(cp
);
9857 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
9860 typedef void (*domtest_t
)(IHTMLDocument2
*);
9862 static void run_domtest(const char *str
, domtest_t test
)
9864 IHTMLDocument2
*doc
;
9868 doc
= create_doc_with_string(str
);
9872 set_client_site(doc
, TRUE
);
9873 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
9875 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
9876 TranslateMessage(&msg
);
9877 DispatchMessageW(&msg
);
9882 set_client_site(doc
, FALSE
);
9883 ref
= IHTMLDocument2_Release(doc
);
9884 ok(!ref
|| broken(ref
== 1), /* Vista */
9888 static void test_quirks_mode(void)
9890 run_domtest("<html></html>", check_quirks_mode
);
9891 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
9892 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
9893 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
9898 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
9899 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
9900 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
9903 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
9904 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
9906 run_domtest(doc_str1
, test_doc_elem
);
9907 run_domtest(doc_str1
, test_get_set_attr
);
9908 run_domtest(range_test_str
, test_txtrange
);
9909 run_domtest(range_test2_str
, test_txtrange2
);
9910 if (winetest_interactive
|| ! is_ie_hardened()) {
9911 run_domtest(elem_test_str
, test_elems
);
9912 run_domtest(elem_test2_str
, test_elems2
);
9913 run_domtest(noscript_str
, test_noscript
);
9915 skip("IE running in Enhanced Security Configuration\n");
9917 run_domtest(doc_blank
, test_create_elems
);
9918 run_domtest(doc_blank
, test_defaults
);
9919 run_domtest(doc_blank
, test_null_write
);
9920 run_domtest(emptydiv_str
, test_create_stylesheet
);
9921 run_domtest(indent_test_str
, test_indent
);
9922 run_domtest(cond_comment_str
, test_cond_comment
);
9923 run_domtest(frameset_str
, test_frameset
);
9924 run_domtest(emptydiv_str
, test_docfrag
);
9925 run_domtest(doc_blank
, test_replacechild_elems
);
9926 run_domtest(doctype_str
, test_doctype
);
9930 DestroyWindow(container_hwnd
);