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>
34 #include "mshtml_test.h"
39 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
40 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
42 static const char doc_blank
[] = "<html></html>";
43 static const char doc_str1
[] = "<html><body>test</body></html>";
44 static const char range_test_str
[] =
45 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
46 static const char range_test2_str
[] =
47 "<html><body>abc<hr />123<br /><hr />def</body></html>";
48 static const char elem_test_str
[] =
49 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
50 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
51 "<link id=\"linkid\"></head>"
52 "<body onload=\"Testing()\">text test<!-- a comment -->"
53 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
54 "<label for=\"in\" id=\"labelid\">Label:</label>"
55 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
56 "<button id=\"btnid\"></button>"
57 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
58 "<textarea id=\"X\">text text</textarea>"
59 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
60 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
61 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
62 "<img id=\"imgid\" name=\"WineImg\"/>"
63 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
64 "<form id=\"frm\"></form>"
65 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
67 static const char elem_test2_str
[] =
68 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
69 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
70 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
73 static const char indent_test_str
[] =
74 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
75 static const char cond_comment_str
[] =
76 "<html><head><title>test</title></head><body>"
77 "<!--[if gte IE 4]> <br> <![endif]-->"
79 static const char frameset_str
[] =
80 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
81 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
82 "<frame src=\"about:blank\" id=\"fr3\">"
84 static const char emptydiv_str
[] =
85 "<html><head><title>emptydiv test</title></head>"
86 "<body><div id=\"divid\"></div></body></html>";
87 static const char noscript_str
[] =
88 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
89 "<body><noscript><div>test</div></noscript></body></html>";
90 static const char doctype_str
[] =
92 "<html><head><title>emptydiv test</title></head>"
93 "<body><div id=\"divid\"></div></body></html>";
95 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
96 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
97 static WCHAR wordW
[] = {'w','o','r','d',0};
136 static const IID
* const none_iids
[] = {
141 static const IID
* const doc_node_iids
[] = {
150 &IID_IConnectionPointContainer
,
151 &IID_IInternetHostSecurityManager
,
154 &IID_IProvideClassInfo
,
158 static const IID
* const doc_obj_iids
[] = {
165 &IID_IConnectionPointContainer
,
169 &IID_IProvideClassInfo
,
170 &IID_ITargetContainer
,
174 #define ELEM_IFACES \
176 &IID_IHTMLDOMNode2, \
178 &IID_IHTMLElement2, \
179 &IID_IHTMLElement3, \
180 &IID_IHTMLElement4, \
183 static const IID
* const elem_iids
[] = {
185 &IID_IConnectionPointContainer
,
189 static const IID
* const body_iids
[] = {
191 &IID_IHTMLTextContainer
,
192 &IID_IHTMLBodyElement
,
193 &IID_IConnectionPointContainer
,
197 static const IID
* const anchor_iids
[] = {
199 &IID_IHTMLAnchorElement
,
200 &IID_IConnectionPointContainer
,
204 static const IID
* const input_iids
[] = {
206 &IID_IHTMLInputElement
,
207 &IID_IHTMLInputTextElement
,
208 &IID_IConnectionPointContainer
,
212 static const IID
*const button_iids
[] = {
214 &IID_IHTMLButtonElement
,
215 &IID_IConnectionPointContainer
,
219 static const IID
* const label_iids
[] = {
221 &IID_IHTMLLabelElement
,
222 &IID_IConnectionPointContainer
,
226 static const IID
* const select_iids
[] = {
228 &IID_IHTMLSelectElement
,
229 &IID_IConnectionPointContainer
,
233 static const IID
* const textarea_iids
[] = {
235 &IID_IHTMLTextAreaElement
,
236 &IID_IConnectionPointContainer
,
240 static const IID
* const option_iids
[] = {
242 &IID_IHTMLOptionElement
,
243 &IID_IConnectionPointContainer
,
247 static const IID
* const table_iids
[] = {
252 &IID_IConnectionPointContainer
,
256 static const IID
* const script_iids
[] = {
258 &IID_IHTMLScriptElement
,
259 &IID_IConnectionPointContainer
,
263 static const IID
* const text_iids
[] = {
266 &IID_IHTMLDOMTextNode
,
270 static const IID
* const attr_iids
[] = {
271 &IID_IHTMLDOMAttribute
,
276 static const IID
* const location_iids
[] = {
282 static const IID
* const window_iids
[] = {
287 &IID_IServiceProvider
,
291 static const IID
* const comment_iids
[] = {
293 &IID_IHTMLCommentElement
,
294 &IID_IConnectionPointContainer
,
298 static const IID
* const img_iids
[] = {
300 &IID_IHTMLImgElement
,
301 &IID_IConnectionPointContainer
,
305 static const IID
* const tr_iids
[] = {
308 &IID_IConnectionPointContainer
,
312 static const IID
* const td_iids
[] = {
315 &IID_IConnectionPointContainer
,
319 static const IID
* const frame_iids
[] = {
322 &IID_IHTMLFrameBase2
,
323 &IID_IConnectionPointContainer
,
327 static const IID
* const head_iids
[] = {
329 &IID_IHTMLHeadElement
,
330 &IID_IConnectionPointContainer
,
334 static const IID
* const title_iids
[] = {
336 &IID_IHTMLTitleElement
,
337 &IID_IConnectionPointContainer
,
341 static const IID
* const meta_iids
[] = {
343 &IID_IHTMLMetaElement
,
344 &IID_IConnectionPointContainer
,
348 static const IID
* const link_iids
[] = {
350 &IID_IHTMLLinkElement
,
351 &IID_IConnectionPointContainer
,
355 static const IID
* const object_iids
[] = {
357 &IID_IHTMLObjectElement
,
358 &IID_IHTMLObjectElement2
,
359 /* FIXME: No IConnectionPointContainer */
363 static const IID
* const embed_iids
[] = {
365 &IID_IHTMLEmbedElement
,
366 /* FIXME: No IConnectionPointContainer */
370 static const IID
* const iframe_iids
[] = {
373 &IID_IHTMLFrameBase2
,
374 &IID_IHTMLIFrameElement
,
375 &IID_IHTMLIFrameElement2
,
376 &IID_IConnectionPointContainer
,
380 static const IID
* const form_iids
[] = {
382 &IID_IHTMLFormElement
,
383 &IID_IConnectionPointContainer
,
384 &DIID_DispHTMLFormElement
,
388 static const IID
* const styleelem_iids
[] = {
390 &IID_IHTMLStyleElement
,
391 &IID_IConnectionPointContainer
,
395 static const IID
* const generic_iids
[] = {
397 &IID_IHTMLGenericElement
,
398 &IID_IConnectionPointContainer
,
402 static const IID
* const style_iids
[] = {
413 static const IID
* const cstyle_iids
[] = {
417 &IID_IHTMLCurrentStyle
,
418 &IID_IHTMLCurrentStyle2
,
419 &IID_IHTMLCurrentStyle3
,
423 static const IID
* const img_factory_iids
[] = {
427 &IID_IHTMLImageElementFactory
,
437 static const elem_type_info_t elem_type_infos
[] = {
438 {"", none_iids
, NULL
},
439 {"HTML", elem_iids
, NULL
},
440 {"HEAD", head_iids
, &DIID_DispHTMLHeadElement
},
441 {"TITLE", title_iids
, &DIID_DispHTMLTitleElement
},
442 {"BODY", body_iids
, &DIID_DispHTMLBody
},
443 {"A", anchor_iids
, &DIID_DispHTMLAnchorElement
},
444 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
445 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
446 {"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
},
447 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
448 {"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
},
449 {"BLOCKQUOTE",elem_iids
, NULL
},
450 {"P", elem_iids
, NULL
},
451 {"BR", elem_iids
, NULL
},
452 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
453 {"TBODY", elem_iids
, NULL
},
454 {"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
},
455 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
456 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
457 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
458 {"IMG", img_iids
, &DIID_DispHTMLImg
},
459 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
460 {"TD", td_iids
, &DIID_DispHTMLTableCell
},
461 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
},
462 {"FORM", form_iids
, &DIID_DispHTMLFormElement
},
463 {"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
},
464 {"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
},
465 {"EMBED", embed_iids
, &DIID_DispHTMLEmbed
},
466 {"DIV", elem_iids
, NULL
},
467 {"META", meta_iids
, &DIID_DispHTMLMetaElement
},
468 {"NOSCRIPT", elem_iids
, NULL
/*&DIID_DispHTMLNoShowElement*/},
469 {"LINK", link_iids
, &DIID_DispHTMLLinkElement
},
470 {"LABEL", label_iids
, &DIID_DispHTMLLabelElement
},
471 {"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
}
474 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
477 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
478 return lstrcmpA(stra
, buf
);
481 static BSTR
a2bstr(const char *str
)
489 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
490 ret
= SysAllocStringLen(NULL
, len
);
491 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
496 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
498 IUnknown
*unk1
, *unk2
;
503 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
504 IUnknown_Release(unk1
);
505 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
506 IUnknown_Release(unk2
);
511 static IHTMLDocument2
*create_document(void)
514 IHTMLDocument5
*doc5
;
517 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
518 &IID_IHTMLDocument2
, (void**)&doc
);
519 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
523 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
525 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
526 IHTMLDocument2_Release(doc
);
530 IHTMLDocument5_Release(doc5
);
534 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
535 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
540 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
541 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
545 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
546 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
548 const IID
* const *piid
;
552 for(piid
= iids
; *piid
; piid
++) {
553 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
554 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid
), hres
);
556 IUnknown_Release(unk
);
560 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
561 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
566 unk
= (void*)0xdeadbeef;
567 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
568 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08x, expected E_NOINTERFACE\n", hres
);
569 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
572 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
573 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
575 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
582 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
583 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
584 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
586 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
587 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
589 if(SUCCEEDED(hres
)) {
592 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
593 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
595 *iid
= type_attr
->guid
;
599 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
600 ITypeInfo_Release(typeinfo
);
603 IDispatchEx_Release(dispex
);
607 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
608 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const char *val
)
610 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
611 DISPPARAMS dp
= {NULL
,NULL
,0,0};
616 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
617 IDispatchEx_Release(dispex
);
618 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08x\n", hres
);
620 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
621 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), val
);
625 #define test_disp(u,id,v) _test_disp(__LINE__,u,id,v)
626 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const char *val
)
630 if(_test_get_dispid(line
, unk
, &iid
))
631 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
), "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
634 _test_disp_value(line
, unk
, val
);
637 #define test_disp2(u,id,id2,v) _test_disp2(__LINE__,u,id,id2,v)
638 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const char *val
)
642 if(_test_get_dispid(line
, unk
, &iid
))
643 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(IsEqualGUID(&iid
, diid2
)),
644 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
647 _test_disp_value(line
, unk
, val
);
650 #define test_class_info(u) _test_class_info(__LINE__,u)
651 static void _test_class_info(unsigned line
, IUnknown
*unk
)
653 IProvideClassInfo
*classinfo
;
658 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&classinfo
);
659 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo interface: %08x\n", hres
);
663 hres
= IProvideClassInfo_GetClassInfo(classinfo
, &typeinfo
);
664 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08x\n", hres
);
667 IProvideClassInfo_Release(classinfo
);
671 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
672 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
675 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, &CLSID_HTMLDocument
),
676 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
677 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
678 "unexpected typekind %d\n", type_attr
->typekind
);
679 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
682 ITypeInfo_Release(typeinfo
);
683 IProvideClassInfo_Release(classinfo
);
686 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
687 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const char *name
, VARIANT
*val
)
689 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
690 DISPPARAMS dp
= {val
, NULL
, 1, 0};
697 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
699 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
701 memset(&ei
, 0, sizeof(ei
));
702 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
703 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
707 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
708 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
713 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
714 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08x\n", hres
);
718 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
719 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
724 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
725 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08x\n", hres
);
729 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
730 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
735 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
736 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08x\n", hres
);
740 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
741 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
746 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
747 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08x\n", hres
);
751 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
752 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
754 IHTMLDocument3
*doc3
;
757 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
758 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
763 #define get_node_iface(u) _get_node_iface(__LINE__,u)
764 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
769 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
770 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08x\n", hres
);
774 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
775 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
780 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
781 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08x\n", hres
);
785 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
786 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
791 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
792 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08x\n", hres
);
796 #define get_img_iface(u) _get_img_iface(__LINE__,u)
797 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
799 IHTMLImgElement
*img
;
802 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
803 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
807 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
808 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
810 IHTMLAnchorElement
*anchor
;
813 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
814 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08x\n", hres
);
818 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
819 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
821 IHTMLTextAreaElement
*textarea
;
824 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
825 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08x\n", hres
);
829 #define get_select_iface(u) _get_select_iface(__LINE__,u)
830 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
832 IHTMLSelectElement
*select
;
835 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
836 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08x\n", hres
);
840 #define get_form_iface(u) _get_form_iface(__LINE__,u)
841 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
843 IHTMLFormElement
*form
;
846 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
847 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08x\n", hres
);
851 #define get_text_iface(u) _get_text_iface(__LINE__,u)
852 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
854 IHTMLDOMTextNode
*text
;
857 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
858 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08x\n", hres
);
862 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
863 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
865 IHTMLCommentElement
*comment
;
868 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
869 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08x\n", hres
);
873 #define get_object_iface(u) _get_object_iface(__LINE__,u)
874 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
876 IHTMLObjectElement
*obj
;
879 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
880 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08x\n", hres
);
884 #define get_style_iface(u) _get_style_iface(__LINE__,u)
885 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
887 IHTMLStyleElement
*obj
;
890 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
891 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08x\n", hres
);
895 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
896 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
898 IHTMLMetaElement
*ret
;
901 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
902 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08x\n", hres
);
906 #define get_link_iface(u) _get_link_iface(__LINE__,u)
907 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
909 IHTMLLinkElement
*ret
;
912 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
913 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08x\n", hres
);
917 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
918 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
920 IHTMLIFrameElement2
*ret
;
923 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
924 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08x\n", hres
);
928 #define get_button_iface(u) _get_button_iface(__LINE__,u)
929 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
931 IHTMLButtonElement
*ret
;
934 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
935 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08x\n", hres
);
939 #define get_label_iface(u) _get_label_iface(__LINE__,u)
940 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
942 IHTMLLabelElement
*ret
;
945 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
946 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08x\n", hres
);
950 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
951 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
953 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
957 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
958 IHTMLDOMNode_Release(node
);
959 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
960 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), exname
);
965 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
966 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
968 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
969 IDispatch
*disp
= (void*)0xdeadbeef;
970 IHTMLDocument2
*doc
= NULL
;
973 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
974 IHTMLDOMNode2_Release(node
);
975 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08x\n", hres
);
978 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
979 IDispatch_Release(disp
);
980 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
986 #define get_doc_window(d) _get_doc_window(__LINE__,d)
987 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
989 IHTMLWindow2
*window
;
993 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
994 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
995 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1000 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1001 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1003 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1004 IHTMLDOMNode
*ret
= NULL
;
1007 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1008 IHTMLDOMNode_Release(node
);
1009 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08x\n", hres
);
1010 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1016 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1017 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
1019 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1023 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1024 IHTMLElement_Release(elem
);
1025 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
1026 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), extag
);
1031 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1032 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1034 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1035 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1037 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
)
1038 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, "[object]");
1041 #define get_node_type(n) _get_node_type(__LINE__,n)
1042 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1044 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1048 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1049 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
1051 IHTMLDOMNode_Release(node
);
1056 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1057 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1059 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1060 IHTMLDOMChildrenCollection
*col
= NULL
;
1064 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1065 IHTMLDOMNode_Release(node
);
1066 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
1070 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1071 IDispatch_Release(disp
);
1072 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
1077 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1078 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1080 IHTMLDOMNode
*node
= NULL
;
1084 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1085 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1087 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1088 IDispatch_Release(disp
);
1093 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1094 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const char *name
, const char *exval
)
1100 VariantInit(&value
);
1103 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1105 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1108 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1109 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1111 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1114 VariantClear(&value
);
1117 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1118 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const char *parent_tag
)
1120 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1121 IHTMLElement
*off_parent
;
1125 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1126 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
1128 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1129 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
1131 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1132 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
1134 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1135 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08x\n", hres
);
1137 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1138 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08x\n", hres
);
1140 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1141 IHTMLElement_Release(off_parent
);
1143 IHTMLElement_Release(elem
);
1146 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1147 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1149 LONG l
= 0xdeadbeef;
1152 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1153 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08x\n", hres
);
1154 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %d, expected %d\n", l
, index
);
1157 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1158 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1160 IHTMLWindow2
*window
;
1161 IHTMLDocument2
*ret
;
1164 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1165 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
1167 hres
= IHTMLWindow2_get_document(window
, &ret
);
1168 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1169 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1174 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1175 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const char *exname
)
1180 hres
= IHTMLWindow2_get_name(window
, &name
);
1181 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1183 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1185 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1186 SysFreeString(name
);
1189 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1190 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const char *name
)
1196 hres
= IHTMLWindow2_put_name(window
, str
);
1198 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1200 _test_window_name(line
, window
, name
);
1203 #define test_window_status(d) _test_window_status(__LINE__,d)
1204 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1209 status
= (void*)0xdeadbeef;
1210 hres
= IHTMLWindow2_get_status(window
, &status
);
1211 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08x\n", hres
);
1212 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1213 SysFreeString(status
);
1216 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1217 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const char *status
)
1222 str
= a2bstr(status
);
1223 hres
= IHTMLWindow2_put_status(window
, str
);
1225 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08x\n", hres
);
1228 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1229 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1234 hres
= IHTMLWindow2_get_length(window
, &length
);
1235 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1236 ok_(__FILE__
,line
)(length
== exlen
, "length = %d, expected %d\n", length
, exlen
);
1239 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1240 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1242 IHTMLFrameBase2
*base2
;
1243 IHTMLWindow2
*window
;
1246 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1247 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
1250 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1251 IHTMLFrameBase2_Release(base2
);
1252 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
1253 ok(window
!= NULL
, "contentWindow = NULL\n");
1258 static void test_get_set_attr(IHTMLDocument2
*doc
)
1261 IHTMLDocument3
*doc3
;
1266 /* grab an element to test with */
1267 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1268 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
1270 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1271 IHTMLDocument3_Release(doc3
);
1272 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1274 /* get a non-present attribute */
1275 bstr
= a2bstr("notAnAttribute");
1276 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1277 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1278 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1280 SysFreeString(bstr
);
1282 /* get a present attribute */
1283 bstr
= a2bstr("scrollHeight");
1284 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1285 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1286 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1288 SysFreeString(bstr
);
1290 /* create a new BSTR attribute */
1291 bstr
= a2bstr("newAttribute");
1293 V_VT(&val
) = VT_BSTR
;
1294 V_BSTR(&val
) = a2bstr("the value");
1295 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1296 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1299 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1300 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1301 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1302 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
)));
1305 /* overwrite the attribute with a BOOL */
1306 V_VT(&val
) = VT_BOOL
;
1307 V_BOOL(&val
) = VARIANT_TRUE
;
1308 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1309 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1312 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1313 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1314 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1315 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1318 SysFreeString(bstr
);
1320 /* case-insensitive */
1321 bstr
= a2bstr("newattribute");
1322 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1323 ok(hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
1324 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1325 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1327 SysFreeString(bstr
);
1329 IHTMLElement_Release(elem
);
1332 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1333 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1336 IHTMLDocument3
*doc3
;
1339 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1340 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
1341 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1342 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
1343 IHTMLDocument3_Release(doc3
);
1348 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1349 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1351 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1355 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1356 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1357 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), exhref
);
1360 _test_disp_value(line
, unk
, exhref
);
1363 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1364 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const char *exhref
)
1366 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1370 str
= a2bstr(exhref
);
1371 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1372 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
1375 _test_disp_value(line
, unk
, exhref
);
1378 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1379 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1381 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1385 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1386 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1388 ok_(__FILE__
,line
)(!strcmp_wa(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), exrel
);
1390 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1394 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1395 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const char *exrel
)
1397 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1401 str
= a2bstr(exrel
);
1402 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1403 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
1407 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1408 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const char *target
)
1410 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1414 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1415 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08x\n", hres
);
1417 ok_(__FILE__
,line
)(!strcmp_wa(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), target
);
1419 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1423 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1424 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const char *target
)
1426 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1430 str
= target
? a2bstr(target
) : NULL
;
1431 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1432 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08x\n", hres
);
1436 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1437 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const char *name
)
1439 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1443 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1444 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1446 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
1448 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1452 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1453 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
1455 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1459 str
= name
? a2bstr(name
) : NULL
;
1460 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1461 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1464 _test_anchor_name(line
, unk
, name
);
1467 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1468 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const char *hostname
)
1470 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1474 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1475 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1477 ok_(__FILE__
,line
)(!strcmp_wa(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), hostname
);
1479 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1483 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1484 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const char *search
, BOOL allowbroken
)
1486 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1490 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1491 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08x\n", hres
);
1492 if ( ! str
&& allowbroken
)
1493 win_skip("skip ie6 incorrect behavior\n");
1495 ok_(__FILE__
,line
)(!strcmp_wa(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), search
);
1497 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1501 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1502 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const char *search
)
1504 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1508 str
= search
? a2bstr(search
) : NULL
;
1509 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1510 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08x\n", hres
);
1514 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1515 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const char *exhash
)
1517 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1521 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1522 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08x\n", hres
);
1524 ok_(__FILE__
,line
)(!strcmp_wa(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), exhash
);
1526 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1530 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1531 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1536 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1537 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
1538 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1539 SysFreeString(bstr
);
1542 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1543 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
1548 bstr
= a2bstr(text
);
1549 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1550 SysFreeString(bstr
);
1551 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
1553 _test_option_text(line
, option
, text
);
1556 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1557 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1562 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1563 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1564 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1565 SysFreeString(bstr
);
1568 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1569 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
1574 bstr
= a2bstr(value
);
1575 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1576 SysFreeString(bstr
);
1577 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1579 _test_option_value(line
, option
, value
);
1582 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1583 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1585 VARIANT_BOOL b
= 0x100;
1588 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1589 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08x\n", hres
);
1590 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1593 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1594 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1598 hres
= IHTMLOptionElement_put_selected(option
, b
);
1599 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08x\n", hres
);
1600 _test_option_selected(line
, option
, b
);
1603 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1604 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1606 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1607 BSTR value
= (void*)0xdeadbeef;
1610 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1611 IHTMLTextAreaElement_Release(textarea
);
1612 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08x\n", hres
);
1614 ok_(__FILE__
,line
)(!strcmp_wa(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), exval
);
1616 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1617 SysFreeString(value
);
1620 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1621 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const char *value
)
1623 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1624 BSTR tmp
= a2bstr(value
);
1627 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1628 IHTMLTextAreaElement_Release(textarea
);
1629 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08x\n", hres
);
1632 _test_textarea_value(line
, unk
, value
);
1635 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1636 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1638 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1639 VARIANT_BOOL b
= 0x100;
1642 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
1643 IHTMLTextAreaElement_Release(textarea
);
1644 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08x\n", hres
);
1645 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
1648 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
1649 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1651 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1654 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
1655 IHTMLTextAreaElement_Release(textarea
);
1656 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08x\n", hres
);
1658 _test_textarea_readonly(line
, unk
, b
);
1661 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
1662 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
1664 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1665 BSTR type
= (void*)0xdeadbeef;
1668 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
1669 IHTMLTextAreaElement_Release(textarea
);
1670 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1671 ok_(__FILE__
,line
)(!strcmp_wa(type
, "textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
1672 SysFreeString(type
);
1675 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
1676 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
1678 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1679 IHTMLFormElement
*form
;
1682 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
1683 IHTMLTextAreaElement_Release(textarea
);
1684 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
1689 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
1690 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const char *extext
)
1692 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1696 text
= a2bstr(extext
);
1697 hres
= IHTMLCommentElement_get_text(comment
, &text
);
1698 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
1699 ok_(__FILE__
,line
)(!strcmp_wa(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), extext
);
1701 IHTMLCommentElement_Release(comment
);
1702 SysFreeString(text
);
1705 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
1706 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
1708 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
1709 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
1710 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
1711 IHTMLDOMAttribute
*attr
;
1712 BSTR name
= a2bstr("test");
1716 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1717 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1718 ok(attr
== NULL
, "attr != NULL\n");
1722 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
1723 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
1725 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
1726 ok(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
1727 ok(attr
!= NULL
, "attr == NULL\n");
1729 IHTMLDOMAttribute_Release(attr
);
1730 IHTMLCommentElement_Release(comment
);
1731 IHTMLElement_Release(elem
);
1732 IHTMLElement4_Release(elem4
);
1733 SysFreeString(name
);
1736 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
1737 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
1739 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
1744 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
1745 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08x\n", hres
);
1746 ok_(__FILE__
,line
)(l
== exl
, "vspace=%d, expected %d\n", l
, exl
);
1747 IHTMLObjectElement_Release(object
);
1750 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
1751 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
1753 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1757 str
= (void*)0xdeadbeef;
1758 hres
= IHTMLObjectElement_get_name(object
, &str
);
1759 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
1761 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), exname
);
1763 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
1765 IHTMLObjectElement_Release(object
);
1768 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
1769 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
1771 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
1776 hres
= IHTMLObjectElement_put_name(object
, str
);
1777 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
1779 IHTMLObjectElement_Release(object
);
1781 _test_object_name(line
, elem
, name
);
1784 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
1785 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
1786 const char *txt
, const char *val
)
1788 IHTMLOptionElementFactory
*factory
;
1789 IHTMLOptionElement
*option
;
1790 IHTMLWindow2
*window
;
1791 VARIANT text
, value
, empty
;
1794 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1795 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1797 hres
= IHTMLWindow2_get_Option(window
, &factory
);
1798 IHTMLWindow2_Release(window
);
1799 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
1801 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, "[object]");
1803 V_VT(&text
) = VT_BSTR
;
1804 V_BSTR(&text
) = a2bstr(txt
);
1805 V_VT(&value
) = VT_BSTR
;
1806 V_BSTR(&value
) = a2bstr(val
);
1807 V_VT(&empty
) = VT_EMPTY
;
1809 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
1810 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1812 IHTMLOptionElementFactory_Release(factory
);
1813 VariantClear(&text
);
1814 VariantClear(&value
);
1816 _test_option_text(line
, option
, txt
);
1817 _test_option_value(line
, option
, val
);
1818 _test_option_selected(line
, option
, VARIANT_FALSE
);
1823 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
1824 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1829 hres
= IHTMLImgElement_get_width(img
, &found
);
1830 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08x\n", hres
);
1831 ok_(__FILE__
,line
) (found
== exp
, "width=%d\n", found
);
1834 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
1835 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
1839 hres
= IHTMLImgElement_put_width(img
, width
);
1840 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
1842 _test_img_width(line
, img
, width
);
1845 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
1846 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
1851 hres
= IHTMLImgElement_get_height(img
, &found
);
1852 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08x\n", hres
);
1853 ok_(__FILE__
,line
) (found
== exp
, "height=%d\n", found
);
1856 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
1857 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
1861 hres
= IHTMLImgElement_put_height(img
, height
);
1862 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
1864 _test_img_height(line
, img
, height
);
1867 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
1868 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
1869 LONG wdth
, LONG hght
)
1871 IHTMLImageElementFactory
*factory
;
1872 IHTMLImgElement
*img
;
1873 IHTMLWindow2
*window
;
1874 VARIANT width
, height
;
1878 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1879 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1881 hres
= IHTMLWindow2_get_Image(window
, &factory
);
1882 IHTMLWindow2_Release(window
);
1883 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08x\n", hres
);
1885 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
1886 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, "[object]");
1889 snprintf(buf
, 16, "%d", wdth
);
1890 V_VT(&width
) = VT_BSTR
;
1891 V_BSTR(&width
) = a2bstr(buf
);
1893 V_VT(&width
) = VT_EMPTY
;
1898 snprintf(buf
, 16, "%d", hght
);
1899 V_VT(&height
) = VT_BSTR
;
1900 V_BSTR(&height
) = a2bstr(buf
);
1902 V_VT(&height
) = VT_EMPTY
;
1906 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
1907 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
1909 IHTMLImageElementFactory_Release(factory
);
1910 VariantClear(&width
);
1911 VariantClear(&height
);
1913 if(SUCCEEDED(hres
)) {
1914 _test_img_width(line
, img
, wdth
);
1915 _test_img_height(line
, img
, hght
);
1922 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
1923 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
1925 LONG len
= 0xdeadbeef;
1928 hres
= IHTMLSelectElement_get_length(select
, &len
);
1929 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1930 ok_(__FILE__
,line
) (len
== length
, "len=%d, expected %d\n", len
, length
);
1933 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
1934 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
1936 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
1939 hres
= IHTMLSelectElement_put_length(select
, length
);
1940 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08x\n", hres
);
1941 _test_select_length(line
, select
, length
);
1942 IHTMLSelectElement_Release(select
);
1945 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
1946 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1948 LONG idx
= 0xdeadbeef;
1951 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
1952 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1953 ok_(__FILE__
,line
) (idx
== index
, "idx=%d, expected %d\n", idx
, index
);
1956 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
1957 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
1961 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
1962 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
1963 _test_select_selidx(line
, select
, index
);
1966 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
1967 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
1972 hres
= IHTMLSelectElement_get_value(select
, &val
);
1973 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1975 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
1977 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
1981 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
1982 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
1988 hres
= IHTMLSelectElement_put_value(select
, bstr
);
1989 SysFreeString(bstr
);
1990 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
1993 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
1994 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
1999 hres
= IHTMLSelectElement_get_type(select
, &type
);
2000 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
2001 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
2002 SysFreeString(type
);
2005 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2006 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2008 VARIANT_BOOL b
= 100;
2011 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2012 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08x\n", hres
);
2013 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2016 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2017 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2021 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2022 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08x\n", hres
);
2024 _test_select_multiple(line
, select
, val
);
2027 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2028 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
2033 hres
= IHTMLTxtRange_get_text(range
, &text
);
2034 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
2037 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2038 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), extext
);
2040 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2043 SysFreeString(text
);
2047 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2048 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2052 hres
= IHTMLTxtRange_collapse(range
, b
);
2053 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
2054 _test_range_text(line
, range
, NULL
);
2057 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2058 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2059 VARIANT_BOOL exb
, const char *extext
)
2061 VARIANT_BOOL b
= 0xe0e0;
2064 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2065 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
2066 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2067 _test_range_text(line
, range
, extext
);
2070 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2071 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2073 LONG c
= 0xdeadbeef;
2076 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2077 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2078 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2079 _test_range_text(line
, range
, NULL
);
2082 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2083 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2084 LPWSTR unit
, LONG cnt
, LONG excnt
)
2086 LONG c
= 0xdeadbeef;
2089 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2090 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2091 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2094 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2095 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2097 LONG c
= 0xdeadbeef;
2100 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2101 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
2102 ok_(__FILE__
,line
) (c
== excnt
, "count=%d, expected %d\n", c
, excnt
);
2105 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2106 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
2109 BSTR bstr
= a2bstr(text
);
2111 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2112 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
2113 SysFreeString(bstr
);
2114 _test_range_text(line
, range
, NULL
);
2117 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2118 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2124 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2125 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2126 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2129 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2130 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2136 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2137 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
2138 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2141 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2142 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
2143 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2146 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2147 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2151 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2152 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2157 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2158 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
2160 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2162 IHTMLElement_Release(elem
);
2165 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2166 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2168 VARIANT name
, index
;
2173 V_VT(&index
) = VT_EMPTY
;
2174 V_VT(&name
) = VT_I4
;
2176 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2177 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08x\n", hres
);
2178 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2180 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2181 IDispatch_Release(disp
);
2185 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2186 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2187 const elem_type_t
*elem_types
, LONG exlen
)
2189 IHTMLElementCollection
*col
;
2190 IEnumVARIANT
*enum_var
;
2195 VARIANT name
, index
, v
, vs
[5];
2196 IDispatch
*disp
, *disp2
;
2199 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2200 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
2202 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, "[object]");
2204 hres
= IHTMLElementCollection_get_length(col
, &len
);
2205 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
2206 ok_(__FILE__
,line
) (len
== exlen
, "len=%d, expected %d\n", len
, exlen
);
2211 V_VT(&index
) = VT_EMPTY
;
2213 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2214 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08x\n", hres
);
2216 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2217 IUnknown_Release(enum_unk
);
2218 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
2220 for(i
=0; i
<len
; i
++) {
2221 V_VT(&name
) = VT_I4
;
2223 disp
= (void*)0xdeadbeef;
2224 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2225 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2226 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2227 if(FAILED(hres
) || !disp
)
2230 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2233 V_VT(&name
) = VT_UINT
;
2235 disp2
= (void*)0xdeadbeef;
2236 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2237 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
2238 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2240 IDispatch_Release(disp2
);
2244 V_VT(&v
) = VT_ERROR
;
2245 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2246 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08x\n", hres
);
2248 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %d\n", fetched
);
2249 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2250 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2251 IDispatch_Release(V_DISPATCH(&v
));
2253 IDispatch_Release(disp
);
2256 fetched
= 0xdeadbeef;
2258 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2259 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
2260 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2261 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2263 hres
= IEnumVARIANT_Reset(enum_var
);
2264 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2266 fetched
= 0xdeadbeef;
2268 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2269 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
2270 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %d\n", fetched
);
2271 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2273 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2274 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08x\n", hres
);
2276 memset(vs
, 0, sizeof(vs
));
2278 hres
= IEnumVARIANT_Next(enum_var
, sizeof(vs
)/sizeof(*vs
), vs
, &fetched
);
2279 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08x\n", hres
);
2280 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %d\n", fetched
);
2282 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2283 IDispatch_Release(V_DISPATCH(vs
));
2286 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2287 IDispatch_Release(V_DISPATCH(vs
+1));
2290 hres
= IEnumVARIANT_Reset(enum_var
);
2291 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08x\n", hres
);
2293 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2294 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
2296 IEnumVARIANT_Release(enum_var
);
2298 V_VT(&name
) = VT_I4
;
2300 disp
= (void*)0xdeadbeef;
2301 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2302 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
2303 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2305 V_VT(&name
) = VT_I4
;
2307 disp
= (void*)0xdeadbeef;
2308 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2309 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
2310 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2312 IHTMLElementCollection_Release(col
);
2315 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2316 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2318 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2322 hres
= IHTMLElement_get_all(elem
, &disp
);
2323 IHTMLElement_Release(elem
);
2324 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2326 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2327 IDispatch_Release(disp
);
2330 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2331 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2333 IHTMLElementCollection
*col
;
2336 hres
= IHTMLDocument2_get_all(doc
, &col
);
2337 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08x\n", hres
);
2339 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2340 IHTMLElementCollection_Release(col
);
2343 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2344 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2346 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2347 IHTMLElementCollection
*col
= NULL
;
2348 elem_type_t
*types
= NULL
;
2353 tmp
= a2bstr(elem_type_infos
[type
].tag
);
2354 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2356 IHTMLElement2_Release(elem
);
2357 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
2358 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2361 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2362 for(i
=0; i
<exlen
; i
++)
2366 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2368 HeapFree(GetProcessHeap(), 0, types
);
2371 *ret
= get_elem_col_item_idx(col
, 0);
2372 IHTMLElementCollection_Release(col
);
2375 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2376 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
2381 hres
= IHTMLElement_get_innerText(elem
, &text
);
2382 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
2384 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
2385 wine_dbgstr_w(text
), extext
);
2387 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2388 SysFreeString(text
);
2391 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2392 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
2394 IHTMLDOMChildrenCollection
*col
;
2399 hres
= IHTMLElement_put_innerText(elem
, str
);
2400 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
2403 _test_elem_innertext(line
, elem
, text
);
2406 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2407 ok(col
!= NULL
, "col == NULL\n");
2409 LONG length
= 0, type
;
2412 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
2413 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2414 ok(length
== 1, "length = %d\n", length
);
2416 node
= _get_child_item(line
, col
, 0);
2417 ok(node
!= NULL
, "node == NULL\n");
2419 type
= _get_node_type(line
, (IUnknown
*)node
);
2420 ok(type
== 3, "type=%d\n", type
);
2421 IHTMLDOMNode_Release(node
);
2424 IHTMLDOMChildrenCollection_Release(col
);
2429 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
2430 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2432 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2436 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
2437 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08x\n", hres
);
2439 ok_(__FILE__
,line
)(!strcmp_wa(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
2441 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
2443 IHTMLElement_Release(elem
);
2444 SysFreeString(html
);
2447 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
2448 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const char *inner_html
)
2450 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2454 html
= a2bstr(inner_html
);
2455 hres
= IHTMLElement_put_innerHTML(elem
, html
);
2456 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
2458 IHTMLElement_Release(elem
);
2459 SysFreeString(html
);
2462 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
2463 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2465 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2469 html
= a2bstr(outer_html
);
2470 hres
= IHTMLElement_put_outerHTML(elem
, html
);
2471 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08x\n", hres
);
2473 IHTMLElement_Release(elem
);
2474 SysFreeString(html
);
2477 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
2478 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const char *outer_html
)
2480 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2484 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
2485 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08x\n", hres
);
2486 ok_(__FILE__
,line
)(!strcmp_wa(html
, outer_html
), "outerHTML = '%s', expected '%s'\n", wine_dbgstr_w(html
), outer_html
);
2488 IHTMLElement_Release(elem
);
2489 SysFreeString(html
);
2492 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
2493 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
2499 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
2500 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08x\n", hres
);
2501 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
2504 #define get_first_child(n) _get_first_child(__LINE__,n)
2505 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
2507 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2508 IHTMLDOMNode
*child
= NULL
;
2511 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
2512 IHTMLDOMNode_Release(node
);
2513 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
2518 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
2519 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2521 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2522 VARIANT_BOOL b
= 0xdead;
2525 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
2526 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
2527 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
2529 IHTMLDOMNode_Release(node
);
2532 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
2533 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
2535 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2536 IHTMLDOMNode
*parent
;
2539 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
2540 IHTMLDOMNode_Release(node
);
2541 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
2546 #define node_get_next(u) _node_get_next(__LINE__,u)
2547 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
2549 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2553 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
2554 IHTMLDOMNode_Release(node
);
2555 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08x\n", hres
);
2560 #define node_get_prev(u) _node_get_prev(__LINE__,u)
2561 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
2563 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
2567 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
2568 IHTMLDOMNode_Release(node
);
2569 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08x\n", hres
);
2574 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
2575 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
2577 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2578 IHTMLElement
*parent
;
2581 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
2582 IHTMLElement_Release(elem
);
2583 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2588 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
2589 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
2591 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2592 VARIANT_BOOL disabled
= 100;
2596 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
2597 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2598 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2599 IHTMLElement3_Release(elem3
);
2602 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
2603 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2605 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
2609 hres
= IHTMLElement3_put_disabled(elem3
, b
);
2610 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2612 IHTMLElement3_Release(elem3
);
2613 _test_elem3_get_disabled(line
, unk
, b
);
2616 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
2617 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
2619 VARIANT_BOOL disabled
= 100;
2622 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
2623 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2624 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
2626 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
2629 static void test_select_remove(IHTMLSelectElement
*select
)
2633 hres
= IHTMLSelectElement_remove(select
, 3);
2634 ok(hres
== S_OK
, "remove failed: %08x, expected S_OK\n", hres
);
2635 test_select_length(select
, 2);
2637 hres
= IHTMLSelectElement_remove(select
, -1);
2639 ok(hres
== E_INVALIDARG
, "remove failed: %08x, expected E_INVALIDARG\n", hres
);
2640 test_select_length(select
, 2);
2642 hres
= IHTMLSelectElement_remove(select
, 0);
2643 ok(hres
== S_OK
, "remove failed:%08x\n", hres
);
2644 test_select_length(select
, 1);
2647 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
2648 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
2650 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2654 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
2655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
2656 ok_(__FILE__
,line
)(length
== l
, "length = %d, expected %d\n", length
, l
);
2657 IHTMLDOMTextNode_Release(text
);
2660 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
2661 static void _test_text_data(unsigned line
, IUnknown
*unk
, const char *exdata
)
2663 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2667 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
2668 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2669 ok_(__FILE__
,line
)(!strcmp_wa(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), exdata
);
2670 IHTMLDOMTextNode_Release(text
);
2674 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
2675 static void _set_text_data(unsigned line
, IUnknown
*unk
, const char *data
)
2677 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
2678 BSTR str
= a2bstr(data
);
2681 hres
= IHTMLDOMTextNode_put_data(text
, str
);
2682 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08x\n", hres
);
2683 IHTMLDOMTextNode_Release(text
);
2687 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
2688 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
2692 hres
= IHTMLSelectElement_put_disabled(select
, b
);
2693 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2695 _test_select_get_disabled(line
, select
, b
);
2698 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
2699 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
2701 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2702 IHTMLTextContainer
*txtcont
;
2703 LONG l
= -1, l2
= -1;
2706 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
2707 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
2708 IHTMLElement2_Release(elem
);
2710 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2711 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2713 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
2714 IHTMLTextContainer_Release(txtcont
);
2715 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %d\n", l2
);
2716 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %d, expected %d\n", l2
, l
);
2721 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
2722 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
2724 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2725 IHTMLTextContainer
*txtcont
;
2726 LONG l
= -1, l2
= -1;
2729 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
2730 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
2731 IHTMLElement2_Release(elem
);
2733 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2734 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2736 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
2737 IHTMLTextContainer_Release(txtcont
);
2738 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %d\n", l2
);
2739 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %d, expected %d\n", l2
, l
);
2744 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
2745 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
2747 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2748 IHTMLTextContainer
*txtcont
;
2749 LONG l
= -1, l2
= -1;
2752 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
2753 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2754 IHTMLElement2_Release(elem
);
2756 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2757 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2759 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
2760 IHTMLTextContainer_Release(txtcont
);
2761 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %d\n", l2
);
2762 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %d, expected %d\n", l2
, l
);
2767 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
2768 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
2770 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2771 IHTMLTextContainer
*txtcont
;
2772 LONG l
= -1, l2
= -1;
2775 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
2776 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
2778 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
2779 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
2780 IHTMLElement2_Release(elem
);
2782 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
2783 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
2785 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
2786 IHTMLTextContainer_Release(txtcont
);
2787 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %d\n", l2
);
2788 ok(l
== l2
, "unexpected left %d, expected %d\n", l2
, l
);
2791 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
2792 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
, const char *broken_src
)
2794 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2798 hres
= IHTMLImgElement_get_src(img
, &src
);
2799 IHTMLImgElement_Release(img
);
2800 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
2801 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
) || (broken_src
&& broken(!strcmp_wa(src
, broken_src
))),
2802 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
2806 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
2807 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
2809 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2814 hres
= IHTMLImgElement_put_src(img
, tmp
);
2815 IHTMLImgElement_Release(img
);
2817 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
2820 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
2821 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
2823 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2827 hres
= IHTMLImgElement_get_alt(img
, &alt
);
2828 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2830 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", wine_dbgstr_w(alt
));
2832 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
2836 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
2837 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
2839 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2844 hres
= IHTMLImgElement_put_alt(img
, tmp
);
2845 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
2848 _test_img_alt(line
, unk
, alt
);
2851 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
2852 static void _test_img_align(unsigned line
, IUnknown
*unk
, const char *align
)
2854 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2858 tmp
= a2bstr(align
);
2859 hres
= IHTMLImgElement_put_align(img
, tmp
);
2860 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2863 hres
= IHTMLImgElement_get_align(img
, &tmp
);
2864 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08x\n", hres
);
2865 ok_(__FILE__
,line
) (!strcmp_wa(tmp
, align
), "Expect %s, got %s\n", align
, wine_dbgstr_w(tmp
));
2869 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
2870 static void _test_img_name(unsigned line
, IUnknown
*unk
, const char *pValue
)
2872 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2876 hres
= IHTMLImgElement_get_name(img
, &sName
);
2877 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08x\n", hres
);
2878 ok_(__FILE__
,line
) (!strcmp_wa (sName
, pValue
), "expected '%s' got '%s'\n", pValue
, wine_dbgstr_w(sName
));
2879 IHTMLImgElement_Release(img
);
2880 SysFreeString(sName
);
2883 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
2884 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
2886 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
2887 VARIANT_BOOL b
= 100;
2890 hres
= IHTMLImgElement_get_complete(img
, &b
);
2891 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08x\n", hres
);
2892 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
2893 IHTMLImgElement_Release(img
);
2896 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
2897 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
2899 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
2900 VARIANT_BOOL b
= 100;
2903 hres
= IHTMLImgElement_put_isMap(img
, v
);
2904 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08x\n", hres
);
2906 hres
= IHTMLImgElement_get_isMap(img
, &b
);
2907 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08x\n", hres
);
2908 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
2910 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
2911 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08x, expected E_INVALIDARG\n", hres
);
2912 IHTMLImgElement_Release(img
);
2915 static void test_dynamic_properties(IHTMLElement
*elem
)
2917 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
2918 IDispatchEx
*dispex
;
2919 BSTR name
, attr1
= SysAllocString(attr1W
);
2923 DISPID id
= DISPID_STARTENUM
;
2926 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2927 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2929 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
2930 ok(hres
== S_OK
, "removeAttribute failed: %08x\n", hres
);
2931 ok(succ
, "removeAttribute set succ to FALSE\n");
2934 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
2935 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08x\n", hres
);
2939 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
2940 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
2942 if(!strcmp_wa(name
, "attr1"))
2943 ok(0, "attr1 should be removed\n");
2944 else if(!strcmp_wa(name
, "attr2") || !strcmp_wa(name
, "attr3"))
2946 SysFreeString(name
);
2948 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
2949 IDispatchEx_Release(dispex
);
2951 V_VT(&val
) = VT_BSTR
;
2952 V_BSTR(&val
) = attr1
;
2953 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
2954 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
2955 SysFreeString(attr1
);
2958 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
2959 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const char *exname
)
2964 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
2965 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
2966 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), exname
);
2970 static void test_attr_collection_disp(IDispatch
*disp
)
2972 IDispatchEx
*dispex
;
2973 IHTMLDOMAttribute
*attr
;
2974 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
2981 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
2982 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
2985 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2986 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2987 SysFreeString(bstr
);
2990 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2991 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2992 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2993 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
2996 bstr
= a2bstr("attr1");
2997 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
2998 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2999 SysFreeString(bstr
);
3002 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3003 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3004 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3005 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3006 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3007 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3009 test_attr_node_name(attr
, "attr1");
3011 IHTMLDOMAttribute_Release(attr
);
3014 IDispatchEx_Release(dispex
);
3017 static void test_attr_collection(IHTMLElement
*elem
)
3019 static const WCHAR testW
[] = {'t','e','s','t',0};
3022 IDispatch
*disp
, *attr
;
3023 IHTMLDOMAttribute
*dom_attr
;
3024 IHTMLAttributeCollection
*attr_col
;
3025 BSTR name
= SysAllocString(testW
);
3027 LONG i
, len
, checked
;
3030 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3031 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3033 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3034 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3036 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3037 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
3038 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3039 IDispatch_Release(attr
);
3040 IHTMLDOMNode_Release(node
);
3042 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3043 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
3045 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3046 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3050 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3051 ok(hres
== S_OK
, "setAttribute failed: %08x\n", hres
);
3052 SysFreeString(name
);
3054 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3055 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3056 ok(len
== i
+1, "get_length returned %d, expected %d\n", len
, i
+1);
3059 for(i
=0; i
<len
; i
++) {
3062 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3063 ok(hres
== S_OK
, "%d) item failed: %08x\n", i
, hres
);
3065 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3066 ok(hres
== S_OK
, "%d) QueryInterface failed: %08x\n", i
, hres
);
3067 IDispatch_Release(attr
);
3069 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3070 ok(hres
== S_OK
, "%d) get_nodeName failed: %08x\n", i
, hres
);
3072 if(!strcmp_wa(name
, "id")) {
3074 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3075 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3076 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3077 ok(!strcmp_wa(V_BSTR(&val
), "attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3078 } else if(!strcmp_wa(name
, "attr1")) {
3080 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3081 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3082 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3083 ok(!strcmp_wa(V_BSTR(&val
), "attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3084 } else if(!strcmp_wa(name
, "attr2")) {
3086 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3087 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3088 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3089 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3090 } else if(!strcmp_wa(name
, "attr3")) {
3092 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3093 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3094 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3095 ok(!strcmp_wa(V_BSTR(&val
), "attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3096 } else if(!strcmp_wa(name
, "test")) {
3098 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3099 ok(hres
== S_OK
, "%d) get_nodeValue failed: %08x\n", i
, hres
);
3100 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3101 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %d\n", V_I4(&val
));
3104 IHTMLDOMAttribute_Release(dom_attr
);
3105 SysFreeString(name
);
3108 ok(checked
==5, "invalid number of specified attributes (%d)\n", checked
);
3111 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3112 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3114 V_VT(&id
) = VT_BSTR
;
3115 V_BSTR(&id
) = a2bstr("nonexisting");
3116 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3117 ok(hres
== E_INVALIDARG
, "item failed: %08x\n", hres
);
3120 test_attr_collection_disp(disp
);
3122 IDispatch_Release(disp
);
3123 IHTMLAttributeCollection_Release(attr_col
);
3126 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
3127 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
3129 VARIANT_BOOL specified
;
3132 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
3133 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08x\n", hres
);
3134 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
3137 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3138 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
3140 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3141 BSTR id
= (void*)0xdeadbeef;
3144 hres
= IHTMLElement_get_id(elem
, &id
);
3145 IHTMLElement_Release(elem
);
3146 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
3149 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3151 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3156 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3157 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const char *exlang
)
3159 BSTR lang
= (void*)0xdeadbeef;
3162 hres
= IHTMLElement_get_language(elem
, &lang
);
3163 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3166 ok_(__FILE__
,line
) (!strcmp_wa(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3168 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3170 SysFreeString(lang
);
3173 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3174 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const char *lang
)
3176 BSTR str
= a2bstr(lang
);
3179 hres
= IHTMLElement_put_language(elem
, str
);
3180 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08x\n", hres
);
3183 _test_elem_language(line
, elem
, lang
);
3186 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3187 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
3189 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3190 BSTR tmp
= a2bstr(new_id
);
3193 hres
= IHTMLElement_put_id(elem
, tmp
);
3194 IHTMLElement_Release(elem
);
3196 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
3198 _test_elem_id(line
, unk
, new_id
);
3201 static void test_contenteditable(IUnknown
*unk
)
3203 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3205 BSTR str
, strDefault
;
3207 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3208 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3210 str
= a2bstr("true");
3211 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3212 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(str
), hres
);
3214 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3215 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08x\n", hres
);
3216 ok(!strcmp_wa(str
, "true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3218 /* Restore origin contentEditable */
3219 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3220 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08x\n", wine_dbgstr_w(strDefault
), hres
);
3221 SysFreeString(strDefault
);
3223 IHTMLElement3_Release(elem3
);
3226 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
3227 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const char *extype
)
3232 hres
= IHTMLInputElement_get_type(input
, &type
);
3233 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
3234 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), extype
);
3235 SysFreeString(type
);
3238 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
3239 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const char *exname
)
3241 BSTR name
= (BSTR
)0xdeadbeef;
3244 hres
= IHTMLInputElement_get_name(input
, &name
);
3245 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08x\n", hres
);
3247 ok_(__FILE__
,line
) (!strcmp_wa (name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), exname
);
3249 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
3250 SysFreeString(name
);
3253 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
3254 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const char *name
)
3256 BSTR tmp
= a2bstr(name
);
3259 hres
= IHTMLInputElement_put_name(input
, tmp
);
3260 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08x\n", hres
);
3263 _test_input_name(line
, input
, name
);
3266 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
3267 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3269 VARIANT_BOOL disabled
= 100;
3272 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
3273 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3274 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3276 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
3279 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
3280 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3284 hres
= IHTMLInputElement_put_disabled(input
, b
);
3285 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
3287 _test_input_get_disabled(line
, input
, b
);
3290 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
3291 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3293 VARIANT_BOOL checked
= 100;
3296 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
3297 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3298 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3301 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
3302 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3306 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
3307 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
3309 _test_input_get_defaultchecked(line
, input
, b
);
3312 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
3313 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
3315 VARIANT_BOOL checked
= 100;
3318 hres
= IHTMLInputElement_get_checked(input
, &checked
);
3319 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
3320 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
3323 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
3324 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
3328 hres
= IHTMLInputElement_put_checked(input
, b
);
3329 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08x\n", hres
);
3331 _test_input_get_checked(line
, input
, b
);
3334 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
3335 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
3337 LONG maxlength
= 0xdeadbeef;
3340 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
3341 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08x\n", hres
);
3342 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%x, expected %d\n", maxlength
, exl
);
3345 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
3346 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
3350 hres
= IHTMLInputElement_put_maxLength(input
, l
);
3351 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08x\n", hres
);
3353 _test_input_maxlength(line
, input
, l
);
3356 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
3357 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
3359 IHTMLInputElement
*input
;
3363 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3364 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3368 hres
= IHTMLInputElement_get_value(input
, &bstr
);
3369 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3371 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
3373 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
3374 SysFreeString(bstr
);
3375 IHTMLInputElement_Release(input
);
3378 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
3379 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const char *id
)
3381 IHTMLInputElement
*input
;
3382 IHTMLFormElement
*form
;
3386 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
3387 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3388 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3389 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
3390 if(FAILED(hres
) || input
== NULL
)
3393 hres
= IHTMLInputElement_get_form(input
, &form
);
3394 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08x\n", hres
);
3395 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
3396 if(FAILED(hres
) || form
== NULL
){
3397 IHTMLInputElement_Release(input
);
3401 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
3402 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08x\n", hres
);
3403 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
3404 if(FAILED(hres
) || elem
== NULL
){
3405 IHTMLInputElement_Release(input
);
3406 IHTMLFormElement_Release(form
);
3410 _test_elem_id(line
, (IUnknown
*)elem
, id
);
3412 IHTMLInputElement_Release(input
);
3413 IHTMLFormElement_Release(form
);
3414 IHTMLElement_Release(elem
);
3417 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
3418 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
3420 IHTMLInputElement
*input
;
3424 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3425 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3430 hres
= IHTMLInputElement_put_value(input
, bstr
);
3431 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
3432 SysFreeString(bstr
);
3433 IHTMLInputElement_Release(input
);
3435 _test_input_value(line
, unk
, val
);
3438 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
3439 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const char *exval
)
3441 IHTMLInputElement
*input
;
3445 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3446 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3450 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
3451 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3453 ok_(__FILE__
,line
) (!strcmp_wa(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
3455 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
3457 IHTMLInputElement_Release(input
);
3460 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
3461 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const char *val
)
3463 IHTMLInputElement
*input
;
3467 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
3468 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3473 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
3474 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08x\n", hres
);
3476 IHTMLInputElement_Release(input
);
3478 _test_input_defaultValue(line
, unk
, val
);
3481 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
3482 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const char *exsrc
)
3487 hres
= IHTMLInputElement_get_src(input
, &src
);
3488 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
3490 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), exsrc
);
3492 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
3496 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
3497 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const char *src
)
3503 hres
= IHTMLInputElement_put_src(input
, tmp
);
3505 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
3507 _test_input_src(line
, input
, src
);
3510 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
3511 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
3515 hres
= IHTMLInputElement_put_size(input
, size
);
3516 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08x, got: %08x\n", exret
, hres
);
3519 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
3520 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
3525 hres
= IHTMLInputElement_get_size(input
, &size
);
3526 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08x\n", hres
);
3527 ok_(__FILE__
,line
) (size
== exsize
, "Expect %d, got %d\n", exsize
, size
);
3529 hres
= IHTMLInputElement_get_size(input
, NULL
);
3530 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08x\n", hres
);
3533 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
3534 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
3537 VARIANT_BOOL b
= 100;
3539 hres
= IHTMLInputElement_put_readOnly(input
, v
);
3540 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08x\n", hres
);
3542 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
3543 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08x\n", hres
);
3544 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
3547 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
3548 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
3550 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3551 BSTR
class = (void*)0xdeadbeef;
3554 hres
= IHTMLElement_get_className(elem
, &class);
3555 IHTMLElement_Release(elem
);
3556 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
3558 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
3560 ok_(__FILE__
,line
) (!class, "class != NULL\n");
3561 SysFreeString(class);
3564 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
3565 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
3567 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3571 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
3572 IHTMLElement2_Release(elem2
);
3573 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3574 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
3577 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
3578 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
3580 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
3583 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
3584 IHTMLElement2_Release(elem2
);
3585 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
3587 _test_elem_tabindex(line
, unk
, index
);
3590 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
3591 static void _test_style_media(unsigned line
, IUnknown
*unk
, const char *exmedia
)
3593 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3597 hres
= IHTMLStyleElement_get_media(style
, &media
);
3598 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
3600 ok_(__FILE__
,line
)(!strcmp_wa(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), exmedia
);
3602 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
3604 IHTMLStyleElement_Release(style
);
3605 SysFreeString(media
);
3608 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
3609 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const char *media
)
3611 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3615 str
= a2bstr(media
);
3616 hres
= IHTMLStyleElement_put_media(style
, str
);
3617 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08x\n", hres
);
3618 IHTMLStyleElement_Release(style
);
3621 _test_style_media(line
, unk
, media
);
3624 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
3625 static void _test_style_type(unsigned line
, IUnknown
*unk
, const char *extype
)
3627 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3631 hres
= IHTMLStyleElement_get_type(style
, &type
);
3632 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3634 ok_(__FILE__
,line
)(!strcmp_wa(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), extype
);
3636 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
3638 IHTMLStyleElement_Release(style
);
3639 SysFreeString(type
);
3642 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
3643 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const char *type
)
3645 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
3650 hres
= IHTMLStyleElement_put_type(style
, str
);
3651 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08x\n", hres
);
3652 IHTMLStyleElement_Release(style
);
3655 _test_style_type(line
, unk
, type
);
3658 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
3659 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
3661 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3663 IHTMLFiltersCollection
*filters
;
3665 hres
= IHTMLElement_get_filters(elem
, &filters
);
3666 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
3667 "get_filters failed: %08x\n", hres
);
3671 IDispatchEx
*dispex
;
3673 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
3674 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
3675 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %d\n", len
);
3677 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
3678 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
3679 "Could not get IDispatchEx interface: %08x\n", hres
);
3680 if(SUCCEEDED(hres
)) {
3681 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, "[object]");
3682 IDispatchEx_Release(dispex
);
3685 IHTMLFiltersCollection_Release(filters
);
3688 IHTMLElement_Release(elem
);
3691 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
3692 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
3694 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3698 tmp
= class ? a2bstr(class) : NULL
;
3699 hres
= IHTMLElement_put_className(elem
, tmp
);
3700 IHTMLElement_Release(elem
);
3701 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
3704 _test_elem_class(line
, unk
, class);
3707 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
3708 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
3710 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3714 hres
= IHTMLElement_get_title(elem
, &title
);
3715 IHTMLElement_Release(elem
);
3716 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3718 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
3720 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
3722 SysFreeString(title
);
3725 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
3726 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
3728 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3732 tmp
= a2bstr(title
);
3733 hres
= IHTMLElement_put_title(elem
, tmp
);
3734 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
3736 IHTMLElement_Release(elem
);
3740 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
3741 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
3743 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3747 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
3748 IHTMLDOMNode_Release(node
);
3749 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3752 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
3753 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
3755 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
3761 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
3762 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
3764 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3768 V_VT(&var
) = VT_BSTR
;
3769 V_BSTR(&var
) = a2bstr(val
);
3771 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
3772 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
3773 IHTMLDOMNode_Release(node
);
3777 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
3778 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
3780 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3784 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
3785 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
3786 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
3787 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
3789 IHTMLElement2_Release(elem
);
3792 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
3793 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
3795 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3799 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
3800 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08x\n", hres
);
3801 ok_(__FILE__
,line
) (!l
, "clientLeft = %d\n", l
);
3803 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
3804 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08x\n", hres
);
3805 ok_(__FILE__
,line
) (!l
, "clientTop = %d\n", l
);
3807 IHTMLElement2_Release(elem
);
3810 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
3811 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
3813 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3814 LONG len
= 0xdeadbeef;
3817 hres
= IHTMLFormElement_get_length(form
, &len
);
3818 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3819 ok_(__FILE__
,line
)(len
== exlen
, "length=%d, expected %d\n", len
, exlen
);
3821 IHTMLFormElement_Release(form
);
3824 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
3825 static void _test_form_action(unsigned line
, IUnknown
*unk
, const char *ex
)
3827 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3828 BSTR action
= (void*)0xdeadbeef;
3831 hres
= IHTMLFormElement_get_action(form
, &action
);
3832 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08x\n", hres
);
3834 ok_(__FILE__
,line
)(!strcmp_wa(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), ex
);
3836 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
3838 SysFreeString(action
);
3839 IHTMLFormElement_Release(form
);
3842 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
3843 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const char *action
)
3845 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3846 BSTR tmp
= a2bstr(action
);
3849 hres
= IHTMLFormElement_put_action(form
, tmp
);
3850 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08x\n", hres
);
3852 IHTMLFormElement_Release(form
);
3854 _test_form_action(line
, unk
, action
);
3857 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
3858 static void _test_form_method(unsigned line
, IUnknown
*unk
, const char *ex
)
3860 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3861 BSTR method
= (void*)0xdeadbeef;
3864 hres
= IHTMLFormElement_get_method(form
, &method
);
3865 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08x\n", hres
);
3867 ok_(__FILE__
,line
)(!strcmp_wa(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), ex
);
3869 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
3871 SysFreeString(method
);
3872 IHTMLFormElement_Release(form
);
3875 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
3876 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *method
)
3878 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3879 BSTR tmp
= a2bstr(method
);
3882 hres
= IHTMLFormElement_put_method(form
, tmp
);
3883 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08x, expected %08x\n", hres
, exp_hres
);
3885 IHTMLFormElement_Release(form
);
3887 if(exp_hres
== S_OK
)
3888 _test_form_method(line
, unk
, method
);
3891 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
3892 static void _test_form_name(unsigned line
, IUnknown
*unk
, const char *ex
)
3894 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3895 BSTR name
= (void*)0xdeadbeef;
3898 hres
= IHTMLFormElement_get_name(form
, &name
);
3899 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
3901 ok_(__FILE__
,line
)(!strcmp_wa(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), ex
);
3903 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
3905 SysFreeString(name
);
3906 IHTMLFormElement_Release(form
);
3909 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
3910 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const char *name
)
3912 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3913 BSTR tmp
= a2bstr(name
);
3916 hres
= IHTMLFormElement_put_name(form
, tmp
);
3917 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
3919 IHTMLFormElement_Release(form
);
3921 _test_form_name(line
, unk
, name
);
3924 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
3925 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const char *ex
)
3927 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3928 BSTR encoding
= (void*)0xdeadbeef;
3931 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
3932 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08x\n", hres
);
3934 ok_(__FILE__
,line
)(!strcmp_wa(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), ex
);
3936 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
3938 SysFreeString(encoding
);
3939 IHTMLFormElement_Release(form
);
3942 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
3943 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const char *encoding
)
3945 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3946 BSTR tmp
= a2bstr(encoding
);
3949 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
3950 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08x, expected %08x\n", hres
, exp_hres
);
3952 IHTMLFormElement_Release(form
);
3954 if(exp_hres
== S_OK
)
3955 _test_form_encoding(line
, unk
, encoding
);
3958 #define test_form_elements(a) _test_form_elements(__LINE__,a)
3959 static void _test_form_elements(unsigned line
, IUnknown
*unk
)
3961 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3966 hres
= IHTMLFormElement_get_elements(form
, &disp
);
3967 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08x\n", hres
);
3968 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
3969 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
3971 IDispatch_Release(disp
);
3972 IHTMLFormElement_Release(form
);
3975 #define test_form_reset(a) _test_form_reset(__LINE__,a)
3976 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
3978 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
3981 hres
= IHTMLFormElement_reset(form
);
3982 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08x\n", hres
);
3984 IHTMLFormElement_Release(form
);
3987 static void test_form_target(IUnknown
*unk
)
3989 IHTMLFormElement
*form
= get_form_iface(unk
);
3992 static const char target
[] = "_blank";
3994 str
= a2bstr(target
);
3995 hres
= IHTMLFormElement_put_target(form
, str
);
3996 ok(hres
== S_OK
, "put_target(%s) failed: %08x\n", target
, hres
);
3999 hres
= IHTMLFormElement_get_target(form
, &str
);
4000 ok(hres
== S_OK
, "get_target failed: %08x\n", hres
);
4001 ok(!strcmp_wa(str
, target
), "Expected %s, got %s\n", target
, wine_dbgstr_w(str
));
4004 IHTMLFormElement_Release(form
);
4007 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4008 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const char *exname
)
4010 IHTMLMetaElement
*meta
;
4014 meta
= _get_metaelem_iface(line
, unk
);
4015 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4016 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
4017 ok_(__FILE__
,line
)(!strcmp_wa(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), exname
);
4018 SysFreeString(name
);
4019 IHTMLMetaElement_Release(meta
);
4022 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4023 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const char *excontent
)
4025 IHTMLMetaElement
*meta
;
4026 BSTR content
= NULL
;
4029 meta
= _get_metaelem_iface(line
, unk
);
4030 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4031 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08x\n", hres
);
4032 ok_(__FILE__
,line
)(!strcmp_wa(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), excontent
);
4033 SysFreeString(content
);
4034 IHTMLMetaElement_Release(meta
);
4037 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4038 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const char *exval
)
4040 IHTMLMetaElement
*meta
;
4044 meta
= _get_metaelem_iface(line
, unk
);
4045 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4046 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08x\n", hres
);
4047 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4049 IHTMLMetaElement_Release(meta
);
4052 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4053 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const char *exval
)
4055 IHTMLMetaElement
*meta
;
4059 meta
= _get_metaelem_iface(line
, unk
);
4060 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4061 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
4063 ok_(__FILE__
,line
)(!strcmp_wa(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), exval
);
4065 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4067 IHTMLMetaElement_Release(meta
);
4070 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4071 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const char *vala
)
4073 BSTR val
= a2bstr(vala
);
4074 IHTMLMetaElement
*meta
;
4077 meta
= _get_metaelem_iface(line
, unk
);
4078 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4079 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08x\n", hres
);
4081 IHTMLMetaElement_Release(meta
);
4083 _test_meta_charset(line
, unk
, vala
);
4086 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4087 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const char *exval
)
4089 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4093 str
= a2bstr(exval
);
4094 hres
= IHTMLLinkElement_put_media(link
, str
);
4095 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media(%s) failed: %08x\n", exval
, hres
);
4098 hres
= IHTMLLinkElement_get_media(link
, &str
);
4099 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08x\n", hres
);
4100 ok_(__FILE__
,line
)(!strcmp_wa(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), exval
);
4102 IHTMLLinkElement_Release(link
);
4105 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4106 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4108 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4109 VARIANT_BOOL b
= 10;
4112 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4113 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
4114 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4116 IHTMLLinkElement_Release(link
);
4119 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4120 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4122 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4125 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4126 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4127 IHTMLLinkElement_Release(link
);
4128 _test_link_disabled(line
, elem
, v
);
4131 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4132 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4134 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4138 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4139 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08x\n", hres
);
4141 ok_(__FILE__
,line
)(!strcmp_wa(rel
, v
), "rel = %s, expected %s\n", wine_dbgstr_w(rel
), v
);
4143 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4145 IHTMLLinkElement_Release(link
);
4148 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4149 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const char *v
)
4151 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4152 BSTR str
= a2bstr(v
);
4155 hres
= IHTMLLinkElement_put_rel(link
, str
);
4156 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4158 IHTMLLinkElement_Release(link
);
4159 _test_link_rel(line
, elem
, v
);
4162 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4163 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4165 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4169 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4170 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08x\n", hres
);
4172 ok_(__FILE__
,line
)(!strcmp_wa(rev
, v
), "rev = %s, expected %s\n", wine_dbgstr_w(rev
), v
);
4174 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4176 IHTMLLinkElement_Release(link
);
4179 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
4180 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const char *v
)
4182 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4183 BSTR str
= a2bstr(v
);
4186 hres
= IHTMLLinkElement_put_rev(link
, str
);
4187 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4189 IHTMLLinkElement_Release(link
);
4190 _test_link_rev(line
, elem
, v
);
4193 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
4194 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4196 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4200 hres
= IHTMLLinkElement_get_type(link
, &type
);
4201 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
4203 ok_(__FILE__
,line
)(!strcmp_wa(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), v
);
4205 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4207 IHTMLLinkElement_Release(link
);
4210 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
4211 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const char *extext
)
4216 str
= (void*)0xdeadbeef;
4217 hres
= IHTMLScriptElement_get_text(script
, &str
);
4218 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08x\n", hres
);
4219 ok(!strcmp_wa(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), extext
);
4223 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
4224 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const char *v
)
4226 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4227 BSTR str
= a2bstr(v
);
4230 hres
= IHTMLLinkElement_put_type(link
, str
);
4231 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4233 IHTMLLinkElement_Release(link
);
4234 _test_link_type(line
, elem
, v
);
4237 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
4238 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4240 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4244 hres
= IHTMLLinkElement_get_href(link
, &href
);
4245 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08x\n", hres
);
4247 ok_(__FILE__
,line
)(!strcmp_wa(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), v
);
4249 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
4251 IHTMLLinkElement_Release(link
);
4254 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
4255 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const char *v
)
4257 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4258 BSTR str
= a2bstr(v
);
4261 hres
= IHTMLLinkElement_put_href(link
, str
);
4262 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
4264 IHTMLLinkElement_Release(link
);
4265 _test_link_href(line
, elem
, v
);
4268 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
4269 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
4271 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4272 IHTMLDocument2
*doc
;
4277 hres
= IHTMLElement_get_document(elem
, &disp
);
4278 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4279 ok(disp
!= NULL
, "disp == NULL\n");
4281 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
4282 IDispatch_Release(disp
);
4283 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08x\n", hres
);
4288 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
4289 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const char *attr_name
, BOOL expect_success
)
4291 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
4292 BSTR str
= a2bstr(attr_name
);
4293 IHTMLDOMAttribute
*attr
;
4296 attr
= (void*)0xdeadbeef;
4297 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
4298 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08x\n", hres
);
4300 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
4302 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
4304 IHTMLElement4_Release(elem
);
4309 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
4310 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
4314 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
4315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x\n", hres
);
4316 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
4319 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
4320 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
4324 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
4325 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08x\n", hres
);
4328 #define get_window_doc(e) _get_window_doc(__LINE__,e)
4329 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
4331 IHTMLDocument2
*doc
;
4335 hres
= IHTMLWindow2_get_document(window
, &doc
);
4336 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
4337 ok(doc
!= NULL
, "disp == NULL\n");
4342 #define doc_get_body(d) _doc_get_body(__LINE__,d)
4343 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
4348 hres
= IHTMLDocument2_get_body(doc
, &elem
);
4349 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08x\n", hres
);
4350 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
4355 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
4356 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
4358 IHTMLElement
*elem
= NULL
;
4363 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
4364 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4365 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
4371 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
4372 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
4374 IHTMLDocument3
*doc3
;
4375 IHTMLDOMNode
*node
= NULL
;
4379 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4380 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
4383 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
4384 IHTMLDocument3_Release(doc3
);
4386 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
4387 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
4392 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
4393 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
4395 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4396 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
4397 IHTMLDOMNode
*new_child
= NULL
;
4400 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
4401 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
4402 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4403 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4405 IHTMLDOMNode_Release(node
);
4406 IHTMLDOMNode_Release(child
);
4411 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
4412 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
4414 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
4415 IHTMLDOMNode
*new_child
= NULL
;
4418 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
4419 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
4420 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
4421 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
4423 IHTMLDOMNode_Release(node
);
4428 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
4429 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
4431 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4432 IHTMLDOMNode
*new_node
= NULL
;
4435 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
4436 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
4437 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
4438 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
4440 IHTMLDOMNode_Release(node
);
4441 IHTMLDOMNode_Release(new_node
);
4444 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
4445 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
4450 hres
= IHTMLDocument2_get_title(doc
, &title
);
4451 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4452 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4453 SysFreeString(title
);
4456 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
4457 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
4462 tmp
= a2bstr(title
);
4463 hres
= IHTMLDocument2_put_title(doc
, tmp
);
4464 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
4468 static void test_elem_bounding_client_rect(IUnknown
*unk
)
4470 IHTMLRect
*rect
, *rect2
;
4471 IHTMLElement2
*elem2
;
4475 elem2
= get_elem2_iface(unk
);
4476 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
4477 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4478 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
4479 IHTMLElement2_Release(elem2
);
4480 ok(hres
== S_OK
, "getBoundingClientRect failed: %08x\n", hres
);
4481 ok(rect
!= NULL
, "rect == NULL\n");
4482 ok(rect
!= rect2
, "rect == rect2\n");
4483 IHTMLRect_Release(rect2
);
4485 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, "[object]");
4488 hres
= IHTMLRect_get_top(rect
, &l
);
4489 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
4490 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4493 hres
= IHTMLRect_get_left(rect
, &l
);
4494 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
4495 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4498 hres
= IHTMLRect_get_bottom(rect
, &l
);
4499 ok(hres
== S_OK
, "get_bottom failed: %08x\n", hres
);
4500 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4503 hres
= IHTMLRect_get_right(rect
, &l
);
4504 ok(hres
== S_OK
, "get_right failed: %08x\n", hres
);
4505 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
4507 IHTMLRect_Release(rect
);
4510 static void test_elem_col_item(IHTMLElementCollection
*col
, const char *n
,
4511 const elem_type_t
*elem_types
, LONG len
)
4514 VARIANT name
, index
;
4518 V_VT(&index
) = VT_EMPTY
;
4519 V_VT(&name
) = VT_BSTR
;
4520 V_BSTR(&name
) = a2bstr(n
);
4522 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4523 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4525 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
4526 IDispatch_Release(disp
);
4528 V_VT(&index
) = VT_I4
;
4530 for(i
=0; i
<len
; i
++) {
4532 disp
= (void*)0xdeadbeef;
4533 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4534 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4535 ok(disp
!= NULL
, "disp == NULL\n");
4536 if(FAILED(hres
) || !disp
)
4539 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
4541 IDispatch_Release(disp
);
4545 disp
= (void*)0xdeadbeef;
4546 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4547 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4548 ok(disp
== NULL
, "disp != NULL\n");
4551 disp
= (void*)0xdeadbeef;
4552 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4553 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4554 ok(disp
== NULL
, "disp != NULL\n");
4556 SysFreeString(V_BSTR(&name
));
4559 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const char *id
, BOOL expect_success
)
4561 IHTMLElementCollection
*col
;
4563 IDispatch
*disp
= (void*)0xdeadbeef;
4564 VARIANT name
, index
;
4567 hres
= IHTMLDocument2_get_all(doc
, &col
);
4568 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
4569 ok(col
!= NULL
, "col == NULL\n");
4570 if(FAILED(hres
) || !col
)
4573 V_VT(&index
) = VT_EMPTY
;
4574 V_VT(&name
) = VT_BSTR
;
4575 V_BSTR(&name
) = a2bstr(id
);
4577 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
4578 IHTMLElementCollection_Release(col
);
4579 SysFreeString(V_BSTR(&name
));
4580 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4581 if(!expect_success
) {
4582 ok(disp
== NULL
, "disp != NULL\n");
4586 ok(disp
!= NULL
, "disp == NULL\n");
4590 elem
= get_elem_iface((IUnknown
*)disp
);
4591 IDispatch_Release(disp
);
4596 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const char *id
)
4598 IHTMLDocument3
*doc3
;
4603 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
4604 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
4607 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
4609 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", id
, hres
);
4611 IHTMLDocument3_Release(doc3
);
4616 static void test_select_elem(IHTMLSelectElement
*select
)
4618 IDispatch
*disp
, *disp2
;
4619 VARIANT name
, index
;
4622 test_select_type(select
, "select-one");
4623 test_select_length(select
, 2);
4624 test_select_selidx(select
, 0);
4625 test_select_put_selidx(select
, 1);
4627 test_select_set_value(select
, "val1");
4628 test_select_value(select
, "val1");
4630 test_select_get_disabled(select
, VARIANT_FALSE
);
4631 test_select_set_disabled(select
, VARIANT_TRUE
);
4632 test_select_set_disabled(select
, VARIANT_FALSE
);
4635 hres
= IHTMLSelectElement_get_options(select
, &disp
);
4636 ok(hres
== S_OK
, "get_options failed: %08x\n", hres
);
4637 ok(disp
!= NULL
, "options == NULL\n");
4638 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
4639 IDispatch_Release(disp
);
4641 V_VT(&index
) = VT_EMPTY
;
4642 V_VT(&name
) = VT_I4
;
4644 disp
= (void*)0xdeadbeef;
4645 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4646 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4647 ok(!disp
, "disp = %p\n", disp
);
4650 disp
= (void*)0xdeadbeef;
4651 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4652 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4653 ok(!disp
, "disp = %p\n", disp
);
4656 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
4657 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08x, expected E_POINTER\n", hres
);
4660 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
4661 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4662 ok(disp
!= NULL
, "disp = NULL\n");
4663 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, NULL
);
4665 V_VT(&index
) = VT_I4
;
4668 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
4669 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4670 ok(disp2
!= NULL
, "disp = NULL\n");
4671 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4672 IDispatch_Release(disp2
);
4673 IDispatch_Release(disp
);
4675 test_select_multiple(select
, VARIANT_FALSE
);
4676 test_select_set_multiple(select
, VARIANT_TRUE
);
4677 test_select_remove(select
);
4680 static void test_form_item(IHTMLElement
*elem
)
4682 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
4683 IDispatch
*disp
, *disp2
;
4684 VARIANT name
, index
;
4687 V_VT(&index
) = VT_EMPTY
;
4688 V_VT(&name
) = VT_I4
;
4690 disp
= (void*)0xdeadbeef;
4691 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4692 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4693 ok(!disp
, "disp = %p\n", disp
);
4696 disp
= (void*)0xdeadbeef;
4697 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4698 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4699 ok(!disp
, "disp = %p\n", disp
);
4702 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
4703 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
4706 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
4707 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4708 ok(disp
!= NULL
, "disp = NULL\n");
4709 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, NULL
);
4711 V_VT(&index
) = VT_I4
;
4714 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
4715 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
4716 ok(disp2
!= NULL
, "disp = NULL\n");
4717 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
4718 IDispatch_Release(disp2
);
4719 IDispatch_Release(disp
);
4722 static void test_create_option_elem(IHTMLDocument2
*doc
)
4724 IHTMLOptionElement
*option
;
4726 option
= create_option_elem(doc
, "test text", "test value");
4728 test_option_put_text(option
, "new text");
4729 test_option_put_value(option
, "new value");
4730 test_option_put_selected(option
, VARIANT_TRUE
);
4731 test_option_put_selected(option
, VARIANT_FALSE
);
4733 IHTMLOptionElement_Release(option
);
4736 static void test_create_img_elem(IHTMLDocument2
*doc
)
4738 IHTMLImgElement
*img
;
4740 img
= create_img_elem(doc
, 10, 15);
4743 test_img_put_width(img
, 5);
4744 test_img_put_height(img
, 20);
4746 IHTMLImgElement_Release(img
);
4750 img
= create_img_elem(doc
, -1, -1);
4753 test_img_put_width(img
, 5);
4754 test_img_put_height(img
, 20);
4756 IHTMLImgElement_Release(img
);
4760 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
4761 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const char *where
, IHTMLElement
*elem
)
4763 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
4764 IHTMLElement
*ret_elem
= NULL
;
4765 BSTR str
= a2bstr(where
);
4768 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
4769 IHTMLElement2_Release(elem2
);
4771 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08x\n", hres
);
4772 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
4773 IHTMLElement_Release(ret_elem
);
4776 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
4778 IHTMLElement
*elem
, *elem2
;
4780 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
4781 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
4783 elem
= test_create_elem(doc
, "BR");
4784 insert_adjacent_elem(parent
, "BeforeEnd", elem
);
4785 IHTMLElement_Release(elem
);
4787 test_elem_all((IUnknown
*)parent
, br_br
, 1);
4789 elem
= test_create_elem(doc
, "BR");
4790 insert_adjacent_elem(parent
, "beforeend", elem
);
4792 test_elem_all((IUnknown
*)parent
, br_br
, 2);
4794 elem2
= test_create_elem(doc
, "DIV");
4795 insert_adjacent_elem(elem
, "beforebegin", elem2
);
4796 IHTMLElement_Release(elem2
);
4797 IHTMLElement_Release(elem
);
4799 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
4802 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
4804 IHTMLBodyElement
*body
;
4805 IHTMLTxtRange
*range
;
4809 elem
= doc_get_body(doc
);
4810 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
4811 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
4812 IHTMLElement_Release(elem
);
4814 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
4815 IHTMLBodyElement_Release(body
);
4816 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
4821 static void test_txtrange(IHTMLDocument2
*doc
)
4823 IHTMLTxtRange
*body_range
, *range
, *range2
;
4824 IHTMLSelectionObject
*selection
;
4825 IDispatch
*disp_range
;
4828 body_range
= test_create_body_range(doc
);
4830 test_range_text(body_range
, "test abc 123\r\nit's text");
4832 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4833 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4835 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
4836 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4837 test_range_isequal(range
, range2
, VARIANT_TRUE
);
4839 test_range_text(range
, "test abc 123\r\nit's text");
4840 test_range_text(body_range
, "test abc 123\r\nit's text");
4842 test_range_collapse(range
, TRUE
);
4843 test_range_isequal(range
, range2
, VARIANT_FALSE
);
4844 test_range_inrange(range
, range2
, VARIANT_FALSE
);
4845 test_range_inrange(range2
, range
, VARIANT_TRUE
);
4846 IHTMLTxtRange_Release(range2
);
4848 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4849 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
4850 test_range_move(range
, characterW
, 2, 2);
4851 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4853 test_range_collapse(range
, FALSE
);
4854 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
4856 test_range_collapse(range
, FALSE
);
4857 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4858 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
4859 test_range_move(range
, characterW
, 2, 2);
4860 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
4861 test_range_moveend(range
, characterW
, -5, -5);
4862 test_range_text(range
, NULL
);
4863 test_range_moveend(range
, characterW
, 3, 3);
4864 test_range_text(range
, "c 1");
4865 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
4866 test_range_collapse(range
, TRUE
);
4867 test_range_move(range
, characterW
, 4, 4);
4868 test_range_moveend(range
, characterW
, 1, 1);
4869 test_range_text(range
, " ");
4870 test_range_move(range
, wordW
, 1, 1);
4871 test_range_moveend(range
, characterW
, 2, 2);
4872 test_range_text(range
, "ab");
4874 IHTMLTxtRange_Release(range
);
4876 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4877 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4879 test_range_text(range
, "test abc 123\r\nit's text");
4880 test_range_move(range
, characterW
, 3, 3);
4881 test_range_moveend(range
, characterW
, 1, 1);
4882 test_range_text(range
, "t");
4883 test_range_moveend(range
, characterW
, 3, 3);
4884 test_range_text(range
, "t ab");
4885 test_range_moveend(range
, characterW
, -2, -2);
4886 test_range_text(range
, "t ");
4887 test_range_move(range
, characterW
, 6, 6);
4888 test_range_moveend(range
, characterW
, 3, 3);
4889 test_range_text(range
, "123");
4890 test_range_moveend(range
, characterW
, 2, 2);
4891 test_range_text(range
, "123\r\ni");
4893 IHTMLTxtRange_Release(range
);
4895 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4896 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4898 test_range_move(range
, wordW
, 1, 1);
4899 test_range_moveend(range
, characterW
, 2, 2);
4900 test_range_text(range
, "ab");
4902 test_range_move(range
, characterW
, -2, -2);
4903 test_range_moveend(range
, characterW
, 2, 2);
4904 test_range_text(range
, "t ");
4906 test_range_move(range
, wordW
, 3, 3);
4907 test_range_move(range
, wordW
, -2, -2);
4908 test_range_moveend(range
, characterW
, 2, 2);
4909 test_range_text(range
, "ab");
4911 test_range_move(range
, characterW
, -6, -5);
4912 test_range_moveend(range
, characterW
, -1, 0);
4913 test_range_moveend(range
, characterW
, -6, 0);
4914 test_range_move(range
, characterW
, 2, 2);
4915 test_range_moveend(range
, characterW
, 2, 2);
4916 test_range_text(range
, "st");
4917 test_range_moveend(range
, characterW
, -6, -4);
4918 test_range_moveend(range
, characterW
, 2, 2);
4920 IHTMLTxtRange_Release(range
);
4922 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4923 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4925 test_range_move(range
, wordW
, 2, 2);
4926 test_range_moveend(range
, characterW
, 2, 2);
4927 test_range_text(range
, "12");
4929 test_range_move(range
, characterW
, 15, 14);
4930 test_range_move(range
, characterW
, -2, -2);
4931 test_range_moveend(range
, characterW
, 3, 2);
4932 test_range_text(range
, "t");
4933 test_range_moveend(range
, characterW
, -1, -1);
4934 test_range_text(range
, "t");
4935 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
4936 test_range_move(range
, characterW
, -2, -2);
4937 test_range_moveend(range
, characterW
, 2, 2);
4938 test_range_text(range
, "s ");
4939 test_range_move(range
, characterW
, 100, 7);
4940 test_range_move(range
, wordW
, 1, 0);
4941 test_range_move(range
, characterW
, -2, -2);
4942 test_range_moveend(range
, characterW
, 3, 2);
4943 test_range_text(range
, "t");
4945 IHTMLTxtRange_Release(range
);
4947 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
4948 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
4950 test_range_collapse(range
, TRUE
);
4951 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
4952 test_range_put_text(range
, "word");
4953 test_range_text(body_range
, "wordabc 123\r\nit's text");
4954 test_range_text(range
, NULL
);
4955 test_range_moveend(range
, characterW
, 3, 3);
4956 test_range_text(range
, "abc");
4957 test_range_movestart(range
, characterW
, -2, -2);
4958 test_range_text(range
, "rdabc");
4959 test_range_movestart(range
, characterW
, 3, 3);
4960 test_range_text(range
, "bc");
4961 test_range_movestart(range
, characterW
, 4, 4);
4962 test_range_text(range
, NULL
);
4963 test_range_movestart(range
, characterW
, -3, -3);
4964 test_range_text(range
, "c 1");
4965 test_range_movestart(range
, characterW
, -7, -6);
4966 test_range_text(range
, "wordabc 1");
4967 test_range_movestart(range
, characterW
, 100, 22);
4968 test_range_text(range
, NULL
);
4970 IHTMLTxtRange_Release(range
);
4971 IHTMLTxtRange_Release(body_range
);
4973 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
4974 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
4976 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
4977 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
4978 IHTMLSelectionObject_Release(selection
);
4980 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
4981 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
4982 IDispatch_Release(disp_range
);
4984 test_range_text(range
, NULL
);
4985 test_range_moveend(range
, characterW
, 3, 3);
4986 test_range_text(range
, "wor");
4987 test_range_parent(range
, ET_BODY
);
4988 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4989 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
4990 test_range_move(range
, characterW
, 3, 3);
4991 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
4992 test_range_moveend(range
, characterW
, -4, -4);
4993 test_range_put_text(range
, "abc def ");
4994 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
4995 test_range_move(range
, wordW
, 1, 1);
4996 test_range_movestart(range
, characterW
, -1, -1);
4997 test_range_text(range
, " ");
4998 test_range_move(range
, wordW
, 1, 1);
4999 test_range_moveend(range
, characterW
, 3, 3);
5000 test_range_text(range
, "def");
5001 test_range_put_text(range
, "xyz");
5002 test_range_moveend(range
, characterW
, 1, 1);
5003 test_range_move(range
, wordW
, 1, 1);
5004 test_range_moveend(range
, characterW
, 2, 2);
5005 test_range_text(range
, "ab");
5007 IHTMLTxtRange_Release(range
);
5010 static void test_txtrange2(IHTMLDocument2
*doc
)
5012 IHTMLTxtRange
*range
;
5014 range
= test_create_body_range(doc
);
5016 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
5017 test_range_move(range
, characterW
, 5, 5);
5018 test_range_moveend(range
, characterW
, 1, 1);
5019 test_range_text(range
, "2");
5020 test_range_move(range
, characterW
, -3, -3);
5021 test_range_moveend(range
, characterW
, 3, 3);
5022 test_range_text(range
, "c\r\n\r\n1");
5023 test_range_collapse(range
, VARIANT_FALSE
);
5024 test_range_moveend(range
, characterW
, 4, 4);
5025 test_range_text(range
, "23");
5026 test_range_moveend(range
, characterW
, 1, 1);
5027 test_range_text(range
, "23\r\n\r\n\r\nd");
5028 test_range_moveend(range
, characterW
, -1, -1);
5029 test_range_text(range
, "23");
5030 test_range_moveend(range
, characterW
, -1, -1);
5031 test_range_text(range
, "23");
5032 test_range_moveend(range
, characterW
, -2, -2);
5033 test_range_text(range
, "2");
5035 IHTMLTxtRange_Release(range
);
5038 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
5039 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const char *excompat
)
5041 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
5045 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
5046 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
5047 ok_(__FILE__
,line
)(!strcmp_wa(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), excompat
);
5049 IHTMLDocument5_Release(doc
);
5052 static void test_location(IHTMLDocument2
*doc
)
5054 IHTMLLocation
*location
, *location2
;
5055 IHTMLWindow2
*window
;
5060 hres
= IHTMLDocument2_get_location(doc
, &location
);
5061 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5063 hres
= IHTMLDocument2_get_location(doc
, &location2
);
5064 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5066 ok(location
== location2
, "location != location2\n");
5067 IHTMLLocation_Release(location2
);
5069 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5070 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5072 hres
= IHTMLWindow2_get_location(window
, &location2
);
5073 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
5074 ok(location
== location2
, "location != location2\n");
5075 IHTMLLocation_Release(location2
);
5077 test_ifaces((IUnknown
*)location
, location_iids
);
5078 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, "about:blank");
5080 hres
= IHTMLLocation_get_pathname(location
, &str
);
5081 ok(hres
== S_OK
, "get_pathname failed: %08x\n", hres
);
5082 ok(!strcmp_wa(str
, "blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
5085 hres
= IHTMLLocation_get_href(location
, NULL
);
5086 ok(hres
== E_POINTER
, "get_href passed: %08x\n", hres
);
5088 hres
= IHTMLLocation_get_href(location
, &str
);
5089 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
5090 ok(!strcmp_wa(str
, "about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
5093 ref
= IHTMLLocation_Release(location
);
5094 ok(!ref
, "location chould be destroyed here\n");
5097 static void test_plugins_col(IHTMLDocument2
*doc
)
5099 IHTMLPluginsCollection
*col
, *col2
;
5100 IHTMLWindow2
*window
;
5106 window
= get_doc_window(doc
);
5107 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
5108 IHTMLWindow2_Release(window
);
5110 hres
= IOmNavigator_get_plugins(nav
, &col
);
5111 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5113 hres
= IOmNavigator_get_plugins(nav
, &col2
);
5114 ok(hres
== S_OK
, "get_plugins failed: %08x\n", hres
);
5115 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5116 IHTMLPluginsCollection_Release(col2
);
5118 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, "[object]");
5121 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
5122 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5123 ok(!len
, "length = %d\n", len
);
5125 ref
= IHTMLPluginsCollection_Release(col
);
5126 ok(!ref
, "ref=%d\n", ref
);
5128 IOmNavigator_Release(nav
);
5131 static void test_mime_types_col(IOmNavigator
*nav
)
5133 IHTMLMimeTypesCollection
*col
, *col2
;
5138 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
5139 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5141 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
5142 ok(hres
== S_OK
, "get_mimeTypes failed: %08x\n", hres
);
5143 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
5144 IHTMLMimeTypesCollection_Release(col2
);
5146 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, "[object]");
5148 length
= 0xdeadbeef;
5149 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
5150 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5151 ok(!length
, "length = %d\n", length
);
5153 ref
= IHTMLMimeTypesCollection_Release(col
);
5154 ok(!ref
, "ref=%d\n", ref
);
5157 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
5158 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5160 BSTR str
= (void*)0xdeadbeef;
5161 IHTMLFrameBase
*fbase
;
5164 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5165 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5167 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
5168 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08x\n", hres
);
5170 ok_(__FILE__
,line
)(!strcmp_wa(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), name
);
5172 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
5175 IHTMLFrameBase_Release(fbase
);
5178 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
5179 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
5181 IHTMLFrameBase
*fbase
;
5185 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5186 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5188 str
= name
? a2bstr(name
) : NULL
;
5189 hres
= IHTMLFrameBase_put_name(fbase
, str
);
5190 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08x\n", hres
);
5193 _test_framebase_name(line
, elem
, name
);
5194 IHTMLFrameBase_Release(fbase
);
5197 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
5198 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5203 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
5204 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08x\n", hres
);
5205 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
5207 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginHeight = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5209 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5213 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
5214 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5220 V_BSTR(&v
) = a2bstr(val
);
5221 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
5222 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08x\n", hres
);
5226 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
5227 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *exval
)
5232 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
5233 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08x\n", hres
);
5234 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
5236 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
5238 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
5242 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
5243 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const char *val
)
5249 V_BSTR(&v
) = a2bstr(val
);
5250 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
5251 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08x\n", hres
);
5255 static void test_framebase(IUnknown
*unk
)
5257 IHTMLFrameBase
*fbase
;
5261 /* get/put scrolling */
5262 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
5263 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres
);
5265 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5266 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5267 ok(!strcmp_wa(str
, "auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
5271 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5272 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08x\n", hres
);
5275 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5276 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5277 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5280 str
= a2bstr("junk");
5281 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
5282 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
5283 "with E_INVALIDARG, instead: 0x%08x\n", hres
);
5286 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
5287 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08x\n", hres
);
5288 ok(!strcmp_wa(str
, "no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
5291 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5292 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5293 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
5296 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
5297 ok(hres
== S_OK
, "put_frameBorder failed: %08x\n", hres
);
5300 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
5301 ok(hres
== S_OK
, "get_frameBorder failed: %08x\n", hres
);
5302 ok(!strcmp_wa(str
, "1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
5304 test_framebase_marginheight(fbase
, NULL
);
5305 set_framebase_marginheight(fbase
, "1px");
5306 test_framebase_marginheight(fbase
, "1");
5308 test_framebase_marginwidth(fbase
, NULL
);
5309 set_framebase_marginwidth(fbase
, "2px");
5310 test_framebase_marginwidth(fbase
, "2");
5312 IHTMLFrameBase_Release(fbase
);
5315 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
5316 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
5321 if(pLCIDToLocaleName
) {
5322 res
= pLCIDToLocaleName(lcid
, buf
, sizeof(buf
)/sizeof(WCHAR
), 0);
5323 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %u\n", GetLastError());
5324 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
5326 win_skip("LCIDToLocaleName not available, unable to test language string\n");
5327 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
5331 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
5332 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
5334 IHTMLElementCollection
*col
;
5338 hres
= IHTMLTable_get_rows(table
, &col
);
5339 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
5340 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
5341 if (hres
!= S_OK
|| col
== NULL
)
5343 hres
= IHTMLElementCollection_get_length(col
, &len
);
5344 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5345 ok_(__FILE__
,line
)(len
== expect
, "Expect %d, got %d\n", expect
, len
);
5347 IHTMLElementCollection_Release(col
);
5350 static void test_navigator(IHTMLDocument2
*doc
)
5352 IHTMLWindow2
*window
;
5353 IOmNavigator
*navigator
, *navigator2
;
5361 static const WCHAR v40
[] = {'4','.','0'};
5363 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5364 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
5366 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
5367 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5368 ok(navigator
!= NULL
, "navigator == NULL\n");
5369 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, "[object]");
5371 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
5372 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
5373 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
5375 IHTMLWindow2_Release(window
);
5376 IOmNavigator_Release(navigator2
);
5378 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
5379 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
5380 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5381 SysFreeString(bstr
);
5384 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
5385 ok(hres
== S_OK
, "get_appName failed: %08x\n", hres
);
5386 ok(!strcmp_wa(bstr
, "Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
5387 SysFreeString(bstr
);
5390 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
5391 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
5392 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "Win64" : "Win32")
5393 || (sizeof(void*) == 8 && broken(!strcmp_wa(bstr
, "Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
5394 SysFreeString(bstr
);
5397 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
5398 ok(hres
== S_OK
, "get_cpuClass failed: %08x\n", hres
);
5399 ok(!strcmp_wa(bstr
, sizeof(void*) == 8 ? "x64" : "x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
5400 SysFreeString(bstr
);
5403 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5404 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5405 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
5406 SysFreeString(bstr
);
5409 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
5410 ok(hres
== S_OK
, "get_systemLanguage failed: %08x\n", hres
);
5411 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
5412 SysFreeString(bstr
);
5414 if (pGetUserDefaultUILanguage
)
5417 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
5418 ok(hres
== S_OK
, "get_browserLanguage failed: %08x\n", hres
);
5419 test_language_string(bstr
, pGetUserDefaultUILanguage());
5420 SysFreeString(bstr
);
5423 win_skip("GetUserDefaultUILanguage not available\n");
5426 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
5427 ok(hres
== S_OK
, "get_userLanguage failed: %08x\n", hres
);
5428 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
5429 SysFreeString(bstr
);
5431 hres
= IOmNavigator_toString(navigator
, NULL
);
5432 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5435 hres
= IOmNavigator_toString(navigator
, &bstr
);
5436 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5437 ok(!strcmp_wa(bstr
, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
5438 SysFreeString(bstr
);
5441 hres
= IOmNavigator_get_onLine(navigator
, &b
);
5442 ok(hres
== S_OK
, "get_onLine failed: %08x\n", hres
);
5443 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
5446 hres
= ObtainUserAgentString(0, buf
, &size
);
5447 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
5450 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
5451 ok(hres
== S_OK
, "get_userAgent failed: %08x\n", hres
);
5452 ok(!strcmp_wa(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
);
5453 SysFreeString(bstr
);
5455 if(!strncmp(buf
, "Mozilla/", 8)) {
5457 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
5458 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
5459 ok(!strcmp_wa(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), buf
+8);
5460 SysFreeString(bstr
);
5462 skip("nonstandard user agent\n");
5466 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
5467 ok(hres
== S_OK
, "get_appMonorVersion failed: %08x\n", hres
);
5468 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
5469 SysFreeString(bstr
);
5471 test_mime_types_col(navigator
);
5473 ref
= IOmNavigator_Release(navigator
);
5474 ok(!ref
, "navigator should be destroyed here\n");
5477 static void test_screen(IHTMLWindow2
*window
)
5479 IHTMLScreen
*screen
, *screen2
;
5480 IDispatchEx
*dispex
;
5487 hres
= IHTMLWindow2_get_screen(window
, &screen
);
5488 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5489 ok(screen
!= NULL
, "screen == NULL\n");
5492 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
5493 ok(hres
== S_OK
, "get_screen failed: %08x\n", hres
);
5494 ok(screen2
!= NULL
, "screen == NULL\n");
5495 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
5496 IHTMLScreen_Release(screen2
);
5498 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
5499 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08x\n", hres
);
5500 if(SUCCEEDED(hres
)) {
5501 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, "[object]");
5502 IDispatchEx_Release(dispex
);
5505 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
5507 exl
= GetDeviceCaps(hdc
, HORZRES
);
5509 hres
= IHTMLScreen_get_width(screen
, &l
);
5510 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
5511 ok(l
== exl
, "width = %d, expected %d\n", l
, exl
);
5513 exl
= GetDeviceCaps(hdc
, VERTRES
);
5515 hres
= IHTMLScreen_get_height(screen
, &l
);
5516 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5517 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5519 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
5521 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
5522 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
5523 ok(l
== exl
, "height = %d, expected %d\n", l
, exl
);
5527 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
5530 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
5531 ok(hres
== S_OK
, "get_availHeight failed: %08x\n", hres
);
5532 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %d, expected %d\n", l
, work_area
.bottom
-work_area
.top
);
5535 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
5536 ok(hres
== S_OK
, "get_availWidth failed: %08x\n", hres
);
5537 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %d, expected %d\n", l
, work_area
.right
-work_area
.left
);
5539 IHTMLScreen_Release(screen
);
5542 static void test_default_selection(IHTMLDocument2
*doc
)
5544 IHTMLSelectionObject
*selection
;
5545 IHTMLTxtRange
*range
;
5550 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5551 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
5553 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5554 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
5555 ok(!strcmp_wa(str
, "None"), "type = %s\n", wine_dbgstr_w(str
));
5558 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
5559 IHTMLSelectionObject_Release(selection
);
5560 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
5562 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
5563 IDispatch_Release(disp
);
5564 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
5566 test_range_text(range
, NULL
);
5567 IHTMLTxtRange_Release(range
);
5570 static void test_doc_elem(IHTMLDocument2
*doc
)
5572 IHTMLDocument2
*doc_node
, *owner_doc
;
5574 IHTMLDocument3
*doc3
;
5578 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5579 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
5581 hres
= IHTMLDocument2_toString(doc
, &bstr
);
5582 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5583 ok(!strcmp_wa(bstr
, "[object]"),
5584 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
5585 SysFreeString(bstr
);
5587 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
5588 IHTMLDocument3_Release(doc3
);
5589 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
5591 test_node_name((IUnknown
*)elem
, "HTML");
5592 test_elem_tag((IUnknown
*)elem
, "HTML");
5594 doc_node
= get_doc_node(doc
);
5595 owner_doc
= get_owner_doc((IUnknown
*)elem
);
5596 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
5597 IHTMLDocument2_Release(owner_doc
);
5599 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
5600 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
5601 IHTMLDocument2_Release(doc_node
);
5603 test_elem_client_rect((IUnknown
*)elem
);
5605 IHTMLElement_Release(elem
);
5608 static void test_default_body(IHTMLBodyElement
*body
)
5615 bstr
= (void*)0xdeadbeef;
5616 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
5617 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
5618 ok(bstr
== NULL
, "bstr != NULL\n");
5620 l
= elem_get_scroll_height((IUnknown
*)body
);
5621 ok(l
!= -1, "scrollHeight == -1\n");
5622 l
= elem_get_scroll_width((IUnknown
*)body
);
5623 ok(l
!= -1, "scrollWidth == -1\n");
5624 l
= elem_get_scroll_top((IUnknown
*)body
);
5625 ok(!l
, "scrollTop = %d\n", l
);
5626 elem_get_scroll_left((IUnknown
*)body
);
5628 /* get_text tests */
5629 hres
= IHTMLBodyElement_get_text(body
, &v
);
5630 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5631 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5632 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
5634 /* get_text - Invalid Text */
5636 V_BSTR(&v
) = a2bstr("Invalid");
5637 hres
= IHTMLBodyElement_put_text(body
, v
);
5638 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5642 hres
= IHTMLBodyElement_get_text(body
, &v
);
5643 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5644 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5645 ok(!strcmp_wa(V_BSTR(&v
), "#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
5648 /* get_text - Valid Text */
5650 V_BSTR(&v
) = a2bstr("#FF0000");
5651 hres
= IHTMLBodyElement_put_text(body
, v
);
5652 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5656 hres
= IHTMLBodyElement_get_text(body
, &v
);
5657 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
5658 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
5659 ok(!strcmp_wa(V_BSTR(&v
), "#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
5663 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
5664 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *ex
)
5669 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
5670 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08x\n", hres
);
5671 ok_(__FILE__
,line
)(ex
? !strcmp_wa(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
5675 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
5676 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const char *val
)
5678 BSTR str
= a2bstr(val
);
5681 hres
= IHTMLBodyElement_put_scroll(body
, str
);
5682 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08x\n", hres
);
5685 _test_body_scroll(line
, body
, val
);
5688 static void test_body_funs(IHTMLBodyElement
*body
)
5690 VARIANT vbg
, vDefaultbg
;
5693 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
5694 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5695 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
5696 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
5698 V_VT(&vbg
) = VT_BSTR
;
5699 V_BSTR(&vbg
) = a2bstr("red");
5700 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
5701 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5704 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
5705 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
5706 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
5707 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
5710 /* Restore Originial */
5711 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
5712 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
5713 VariantClear(&vDefaultbg
);
5715 test_body_scroll(body
, NULL
);
5716 set_body_scroll(body
, "yes");
5717 set_body_scroll(body
, "no");
5718 set_body_scroll(body
, "auto");
5721 static void test_history(IHTMLWindow2
*window
)
5723 IOmHistory
*history
, *history2
;
5727 hres
= IHTMLWindow2_get_history(window
, &history
);
5728 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5729 ok(history
!= NULL
, "history = NULL\n");
5731 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, "[object]");
5734 hres
= IHTMLWindow2_get_history(window
, &history2
);
5735 ok(hres
== S_OK
, "get_history failed: %08x\n", hres
);
5736 ok(history2
!= NULL
, "history2 = NULL\n");
5737 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
5739 IOmHistory_Release(history2
);
5740 IOmHistory_Release(history
);
5743 static void test_window(IHTMLDocument2
*doc
)
5745 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
5746 IHTMLDocument2
*doc2
= NULL
;
5753 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
5754 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
5755 test_ifaces((IUnknown
*)window
, window_iids
);
5756 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
5758 IUnknown_Release(unk
);
5760 win_skip("IID_ITravelLogClient not supported\n");
5762 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, "[object]");
5764 hres
= IHTMLWindow2_get_document(window
, &doc2
);
5765 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
5766 ok(doc2
!= NULL
, "doc2 == NULL\n");
5768 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
5769 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, "[object]");
5770 test_class_info((IUnknown
*)doc2
);
5772 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
5773 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, "[object]");
5774 test_class_info((IUnknown
*)doc
);
5776 unk
= (void*)0xdeadbeef;
5777 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
5778 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres
);
5779 ok(!unk
, "unk = %p\n", unk
);
5781 IHTMLDocument2_Release(doc2
);
5783 hres
= IHTMLWindow2_get_window(window
, &window2
);
5784 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
5785 ok(window2
!= NULL
, "window2 == NULL\n");
5787 hres
= IHTMLWindow2_get_self(window
, &self
);
5788 ok(hres
== S_OK
, "get_self failed: %08x\n", hres
);
5789 ok(window2
!= NULL
, "self == NULL\n");
5791 ok(self
== window2
, "self != window2\n");
5793 IHTMLWindow2_Release(window2
);
5796 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
5797 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
5798 ok(disp
== (void*)window
, "disp != window\n");
5799 IDispatch_Release(disp
);
5801 hres
= IHTMLWindow2_toString(window
, NULL
);
5802 ok(hres
== E_INVALIDARG
, "toString failed: %08x\n", hres
);
5805 hres
= IHTMLWindow2_toString(window
, &str
);
5806 ok(hres
== S_OK
, "toString failed: %08x\n", hres
);
5807 ok(!strcmp_wa(str
, "[object]") ||
5808 !strcmp_wa(str
, "[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
5811 V_VT(&v
) = VT_ERROR
;
5812 hres
= IHTMLWindow2_get_opener(window
, &v
);
5813 ok(hres
== S_OK
, "get_opener failed: %08x\n", hres
);
5814 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
5817 hres
= IHTMLWindow2_get_parent(window
, &parent
);
5818 ok(hres
== S_OK
, "get_parent failed: %08x\n", hres
);
5819 ok(parent
!= NULL
, "parent == NULL\n");
5820 ok(parent
== self
, "parent != window\n");
5821 IHTMLWindow2_Release(parent
);
5822 IHTMLWindow2_Release(self
);
5824 test_window_name(window
, NULL
);
5825 set_window_name(window
, "test");
5826 test_window_length(window
, 0);
5827 test_screen(window
);
5828 test_window_status(window
);
5829 set_window_status(window
, "Test!");
5830 test_history(window
);
5832 IHTMLWindow2_Release(window
);
5835 static void test_dom_implementation(IHTMLDocument2
*doc
)
5837 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
5838 IHTMLDOMImplementation
*dom_implementation
;
5844 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
5845 IHTMLDocument5_Release(doc5
);
5846 ok(hres
== S_OK
, "get_implementation failed: %08x\n", hres
);
5847 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
5849 str
= a2bstr("test");
5851 V_BSTR(&v
) = a2bstr("1.0");
5853 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
5856 ok(hres
== S_OK
, "hasFeature failed: %08x\n", hres
);
5857 ok(!b
, "hasFeature returned %x\n", b
);
5859 IHTMLDOMImplementation_Release(dom_implementation
);
5862 static void test_defaults(IHTMLDocument2
*doc
)
5864 IHTMLStyleSheetsCollection
*stylesheetcol
;
5865 IHTMLCurrentStyle
*cstyle
;
5866 IHTMLBodyElement
*body
;
5867 IHTMLElement2
*elem2
;
5873 IHTMLElementCollection
*collection
;
5875 elem
= doc_get_body(doc
);
5877 hres
= IHTMLDocument2_get_images(doc
, NULL
);
5878 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5880 hres
= IHTMLDocument2_get_images(doc
, &collection
);
5881 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
5884 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5885 IHTMLElementCollection_Release(collection
);
5888 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
5889 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5891 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
5892 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
5895 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5896 IHTMLElementCollection_Release(collection
);
5899 hres
= IHTMLDocument2_get_links(doc
, NULL
);
5900 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5902 hres
= IHTMLDocument2_get_links(doc
, &collection
);
5903 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
5906 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5907 IHTMLElementCollection_Release(collection
);
5910 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
5911 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5913 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
5914 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
5917 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5918 IHTMLElementCollection_Release(collection
);
5921 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
5922 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
5924 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
5925 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
5928 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
5929 IHTMLElementCollection_Release(collection
);
5932 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5933 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
5934 test_default_body(body
);
5935 test_body_funs(body
);
5936 IHTMLBodyElement_Release(body
);
5938 hres
= IHTMLElement_get_style(elem
, &style
);
5939 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
5941 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, "[object]");
5942 test_ifaces((IUnknown
*)style
, style_iids
);
5943 IHTMLStyle_Release(style
);
5946 hres
= IHTMLDocument2_get_charset(doc
, &str
);
5947 ok(hres
== S_OK
, "get_charset failed: %08x\n", hres
);
5948 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
5952 test_compatmode(doc
, "BackCompat");
5954 test_navigator(doc
);
5955 test_plugins_col(doc
);
5957 elem2
= get_elem2_iface((IUnknown
*)elem
);
5958 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
5959 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
5960 if(SUCCEEDED(hres
)) {
5963 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, "[object]");
5964 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
5966 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
5968 IUnknown_Release(unk
);
5971 /*IE6 doesn't have interface */
5972 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
5975 IHTMLCurrentStyle_Release(cstyle
);
5977 IHTMLElement2_Release(elem2
);
5979 IHTMLElement_Release(elem
);
5981 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
5982 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
5985 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
5986 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
5987 ok(l
== 0, "length = %d\n", l
);
5989 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
5991 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
5992 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
5994 test_default_selection(doc
);
5995 test_doc_title(doc
, "");
5996 test_dom_implementation(doc
);
5999 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
6000 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const char *exname
)
6002 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6006 str
= (void*)0xdeadbeef;
6007 hres
= IHTMLButtonElement_get_name(button
, &str
);
6008 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6010 ok_(__FILE__
,line
)(!strcmp_wa(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), exname
);
6012 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6014 IHTMLButtonElement_Release(button
);
6017 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
6018 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const char *name
)
6020 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6021 BSTR str
= a2bstr(name
);
6024 hres
= IHTMLButtonElement_put_name(button
, str
);
6025 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08x\n", hres
);
6027 IHTMLButtonElement_Release(button
);
6029 _test_button_name(line
, elem
, name
);
6032 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
6033 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
6035 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6036 VARIANT_BOOL disabled
= 100;
6039 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
6040 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
6041 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
6042 IHTMLButtonElement_Release(button
);
6044 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
6047 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
6048 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
6050 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
6053 hres
= IHTMLButtonElement_put_disabled(button
, b
);
6054 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08x\n", hres
);
6055 IHTMLButtonElement_Release(button
);
6057 _test_button_get_disabled(line
, elem
, b
);
6060 static void test_button_elem(IHTMLElement
*elem
)
6062 test_button_name(elem
, NULL
);
6063 set_button_name(elem
, "button name");
6066 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
6067 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
6068 IHTMLTableRow
*row
, LONG len
, const char *id
)
6070 IHTMLElementCollection
*col
;
6076 hres
= IHTMLTableRow_get_cells(row
, &col
);
6077 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6078 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
6080 hres
= IHTMLElementCollection_get_length(col
, &lval
);
6081 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08x\n", hres
);
6082 ok_(__FILE__
, line
)(lval
== len
, "expected len = %d, got %d\n", len
, lval
);
6084 V_VT(&var
) = VT_BSTR
;
6085 V_BSTR(&var
) = a2bstr(id
);
6086 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
6087 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08x\n", id
, hres
);
6088 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
6091 IDispatch_Release(disp
);
6092 IHTMLElementCollection_Release(col
);
6095 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
6099 IHTMLTableCell
*cell
;
6101 hres
= IHTMLTableRow_deleteCell(row
, 0);
6102 ok(hres
== S_OK
, "deleteCell failed: %08x\n", hres
);
6103 test_tr_possess(elem
, row
, 1, "td2");
6105 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
6106 ok(hres
== S_OK
, "insertCell failed: %08x\n", hres
);
6107 ok(disp
!= NULL
, "disp == NULL\n");
6108 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
6109 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08x\n", hres
);
6110 ok(cell
!= NULL
, "cell == NULL\n");
6111 if (SUCCEEDED(hres
))
6112 IHTMLTableCell_Release(cell
);
6113 test_tr_possess(elem
, row
, 2, "td2");
6114 IDispatch_Release(disp
);
6117 static void test_tr_elem(IHTMLElement
*elem
)
6119 IHTMLElementCollection
*col
;
6124 VARIANT vbg
, vDefaultbg
;
6126 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
6128 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
6129 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6134 hres
= IHTMLTableRow_get_cells(row
, &col
);
6135 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
6136 ok(col
!= NULL
, "get_cells returned NULL\n");
6138 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
6139 IHTMLElementCollection_Release(col
);
6141 bstr
= a2bstr("left");
6142 hres
= IHTMLTableRow_put_align(row
, bstr
);
6143 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6144 SysFreeString(bstr
);
6147 hres
= IHTMLTableRow_get_align(row
, &bstr
);
6148 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6149 ok(bstr
!= NULL
, "get_align returned NULL\n");
6150 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6151 SysFreeString(bstr
);
6153 bstr
= a2bstr("top");
6154 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
6155 ok(hres
== S_OK
, "set_valign failed: %08x\n", hres
);
6156 SysFreeString(bstr
);
6159 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
6160 ok(hres
== S_OK
, "get_valign failed: %08x\n", hres
);
6161 ok(bstr
!= NULL
, "get_valign returned NULL\n");
6162 ok(!strcmp_wa(bstr
, "top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
6163 SysFreeString(bstr
);
6166 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
6167 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6168 ok(lval
== 1, "get_rowIndex returned %d\n", lval
);
6171 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
6172 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08x\n", hres
);
6173 ok(lval
== 1, "get_sectionRowIndex returned %d\n", lval
);
6175 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
6176 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6177 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6178 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6180 V_VT(&vbg
) = VT_BSTR
;
6181 V_BSTR(&vbg
) = a2bstr("red");
6182 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6183 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6186 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6187 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6188 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6189 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6193 V_I4(&vbg
) = 0xff0000;
6194 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
6195 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6198 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
6199 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6200 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6201 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6204 /* Restore Originial */
6205 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
6206 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6207 VariantClear(&vDefaultbg
);
6209 test_tr_modify(elem
, row
);
6211 IHTMLTableRow_Release(row
);
6214 static void test_td_elem(IHTMLElement
*elem
)
6216 IHTMLTableCell
*cell
;
6220 VARIANT vbg
, vDefaultbg
;
6222 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
6223 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
6228 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
6229 ok(hres
== S_OK
, "get cellIndex failed: %08x\n", hres
);
6230 ok(lval
== 1, "Expected 1, got %d\n", lval
);
6232 str
= a2bstr("left");
6233 hres
= IHTMLTableCell_put_align(cell
, str
);
6234 ok(hres
== S_OK
, "put_align failed: %08x\n", hres
);
6238 hres
= IHTMLTableCell_get_align(cell
, &str
);
6239 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6240 ok(str
!= NULL
, "str is NULL\n");
6241 if (str
!= NULL
&& hres
== S_OK
) {
6242 ok(!strcmp_wa(str
, "left"), "got %s\n", wine_dbgstr_w(str
));
6246 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
6247 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6248 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6249 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6251 V_VT(&vbg
) = VT_BSTR
;
6252 V_BSTR(&vbg
) = a2bstr("red");
6253 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6254 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6257 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6258 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6259 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6260 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6264 V_I4(&vbg
) = 0xff0000;
6265 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
6266 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6269 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
6270 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6271 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6272 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6275 /* Restore Originial */
6276 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
6277 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6278 VariantClear(&vDefaultbg
);
6280 IHTMLTableCell_Release(cell
);
6283 static void test_label_elem(IHTMLElement
*elem
)
6285 IHTMLLabelElement
*label
;
6289 label
= get_label_iface((IUnknown
*)elem
);
6292 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6293 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6294 ok(!strcmp_wa(str
, "in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6298 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6299 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6302 str
= (void*)0xdeadbeef;
6303 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6304 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6305 ok(!strcmp_wa(str
, ""), "htmlFor = %s\n", wine_dbgstr_w(str
));
6307 str
= a2bstr("abc");
6308 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
6309 ok(hres
== S_OK
, "put_htmlFor failed: %08x\n", hres
);
6313 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
6314 ok(hres
== S_OK
, "get_htmlFor failed: %08x\n", hres
);
6315 ok(!strcmp_wa(str
, "abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
6318 IHTMLLabelElement_Release(label
);
6321 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
6322 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const char *exstr
)
6327 V_VT(&v
) = VT_ERROR
;
6328 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
6329 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08x\n", hres
);
6330 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
6332 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exstr
);
6334 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6338 static void test_table_modify(IHTMLTable
*table
)
6345 test_table_length(table
, 2);
6347 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
6348 ok(hres
== S_OK
, "insertRow failed: %08x\n", hres
);
6349 ok(disp
!= NULL
, "disp == NULL\n");
6350 test_table_length(table
, 3);
6351 if (hres
!= S_OK
|| disp
== NULL
)
6354 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
6355 IDispatch_Release(disp
);
6357 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
6358 ok(row
!= NULL
, "row == NULL\n");
6361 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
6362 ok(hres
== S_OK
, "get_rowIndex failed: %08x\n", hres
);
6363 ok(index
== 0, "index = %d, expected 0\n", index
);
6365 IHTMLTableRow_Release(row
);
6367 hres
= IHTMLTable_deleteRow(table
, 0);
6368 ok(hres
== S_OK
, "deleteRow failed: %08x\n", hres
);
6369 test_table_length(table
, 2);
6372 static void test_table_elem(IHTMLElement
*elem
)
6374 IHTMLElementCollection
*col
;
6376 IHTMLTable3
*table3
;
6381 VARIANT vbg
, vDefaultbg
;
6383 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
6384 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
6385 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
6387 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
6388 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
6392 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
6393 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08x\n", hres
);
6398 hres
= IHTMLTable_get_rows(table
, &col
);
6399 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
6400 ok(col
!= NULL
, "get_rows returned NULL\n");
6402 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
6403 IHTMLElementCollection_Release(col
);
6405 test_elem_all((IUnknown
*)table
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6407 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
6408 test_elem_tag((IUnknown
*)node
, "TABLE");
6409 test_elem_all((IUnknown
*)node
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
6410 IHTMLDOMNode_Release(node
);
6412 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
6413 test_elem_tag((IUnknown
*)node
, "TABLE");
6414 test_elem_all((IUnknown
*)node
, NULL
, 0);
6415 IHTMLDOMNode_Release(node
);
6418 hres
= IHTMLTable_get_tBodies(table
, &col
);
6419 ok(hres
== S_OK
, "get_tBodies failed: %08x\n", hres
);
6420 ok(col
!= NULL
, "get_tBodies returned NULL\n");
6422 test_elem_collection((IUnknown
*)col
, tbodies_types
, sizeof(tbodies_types
)/sizeof(*tbodies_types
));
6423 IHTMLElementCollection_Release(col
);
6425 test_table_cell_spacing(table
, NULL
);
6429 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6430 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6431 test_table_cell_spacing(table
, "10");
6434 V_BSTR(&v
) = a2bstr("11");
6435 hres
= IHTMLTable_put_cellSpacing(table
, v
);
6436 ok(hres
== S_OK
, "put_cellSpacing = %08x\n", hres
);
6437 test_table_cell_spacing(table
, "11");
6440 bstr
= a2bstr("left");
6441 hres
= IHTMLTable_put_align(table
, bstr
);
6442 ok(hres
== S_OK
, "set_align failed: %08x\n", hres
);
6443 SysFreeString(bstr
);
6446 hres
= IHTMLTable_get_align(table
, &bstr
);
6447 ok(hres
== S_OK
, "get_align failed: %08x\n", hres
);
6448 ok(bstr
!= NULL
, "get_align returned NULL\n");
6449 ok(!strcmp_wa(bstr
, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
6450 SysFreeString(bstr
);
6452 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
6453 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6454 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
6455 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
6457 V_VT(&vbg
) = VT_BSTR
;
6458 V_BSTR(&vbg
) = a2bstr("red");
6459 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6460 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6463 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6464 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6465 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6466 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6470 V_I4(&vbg
) = 0xff0000;
6471 hres
= IHTMLTable_put_bgColor(table
, vbg
);
6472 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6475 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
6476 ok(hres
== S_OK
, "get_bgColor failed: %08x\n", hres
);
6477 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
6478 ok(!strcmp_wa(V_BSTR(&vbg
), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
6481 /* Restore Originial */
6482 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
6483 ok(hres
== S_OK
, "put_bgColor failed: %08x\n", hres
);
6484 VariantClear(&vDefaultbg
);
6487 V_BSTR(&v
) = a2bstr("11");
6488 hres
= IHTMLTable_put_width(table
, v
);
6489 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6491 IHTMLTable_get_width(table
, &v
);
6492 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6493 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6497 V_BSTR(&v
) = a2bstr("11.9");
6498 hres
= IHTMLTable_put_width(table
, v
);
6499 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6501 IHTMLTable_get_width(table
, &v
);
6502 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6503 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6507 V_BSTR(&v
) = a2bstr("40.2%");
6508 hres
= IHTMLTable_put_width(table
, v
);
6509 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6511 IHTMLTable_get_width(table
, &v
);
6512 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6513 ok(!strcmp_wa(V_BSTR(&v
), "40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6518 hres
= IHTMLTable_put_width(table
, v
);
6519 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6520 IHTMLTable_get_width(table
, &v
);
6521 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6522 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6527 hres
= IHTMLTable_put_width(table
, v
);
6528 ok(hres
== S_OK
, "put_width = %08x\n", hres
);
6529 IHTMLTable_get_width(table
, &v
);
6530 ok(hres
== S_OK
, "get_width = %08x\n", hres
);
6531 ok(!strcmp_wa(V_BSTR(&v
), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6535 bstr
= a2bstr("box");
6536 hres
= IHTMLTable_put_frame(table
, bstr
);
6537 ok(hres
== S_OK
, "put_frame = %08x\n", hres
);
6538 SysFreeString(bstr
);
6539 hres
= IHTMLTable_get_frame(table
, &bstr
);
6540 ok(hres
== S_OK
, "get_frame = %08x\n", hres
);
6541 ok(!strcmp_wa(bstr
, "box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
6542 SysFreeString(bstr
);
6544 test_table_modify(table
);
6545 bstr
= a2bstr("summary");
6546 hres
= IHTMLTable3_put_summary(table3
, bstr
);
6547 ok(hres
== S_OK
, "put_summary = %08x\n", hres
);
6548 SysFreeString(bstr
);
6550 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
6551 ok(hres
== S_OK
, "get_summary = %08x\n", hres
);
6552 ok(!strcmp_wa(bstr
, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
6553 SysFreeString(bstr
);
6555 IHTMLTable3_Release(table3
);
6556 IHTMLTable_Release(table
);
6559 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const char *text
)
6568 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6569 SafeArrayAccessData(sa
, (void**)&var
);
6570 V_VT(var
) = VT_BSTR
;
6571 V_BSTR(var
) = a2bstr(text
);
6572 SafeArrayUnaccessData(sa
);
6575 hres
= IHTMLDocument2_writeln(doc
, sa
);
6577 hres
= IHTMLDocument2_write(doc
, sa
);
6578 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6580 SafeArrayDestroy(sa
);
6583 static void doc_complex_write(IHTMLDocument2
*doc
)
6585 SAFEARRAYBOUND dim
= {5, 0};
6590 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
6591 SafeArrayAccessData(sa
, (void**)&args
);
6593 V_VT(args
) = VT_BSTR
;
6594 V_BSTR(args
) = a2bstr("<body i4val=\"");
6595 V_VT(args
+1) = VT_I4
;
6597 V_VT(args
+2) = VT_BSTR
;
6598 V_BSTR(args
+2) = a2bstr("\" r8val=\"");
6599 V_VT(args
+3) = VT_R8
;
6600 V_R8(args
+3) = 3.14;
6601 V_VT(args
+4) = VT_BSTR
;
6602 V_BSTR(args
+4) = a2bstr("\">");
6603 SafeArrayUnaccessData(sa
);
6605 hres
= IHTMLDocument2_write(doc
, sa
);
6606 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
6608 SafeArrayDestroy(sa
);
6611 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
6613 IHTMLDocument2
*window_doc
, *elem_doc
;
6614 IHTMLFrameElement3
*frame_elem3
;
6615 IHTMLWindow2
*content_window
;
6618 content_window
= get_frame_content_window(frame_elem
);
6619 test_ifaces((IUnknown
*)content_window
, window_iids
);
6620 window_doc
= get_window_doc(content_window
);
6621 IHTMLWindow2_Release(content_window
);
6623 elem_doc
= get_elem_doc(frame_elem
);
6624 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
6627 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
6628 if(SUCCEEDED(hres
)) {
6629 IDispatch
*disp
= NULL
;
6631 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
6632 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6633 ok(disp
!= NULL
, "contentDocument == NULL\n");
6634 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
6636 IDispatch_Release(disp
);
6637 IHTMLFrameElement3_Release(frame_elem3
);
6639 win_skip("IHTMLFrameElement3 not supported\n");
6643 IHTMLDocument2_Release(elem_doc
);
6644 IHTMLDocument2_Release(window_doc
);
6647 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
6648 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6650 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6654 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
6655 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08x\n", hres
);
6656 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
6658 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "height = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6660 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6662 IHTMLIFrameElement2_Release(iframe
);
6665 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
6666 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const char *val
)
6668 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6673 V_BSTR(&v
) = a2bstr(val
);
6674 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
6675 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08x\n", hres
);
6677 IHTMLIFrameElement2_Release(iframe
);
6680 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
6681 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *exval
)
6683 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6687 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
6688 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08x\n", hres
);
6689 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
6691 ok_(__FILE__
,line
)(!strcmp_wa(V_BSTR(&v
), exval
), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), exval
);
6693 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6695 IHTMLIFrameElement2_Release(iframe
);
6698 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
6699 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const char *val
)
6701 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
6706 V_BSTR(&v
) = a2bstr(val
);
6707 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
6708 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08x\n", hres
);
6710 IHTMLIFrameElement2_Release(iframe
);
6713 static void test_iframe_elem(IHTMLElement
*elem
)
6715 IHTMLDocument2
*content_doc
, *owner_doc
;
6716 IHTMLIFrameElement3
*iframe3
;
6717 IHTMLElementCollection
*col
;
6718 IHTMLWindow2
*content_window
;
6725 static const elem_type_t all_types
[] = {
6733 test_frame_doc((IUnknown
*)elem
, TRUE
);
6734 test_framebase((IUnknown
*)elem
);
6736 content_window
= get_frame_content_window((IUnknown
*)elem
);
6737 test_ifaces((IUnknown
*)content_window
, window_iids
);
6738 test_window_length(content_window
, 0);
6740 content_doc
= get_window_doc(content_window
);
6741 IHTMLWindow2_Release(content_window
);
6743 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
6744 if(SUCCEEDED(hres
)) {
6745 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
6746 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
6747 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
6748 IDispatch_Release(disp
);
6750 IHTMLIFrameElement3_Release(iframe3
);
6752 win_skip("IHTMLIFrameElement3 not supported\n");
6755 test_iframe_height(elem
, NULL
);
6756 set_iframe_height(elem
, "100px");
6757 set_iframe_height(elem
, "50%");
6758 test_iframe_height(elem
, "50%");
6760 test_iframe_width(elem
, NULL
);
6761 set_iframe_width(elem
, "150px");
6762 set_iframe_width(elem
, "70%");
6763 test_iframe_width(elem
, "70%");
6765 str
= a2bstr("text/html");
6766 V_VT(&errv
) = VT_ERROR
;
6768 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
6770 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
6771 ok(disp
!= NULL
, "disp == NULL\n");
6772 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
6773 IDispatch_Release(disp
);
6775 doc_write(content_doc
, FALSE
, "<html><head><title>test</title></head>");
6776 doc_complex_write(content_doc
);
6777 doc_write(content_doc
, TRUE
, "<br />");
6778 doc_write(content_doc
, TRUE
, "</html>");
6780 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
6781 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
6782 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
6783 IHTMLElementCollection_Release(col
);
6785 body
= doc_get_body(content_doc
);
6786 test_elem_attr(body
, "i4val", "4");
6787 test_elem_attr(body
, "r8val", "3.14");
6788 IHTMLElement_Release(body
);
6790 hres
= IHTMLDocument2_close(content_doc
);
6791 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
6793 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
6794 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
6796 IHTMLDocument2_Release(content_doc
);
6799 static void test_stylesheet(IDispatch
*disp
)
6801 IHTMLStyleSheetRulesCollection
*col
= NULL
;
6802 IHTMLStyleSheet
*stylesheet
;
6806 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, "[object]");
6808 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
6809 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
6811 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
6812 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
6813 ok(col
!= NULL
, "col == NULL\n");
6815 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, "[object]");
6816 IHTMLStyleSheetRulesCollection_Release(col
);
6818 href
= (void*)0xdeadbeef;
6819 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
6820 ok(hres
== S_OK
, "get_href failed: %08x\n", hres
);
6821 ok(href
== NULL
, "got href != NULL\n");
6822 SysFreeString(href
);
6824 IHTMLStyleSheet_Release(stylesheet
);
6827 static void test_stylesheets(IHTMLDocument2
*doc
)
6829 IHTMLStyleSheetsCollection
*col
= NULL
;
6834 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
6835 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
6836 ok(col
!= NULL
, "col == NULL\n");
6838 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, "[object]");
6840 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
6841 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
6842 ok(len
== 1, "len=%d\n", len
);
6848 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
6849 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
6850 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
6851 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
6852 test_stylesheet(V_DISPATCH(&res
));
6859 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
6860 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
6861 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
6864 IHTMLStyleSheetsCollection_Release(col
);
6867 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
6869 IDispatchEx
*dispex
;
6871 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
6879 static const WCHAR w0
[] = {'0',0};
6880 static const WCHAR w100
[] = {'1','0','0',0};
6882 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
6883 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
6885 bstr
= SysAllocString(w0
);
6886 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6887 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
6888 SysFreeString(bstr
);
6891 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
6892 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
6893 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
6894 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
6895 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
6896 type
= get_node_type((IUnknown
*)node
);
6897 ok(type
== 3, "type=%d\n", type
);
6898 IHTMLDOMNode_Release(node
);
6901 bstr
= SysAllocString(w100
);
6902 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
6903 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
6904 SysFreeString(bstr
);
6906 IDispatchEx_Release(dispex
);
6909 static void test_enum_children(IUnknown
*unk
, unsigned len
)
6911 IEnumVARIANT
*enum_var
;
6916 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
6917 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08x\n", hres
);
6919 for(i
=0; i
<len
; i
++) {
6921 V_VT(&v
) = VT_ERROR
;
6922 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
6923 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
6925 ok(fetched
== 1, "fetched = %d\n", fetched
);
6926 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
6927 IDispatch_Release(V_DISPATCH(&v
));
6930 fetched
= 0xdeadbeef;
6932 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
6933 ok(hres
== S_FALSE
, "Next returned %08x, expected S_FALSE\n", hres
);
6934 ok(fetched
== 0, "fetched = %d\n", fetched
);
6935 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
6937 hres
= IEnumVARIANT_Reset(enum_var
);
6938 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
6940 fetched
= 0xdeadbeef;
6942 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
6943 ok(hres
== S_OK
, "Next returned %08x, expected S_FALSE\n", hres
);
6944 ok(fetched
== 0, "fetched = %d\n", fetched
);
6945 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
6947 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
6948 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
6950 hres
= IEnumVARIANT_Reset(enum_var
);
6951 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
6953 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
6954 ok(hres
== S_FALSE
, "Skip failed: %08x\n", hres
);
6956 IEnumVARIANT_Release(enum_var
);
6959 static void test_elems(IHTMLDocument2
*doc
)
6961 IHTMLElementCollection
*col
;
6962 IHTMLDOMChildrenCollection
*child_col
;
6963 IHTMLElement
*elem
, *elem2
, *elem3
;
6964 IHTMLDOMNode
*node
, *node2
;
6965 IHTMLWindow2
*window
;
6969 IHTMLElementCollection
*collection
;
6970 IHTMLDocument3
*doc3
;
6973 static const elem_type_t all_types
[] = {
7006 static const elem_type_t item_types
[] = {
7012 hres
= IHTMLDocument2_get_all(doc
, &col
);
7013 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7014 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
7015 test_elem_col_item(col
, "x", item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
7017 elem
= get_elem_col_item_idx(col
, 0);
7018 test_elem_source_index(elem
, 0);
7019 IHTMLElement_Release(elem
);
7021 elem
= get_elem_col_item_idx(col
, 3);
7022 test_elem_source_index(elem
, 3);
7023 IHTMLElement_Release(elem
);
7025 IHTMLElementCollection_Release(col
);
7027 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7028 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
7031 static const elem_type_t images_types
[] = {ET_IMG
};
7032 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7034 IHTMLElementCollection_Release(collection
);
7037 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7038 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
7041 static const elem_type_t images_types
[] = {ET_A
};
7042 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
7044 IHTMLElementCollection_Release(collection
);
7047 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7048 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
7051 static const elem_type_t anchor_types
[] = {ET_A
};
7052 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
7054 IHTMLElementCollection_Release(collection
);
7057 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
7058 ok(hres
== S_OK
, "get_scripts failed: %08x\n", hres
);
7060 static const elem_type_t script_types
[] = {ET_SCRIPT
};
7061 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
7062 IHTMLElementCollection_Release(collection
);
7065 test_plugins_col(doc
);
7067 elem
= get_doc_elem(doc
);
7068 test_elem_all((IUnknown
*)elem
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
7069 IHTMLElement_Release(elem
);
7071 get_elem_by_id(doc
, "xxx", FALSE
);
7072 elem
= get_doc_elem_by_id(doc
, "xxx");
7073 ok(!elem
, "elem != NULL\n");
7075 elem
= get_doc_elem_by_id(doc
, "s");
7076 ok(elem
!= NULL
, "elem == NULL\n");
7078 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
7079 test_elem_attr(elem
, "xxx", NULL
);
7080 test_elem_attr(elem
, "id", "s");
7081 test_elem_class((IUnknown
*)elem
, NULL
);
7082 test_elem_set_class((IUnknown
*)elem
, "cl");
7083 test_elem_set_class((IUnknown
*)elem
, NULL
);
7084 test_elem_tabindex((IUnknown
*)elem
, 0);
7085 test_elem_set_tabindex((IUnknown
*)elem
, 1);
7086 test_elem_filters((IUnknown
*)elem
);
7088 node
= test_node_get_parent((IUnknown
*)elem
);
7089 ok(node
!= NULL
, "node == NULL\n");
7090 test_node_name((IUnknown
*)node
, "BODY");
7091 node2
= test_node_get_parent((IUnknown
*)node
);
7092 IHTMLDOMNode_Release(node
);
7093 ok(node2
!= NULL
, "node == NULL\n");
7094 test_node_name((IUnknown
*)node2
, "HTML");
7095 node
= test_node_get_parent((IUnknown
*)node2
);
7096 IHTMLDOMNode_Release(node2
);
7097 ok(node
!= NULL
, "node == NULL\n");
7100 test_node_name((IUnknown
*)node
, "#document");
7101 type
= get_node_type((IUnknown
*)node
);
7102 ok(type
== 9, "type=%d, expected 9\n", type
);
7103 node2
= test_node_get_parent((IUnknown
*)node
);
7104 IHTMLDOMNode_Release(node
);
7105 ok(node2
== NULL
, "node != NULL\n");
7108 elem2
= test_elem_get_parent((IUnknown
*)elem
);
7109 ok(elem2
!= NULL
, "elem2 == NULL\n");
7110 test_node_name((IUnknown
*)elem2
, "BODY");
7112 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
7113 ok(elem3
!= NULL
, "elem3 == NULL\n");
7114 test_node_name((IUnknown
*)elem3
, "HTML");
7116 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
7117 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
7118 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
7119 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
7120 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
7121 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
7122 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
7123 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
7124 IHTMLElement_Release(elem2
);
7126 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
7127 ok(elem2
== NULL
, "elem2 != NULL\n");
7128 test_elem_source_index(elem3
, 0);
7129 IHTMLElement_Release(elem3
);
7131 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
7132 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
7133 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
7135 test_elem_innertext(elem
, "opt1opt2");
7137 IHTMLElement_Release(elem
);
7140 elem
= get_elem_by_id(doc
, "s", TRUE
);
7142 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
7143 IHTMLDocument2
*doc_node
, *elem_doc
;
7145 test_select_elem(select
);
7147 test_elem_title((IUnknown
*)select
, NULL
);
7148 test_elem_set_title((IUnknown
*)select
, "Title");
7149 test_elem_title((IUnknown
*)select
, "Title");
7150 test_elem_offset((IUnknown
*)select
, "BODY");
7151 test_elem_bounding_client_rect((IUnknown
*)select
);
7153 node
= get_first_child((IUnknown
*)select
);
7154 ok(node
!= NULL
, "node == NULL\n");
7156 test_elem_type((IUnknown
*)node
, ET_OPTION
);
7157 IHTMLDOMNode_Release(node
);
7160 type
= get_node_type((IUnknown
*)select
);
7161 ok(type
== 1, "type=%d\n", type
);
7163 IHTMLSelectElement_Release(select
);
7165 elem_doc
= get_elem_doc((IUnknown
*)elem
);
7167 doc_node
= get_doc_node(doc
);
7168 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
7169 IHTMLDocument2_Release(doc_node
);
7170 IHTMLDocument2_Release(elem_doc
);
7172 IHTMLElement_Release(elem
);
7175 elem
= get_elem_by_id(doc
, "sc", TRUE
);
7177 IHTMLScriptElement
*script
;
7180 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
7181 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
7183 test_elem_language(elem
, NULL
);
7189 hres
= IHTMLScriptElement_put_type (script
, NULL
);
7190 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7191 hres
= IHTMLScriptElement_get_type(script
, &type
);
7192 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7193 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
7195 type
= a2bstr("text/javascript");
7196 hres
= IHTMLScriptElement_put_type (script
, type
);
7197 ok(hres
== S_OK
, "put_type failed: %08x\n", hres
);
7198 SysFreeString(type
);
7199 hres
= IHTMLScriptElement_get_type(script
, &type
);
7200 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
7201 ok(!strcmp_wa(type
, "text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
7202 SysFreeString(type
);
7204 test_script_text(script
, "<!--\nfunction Testing() {}\n// -->\n");
7207 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
7208 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7210 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
7211 ok(hres
== S_OK
, "get_defer failed: %08x\n", hres
);
7212 ok(vb
== VARIANT_TRUE
, "get_defer result is %08x\n", hres
);
7214 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
7215 ok(hres
== S_OK
, "put_defer failed: %08x\n", hres
);
7217 str
= (BSTR
)0xdeadbeef;
7218 hres
= IHTMLScriptElement_get_src(script
, &str
);
7219 ok(hres
== S_OK
, "get_src failed: %08x\n", hres
);
7220 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
7223 IHTMLScriptElement_Release(script
);
7225 set_elem_language(elem
, "vbscript");
7226 set_elem_language(elem
, "xxx");
7229 elem
= get_elem_by_id(doc
, "in", TRUE
);
7231 IHTMLInputElement
*input
;
7233 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
7234 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
7236 test_elem_id((IUnknown
*)elem
, "in");
7237 test_elem_put_id((IUnknown
*)elem
, "newin");
7238 test_input_get_disabled(input
, VARIANT_FALSE
);
7239 test_input_set_disabled(input
, VARIANT_TRUE
);
7240 test_input_set_disabled(input
, VARIANT_FALSE
);
7241 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
7242 test_input_get_disabled(input
, VARIANT_TRUE
);
7243 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
7244 test_input_get_disabled(input
, VARIANT_FALSE
);
7245 test_elem_client_size((IUnknown
*)elem
);
7246 test_input_type(input
, "text");
7248 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7249 test_node_put_value_str((IUnknown
*)elem
, "test");
7250 test_node_get_value_str((IUnknown
*)elem
, NULL
);
7251 test_input_value((IUnknown
*)elem
, NULL
);
7252 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7253 test_input_put_value((IUnknown
*)elem
, "test");
7254 test_input_defaultValue((IUnknown
*)elem
, NULL
);
7255 test_elem_class((IUnknown
*)elem
, "testclass");
7256 test_elem_tabindex((IUnknown
*)elem
, 2);
7257 test_elem_set_tabindex((IUnknown
*)elem
, 3);
7258 test_elem_title((IUnknown
*)elem
, "test title");
7260 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
7261 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
7262 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
7264 test_input_get_checked(input
, VARIANT_FALSE
);
7265 test_input_set_checked(input
, VARIANT_TRUE
);
7266 test_input_set_checked(input
, VARIANT_FALSE
);
7268 test_input_maxlength(input
, 0x7fffffff);
7269 test_input_set_maxlength(input
, 30);
7271 test_input_name(input
, NULL
);
7272 test_input_set_name(input
, "test");
7274 test_input_src(input
, NULL
);
7275 test_input_set_src(input
, "about:blank");
7277 test_input_set_size(input
, 15, S_OK
);
7278 test_input_get_size(input
, 15);
7279 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
7280 test_input_get_size(input
, 15);
7281 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
7282 test_input_get_size(input
, 15);
7284 test_input_readOnly(input
, VARIANT_TRUE
);
7285 test_input_readOnly(input
, VARIANT_FALSE
);
7287 IHTMLInputElement_Release(input
);
7288 IHTMLElement_Release(elem
);
7291 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7293 test_img_align((IUnknown
*)elem
, "left");
7294 test_img_name((IUnknown
*)elem
, "WineImg");
7295 test_img_src((IUnknown
*)elem
, "", NULL
);
7296 test_img_set_src((IUnknown
*)elem
, "about:blank");
7297 test_img_src((IUnknown
*)elem
, "about:blank", NULL
);
7298 test_img_alt((IUnknown
*)elem
, NULL
);
7299 test_img_set_alt((IUnknown
*)elem
, "alt test");
7300 test_img_name((IUnknown
*)elem
, "WineImg");
7301 test_img_complete(elem
, VARIANT_FALSE
);
7302 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
7303 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
7304 IHTMLElement_Release(elem
);
7307 elem
= get_elem_by_id(doc
, "attr", TRUE
);
7309 test_dynamic_properties(elem
);
7310 test_attr_collection(elem
);
7311 test_contenteditable((IUnknown
*)elem
);
7312 IHTMLElement_Release(elem
);
7315 elem
= get_elem_by_id(doc
, "styleid", TRUE
);
7317 test_style_media((IUnknown
*)elem
, NULL
);
7318 test_style_put_media((IUnknown
*)elem
, "screen");
7319 test_style_type((IUnknown
*)elem
, NULL
);
7320 test_style_put_type((IUnknown
*)elem
, "text/css");
7321 IHTMLElement_Release(elem
);
7324 elem
= get_doc_elem_by_id(doc
, "tbl");
7325 ok(elem
!= NULL
, "elem == NULL\n");
7327 test_table_elem(elem
);
7328 IHTMLElement_Release(elem
);
7331 elem
= get_doc_elem_by_id(doc
, "labelid");
7332 ok(elem
!= NULL
, "elem == NULL\n");
7334 test_label_elem(elem
);
7335 IHTMLElement_Release(elem
);
7338 elem
= get_doc_elem_by_id(doc
, "td2");
7339 ok(elem
!= NULL
, "elem == NULL\n");
7342 IHTMLElement_Release(elem
);
7345 elem
= get_doc_elem_by_id(doc
, "row2");
7346 ok(elem
!= NULL
, "elem == NULL\n");
7349 IHTMLElement_Release(elem
);
7352 elem
= get_doc_elem_by_id(doc
, "ifr");
7353 ok(elem
!= NULL
, "elem == NULL\n");
7355 test_iframe_elem(elem
);
7356 IHTMLElement_Release(elem
);
7359 elem
= get_doc_elem_by_id(doc
, "btnid");
7360 ok(elem
!= NULL
, "elem == NULL\n");
7362 test_button_elem(elem
);
7363 test_button_get_disabled(elem
, VARIANT_FALSE
);
7364 test_button_set_disabled(elem
, VARIANT_TRUE
);
7365 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7366 test_button_get_disabled(elem
, VARIANT_FALSE
);
7367 IHTMLElement_Release(elem
);
7370 elem
= get_doc_elem_by_id(doc
, "objid");
7371 ok(elem
!= NULL
, "elem == NULL\n");
7373 test_object_vspace((IUnknown
*)elem
, 100);
7374 test_object_name(elem
, "objname");
7375 set_object_name(elem
, "test");
7376 set_object_name(elem
, NULL
);
7377 IHTMLElement_Release(elem
);
7380 elem
= get_elem_by_id(doc
, "a", TRUE
);
7382 test_anchor_href((IUnknown
*)elem
, "http://test/");
7384 /* Change the href */
7385 test_anchor_put_href((IUnknown
*)elem
, "http://test1/");
7386 test_anchor_href((IUnknown
*)elem
, "http://test1/");
7387 test_anchor_hostname((IUnknown
*)elem
, "test1");
7389 /* Restore the href */
7390 test_anchor_put_href((IUnknown
*)elem
, "http://test/");
7391 test_anchor_href((IUnknown
*)elem
, "http://test/");
7392 test_anchor_hostname((IUnknown
*)elem
, "test");
7393 test_anchor_hash(elem
, NULL
);
7396 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7398 test_anchor_rel((IUnknown
*)elem
, NULL
);
7399 test_anchor_put_rel((IUnknown
*)elem
, "Next");
7400 test_anchor_rel((IUnknown
*)elem
, "Next");
7402 /* Change the target */
7403 test_anchor_put_target((IUnknown
*)elem
, "wine");
7404 test_anchor_get_target((IUnknown
*)elem
, "wine");
7406 /* Restore the target */
7407 test_anchor_put_target((IUnknown
*)elem
, NULL
);
7408 test_anchor_get_target((IUnknown
*)elem
, NULL
);
7410 test_anchor_name((IUnknown
*)elem
, "x");
7411 test_anchor_put_name((IUnknown
*)elem
, "anchor name");
7412 test_anchor_put_name((IUnknown
*)elem
, NULL
);
7413 test_anchor_put_name((IUnknown
*)elem
, "x");
7415 test_anchor_put_href((IUnknown
*)elem
, "http://test/?how#hash");
7416 test_anchor_hash(elem
, "#hash");
7417 test_anchor_search((IUnknown
*)elem
, "?how", FALSE
);
7419 test_anchor_put_search((IUnknown
*)elem
, "?word=press");
7420 test_anchor_search((IUnknown
*)elem
, "?word=press", FALSE
);
7421 test_anchor_put_search((IUnknown
*)elem
, "?????word???press");
7422 test_anchor_search((IUnknown
*)elem
, "?????word???press", FALSE
);
7424 test_anchor_put_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD"); /* encoded cjk characters */
7425 test_anchor_search((IUnknown
*)elem
, "?q=\%E4\%BD\%A0\%E5\%A5\%BD", FALSE
);
7427 test_anchor_put_search((IUnknown
*)elem
, "?how?old=are");
7428 test_anchor_search((IUnknown
*)elem
, "?how?old=are", FALSE
);
7430 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
7431 as part of the pathname, and cannot be accessed by get_search. */
7432 test_anchor_put_search((IUnknown
*)elem
, "word=abc");
7433 test_anchor_search((IUnknown
*)elem
, "?word=abc", TRUE
);
7435 IHTMLElement_Release(elem
);
7438 elem
= get_doc_elem_by_id(doc
, "metaid");
7440 test_meta_name((IUnknown
*)elem
, "meta name");
7441 test_meta_content((IUnknown
*)elem
, "text/html; charset=utf-8");
7442 test_meta_httpequiv((IUnknown
*)elem
, "Content-Type");
7443 test_meta_charset((IUnknown
*)elem
, NULL
);
7444 set_meta_charset((IUnknown
*)elem
, "utf-8");
7445 IHTMLElement_Release(elem
);
7448 elem
= doc_get_body(doc
);
7450 node
= get_first_child((IUnknown
*)elem
);
7451 ok(node
!= NULL
, "node == NULL\n");
7453 test_ifaces((IUnknown
*)node
, text_iids
);
7454 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
7456 node2
= get_first_child((IUnknown
*)node
);
7457 ok(!node2
, "node2 != NULL\n");
7459 type
= get_node_type((IUnknown
*)node
);
7460 ok(type
== 3, "type=%d\n", type
);
7462 test_node_get_value_str((IUnknown
*)node
, "text test");
7463 test_node_put_value_str((IUnknown
*)elem
, "test text");
7464 test_node_get_value_str((IUnknown
*)node
, "text test");
7466 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
7467 ok(hres
== S_OK
, "get_attributes failed: %08x\n", hres
);
7468 ok(!disp
, "disp != NULL\n");
7470 IHTMLDOMNode_Release(node
);
7473 child_col
= get_child_nodes((IUnknown
*)elem
);
7474 ok(child_col
!= NULL
, "child_coll == NULL\n");
7479 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, "[object]");
7481 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
7482 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7483 ok(length
, "length=0\n");
7486 node
= get_child_item(child_col
, 0);
7487 ok(node
!= NULL
, "node == NULL\n");
7491 type
= get_node_type((IUnknown
*)node
);
7492 ok(type
== 3, "type=%d\n", type
);
7493 node2
= node_get_next((IUnknown
*)node
);
7495 prev
= node_get_prev((IUnknown
*)node2
);
7496 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
7497 IHTMLDOMNode_Release(prev
);
7499 IHTMLDOMNode_Release(node
);
7502 node
= get_child_item(child_col
, 1);
7503 ok(node
!= NULL
, "node == NULL\n");
7505 type
= get_node_type((IUnknown
*)node
);
7506 ok(type
== 8, "type=%d\n", type
);
7508 test_elem_id((IUnknown
*)node
, NULL
);
7509 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
7510 IHTMLDOMNode_Release(node2
);
7511 IHTMLDOMNode_Release(node
);
7514 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
7515 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7517 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
7518 ok(hres
== E_POINTER
, "item failed: %08x, expected E_POINTER\n", hres
);
7520 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
7521 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7523 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
7524 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
7526 test_child_col_disp(child_col
);
7528 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
7529 ok(hres
== S_OK
, "get__newEnum failed: %08x\n", hres
);
7531 test_enum_children(enum_unk
, length
);
7533 IUnknown_Release(enum_unk
);
7535 IHTMLDOMChildrenCollection_Release(child_col
);
7538 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7539 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
7540 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
7542 IHTMLElement_Release(elem
);
7544 elem
= get_doc_elem_by_id(doc
, "frm");
7545 ok(elem
!= NULL
, "elem == NULL\n");
7547 test_form_length((IUnknown
*)elem
, 0);
7548 test_form_elements((IUnknown
*)elem
);
7549 IHTMLElement_Release(elem
);
7552 test_stylesheets(doc
);
7553 test_create_option_elem(doc
);
7554 test_create_img_elem(doc
);
7556 elem
= get_doc_elem_by_id(doc
, "tbl");
7557 ok(elem
!= NULL
, "elem = NULL\n");
7558 test_elem_set_innertext(elem
, "inner text");
7559 IHTMLElement_Release(elem
);
7561 test_doc_title(doc
, "test");
7562 test_doc_set_title(doc
, "test title");
7563 test_doc_title(doc
, "test title");
7566 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
7567 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
7570 IDispatchEx
*dispex
;
7571 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
7572 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
7576 BSTR str
= a2bstr("Testing");
7577 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
7578 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
7579 ok(pid
!= -1, "pid == -1\n");
7581 IDispatchEx_Release(dispex
);
7584 IDispatch_Release(disp
);
7586 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
7587 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
7589 str
= a2bstr("Img");
7590 hres
= IHTMLDocument3_getElementsByTagName(doc3
, str
, &col
);
7591 ok(hres
== S_OK
, "getElementsByTagName(%s) failed: %08x\n", wine_dbgstr_w(str
), hres
);
7595 static const elem_type_t img_types
[] = { ET_IMG
};
7597 test_elem_collection((IUnknown
*)col
, img_types
, sizeof(img_types
)/sizeof(img_types
[0]));
7598 IHTMLElementCollection_Release(col
);
7601 elem
= get_doc_elem_by_id(doc
, "y");
7602 test_elem_set_innerhtml((IUnknown
*)elem
, "inner html");
7603 test_elem_innerhtml((IUnknown
*)elem
, "inner html");
7604 test_elem_set_innerhtml((IUnknown
*)elem
, "");
7605 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
7606 node
= node_get_next((IUnknown
*)elem
);
7607 ok(!node
, "node = %p\n", node
);
7609 elem2
= get_doc_elem_by_id(doc
, "x");
7610 test_elem_tag((IUnknown
*)elem2
, "A");
7611 node
= node_get_next((IUnknown
*)elem2
);
7612 IHTMLDOMNode_Release(node
);
7613 IHTMLElement_Release(elem2
);
7614 IHTMLElement_Release(elem
);
7616 IHTMLDocument3_Release(doc3
);
7618 elem
= get_elem_by_id(doc
, "s", TRUE
);
7620 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
7622 test_select_put_length((IUnknown
*)elem
, 3);
7623 test_elem_all((IUnknown
*)elem
, select_types
, sizeof(select_types
)/sizeof(*select_types
));
7624 test_select_put_length((IUnknown
*)elem
, 1);
7625 test_elem_all((IUnknown
*)elem
, select_types
, 1);
7626 IHTMLElement_Release(elem
);
7629 window
= get_doc_window(doc
);
7630 test_window_name(window
, NULL
);
7631 set_window_name(window
, "test name");
7632 test_window_length(window
, 1);
7633 IHTMLWindow2_Release(window
);
7636 static void test_attr(IHTMLElement
*elem
)
7638 IHTMLDOMAttribute
*attr
, *attr2
;
7641 get_elem_attr_node((IUnknown
*)elem
, "noattr", FALSE
);
7643 attr
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7645 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
7646 test_ifaces((IUnknown
*)attr
, attr_iids
);
7647 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
7648 test_attr_specified(attr
, VARIANT_TRUE
);
7650 attr2
= get_elem_attr_node((IUnknown
*)elem
, "id", TRUE
);
7651 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
7652 IHTMLDOMAttribute_Release(attr2
);
7654 get_attr_node_value(attr
, &v
, VT_BSTR
);
7655 ok(!strcmp_wa(V_BSTR(&v
), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7659 V_BSTR(&v
) = a2bstr("divid2");
7660 put_attr_node_value(attr
, v
);
7662 get_attr_node_value(attr
, &v
, VT_BSTR
);
7663 ok(!strcmp_wa(V_BSTR(&v
), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7666 IHTMLDOMAttribute_Release(attr
);
7668 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7669 get_attr_node_value(attr
, &v
, VT_BSTR
);
7670 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7674 V_BSTR(&v
) = a2bstr("newvalue");
7675 put_attr_node_value(attr
, v
);
7678 attr
= get_elem_attr_node((IUnknown
*)elem
, "emptyattr", TRUE
);
7679 get_attr_node_value(attr
, &v
, VT_BSTR
);
7680 ok(!strcmp_wa(V_BSTR(&v
), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7683 test_attr_specified(attr
, VARIANT_TRUE
);
7684 IHTMLDOMAttribute_Release(attr
);
7688 set_dispex_value((IUnknown
*)elem
, "dispprop", &v
);
7689 attr
= get_elem_attr_node((IUnknown
*)elem
, "dispprop", TRUE
);
7690 get_attr_node_value(attr
, &v
, VT_I4
);
7691 ok(V_I4(&v
) == 100, "V_I4(v) = %d\n", V_I4(&v
));
7692 test_attr_specified(attr
, VARIANT_TRUE
);
7696 put_attr_node_value(attr
, v
);
7698 get_attr_node_value(attr
, &v
, VT_I4
);
7699 ok(V_I4(&v
) == 150, "V_I4(v) = %d\n", V_I4(&v
));
7701 IHTMLDOMAttribute_Release(attr
);
7703 attr
= get_elem_attr_node((IUnknown
*)elem
, "tabIndex", TRUE
);
7704 test_attr_specified(attr
, VARIANT_FALSE
);
7705 IHTMLDOMAttribute_Release(attr
);
7708 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
7712 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7713 "<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
7714 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7716 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7717 IHTMLElement_Release(elem
);
7720 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
7721 "<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
7722 elem
= get_elem_by_id(doc
, "imgid", TRUE
);
7724 test_img_src((IUnknown
*)elem
, "blocke::http://www.winehq.org/img.png", NULL
);
7725 test_img_set_src((IUnknown
*)elem
, "BLOCKED:http://www.winehq.org/img.png");
7726 test_img_src((IUnknown
*)elem
, "blocked:http://www.winehq.org/img.png", NULL
);
7727 test_img_set_src((IUnknown
*)elem
, "blocked::http://www.winehq.org/img.png");
7728 test_img_src((IUnknown
*)elem
, "BLOCKED::", "blocked::http://www.winehq.org/img.png");
7729 IHTMLElement_Release(elem
);
7733 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
7734 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const char *name
)
7736 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
7737 IHTMLElementCollection
*col
;
7738 BSTR str
= a2bstr(name
);
7741 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
7742 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08x\n", hres
);
7743 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
7745 IHTMLDocument3_Release(doc3
);
7750 static void test_elem_names(IHTMLDocument2
*doc
)
7752 IHTMLElementCollection
*col
;
7757 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
7759 body
= doc_get_body(doc
);
7761 test_elem_set_innerhtml((IUnknown
*)body
,
7762 "<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
7763 col
= doc_get_elems_by_name(doc
, "test");
7764 test_elem_collection((IUnknown
*)col
, test1_types
, sizeof(test1_types
)/sizeof(*test1_types
));
7765 IHTMLElementCollection_Release(col
);
7767 col
= doc_get_elems_by_name(doc
, "yyy");
7768 test_elem_collection((IUnknown
*)col
, NULL
, 0);
7769 IHTMLElementCollection_Release(col
);
7771 /* case insensivity test */
7772 col
= doc_get_elems_by_name(doc
, "Xxx");
7773 hres
= IHTMLElementCollection_get_length(col
, &len
);
7774 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
7775 todo_wine
ok(len
== 1, "len = %d\n", len
);
7776 IHTMLElementCollection_Release(col
);
7778 IHTMLElement_Release(body
);
7781 static void test_elems2(IHTMLDocument2
*doc
)
7783 IHTMLElement
*elem
, *elem2
, *div
;
7785 static const elem_type_t outer_types
[] = {
7790 div
= get_doc_elem_by_id(doc
, "divid");
7792 elem
= get_elem_by_id(doc
, "linkid", TRUE
);
7794 test_link_disabled(elem
, VARIANT_FALSE
);
7795 test_link_rel(elem
, "stylesheet");
7796 test_link_rev(elem
, NULL
);
7797 test_link_type(elem
, "text/css");
7798 test_link_href(elem
, "about:blank");
7799 test_link_media(elem
, "all");
7800 link_put_disabled(elem
, VARIANT_TRUE
);
7801 link_put_rel(elem
, "prev");
7802 link_put_rev(elem
, "next");
7803 link_put_type(elem
, "text/plain");
7804 link_put_href(elem
, "about:prev");
7805 IHTMLElement_Release(elem
);
7808 test_elem_set_innerhtml((IUnknown
*)div
, "<div id=\"innerid\"></div>");
7809 elem2
= get_doc_elem_by_id(doc
, "innerid");
7810 ok(elem2
!= NULL
, "elem2 == NULL\n");
7811 test_elem_set_outerhtml((IUnknown
*)elem2
, "<br><a href=\"about:blank\" id=\"aid\">a</a>");
7812 test_elem_all((IUnknown
*)div
, outer_types
, sizeof(outer_types
)/sizeof(*outer_types
));
7813 IHTMLElement_Release(elem2
);
7815 elem2
= get_doc_elem_by_id(doc
, "aid");
7816 ok(elem2
!= NULL
, "elem2 == NULL\n");
7817 test_elem_set_outerhtml((IUnknown
*)elem2
, "");
7818 test_elem_all((IUnknown
*)div
, outer_types
, 1);
7819 IHTMLElement_Release(elem2
);
7821 test_elem_set_innerhtml((IUnknown
*)div
, "<textarea id=\"ta\"></textarea>");
7822 elem
= get_elem_by_id(doc
, "ta", TRUE
);
7824 IHTMLFormElement
*form
;
7826 test_textarea_value((IUnknown
*)elem
, NULL
);
7827 test_textarea_put_value((IUnknown
*)elem
, "test");
7828 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
7829 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
7830 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
7831 test_textarea_type((IUnknown
*)elem
);
7833 form
= get_textarea_form((IUnknown
*)elem
);
7834 ok(!form
, "form = %p\n", form
);
7836 IHTMLElement_Release(elem
);
7839 test_elem_set_innerhtml((IUnknown
*)div
, "<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
7840 elem
= get_elem_by_id(doc
, "ta", TRUE
);
7842 IHTMLFormElement
*form
;
7844 elem2
= get_elem_by_id(doc
, "fid", TRUE
);
7845 ok(elem2
!= NULL
, "elem2 == NULL\n");
7847 form
= get_textarea_form((IUnknown
*)elem
);
7848 ok(form
!= NULL
, "form = NULL\n");
7849 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
7851 IHTMLFormElement_Release(form
);
7852 IHTMLElement_Release(elem2
);
7853 IHTMLElement_Release(elem
);
7856 test_elem_set_innerhtml((IUnknown
*)div
,
7857 "<input value=\"val\" id =\"inputid\" />");
7858 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
7860 test_input_defaultValue((IUnknown
*)elem
, "val");
7861 test_input_put_value((IUnknown
*)elem
, "test");
7862 test_input_put_defaultValue((IUnknown
*)elem
, "new val");
7863 test_input_value((IUnknown
*)elem
, "test");
7864 IHTMLElement_Release(elem
);
7867 test_elem_set_innerhtml((IUnknown
*)div
, "");
7868 test_insert_adjacent_elems(doc
, div
);
7870 test_elem_set_innerhtml((IUnknown
*)div
,
7871 "<form id=\"form\"><input type=\"button\" /><div><input type=\"text\" id=\"inputid\"/></div></textarea>");
7872 elem
= get_elem_by_id(doc
, "form", TRUE
);
7874 test_form_length((IUnknown
*)elem
, 2);
7875 test_form_item(elem
);
7876 test_form_action((IUnknown
*)elem
, NULL
);
7877 test_form_put_action((IUnknown
*)elem
, "about:blank");
7878 test_form_method((IUnknown
*)elem
, "get");
7879 test_form_put_method((IUnknown
*)elem
, S_OK
, "post");
7880 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, "put");
7881 test_form_method((IUnknown
*)elem
, "post");
7882 test_form_name((IUnknown
*)elem
, NULL
);
7883 test_form_put_name((IUnknown
*)elem
, "Name");
7884 test_form_encoding((IUnknown
*)elem
, "application/x-www-form-urlencoded");
7885 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "text/plain");
7886 test_form_put_encoding((IUnknown
*)elem
, S_OK
, "multipart/form-data");
7887 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, "image/png");
7888 test_form_encoding((IUnknown
*)elem
, "multipart/form-data");
7889 test_form_elements((IUnknown
*)elem
);
7890 test_form_reset((IUnknown
*)elem
);
7891 test_form_target((IUnknown
*)elem
);
7892 IHTMLElement_Release(elem
);
7894 elem
= get_elem_by_id(doc
, "inputid", TRUE
);
7895 test_input_get_form((IUnknown
*)elem
, "form");
7896 IHTMLElement_Release(elem
);
7900 test_blocked(doc
, div
);
7901 test_elem_names(doc
);
7903 IHTMLElement_Release(div
);
7906 static void test_create_elems(IHTMLDocument2
*doc
)
7908 IHTMLElement
*elem
, *body
, *elem2
;
7909 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
7910 IHTMLDOMAttribute
*attr
;
7911 IHTMLDocument5
*doc5
;
7918 static const elem_type_t types1
[] = { ET_TESTG
};
7920 elem
= test_create_elem(doc
, "TEST");
7921 test_elem_tag((IUnknown
*)elem
, "TEST");
7922 type
= get_node_type((IUnknown
*)elem
);
7923 ok(type
== 1, "type=%d\n", type
);
7924 test_ifaces((IUnknown
*)elem
, elem_iids
);
7925 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, "[object]");
7926 test_elem_source_index(elem
, -1);
7928 body
= doc_get_body(doc
);
7929 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
7931 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
7932 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
7933 elem2
= get_elem_iface((IUnknown
*)node
);
7934 IHTMLElement_Release(elem2
);
7936 hres
= IHTMLElement_get_all(body
, &disp
);
7937 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7938 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
7939 IDispatch_Release(disp
);
7941 test_node_remove_child((IUnknown
*)body
, node
);
7943 hres
= IHTMLElement_get_all(body
, &disp
);
7944 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
7945 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
7946 IDispatch_Release(disp
);
7947 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
7949 IHTMLElement_Release(elem
);
7950 IHTMLDOMNode_Release(node
);
7952 node
= test_create_text(doc
, "abc");
7953 test_ifaces((IUnknown
*)node
, text_iids
);
7954 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, "[object]");
7955 test_text_length((IUnknown
*)node
, 3);
7956 test_text_data((IUnknown
*)node
, "abc");
7957 set_text_data((IUnknown
*)node
, "test");
7958 test_text_data((IUnknown
*)node
, "test");
7960 V_VT(&var
) = VT_NULL
;
7961 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7962 IHTMLDOMNode_Release(node
);
7964 node
= test_create_text(doc
, "insert ");
7966 V_VT(&var
) = VT_DISPATCH
;
7967 V_DISPATCH(&var
) = (IDispatch
*)node2
;
7968 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7969 IHTMLDOMNode_Release(node
);
7970 IHTMLDOMNode_Release(node2
);
7971 IHTMLDOMNode_Release(node3
);
7973 test_elem_innertext(body
, "insert test");
7974 test_elem_innerhtml((IUnknown
*)body
, "insert test");
7976 node
= test_create_text(doc
, " Test");
7977 V_VT(&var
) = VT_DISPATCH
;
7978 V_DISPATCH(&var
) = NULL
;
7979 test_node_insertbefore((IUnknown
*)body
, node
, &var
);
7980 test_elem_innertext(body
, "insert test Test");
7981 IHTMLDOMNode_Release(node
);
7983 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
7985 str
= a2bstr("testing");
7986 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
7988 ok(hres
== S_OK
, "createComment failed: %08x\n", hres
);
7991 type
= get_node_type((IUnknown
*)comment
);
7992 ok(type
== 8, "type=%d, expected 8\n", type
);
7994 test_node_get_value_str((IUnknown
*)comment
, "testing");
7995 test_elem_title((IUnknown
*)comment
, NULL
);
7996 test_elem_set_title((IUnknown
*)comment
, "comment title");
7997 test_elem_title((IUnknown
*)comment
, "comment title");
7998 test_comment_text((IUnknown
*)comment
, "<!--testing-->");
7999 test_elem_outerhtml((IUnknown
*)comment
, "<!--testing-->");
8000 test_comment_attrs((IUnknown
*)comment
);
8002 IHTMLDOMNode_Release(comment
);
8005 str
= a2bstr("Test");
8006 hres
= IHTMLDocument5_createAttribute(doc5
, str
, &attr
);
8007 ok(hres
== S_OK
, "createAttribute dailed: %08x\n", hres
);
8009 if(SUCCEEDED(hres
)) {
8010 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, "[object]");
8011 test_ifaces((IUnknown
*)attr
, attr_iids
);
8012 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
8014 test_attr_node_name(attr
, "Test");
8016 IHTMLDOMAttribute_Release(attr
);
8019 IHTMLDocument5_Release(doc5
);
8022 IHTMLElement_Release(body
);
8025 static void test_replacechild_elems(IHTMLDocument2
*doc
)
8028 IHTMLDOMNode
*node
, *node2
, *node3
;
8029 IHTMLDOMNode
*nodeBody
, *nodeNew
;
8033 body
= doc_get_body(doc
);
8035 node
= test_create_text(doc
, "insert");
8037 V_VT(&var
) = VT_NULL
;
8038 V_DISPATCH(&var
) = NULL
;
8039 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
8040 IHTMLDOMNode_Release(node
);
8042 test_elem_innertext(body
, "insert");
8044 node3
= test_create_text(doc
, "replaced");
8046 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
8048 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
8049 ok(hres
== S_OK
, "Expected S_OK, got 0x%08x\n", hres
);
8051 test_elem_innertext(body
, "replaced");
8053 IHTMLDOMNode_Release(node2
);
8054 IHTMLDOMNode_Release(node3
);
8055 IHTMLDOMNode_Release(nodeBody
);
8057 IHTMLElement_Release(body
);
8060 static void test_noscript(IHTMLDocument2
*doc
)
8062 IHTMLElementCollection
*col
;
8066 static const elem_type_t all_types
[] = {
8075 static const elem_type_t body_all_types
[] = {
8080 hres
= IHTMLDocument2_get_all(doc
, &col
);
8081 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8082 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8083 IHTMLElementCollection_Release(col
);
8085 body
= doc_get_body(doc
);
8086 test_elem_set_innerhtml((IUnknown
*)body
, "<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
8087 test_elem_all((IUnknown
*)body
, body_all_types
, sizeof(body_all_types
)/sizeof(*body_all_types
));
8088 IHTMLElement_Release(body
);
8091 static void test_doctype(IHTMLDocument2
*doc
)
8093 IHTMLDocument2
*doc_node
;
8094 IHTMLDOMNode
*doctype
;
8097 doc_node
= get_doc_node(doc
);
8098 doctype
= get_first_child((IUnknown
*)doc_node
);
8099 IHTMLDocument2_Release(doc_node
);
8101 type
= get_node_type((IUnknown
*)doctype
);
8102 ok(type
== 8, "type = %d\n", type
);
8104 test_comment_text((IUnknown
*)doctype
, "<!DOCTYPE html>");
8105 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
8106 IHTMLDOMNode_Release(doctype
);
8109 static void test_null_write(IHTMLDocument2
*doc
)
8113 doc_write(doc
, FALSE
, NULL
);
8114 doc_write(doc
, TRUE
, NULL
);
8116 hres
= IHTMLDocument2_write(doc
, NULL
);
8118 "Expected IHTMLDocument2::write to return S_OK, got 0x%08x\n", hres
);
8120 hres
= IHTMLDocument2_writeln(doc
, NULL
);
8122 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08x\n", hres
);
8125 static void test_create_stylesheet(IHTMLDocument2
*doc
)
8127 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
8128 IHTMLStyleElement
*style_elem
;
8129 IHTMLElement
*doc_elem
, *elem
;
8132 static const elem_type_t all_types
[] = {
8140 static const elem_type_t all_types2
[] = {
8149 test_doc_all(doc
, all_types
, sizeof(all_types
)/sizeof(*all_types
));
8151 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
8152 ok(hres
== S_OK
, "createStyleSheet failed: %08x\n", hres
);
8154 test_doc_all(doc
, all_types2
, sizeof(all_types2
)/sizeof(*all_types2
));
8156 doc_elem
= get_doc_elem(doc
);
8158 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
8159 IHTMLElement_Release(doc_elem
);
8161 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
8162 IHTMLElement_Release(elem
);
8163 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08x\n", hres
);
8166 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
8167 ok(hres
== S_OK
, "get_styleSheet failed: %08x\n", hres
);
8168 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
8169 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
8171 IHTMLStyleSheet_Release(stylesheet2
);
8172 IHTMLStyleSheet_Release(stylesheet
);
8174 IHTMLStyleElement_Release(style_elem
);
8177 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
8179 IOleCommandTarget
*cmdtrg
;
8182 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
8183 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
8185 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
8186 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
8188 IOleCommandTarget_Release(cmdtrg
);
8191 static void test_indent(IHTMLDocument2
*doc
)
8193 IHTMLElementCollection
*col
;
8194 IHTMLTxtRange
*range
;
8197 static const elem_type_t all_types
[] = {
8206 static const elem_type_t indent_types
[] = {
8217 hres
= IHTMLDocument2_get_all(doc
, &col
);
8218 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8219 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8220 IHTMLElementCollection_Release(col
);
8222 range
= test_create_body_range(doc
);
8223 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
8224 IHTMLTxtRange_Release(range
);
8226 hres
= IHTMLDocument2_get_all(doc
, &col
);
8227 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8228 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
8229 IHTMLElementCollection_Release(col
);
8232 static void test_cond_comment(IHTMLDocument2
*doc
)
8234 IHTMLElementCollection
*col
;
8237 static const elem_type_t all_types
[] = {
8245 hres
= IHTMLDocument2_get_all(doc
, &col
);
8246 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8247 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8248 IHTMLElementCollection_Release(col
);
8251 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
8253 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
8254 return E_NOINTERFACE
;
8257 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
8262 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
8267 static const IUnknownVtbl UnknownVtbl
= {
8268 Unknown_QueryInterface
,
8272 static IUnknown obj_ident_test
= { &UnknownVtbl
};
8274 static void test_frame(IDispatch
*disp
, const char *exp_id
)
8276 IHTMLWindow2
*frame2
, *parent
, *top
;
8277 IHTMLDocument2
*parent_doc
, *top_doc
;
8278 IHTMLWindow4
*frame
;
8279 IHTMLFrameBase
*frame_elem
;
8280 IObjectIdentity
*obj_ident
;
8281 ITravelLogClient
*tlc
;
8284 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
8285 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08x\n", hres
);
8289 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
8290 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08x\n", hres
);
8291 IHTMLWindow4_Release(frame
);
8295 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
8296 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
8297 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
8298 IHTMLFrameBase_Release(frame_elem
);
8300 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
8301 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08x\n", hres
);
8305 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
8306 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08x\n", hres
);
8308 IHTMLWindow2_Release(frame2
);
8312 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
8313 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08x\n", hres
);
8314 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
8315 if(hres
== E_NOINTERFACE
) {
8316 win_skip("IID_ITravelLogClient not available\n");
8319 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08x\n", hres
);
8321 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
8322 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8323 ITravelLogClient_Release(tlc
);
8326 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
8327 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08x\n", hres
);
8328 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
8329 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08x\n", hres
);
8330 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
8331 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08x\n", hres
);
8333 IObjectIdentity_Release(obj_ident
);
8335 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
8336 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8337 IHTMLWindow2_Release(parent
);
8339 IHTMLWindow2_Release(frame2
);
8343 test_doc_title(parent_doc
, "frameset test");
8344 IHTMLDocument2_Release(parent_doc
);
8347 hres
= IHTMLWindow2_get_top(frame2
, &top
);
8348 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08x\n", hres
);
8349 IHTMLWindow2_Release(frame2
);
8353 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
8354 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08x\n", hres
);
8355 IHTMLWindow2_Release(top
);
8359 test_doc_title(top_doc
, "frameset test");
8360 IHTMLDocument2_Release(top_doc
);
8363 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const char *frid
)
8365 VARIANT index_var
, result_var
;
8369 /* test result length */
8370 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
8371 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres
);
8372 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %d\n", length
);
8374 /* test first frame */
8375 V_VT(&index_var
) = VT_I4
;
8376 V_I4(&index_var
) = 0;
8377 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8378 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8379 if(SUCCEEDED(hres
)) {
8380 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8381 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr1");
8383 VariantClear(&result_var
);
8385 /* test second frame */
8386 V_I4(&index_var
) = 1;
8387 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8388 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8389 if(SUCCEEDED(hres
)) {
8390 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8391 test_frame((IDispatch
*)V_DISPATCH(&result_var
), "fr2");
8393 VariantClear(&result_var
);
8395 /* fail on next frame */
8396 V_I4(&index_var
) = 3;
8397 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8398 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
8399 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres
);
8400 VariantClear(&result_var
);
8402 /* string argument (element id lookup) */
8403 V_VT(&index_var
) = VT_BSTR
;
8404 V_BSTR(&index_var
) = a2bstr(frid
);
8405 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8406 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres
);
8407 if(SUCCEEDED(hres
)) {
8408 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
8409 test_frame(V_DISPATCH(&result_var
), frid
);
8411 VariantClear(&result_var
);
8412 VariantClear(&index_var
);
8414 /* invalid argument */
8415 V_VT(&index_var
) = VT_BOOL
;
8416 V_BOOL(&index_var
) = VARIANT_TRUE
;
8417 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
8418 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
8419 "failed with E_INVALIDARG, instead: 0x%08x\n", hres
);
8420 VariantClear(&result_var
);
8423 static void test_frameset(IHTMLDocument2
*doc
)
8425 IHTMLWindow2
*window
;
8426 IHTMLFramesCollection2
*frames
;
8430 window
= get_doc_window(doc
);
8432 /* test using IHTMLFramesCollection object */
8434 hres
= IHTMLWindow2_get_frames(window
, &frames
);
8435 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres
);
8439 test_frames_collection(frames
, "fr1");
8440 IHTMLFramesCollection2_Release(frames
);
8442 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
8443 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08x\n", hres
);
8447 test_frames_collection(frames
, "fr1");
8448 IHTMLFramesCollection2_Release(frames
);
8450 /* test using IHTMLWindow2 inheritance */
8451 test_frames_collection((IHTMLFramesCollection2
*)window
, "fr2");
8453 /* getElementById with node name attributes */
8454 elem
= get_doc_elem_by_id(doc
, "nm1");
8455 test_elem_id((IUnknown
*)elem
, "fr1");
8457 test_framebase((IUnknown
*)elem
);
8458 test_framebase_name(elem
, "nm1");
8459 test_framebase_put_name(elem
, "frame name");
8460 test_framebase_put_name(elem
, NULL
);
8461 test_framebase_put_name(elem
, "nm1");
8462 IHTMLElement_Release(elem
);
8464 /* get_name with no name attr */
8465 elem
= get_doc_elem_by_id(doc
, "fr3");
8466 test_framebase_name(elem
, NULL
);
8467 test_framebase_put_name(elem
, "frame name");
8468 test_framebase_put_name(elem
, NULL
);
8469 IHTMLElement_Release(elem
);
8471 IHTMLWindow2_Release(window
);
8474 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
8476 IHTMLDocument2
*frag
;
8477 IHTMLDocument3
*doc3
;
8480 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
8481 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
8483 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
8484 IHTMLDocument3_Release(doc3
);
8485 ok(hres
== S_OK
, "createDocumentFragment failed: %08x\n", hres
);
8486 ok(frag
!= NULL
, "frag == NULL\n");
8491 static void test_docfrag(IHTMLDocument2
*doc
)
8493 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
8494 IHTMLElement
*div
, *body
, *br
;
8495 IHTMLElementCollection
*col
;
8496 IHTMLLocation
*location
;
8499 static const elem_type_t all_types
[] = {
8508 frag
= create_docfrag(doc
);
8510 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, "[object]");
8512 body
= (void*)0xdeadbeef;
8513 hres
= IHTMLDocument2_get_body(frag
, &body
);
8514 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
8515 ok(!body
, "body != NULL\n");
8517 location
= (void*)0xdeadbeef;
8518 hres
= IHTMLDocument2_get_location(frag
, &location
);
8519 ok(hres
== E_UNEXPECTED
, "get_location failed: %08x\n", hres
);
8520 ok(location
== (void*)0xdeadbeef, "location changed\n");
8522 br
= test_create_elem(doc
, "BR");
8523 test_elem_source_index(br
, -1);
8524 test_node_append_child((IUnknown
*)frag
, (IUnknown
*)br
);
8525 test_elem_source_index(br
, 0);
8526 IHTMLElement_Release(br
);
8528 div
= get_elem_by_id(doc
, "divid", TRUE
);
8529 test_node_append_child((IUnknown
*)div
, (IUnknown
*)frag
);
8530 IHTMLElement_Release(div
);
8532 hres
= IHTMLDocument2_get_all(doc
, &col
);
8533 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
8534 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
8535 IHTMLElementCollection_Release(col
);
8537 div
= test_create_elem(frag
, "div");
8538 owner_doc
= get_owner_doc((IUnknown
*)div
);
8539 doc_node
= get_doc_node(doc
);
8540 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
8541 IHTMLDocument2_Release(doc_node
);
8542 IHTMLDocument2_Release(owner_doc
);
8543 IHTMLElement_Release(div
);
8545 IHTMLDocument2_Release(frag
);
8548 static void check_quirks_mode(IHTMLDocument2
*doc
)
8550 test_compatmode(doc
, "BackCompat");
8553 static void check_strict_mode(IHTMLDocument2
*doc
)
8555 test_compatmode(doc
, "CSS1Compat");
8558 static IHTMLDocument2
*notif_doc
;
8559 static BOOL doc_complete
;
8561 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
8562 REFIID riid
, void**ppv
)
8564 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
8569 ok(0, "unexpected call\n");
8570 return E_NOINTERFACE
;
8573 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
8578 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
8583 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
8585 if(dispID
== DISPID_READYSTATE
){
8589 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
8590 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
8592 if(!strcmp_wa(state
, "complete"))
8593 doc_complete
= TRUE
;
8595 SysFreeString(state
);
8601 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
8603 ok(0, "unexpected call\n");
8607 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
8608 PropertyNotifySink_QueryInterface
,
8609 PropertyNotifySink_AddRef
,
8610 PropertyNotifySink_Release
,
8611 PropertyNotifySink_OnChanged
,
8612 PropertyNotifySink_OnRequestEdit
8615 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
8617 static IHTMLDocument2
*create_doc_with_string(const char *str
)
8619 IPersistStreamInit
*init
;
8621 IHTMLDocument2
*doc
;
8625 notif_doc
= doc
= create_document();
8629 doc_complete
= FALSE
;
8631 mem
= GlobalAlloc(0, len
);
8632 memcpy(mem
, str
, len
);
8633 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
8635 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
8637 IPersistStreamInit_Load(init
, stream
);
8638 IPersistStreamInit_Release(init
);
8639 IStream_Release(stream
);
8644 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
8646 IConnectionPointContainer
*container
;
8647 IConnectionPoint
*cp
;
8651 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
8652 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
8654 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
8655 IConnectionPointContainer_Release(container
);
8656 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
8658 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
8659 IConnectionPoint_Release(cp
);
8660 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
8663 typedef void (*domtest_t
)(IHTMLDocument2
*);
8665 static void run_domtest(const char *str
, domtest_t test
)
8667 IHTMLDocument2
*doc
;
8671 doc
= create_doc_with_string(str
);
8675 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
8677 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
8678 TranslateMessage(&msg
);
8679 DispatchMessageW(&msg
);
8684 ref
= IHTMLDocument2_Release(doc
);
8685 ok(!ref
|| broken(ref
== 1), /* Vista */
8689 static void test_quirks_mode(void)
8691 run_domtest("<html></html>", check_quirks_mode
);
8692 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
8693 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
8698 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
8699 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
8700 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
8704 run_domtest(doc_str1
, test_doc_elem
);
8705 run_domtest(doc_str1
, test_get_set_attr
);
8706 run_domtest(range_test_str
, test_txtrange
);
8707 run_domtest(range_test2_str
, test_txtrange2
);
8708 if (winetest_interactive
|| ! is_ie_hardened()) {
8709 run_domtest(elem_test_str
, test_elems
);
8710 run_domtest(elem_test2_str
, test_elems2
);
8711 run_domtest(noscript_str
, test_noscript
);
8713 skip("IE running in Enhanced Security Configuration\n");
8715 run_domtest(doc_blank
, test_create_elems
);
8716 run_domtest(doc_blank
, test_defaults
);
8717 run_domtest(doc_blank
, test_null_write
);
8718 run_domtest(emptydiv_str
, test_create_stylesheet
);
8719 run_domtest(indent_test_str
, test_indent
);
8720 run_domtest(cond_comment_str
, test_cond_comment
);
8721 run_domtest(frameset_str
, test_frameset
);
8722 run_domtest(emptydiv_str
, test_docfrag
);
8723 run_domtest(doc_blank
, test_replacechild_elems
);
8724 run_domtest(doctype_str
, test_doctype
);